Skip to contentSkip to conversation

waiting for timeouts in FPGA code?

U-Boot-Users Steven Scholz 2 participants 6 messages Feb 24, 2004 – Feb 27, 2004

lore
Share & tools
lore
#0 lore raw

Hi there ,

in the U-Boot FPGA code timeouts are realized by

if (get_timer (ts) > CFG_FPGA_WAIT{_INIT})

	...

while CFG_FPGA_WAIT{_INIT} is supposed to be the timeout in milliseconds. This does not work for the AT91RM9200. Instead of using

#define CFG_FPGA_WAIT 10

I have to use

#define CFG_FPGA_WAIT CFG_HZ/10

Is CFG_HZ defined for all other architectures? Should we use CFG_HZ instead of hardcoded numbers?

Thanks.

Signature · 6 lines
Steven Scholz

imc Measurement & Control               imc Me?systeme GmbH
Voltastr. 5                             Voltastr. 5
13355 Berlin                            13355 Berlin
Germany                                 Deutschland
#1 lore raw
Quoted 7 lines · In message <[email protected]> you wrote:

in the U-Boot FPGA code timeouts are realized by

if (get_timer (ts) > CFG_FPGA_WAIT{_INIT})

	...

while CFG_FPGA_WAIT{_INIT} is supposed to be the timeout in milliseconds.

Then this design is broken; get_timer() returns the number of timer ticks (= CFG_HZ per second). This is only milliseconds for CFG_HZ == 1000.

Quoted 7 lines

This does not work for the AT91RM9200. Instead of using

#define CFG_FPGA_WAIT 10

I have to use

#define CFG_FPGA_WAIT CFG_HZ/10

Note that this is ten times as long as the original timeout.

Quoted 1 line

Is CFG_HZ defined for all other architectures?

It is supposed to be defined. But many boards define it incorrectly.

Quoted 1 line

Should we use CFG_HZ instead of hardcoded numbers?

Definitely.

Best regards,

Wolfgang Denk

Signature · 3 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
A fail-safe circuit will destroy others.                 -- Klipstein
#2 lore raw
Quoted 4 lines · Wolfgang Denk
Quoted 2 lines · In message <[email protected]> you wrote:

in the U-Boot FPGA code timeouts are realized by

Quoted 8 lines
Quoted 4 lines

if (get_timer (ts) > CFG_FPGA_WAIT{_INIT})

	...

while CFG_FPGA_WAIT{_INIT} is supposed to be the timeout in milliseconds.

Then this design is broken; get_timer() returns the number of timer ticks (= CFG_HZ per second). This is only milliseconds for CFG_HZ == 1000.

So I does not matter how fast the timer ticks as long as CFG_HZ is set to the correct value and timeouts are based on CFG_HZ. Correct?

Quoted 9 lines
Quoted 7 lines

This does not work for the AT91RM9200. Instead of using

#define CFG_FPGA_WAIT 10

I have to use

#define CFG_FPGA_WAIT CFG_HZ/10

Note that this is ten times as long as the original timeout.

Of course. Typo.

Quoted 4 lines
Quoted 1 line

Is CFG_HZ defined for all other architectures?

It is supposed to be defined. But many boards define it incorrectly.

Quoted 1 line

Should we use CFG_HZ instead of hardcoded numbers?

Definitely.

Hmm. But that means that when we change e.g. the above mentioned FPGA code to use CFG_HZ that we might break these archictectures !?

Signature · 6 lines
Steven Scholz

imc Measurement & Control               imc Me?systeme GmbH
Voltastr. 5                             Voltastr. 5
13355 Berlin                            13355 Berlin
Germany                                 Deutschland
#4 lore raw
In reply to Wolfgang Denk
Quoted 5 lines · Wolfgang Denk
Quoted 1 line

Is CFG_HZ defined for all other architectures?

It is supposed to be defined. But many boards define it incorrectly.

Quoted 1 line

Should we use CFG_HZ instead of hardcoded numbers?

Definitely.

Here we go:

* Patch by Steven Scholz, 25 Feb 2004:
- Timeouts in FPGA code should be based on CFG_HZ
- Minor cleanup in code for Altera FPGA ACEX1K

BTW: I just noticed that loads of timeouts (e.g. CFG_FLASH_ERASE_TOUT) are _not_ defined using CFG_HZ ...

Signature · 10 lines
Steven Scholz

imc Measurement & Control               imc Me?systeme GmbH
Voltastr. 5                             Voltastr. 5
13355 Berlin                            13355 Berlin
Germany                                 Deutschland
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: fpga-CFG_HZ.patch
Url: http://lists.denx.de/pipermail/u-boot/attachments/20040225/f24e0a1b/attachment.txt 
#3 lore raw
In reply to Steven Scholz
Quoted 9 lines · In message <[email protected]> you wrote:
Quoted 6 lines
Quoted 2 lines

while CFG_FPGA_WAIT{_INIT} is supposed to be the timeout in milliseconds.

Then this design is broken; get_timer() returns the number of timer ticks (= CFG_HZ per second). This is only milliseconds for CFG_HZ == 1000.

So I does not matter how fast the timer ticks as long as CFG_HZ is set to the correct value and timeouts are based on CFG_HZ. Correct?

Intheory, yes. Unless CFG_HZ is insane and causes integer arithmetics overflow.

Quoted 6 lines
Quoted 3 lines

It is supposed to be defined. But many boards define it incorrectly.

Quoted 1 line

Should we use CFG_HZ instead of hardcoded numbers?

Definitely.

Hmm. But that means that when we change e.g. the above mentioned FPGA code to use CFG_HZ that we might break these archictectures !?

Indeed. Do you know a better way? I don't. So let's do this right first, and then clean up any mess that you unsheathe.

Best regards,

Wolfgang Denk

Signature · 4 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
No one wants war.
	-- Kirk, "Errand of Mercy", stardate 3201.7
#5 lore raw
In reply to Steven Scholz
Quoted 6 lines · In message <[email protected]> you wrote:

Here we go:

* Patch by Steven Scholz, 25 Feb 2004:
- Timeouts in FPGA code should be based on CFG_HZ
- Minor cleanup in code for Altera FPGA ACEX1K

Added, thanks.

Quoted 2 lines

BTW: I just noticed that loads of timeouts (e.g. CFG_FLASH_ERASE_TOUT) are _not_ defined using CFG_HZ ...

Argh.. :-(

Best regards,

Wolfgang Denk

Signature · 4 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
Real programmers don't comment their code. It was hard to  write,  it
should be hard to understand.