Is the devicetree in zephyr sdk supports the dynamic running time flow control ?


"曹子龙
 

Hi folks:

   I know the device three mechanism is also applied in zephyr sdk, but it seems something diffferent  compare with in linux.

 in linux, the dtsi script file would be compiled to a binary blob which would be pared in running time, so, the driver would do some dynamically decision in running time to different branch.

but in zephyr sdk, the dts are commpiled to a intermidate dts script file, which would be parsed by tools before building process are held.
finally, the dts configuration would convert to header files,and just used in compile time, so cant  used to do the branch control like linux.

is this right?  and is there anyway to get the configuration in runtime in zephyr?

thnks for your help.


曹子龙

珠海全志科技股份有限公司      BU1-PSW

地址:广东省珠海市高新区唐家湾镇科技2路9号

TEL:13824125580

Email:caozilong@...

网址: http://www.allwinnertech.com

 



Kumar Gala
 

On Nov 20, 2019, at 5:11 AM, "曹子龙 <caozilong@allwinnertech.com> wrote:

Hi folks:

I know the device three mechanism is also applied in zephyr sdk, but it seems something diffferent compare with in linux.

in linux, the dtsi script file would be compiled to a binary blob which would be pared in running time, so, the driver would do some dynamically decision in running time to different branch.

but in zephyr sdk, the dts are commpiled to a intermidate dts script file, which would be parsed by tools before building process are held.
finally, the dts configuration would convert to header files,and just used in compile time, so cant used to do the branch control like linux.

is this right? and is there anyway to get the configuration in runtime in zephyr?

thnks for your help.
Your understanding is correct. Because of the space constrained systems Zephyr has targeted the size of both the DTB and code to parse the DTB is seen as too large, and thus we went the way of using DTS for code generation.

Can you explain a bit further what kinda of config you’d like to do at run time? This might help us understand what solution would make sense.

- k


Christopher Friedt
 



On Wed., Nov. 20, 2019, 6:11 a.m. "曹子龙, <caozilong@...> wrote:
but in zephyr sdk, the dts are commpiled to a intermidate dts script file, whi
is this right?  and is there anyway to get the configuration in runtime in zephyr?

Personally, I think that the build-time / compile-time DeviceTree usage in Zephyr is actually pretty elegant.

However, there is nothing stopping anyone from adding a libfdt to Zephyr for runtime examination of device tree binaries. It's just not as common to do so on a microcontroller platform.

Once you have the .dtb, you can quite easily convert it to a C array using something like xxd.

I would strongly encourage gzip compression to be used for compressing the .dtb though (assuming it was constant data and the dtb was only there for examination). Otherwise it will take up precious code space. At least if memory is dynamically allocated for the uncompressed dtb it can be freed and reused later.

Due to Zephyr's conversion of DTB data to C preprocessor symbols, I do not see live device tree modification being a thing that will be supported in Zephyr anytime soon.