Let me preface this by saying I don't know much about device trees. I do know a bit about ATAGs, since I'm working with this operating system that currently only uses ATAGs.

I'm modifying the operating system to work on the Raspberry Pi 3s, and the stack address that the kernel gets from the ATAGs seems to be off, since I can't, for example, print out what's in saddr[0]. I've found that ATAGs are becoming obsolete, so instead of figuring out what's wrong with the ATAGs, I'm thinking about switching the OS over to using device trees.

Problem is, I don't even know where to start. My team tried adding a .dtb file taken from here: Raspberry Pi 3 UART Overlay Workaround to our SD card but said it "didn't work." To be fair, we had no idea what we were doing when we added that file. We hadn't modified the operating system to work with device trees, and we were focusing on a different problem when we added that file (so the thing that "didn't work" was that we couldn't get any input from PL011 UART driver, and there are so many things that could have caused that to not work).

So if I want the operating system to use device trees, where do I start? Do I have to make my own or is there one already available that I can use? Are dtb files specific to specific platforms, operating systems, or processors? I can't find much documentation for this online, so if you could give me something to read that'd be great.

  • "My team tried adding a .dtb file to our SD card but said it didn't work." - That's a very poor problem statement. – Dmitry Grigoryev Jun 29 '17 at 14:03

You only need to think about adding Device Tree support under following conditions:

  • you know how to write operating systems
  • you are currently in the process of writing an operating system
  • your operating system has to run on multiple different ARM devices, not only the Raspberry Pi
  • your devices do not offer ACPI and have peripherals which cannot be enumerated over an bus (unlike PCI and USB devices)
  • you want to leverage code and work which is mainly Linux-focused

Device Tree was invented so that Linux users don't need to compile a different kernel for each different ARM board out there. The idea is that the same kernel reads different DTB files and loads the appropriate drivers instead. On the x86 platform Linux could rely on the high degree of standardization which simply doesn't exist in the ARM world.

So far i know the only operating systems using device tree are Linux and FreeBSD.

If your OS doesn't support flattened device trees, you must add the support yourself. DTB files are specific to a board and describe the CPU, memory map, on-board peripherals and in the case of the Pi things connected via GPIO too.

DTB files are compiled from DTS files via dtc, the device tree compiler. The dtc project also maintains libfdt , which can parse DTB files.

The most experience on ATAG parsing on the Pi is probably concentrated in the bare metal forum on raspberrypi.org , along with people versed in OS development for the Raspberry Pi.

Most documentation on device tree will be for Linux.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.