[U-Boot-Users] Dynamic U-Boot configuration via FDT

Hello,
it want to report on my experience with using FDT to configure U-Boot dynamically for a custom board based on the MPC823. The customer wanted _one_ U-Boot and Linux image for various variants of that board mainly to simplify software maintenance. The following devices required configuration via FDT blob:
- LCD panel (type, orientation, color, etc.) - RTC - PCMCIA/IDE - DTT - CAN controller - Some custom devices
For most devices it was sufficient to check their presence. Only the LCD panel and the CAN controller required a more sophisticated FDT-based initialization. The FDT was used in a minimalistic and way. This project still uses the good old Linux 2.4.25 from DENX and therefore it's not a good food for discussion. I have attached a patch implementing the essential parts to configure IDE of my Icecube MPC5200 eval board:
- The macro definition CFG_FDT_ADDR points to the FDT blob in the Flash. Note that it can also be used before relocation.
- After relocation and availability of the U-Boot environment, the function fdt_relocate() copies the blob to a bootable address in RAM defined by the environment variable "fdt_boot_addr". bootm is aware of that address and will use it to boot Linux 2.6 (without third bootm argument). Moving to RAM that early has the advantage of faster access to the FDT and it could be updated by board specific code.
- fdt_relocate() calls the board specific function fdt_fixup_board() if the corresponding macro is defined. It might make sense to use the already existing ft_board_setup() for that purpose.
- The function cmd_disable() is used to disable U-boot commands for unavailable devices. Note that it cannot be used before relocation.
- A lot of dynamic configuration using fdt_find_compatible_node() or fdt_find_node_by_type() could be done in board specific code. Common code like U-Boot commands or device drivers must use the FDT directly. Unfortunately, it requires adding FDT code in many places. For the next generation of U-Boot, FDT probing should therefore be done by a clever device interface. The patch demonstrates how to configure IDE by looking for the "ata" node in the FDT.
Limitation, improvements, ideas and further comments:
- The LIBFDT can only be used for addresses accessible via pointer. Therefore it cannot be used as-is before relocation and for this reason I have just defined and implemented CFG_FDT_ADDR (FDT in EEPROM or NAND is not supported).
- Many drivers do not yet support multiple configurations like DTT, RTC, LCD, etc.
- A suitable default address for FDT blob relocation could be used instead of an address defined by the U-Boot environment variable "fdt_boot_addr", (or both).
- fdt_relocate() could also heck for a FDT U-Boot image at the address (CFG_FDT_ADDR - 64) and act accordingly.
- The U-Boot command "fdt" works right away.
- We might want to support multiple FDT blobs, which could be selected through an U-Boot environment variable. But such blobs could not be used in the early boot phase.
In May there was already some basic discussion on this topic: See http://sourceforge.net/mailarchive/forum.php?thread_name=464D6D4A.4000200%40...
The central question is to what extend we want to use the FDT to configure U-Boot. I already regard the extensive use of the FDT in Linux 2.6 as kind of overkill.
Please comment.
Thanks.
Wolfgang.

Wolfgang Grandegger wrote:
Hello,
it want to report on my experience with using FDT to configure U-Boot dynamically for a custom board based on the MPC823. The customer wanted _one_ U-Boot and Linux image for various variants of that board mainly to simplify software maintenance. The following devices required configuration via FDT blob:
[snip]
The central question is to what extend we want to use the FDT to configure U-Boot. I already regard the extensive use of the FDT in Linux 2.6 as kind of overkill.
Beauty is in the eye of the beholder. :-)
In the kernel's defense, they are working in a vastly more diverse (hardware-wise) environment than us embedded guys and many of their users (probably overwhelmingly most of their users by a simple head count) have no desire to configure and build a custom kernel for their hardware.
Personally, it has been a looong time since I built an x86 kernel for one of my workstations. Since my workstation hardware is probeable, I don't need to do it. The FDT brings that configuration to non-probeable hardware by having wizards (that's us, kindly deposit your money at the door ;-) generate the hardware description that the kernel can use to auto-configure itself.
I look at the FDT as a kernel "make menuconfig" done once by the wizards rather than having to repeat it every time you want to upgrade your kernel.
"The Navy is a master plan designed by geniuses for execution by idiots." - Wouk, Herman: The Caine Mutiny : a novel of World War II
s/Navy/FDT/
Please comment.
Thanks. Wolfgang.
Thanks for the update, Wolfgang, and I'm pleased that it went so well.
gvb
participants (2)
-
Jerry Van Baren
-
Wolfgang Grandegger