Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Linux - Kernel This forum is for all discussion relating to the Linux kernel.


  Search this Thread
Old 04-06-2018, 05:36 AM   #1
LQ Newbie
Registered: Apr 2018
Posts: 2

Rep: Reputation: Disabled
Custom module to add device tree overlay - kernel 4.14-rc4


I made a custom module using the kernel API (of_fdt_unflatten_tree + of_resolve_phandles + of_overlay_create ) to dynamically (after my kernel has booted) insert an overlay.

It seems to work just fine, I can see the result in /proc/device-tree, but theses changes are not propagated to /dev or to /sys/devices/plateform. So I can't use what I have added using my overlay.

I first though that the device/plateform driver was not re-probed, but even if I include a line like this one :
platform_device_register_simple("at91_rtc", -1, NULL, 0);
it does not work :/.

So I was wondering if someone knows a way to dynamically add an overlay and can see the changes. (not only in /proc/device-tree).

PS: I don't use U-Boot, nor configfs, and I don't want to use my overlay through the bootloader.

Best regards,
Old 05-28-2018, 03:17 AM   #2
LQ Newbie
Registered: May 2018
Posts: 2

Rep: Reputation: Disabled
Hi Carli-K
I'm looking to do the same thing. Don't suppose you got something working?
Have a stub driver that loads a specific dst overlay depending on what it finds.
In this case it is similar to the cape manager I think. Ie go and scan for the presence of some hardware and if found load in an overlay.
I can't find any real examples of how to do this.
There are hints about using request_firmware(), of_fdt_unflatten_tree(), of_resolve_phandles(), of_overlay_create() to load a dtbo but no real full flow descriptions.

Reading the kernel code only gets you sofar..
Not sure of what the effects are.. ie does doing this automatically then go and trigger another probe looking for any matching of compatible entries?

I for example just simply want to define some GPIO's differently depending on the board detected..
Spent a few days trying to come to grips with this, very frustrating.

Old 05-28-2018, 03:54 AM   #3
LQ Newbie
Registered: Apr 2018
Posts: 2

Original Poster
Rep: Reputation: Disabled
Hi Richard,

I am sorry, I did not find any solution for this issue. I have asked the devicetree/kernel mailing list but I did not get any answers :/.

But yea the idea is to create a "driver" using the kernel API, request_firmware(), of_fdt_unflatten_tree(), of_resolve_phandles(), of_overlay_create().
You have an example in "drivers/of/unittest.c".
And then with some magic re-probe the driver to take what we've just added into account. Otherwise the changes will just be visible in /proc/device-tree.

I saw a lot of people doing this through the bootloader, so I guess that currently it is the only reliable way of adding overlays.

I wish you good luck with this, and if I found a solution I will let you know .

Old 05-29-2018, 09:40 PM   #4
LQ Newbie
Registered: May 2018
Posts: 2

Rep: Reputation: Disabled
Hi Carli
Thanks for getting back to me.
Yep it's rather frustrating as the docs say to do just that, but then seem to miss out I don't know how many other steps to actually make it work. Think some of the driver maintainers need to be forced into updating the docs when they add/change features because they are in a woeful state. Don't know if any of them have actually tried to use what they design :/

I'll post back if I figure something out.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Kernel Module: How may I access my ADC (mcp3208) via SPI within my custom driver? d3adwood Programming 0 03-22-2018 10:45 PM
Reading device tree from user space and kernel module moo-cow Linux - Embedded & Single-board computer 1 08-26-2013 09:27 AM
rc4 kernel module azza Programming 1 06-28-2009 04:25 PM
is it necessary to recompile the entire kernel to add support for a device as module kushalkoolwal Debian 9 05-24-2006 01:16 PM > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 12:50 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration