Re: [U-Boot] register polling from HUSH parser?
Dear Masahiro, In messageyou wrote: > > Yes, it really helped me. > Thank you! You are welcome. > I think itest.l works as expected on 32bit architecture, > but the problem is that sizeof(unsigned long) is 8 > on 64bit architecture. Oh, yes, you are right, of course. Well, U-Boot has been too long written for 32 bit only... > So, "case 4" in the following gets 8-byte data. > This is probably not what we expect... > > switch (w) { > case 1: > l = (long)(*(unsigned char *)buf); > break; > case 2: > l = (long)(*(unsigned short *)buf); > break; > case 4: > l = (long)(*(unsigned long *)buf); > break; > } You are right. We should replace char/short/long by something more descriptive like u8/u16/u32 - and for 64 bit systems, we should a branch for 64 bit entities, too. Do you think you can prepare such a patch? Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de Machines take me by surprise with great frequency. - Alan Turing ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] register polling from HUSH parser?
Hi Wolfgang, 2016-04-27 18:46 GMT+09:00 Wolfgang Denk: > Dear Masahiro, > > In message > you > wrote: >> >> Is there any good way to poll a certain register >> in a HUSH parser script? > > Yes, there is :-) > >> For example, I want to wait >> until the register value of 0x5000 becomes 1 >> in a HUSH script. > > OK... > >> The pseudo code would be like this: >> >> while readl(0x5000) != 1 >> do >>; >> done; > > And in HUSH: > > while itest *5000 != 1 > do > ... > done > >> I wish there were a command that >> stores a value of a given address into an environment, >> but I have no idea about that. > > Try "help setexpr". If you want to store the value as is, just apply > a null operation, like > > => setexp foo *5000 | 0 > => printenv foo > > > Hope this helps... Yes, it really helped me. Thank you! I think itest.l works as expected on 32bit architecture, but the problem is that sizeof(unsigned long) is 8 on 64bit architecture. So, "case 4" in the following gets 8-byte data. This is probably not what we expect... switch (w) { case 1: l = (long)(*(unsigned char *)buf); break; case 2: l = (long)(*(unsigned short *)buf); break; case 4: l = (long)(*(unsigned long *)buf); break; } -- Best Regards Masahiro Yamada ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] register polling from HUSH parser?
Dear Masahiro, In messageyou wrote: > > Is there any good way to poll a certain register > in a HUSH parser script? Yes, there is :-) > For example, I want to wait > until the register value of 0x5000 becomes 1 > in a HUSH script. OK... > The pseudo code would be like this: > > while readl(0x5000) != 1 > do >; > done; And in HUSH: while itest *5000 != 1 do ... done > I wish there were a command that > stores a value of a given address into an environment, > but I have no idea about that. Try "help setexpr". If you want to store the value as is, just apply a null operation, like => setexp foo *5000 | 0 => printenv foo Hope this helps... Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de "The X11 source code style is ATROCIOUS and should not be used as a model." - Doug Gwyn ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] register polling from HUSH parser?
Hi. Is there any good way to poll a certain register in a HUSH parser script? For example, I want to wait until the register value of 0x5000 becomes 1 in a HUSH script. The pseudo code would be like this: while readl(0x5000) != 1 do ; done; I wish there were a command that stores a value of a given address into an environment, but I have no idea about that. Any idea? -- Best Regards Masahiro Yamada ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot