Unable to load device tree overlay at runtime and see the modules defined by it

Discussion around products based on ARM Cortex-A5 core.

Moderator: nferre

sramnath
Posts: 8
Joined: Fri May 01, 2020 6:05 pm

Unable to load device tree overlay at runtime and see the modules defined by it

Tue Aug 25, 2020 12:27 am

I have two revisions of a board and want to boot up with a different device tree binary at runtime, based on a runtime check. I am trying to do the following - have a base device tree binary that has attributes that are common to both revisions of the board, and add different device tree overlays that are unique to each revision of the board. eg. the eval board and the system prototype board. when booting up, the correct device tree overlay would be chosed based the value read from a pin. I've got the check right, but unable to load a device tree overlay correctly.

I am using a SAMA5D27 chip and using Yocto as the build system.

I have edited the dt-overlay-at91 sama5d27_som1_ek.its file with the base device tree binary and added a patch adding those changes. I have also added the dtso files in sama5d27-som1-ek for the eval board and the system prototype. I also added the blobs to the sama5d27_som1_ek.its file, and these built successfully. I added the base device tree dts file to the kernel source (linux-at91) and added the corresponding dtb file to the Makefile in the linux-at91 source. The yocto build ran successfully without any errors and I can see the compiled dtb and dtbo blobs in the build artifacts.

I boot up the board, and stop the system at u-boot and run commands from u-boot. I run

Code: Select all

=> iminfo 0x24000000

## Checking Image at 24000000 ...
   FIT image found
   FIT description: Microchip SAMA5D27 SOM1 EK FIT Image
    Image 0 (kernel@1)
     Description:  Linux4SAM Linux kernel
     Type:         Kernel Image
     Compression:  uncompressed
     Data Start:   0x240000e0
     Data Size:    4644272 Bytes = 4.4 MiB
     Architecture: ARM
     OS:           Linux
     Load Address: 0x22000000
     Entry Point:  0x22000000
     Hash algo:    crc32
     Hash value:   21bac23e
     Hash algo:    sha1
     Hash value:   df1cb959206591a2c90f33190391326de8ccd01a
    Image 1 (base_fdt)
     Description:  Flattened Device Tree blob
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x2446dfbc
     Data Size:    31300 Bytes = 30.6 KiB
     Architecture: ARM
     Load Address: 0x23000000
     Hash algo:    crc32
     Hash value:   24570d08
     Hash algo:    sha1
     Hash value:   0e0321115bfe8f09926d410eb4b62bf819bd7e1c
    Image 2 (fdt_pda4)
     Description:  Device Tree blob pda4300 overlay
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x24475b10
     Data Size:    4270 Bytes = 4.2 KiB
     Architecture: ARM
     Load Address: 0x23130000
     Hash algo:    crc32
     Hash value:   f6fe6973
     Hash algo:    sha1
     Hash value:   1fd381fb48ddd882d053b210410dbacc1f6b3d15
    Image 3 (fdt_pda5)
     Description:  Device Tree blob pda5000 overlay
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x24476cd0
     Data Size:    4270 Bytes = 4.2 KiB
     Architecture: ARM
     Load Address: 0x23140000
     Hash algo:    crc32
     Hash value:   93ad9d77
     Hash algo:    sha1
     Hash value:   6dce6ca819440ed34a59262dd17a699f54326a8b
    Image 4 (fdt_pda7)
     Description:  Device Tree blob pda7000 overlay
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x24477e90
     Data Size:    4278 Bytes = 4.2 KiB
     Architecture: ARM
     Load Address: 0x23150000
     Hash algo:    crc32
     Hash value:   a206f1b3
     Hash algo:    sha1
     Hash value:   fb64a04539297b3b1f5b3a7c8a86d49a5c1104e6
    Image 5 (fdt_pda7b)
     Description:  Device Tree blob pda7000b overlay
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x24479058
     Data Size:    4278 Bytes = 4.2 KiB
     Architecture: ARM
     Load Address: 0x23160000
     Hash algo:    crc32
     Hash value:   a9b70051
     Hash algo:    sha1
     Hash value:   e2dc82ad40495c4295bd855fbc4338eeec3bdc9c
    Image 6 (fdt_ov5640)
     Description:  Device Tree blob ov5640 overlay
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x2447a21c
     Data Size:    2296 Bytes = 2.2 KiB
     Architecture: ARM
     Load Address: 0x23170000
     Hash algo:    crc32
     Hash value:   4917c557
     Hash algo:    sha1
     Hash value:   d584a2d164b4b271cd8fcb7c6f5ddb2997fd2b67
    Image 7 (fdt_mt9v022)
     Description:  Device Tree blob MT9V022 overlay
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x2447ac24
     Data Size:    2694 Bytes = 2.6 KiB
     Architecture: ARM
     Load Address: 0x23180000
     Hash algo:    crc32
     Hash value:   2d82d00e
     Hash algo:    sha1
     Hash value:   f6036735bc494265c823c4fc404b6eafec7cedf8
    Image 8 (fdt_thermo5)
     Description:  Device Tree blob Thermo5 Click overlay
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x2447b7c0
     Data Size:    487 Bytes = 487 Bytes
     Architecture: ARM
     Load Address: 0x23190000
     Hash algo:    crc32
     Hash value:   5e01bacb
     Hash algo:    sha1
     Hash value:   4dbd460f1d605a61373cad11c2d46f6f52716672
    Image 9 (fdt_sp)
     Description:  Device Tree blob SP board overlay
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x2447bab4
     Data Size:    23970 Bytes = 23.4 KiB
     Architecture: ARM
     Load Address: 0x231a0000
     Hash algo:    crc32
     Hash value:   029d7438
     Hash algo:    sha1
     Hash value:   5d1c3ab30b8b80240e37641aacef571e8de097ba
    Image 10 (fdt_ek)
     Description:  Device Tree blob EK board overlay
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x24481964
     Data Size:    22151 Bytes = 21.6 KiB
     Architecture: ARM
     Load Address: 0x231b0000
     Hash algo:    crc32
     Hash value:   8d015b6a
     Hash algo:    sha1
     Hash value:   338005439c44fa56ce3c6be45d16d72d47008e82
    Default Configuration: 'kernel_dtb'
    Configuration 0 (kernel_dtb)
     Description:  Linux kernel and base FDT blob for SAMA5D27_SOM1_EK board
     Kernel:       kernel@1
     FDT:          base_fdt
    Configuration 1 (base_dtb)
     Description:  FDT blob for base SAMA5D27_SOM1_EK board
     Kernel:       unavailable
     FDT:          base_fdt
    Configuration 2 (mt9v022)
     Description:  FDT overlay blob for mt9v022 sensor
     Kernel:       unavailable
     FDT:          fdt_mt9v022
    Configuration 3 (pda4)
     Description:  FDT overlay blob for PDA TM4300 screen
     Kernel:       unavailable
     FDT:          fdt_pda4
    Configuration 4 (pda5)
     Description:  FDT overlay blob for PDA TM5000 screen
     Kernel:       unavailable
     FDT:          fdt_pda5
    Configuration 5 (pda7)
     Description:  FDT overlay blob for PDA TM7000 screen
     Kernel:       unavailable
     FDT:          fdt_pda7
    Configuration 6 (pda7b)
     Description:  FDT overlay blob for PDA TM7000B screen
     Kernel:       unavailable
     FDT:          fdt_pda7b
    Configuration 7 (ov5640)
     Description:  FDT overlay blob for ov5640 sensor
     Kernel:       unavailable
     FDT:          fdt_ov5640
    Configuration 8 (thermo5)
     Description:  FDT overlay blob for Thermo5 click
     Kernel:       unavailable
     FDT:          fdt_thermo5
    Configuration 9 (sp)
     Description:  Device Tree blob SP board overlay
     Kernel:       unavailable
     FDT:          fdt_sp
    Configuration 10 (ek)
     Description:  Device Tree blob EK board overlay
     Kernel:       unavailable
     FDT:          fdt_ek
## Checking hash(es) for FIT Image at 24000000 ...
   Hash(es) for Image 0 (kernel@1): crc32+ sha1+ 
   Hash(es) for Image 1 (base_fdt): crc32+ sha1+ 
   Hash(es) for Image 2 (fdt_pda4): crc32+ sha1+ 
   Hash(es) for Image 3 (fdt_pda5): crc32+ sha1+ 
   Hash(es) for Image 4 (fdt_pda7): crc32+ sha1+ 
   Hash(es) for Image 5 (fdt_pda7b): crc32+ sha1+ 
   Hash(es) for Image 6 (fdt_ov5640): crc32+ sha1+ 
   Hash(es) for Image 7 (fdt_mt9v022): crc32+ sha1+ 
   Hash(es) for Image 8 (fdt_thermo5): crc32+ sha1+ 
   Hash(es) for Image 9 (fdt_sp): crc32+ sha1+ 
   Hash(es) for Image 10 (fdt_ek): crc32+ sha1+ 

so I see the fdt_sp and fdt_ek blobs that I added separately. Now I tried to apply the fdt_sp overlay by running the following commands :

Code: Select all

==> print

bootcmd_boot=fatload mmc 0:1 0x24000000 sama5d27_som1_ek.itb; bootm 0x24000000#kernel_dtb${at91_overlays_config}

Environment size: 1894/16380 bytes
I modified the boot command by setting at01_overlays_config as such, and then booting

Code: Select all

=> setenv at91_overlays_config '#sp'
=> boot
4749104 bytes read in 295 ms (15.4 MiB/s)
## Loading kernel from FIT Image at 24000000 ...
   Using 'kernel_dtb' configuration
   Trying 'kernel@1' kernel subimage
     Description:  Linux4SAM Linux kernel
     Type:         Kernel Image
     Compression:  uncompressed
     Data Start:   0x240000e0
     Data Size:    4644272 Bytes = 4.4 MiB
     Architecture: ARM
     OS:           Linux
     Load Address: 0x22000000
     Entry Point:  0x22000000
     Hash algo:    crc32
     Hash value:   21bac23e
     Hash algo:    sha1
     Hash value:   df1cb959206591a2c90f33190391326de8ccd01a
   Verifying Hash Integrity ... crc32+ sha1+ OK
## Loading fdt from FIT Image at 24000000 ...
   Using 'kernel_dtb' configuration
   Trying 'base_fdt' fdt subimage
     Description:  Flattened Device Tree blob
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x2446dfbc
     Data Size:    31300 Bytes = 30.6 KiB
     Architecture: ARM
     Load Address: 0x23000000
     Hash algo:    crc32
     Hash value:   24570d08
     Hash algo:    sha1
     Hash value:   0e0321115bfe8f09926d410eb4b62bf819bd7e1c
   Verifying Hash Integrity ... crc32+ sha1+ OK
   Loading fdt from 0x2446dfbc to 0x23000000
## Loading fdt from FIT Image at 24000000 ...
   Using 'sp' configuration
   Trying 'fdt_sp' fdt subimage
     Description:  Device Tree blob SP board overlay
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x2447bab4
     Data Size:    23970 Bytes = 23.4 KiB
     Architecture: ARM
     Load Address: 0x231a0000
     Hash algo:    crc32
     Hash value:   029d7438
     Hash algo:    sha1
     Hash value:   5d1c3ab30b8b80240e37641aacef571e8de097ba
   Verifying Hash Integrity ... crc32+ sha1+ OK
   Loading fdt from 0x2447bab4 to 0x231a0000
   Booting using the fdt blob at 0x23000000
   Loading Kernel Image
   Loading Device Tree to 27b5e000, end 27b68a43 ... OK

Starting kernel ...


So after adding #sp to the bootcmd, u-boot was able to find the fdt_sp subimage in the FIT image, (Loading fdt from FIT Image at 24000000 ... Using 'sp' configuration Trying 'fdt_sp' fdt subimage) However, after booting up, I don't see any of the changes that I made in the fdt_sp dtbo. For example I have defined leds in the fdt_sp dtso, but I don't see the leds defined once the board is booted up and I run

Code: Select all

#root $ ls /sys/class/leds
moreover, when I try to check the /boot directory, I don't see the two dtbo files that I created:

Code: Select all

root@sama5d27-som1-ek-sd:~# ls /boot
sama5d27_som1_ek.itb  sama5d27_som1_ek_mt9v022.dtbo  sama5d27_som1_ek_pda4.dtbo  sama5d27_som1_ek_pda7.dtbo   sama5d27_som1_ek_thermo5.dtbo
sama5d27_som1_ek.its  sama5d27_som1_ek_ov5640.dtbo   sama5d27_som1_ek_pda5.dtbo  sama5d27_som1_ek_pda7b.dtbo

Can anyone explain what I might be doing wrong?
blue_z
Location: USA
Posts: 2115
Joined: Thu Apr 19, 2007 10:15 pm

Re: Unable to load device tree overlay at runtime and see the modules defined by it

Wed Aug 26, 2020 3:29 am

sramnath wrote: I am using a SAMA5D27 chip and using Yocto as the build system.
But you provide no version information for the software that you're using.

sramnath wrote: I added the base device tree dts file to the kernel source (linux-at91) ...
Reusing a Microchip board name for your special purpose is confusing/misguided.

sramnath wrote: moreover, when I try to check the /boot directory, I don't see the two dtbo files that I created: ...
"Moreover"?
You seem to misunderstand what you're looking at.
What additional evidence of a problem do you think is in the /boot directory of the rootfs?

The directory to investigate is /proc/device-tree.

sramnath wrote: Unable to load device tree overlay at runtime and see the modules defined by it

Can anyone explain what I might be doing wrong?
Well, your title is misleading.
There is no indication that the DT overlay is not "loaded". On the contrary, you describe that the overlay is loaded (and relocated).
You are using the DT overlay at boot-time, not "runtime".
U-Boot can merge a DT overlay with a base DT, which is essentially a data structure manipulation.
The Linux kernel also accepts a DT overlay at runtime, which affects the configuration of a live system.

You seem to be confusing "modules" with Device Tree nodes?

You seem to be focusing on the wrong issue, i.e. "loading" (partly because you overload that term with too much functionality).
How have you verified that your fdt_sp overlay applied to the base_fdt DT correctly describes the "system prototype board"?
Have you tried using the U-Boot commands for fdt to validate your DT files?
Or simply considered using conventional .dts/.dtb files for each board?

Regards

Return to “SAMA5D Cortex-A5 MPU”

Who is online

Users browsing this forum: No registered users and 2 guests