ericcooper
Posts: 63
Joined: Sat Apr 08, 2017 6:23 pm

how to include overlays for a multi-device hat?

Thu Oct 12, 2017 3:09 pm

I'm working on a hat with several devices for which device tree overlays already exist (RTC, ADC, etc.) I'd like to come up with a single overlay (and specify it in the hat EEPROM) rather than require users to add each one to their config. Is there any way to do that?

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1419
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: how to include overlays for a multi-device hat?

Thu Oct 12, 2017 3:20 pm

Overlays can be as large or small as you like. Aside from the header and fragment renumbering you can basically just concatenate several overlays to make a composite.

The HAT EEPROM format was original designed to hold the overlay content, but the firmware now looks at the content of that section and if it doesn't look like a .dtbo file it tries it as the name of an overlay to load from the filing system. With a suitably formatted EEPROM your users just need to copy the .dtbo of your overlay into /boot in order for it to be loaded automatically.

ericcooper
Posts: 63
Joined: Sat Apr 08, 2017 6:23 pm

Re: how to include overlays for a multi-device hat?

Thu Oct 12, 2017 8:07 pm

Thanks for the info about the EEPROM semantics, that will be helpful.

But I was unclear: I'm hoping to do some kind of "include" or "import" of the other overlays, either at compile time or load time, so that I don't duplicate code and have all the maintenance issues that entails.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1419
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: how to include overlays for a multi-device hat?

Mon Oct 16, 2017 1:40 pm

There is no existing mechanism to do this. It wouldn't be too hard to implement one, but it would require either learning fdtlib (for dtbo files) or some text munging (for dts files). Working from source might be easier because then the compiler can work out the phandles (like pointers) for you, but has the potential pitfall of name clashes unless you uniquify the symbols.

Return to “Device Tree”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest