[U-Boot-Users] TFTP times out?
Wolfgang Denk
wd at denx.de
Fri Nov 11 10:36:02 CET 2005
In message <47F3F98010FF784EBEE6526EAAB078D1C05E8D at tq-mailsrv.tq-net.de> you wrote:
>
> CFG_HZ defines the number of timer ticks per second. The function
> get_timer() returns the current vaule of the internal timer tick
> counter (with the variable name: 'timestamp'). The following code
> snippet should delay for exat one second:
>
> ...
> tmo = get_timer(0) + 1 * CFG_HZ;
> while (get_timer(0) < tmo);
Warning. This code will NOT work when there is a wrap-around.
> There actually seems to be a bug. CFG_HZ is set to 1000 on your board.
This setting is the correct value. It was a mistake of mine to name
this CFG_* and give users the idea this could be changed.
> This means in one second the counter returned by get_timer() should
> increase by 1000. But this doesn't correspond to the implementation
> of udelay() on your board (from cpu/s3c44b0/interrupts.c):
>
> void udelay (unsigned long usec)
> {
> ulong tmo;
>
> tmo = usec / 1000;
> tmo *= CFG_HZ;
> tmo /= 8;
>
> tmo += get_timer (0);
>
> while (get_timer_masked () < tmo)
> /*NOP*/;
> }
Indeed. This implementetion is seriously broken.
It will also result in totally unexpected delays in case of
wrap-around (there are more broken implementations like this in the
existing U-Boot code; maintainers should take care).
Best regards,
Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Without followers, evil cannot spread.
-- Spock, "And The Children Shall Lead", stardate 5029.5
More information about the U-Boot
mailing list