Flattened Device Tree
The mandate of the Flattened Device Tree custodian repository is to improve fdt "blob" support in u-boot. It does this by adapting David Gibson's libfdt for use in u-boot and adds a
fdt command to allow easy manipulation of "fdt blobs."
Branches / Patches Queued for the Next Window
None.
Important Safety Tips
- You must use the latest device tree compiler (dtc) to generate a Version 17 blob (note that this is now the default for dtc).
-
libfdt needs a Version 17 or better blob in order to write to the blob.
- Use
-R 4 (need at least 1 extra reserve map slot for the initrd, making 4 slots is probably a good idea)
- Use
-S 0x3000 (or some sufficiently large number) to add extra space to allow libfdt to modify the blob. By default, the blob has the minimum necessary size for its compiled content. This means there is no room to add a "chosen" (or other) node. The result is that bootm will complain and not boot the kernel.
libfdt
ToDo - libfdt
Ongoing: Catch up with
dtc (
libfdt/* to be slightly more explicit).
Outstanding Patches
Hopefully.
ToDo
- For
fdt addr, enhance to implement "fdt addr X +Y", where "Y" is the number of additional bytes to add to the blob.
- Suggestion from Timur:
If the device tree is wrapped in a uimage (a 'dtu'), then the hdr->ih_load field contains the location where the device tree should be copied. If that value is zero, bad things happen. So I have two suggestions: - If the value is zero, report an error and stop
- If the value is zero, assume the user doesn't want the device tree to be copied, and the code should fill it in with the current location of the device tree.
I like option #2 better, because then I don't have to hard-code an address into the dtu.
- Save and load the blob to flash (likely after env space)
- Add a CRC a'la env
- Add a backup version a'la env
- Proposed additional
fdt commands
-
merge - merge two trees. Need a conflict resolution: source tree #1 has priority?
- David Gibson has talked about creating a "graft" function for libfdt.
-
load - load from flash
- Not needed, see
fdt move (but non-memory mapped storage such as NAND flash won't work with fdt move)
-
save - save to flash
-
cp should handle this already
-
header - print useful blob info like validity, version, total and used reserved slots, extra space, presence of <NOP> filling(?), etc.
- Kumar submitted a patch to print the header info... some additional info showing extra space would be useful.
NOTE: Grant Likely has adapted
libfdt for the 5xxx family, his methodology is the recommended template.
Background Information on Flattened Device Trees
1275 spec:
Power.org™ Standard for Embedded Power Architecture™ Platform Requirements (ePAPR)
PowerPC processor binding:
booting-without-of.txt
- In the kernel source tree under
Documentation/powerpc) - Describes the flat device tree as it is used in the Linux kernel.
Device Trees Everywhere-- paper by David Gibson and Ben Herrenschmidt-- an overview of the concept
PCI Bus binding:
USB Bus binding:
CHRP Binding:
64-bit extension:
Interrupt mappings ( very important ):
Misc device types (network, RTC, sound, etc)
Notes
All Your Base are Belong to Us
...aka some more git usage...
# See what branch I'm on (it happens to be master)
git branch
# Switch to my "sync with Wolfgang" branch (use -b the first time)
git checkout uboot
# Pull the latest u-boot.git (supreme master) changes into my uboot branch
git pull git://www.denx.de/git/u-boot.git
# Switch back to my master branch (where my pending changes are/would be)
git checkout master
# Rebase against u-boot.git latest
git rebase uboot
# Want to see what Kumar Gala is cooking with libfdt - start a new branch
git checkout -b galak
# Pull Kumar's libfdt branch
git pull git://git.kernel.org/pub/scm/boot/u-boot/galak/u-boot.git libfdt
# See what the changes are
git diff master
# Visual version
gitk
# Rebase against the master (which was rebased against Wolfgang's supreme
# master), our (Kumar's) changes are now against the master.
git rebase master
Testing (not fdt-specific)
- See DENX Universal Test System (DUTS)
- Debian python pexpect and pyserial packages:
>>> import serial
>>> ser = serial.Serial(0, 115200, timeout=100, parity=serial.PARITY_NONE, rtscts=0)
>>> ser.write("help\n")
>>> ser.inWaiting()
2304L
>>> s=ser.read(2304)
>>> print s
help
? - alias for 'help'
askenv - get environment variables from stdin
:
:
version - print monitor version
=>
>>> ser.write("help\n")
>>> s = ser.read(100)
>>> print s
help
? - alias for 'help'
askenv - get environment variables from stdin
autoscr - run scri
>>> s = ser.readline()
>>> print s
pt from memory
>>> s = ser.readline()
>>> print s
base - print or set address offset