[U-Boot] FDT howto

Simon Glass sjg at chromium.org
Mon Feb 25 00:10:38 CET 2013


Hi Jagan,

On Sun, Feb 24, 2013 at 10:58 AM, Jagan Teki <jagannadh.teki at gmail.com> wrote:
> Hi Simon,
>
> On Sun, Feb 24, 2013 at 11:55 PM, Jagan Teki <jagannadh.teki at gmail.com> wrote:
>> Hi Simon,
>>
>> On Sun, Feb 24, 2013 at 11:50 PM, Simon Glass <sjg at chromium.org> wrote:
>>> Hi,
>>>
>>> On Sun, Feb 24, 2013 at 9:55 AM, Jagan Teki <jagannadh.teki at gmail.com> wrote:
>>>> Hi Simon,
>>>>
>>>> On Sun, Feb 24, 2013 at 11:18 PM, Simon Glass <sjg at chromium.org> wrote:
>>>>> Hi Jegan,
>>>>>
>>>>> On Sun, Feb 24, 2013 at 9:45 AM, Jagan Teki <jagannadh.teki at gmail.com> wrote:
>>>>>> Hi Simon,
>>>>>>
>>>>>> On Sun, Feb 24, 2013 at 11:08 PM, Simon Glass <sjg at chromium.org> wrote:
>>>>>>> Hi Jagan,
>>>>>>>
>>>>>>> On Sun, Feb 24, 2013 at 8:19 AM, Jagan Teki <jagannadh.teki at gmail.com> wrote:
>>>>>>>> Hi Simon,
>>>>>>>>
>>>>>>>> Thanks for your response, please find my below comments.
>>>>>>>>
>>>>>>>> On Sun, Feb 24, 2013 at 9:24 PM, Simon Glass <sjg at chromium.org> wrote:
>>>>>>>>> Hi Jagan,
>>>>>>>>>
>>>>>>>>> On Thu, Feb 21, 2013 at 9:03 AM, Jagan Teki <jagannadh.teki at gmail.com> wrote:
>>>>>>>>>> Hi All,
>>>>>>>>>>
>>>>>>>>>> I am planning to use devicetree on u-boot.
>>>>>>>>>> I have an experience to work with devicetree on Linux.
>>>>>>>>>>
>>>>>>>>>> For u-boot, I have read doc from doc/README.fdt-control.
>>>>>>>>>> I see some dts usages on tegra boards.
>>>>>>>>>>
>>>>>>>>>> I have lot of confusions with the concept itself.
>>>>>>>>>>
>>>>>>>>>> Is Linux and u-boot devicetree concept and build system are same?
>>>>>>>>>
>>>>>>>>> I don't really understand this question sorry. U-Boot and Linux use
>>>>>>>>> the device tree mainly for run-time configuration of drivers, so that
>>>>>>>>> the same driver code can operate on different boards.
>>>>>>>>
>>>>>>>> I am some how confusing the fdt usage in u-boot.
>>>>>>>> Because when compared to Linux, u-boot fdt setup mandatory to require
>>>>>>>> the CONFIG_DEFAULT_DEVICE_TREE
>>>>>>>> on the config file [from your previous comments].
>>>>>>>>
>>>>>>>> is this the only difference when compared to Linux i guess..is it?
>>>>>>>> Linux defconfig file does need to hot-code
>>>>>>>> the dts.
>>>>>>>
>>>>>>> Yes - that is a difference. Linux provides a way to build .dts files
>>>>>>> but it is not mandatory. At present it is mandatory with U-Boot, and
>>>>>>> only one file is built. It can easily be ignored though.
>>>>>>
>>>>>> Ok.
>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Suppose I have 4 boards J1, J2, J3 & J4 on my soc "emb".of vendor "vast"
>>>>>>>>>>    For this requirement I have
>>>>>>>>>>    board/vast/dts/J1.dts
>>>>>>>>>>    board/vast/dts/J2.dts
>>>>>>>>>>    board/vast/dts/J3.dts
>>>>>>>>>>    board/vast/dts/J4.dts
>>>>>>>>>>
>>>>>>>>>>    include/configs/emb_common.h ==> single configuration of all SOC
>>>>>>>>>> needed definitions
>>>>>>>>>>    like defconfig in Linux.
>>>>>>>>>>
>>>>>>>>>>    do I need any more files?
>>>>>>>>>
>>>>>>>>> That's enough for the basics I think.
>>>>>>>>
>>>>>>>> Is dtsi file require to add it on arch folder along with above.
>>>>>>>
>>>>>>> If your architecture is not one of those already supported (like arm
>>>>>>> tegra/exynos and x86) then yes you need to add this file in
>>>>>>> arch/<arch>/dts. What architecture are you using?
>>>>>>
>>>>>> My architecture is armv7, may be for me dtsi not required as arm is
>>>>>> existing architecture
>>>>>> to support fdt on u-boot.. is it?
>>>>>
>>>>> Which sub-arch? If it is tegra/exynos5250 then you might be OK. For
>>>>> something else, you should get the kernel's .dtsi file for that chip.
>>>>
>>>> I am having armv7, xilinx zynq soc..but i coun't get any .dtsi on kernel source.
>>>> may be I will create new one.
>>>
>>> OK, well if the kernel doesn't have FDT support yet then yes you will
>>> need to create a new one.
>>>
>>>>
>>>>>
>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>    In emb_common.h i am defining
>>>>>>>>>>    CONFIG_OF_SEPARATE is it sufficient?
>>>>>>>>>
>>>>>>>>> And CONFIG_OF_CONTROL
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>    My plan is to build u-boot and then build the dtb with specific
>>>>>>>>>> board and then combine.
>>>>>>>>>
>>>>>>>>> That's fine, and is how we do things on Chromium also. U-Boot tries to
>>>>>>>>> build an FDT even with CONFIG_OF_SEPARATE, so you need to put a
>>>>>>>>> default device tree file in your emb_common.h file that it can find.
>>>>>>>>> But you can ignore it, and for flashing your boards just use
>>>>>>>>> u-boot.bin plus whatever .dtb you want to select.
>>>>>>>>
>>>>>>>> So I will add the fdt support and then build the u-boot.
>>>>>>>> Is there any separate u-boot build command to build dts file.
>>>>>>>> My plan is to combine both u-boot and dtb.
>>>>>>>
>>>>>>> You can run dtc yourself if you like - see Makefile/dts for how it is
>>>>>>> done there. Once you have the .dtb binary, the easiest thing is to add
>>>>>>> it to the end of u-boot.bin, as described in README.fdt-control.
>>>>>>
>>>>>> Thanks, I tried with above setup for adding dts.
>>>>>> I have added simple dts file on my board.
>>>>>>
>>>>>> I got the below build error
>>>>>> /proj/mypc/u-boot/include/asm/gpio.h:1:27: fatal error:
>>>>>> asm/arch/gpio.h: No such file or directory
>>>>>> compilation terminated.
>>>>>> make[1]: *** No rule to make target `.depend.fdtdec', needed by
>>>>>> `.depend'.  Stop.
>>>>>>
>>>>>> is gpio.h is mandatory for fdt build?
>>>>>
>>>>> Yes because basic GPIO support is included. You can create one for
>>>>> your sub-arch and make it #include <asm-generic/gpio.h> as a starting
>>>>> point.
>>>>>
>>>>
>>>> Should I create an empty gpio.h file..it still asking some gpio
>>>> definitions right..
>>>
>>> It might be OK if you just have "#include <asm-generic/gpio.h>" in that file.
>>
>> Thanks.
>>
>> Finally I have created u-boot-dtb.bin.
>> for building dtb separately I have used
>> $ make DEVICE_TREE=zynq .. it creates a u-boot.dtb
>>
>> is there any option for building separate name, for example I need to
>> create zynq.dtb

No - but  you can just use 'mv' in a script external to the U-Boot build system.

>
> Some how I am able to create a fdt build on my target.
> But what is this gpio mandatory, because currently my target currently
> need a GPIO setup.
> Add ing gpio.h/ with equivalent definitions is an extra overhead is
> it? please explain.

It is just a header file - unless you actually use the GPIO functions,
you can compile with -ffunction-sections and you won't get the GPIO
code included. Anyway, the overhead is small, if any.

Regards,
Simon

>
> Thanks,
> Jagan.


More information about the U-Boot mailing list