[U-Boot-Users] Atmel DataFlash hooks.

There is a mountain of stuff that should probably be reworked in u-boot (notably the maze of #ifdefs), but all I've got is a small spade. So, I'll just pick things off as I come across them...
Issue: CONFIG_HAS_DATAFLASH hooks are invasive Background: Atmel DataFlash is a serial FLASH device with an SPI interface. There is code in u-boot that pretends that it is bus-addressable.
For all but a handful of boards, the commands in cmd_bootm.c, cmd_flash.c and cmd_mem.c (md, mm, cp, bootm, etc) interface with bus addressable memories. However, when CONFIG_HAS_DATAFLASH is defined, extra code is enabled to make it appear that SPI DataFlash is bus addressable to those commands.
IMHO, pretending that a serial flash device occupies a range of bus addresses is a bad precedence and a "Really Bad Idea". It means that every command that manipulates memory needs to have special hooks to be aware of DataFlash. The way the current hooks are implemented are ugly and dangerous. (search for CONFIG_HAS_DATAFLASH to see the hooks). Dangerous because code indentation is messed up which makes the code flow hard to follow, and also it invites a great mess if other non-bus-addressable memories are added in the same way.
The current hooks should be removed and the DataFlash support should be reworked so it no longer pretends to be bus addressable memories. This leaves the question, "then how should it be accessed?". There are other non-bus-addressable memories out there which have the same problem. For example, i2c eeproms, USB storage, CF, SCSI & IDE drivers. Currently USB storage, IDE, SCSI and MMC share the block device infrastructure used by the filesystem drivers. However it is read-only at the moment (but I've got some patches to fix that).
Possible solutions: 1. Move DataFlash support over to the block device infrastructure and add commands for direct manipulation of block devices. This assumes that it makes sense to look at a DataFlash device as just like any other block device. 2. Create a new set of commands specifically for manipulating dataflash 3. Create an abstraction layer for accessing both bus addressable and non bus addressable memories. Add a naming convention for commands to specify non-bus-addressable devices. ie. "cp.b 00004000 DF:0000 100" would copy 0x100 bytes from bus address 0x4000 to dataflash 0x0000. (but I really don't think this is the route to go; far to complex. I don't think it is unreasonable to require a separate command to copy to/from off-bus memories before comparing, booting, etc.)
and for completeness: 3. SImply remove the current hooks and leave DataFlash support out of mainline. 4. Grant is on drugs, do nothing.
Comments? If I don't here anything, then I'll go ahead an generate a patch to pull out the DataFlash hooks.

I bottom post
-----Original Message----- From: glikely@gmail.com [mailto:glikely@gmail.com] On Behalf Of Grant Likely Sent: 26 January 2007 08:45 To: uboot Cc: Peter Pearse; Peter Menzebach Subject: Atmel DataFlash hooks.
Issue: CONFIG_HAS_DATAFLASH hooks are invasive Background: Atmel DataFlash is a serial FLASH device with an SPI interface. There is code in u-boot that pretends that it is bus-addressable. Possible solutions:
- Move DataFlash support over to the block device
infrastructure and add commands for direct manipulation of block devices. This assumes that it makes sense to look at a DataFlash device as just like any other block device.
Grant
My first reaction is.
If it walks like a block device & quacks like a block device - it's a block device.
However I've forwarded to Hamid (author of dataflash.c) && Rick (AT91RM9200DK maintainer) for their opinions.
In the absence of any evidence otherwise, I just assume Atmel wanted to show
how neatly DataFlash can be treated as bus addressable.....
Regards
Peter

Hi guys
for debug purpose I want to skip network driver
How to do that?
Seems the NET part always is compiled and many other items rely on it.
Regards rui

Hi, On 26 Jan 2007 at 17:46, Rui.Zhou@nokia.com wrote:
Hi guys
for debug purpose I want to skip network driver
How to do that?
Seems the NET part always is compiled and many other items rely on it.
I stumbled over that myself, too.
Probably you have defined CONFIG_COMMANDS to be CONFIG_CMD_DFL somewhere. In my case, simply masking out CFG_CMD_NET worked for compiling without network:
#define CONFIG_COMMANDS ( CONFIG_CMD_DFL & ~(CFG_CMD_LOADS | \ CFG_CMD_LOADB | CFG_CMD_NET) )
(To be honest, I did not worry about CFG_CMD_LOAD[SB] yet, these are just copied from the template...)
Regards rui
Regards, Wolfgang

In message 1E9D602D891FA142A769E9EF164712EC4EA7F1@beebe101.NOE.Nokia.com you wrote:
for debug purpose I want to skip network driver
How to do that?
Just disable it from your board configuration (including the network related commands).
Seems the NET part always is compiled and many other items rely on it.
No, you can configure it out.
Best regards,
Wolfgang Denk

In message 528646bc0701260044t56b5cfd6h98ac591f7edc02b9@mail.gmail.com you wrote:
Comments? If I don't here anything, then I'll go ahead an generate a patch to pull out the DataFlash hooks.
Please don't rip out working code (even if ugly) as long as you don't have a working (= tested) replacement.
Best regards,
Wolfgang Denk

On 1/26/07, Wolfgang Denk wd@denx.de wrote:
In message 528646bc0701260044t56b5cfd6h98ac591f7edc02b9@mail.gmail.com you wrote:
Comments? If I don't here anything, then I'll go ahead an generate a patch to pull out the DataFlash hooks.
Please don't rip out working code (even if ugly) as long as you don't have a working (= tested) replacement.
hehehe; even if I write such a patch, I would need to also convince you to pick it up. :)
g.

In message 528646bc0701261124p671ee3a7qc42f1b747b3b1c1a@mail.gmail.com you wrote:
Please don't rip out working code (even if ugly) as long as you don't have a working (= tested) replacement.
hehehe; even if I write such a patch, I would need to also convince you to pick it up. :)
Indeed. And having no replacement that is obviously better than the replaced code is a pretty sure method to have a patch rejected. Ugly, but working code is IMHO still better than no code at all.
Best regards,
Wolfgang Denk

On 1/26/07, Wolfgang Denk wd@denx.de wrote:
In message 528646bc0701261124p671ee3a7qc42f1b747b3b1c1a@mail.gmail.com you wrote:
hehehe; even if I write such a patch, I would need to also convince you to pick it up. :)
Indeed. And having no replacement that is obviously better than the replaced code is a pretty sure method to have a patch rejected. Ugly, but working code is IMHO still better than no code at all.
agreed
g.
participants (5)
-
Grant Likely
-
Peter.Pearse
-
Rui.Zhou@nokia.com
-
w.wegner@astro-kom.de
-
Wolfgang Denk