Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
What's the right way to build the DTS Blob
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on ARM
View previous topic :: View next topic  
Author Message
TJNII
l33t
l33t


Joined: 09 Nov 2003
Posts: 648
Location: for(;;);

PostPosted: Sun Jun 16, 2024 3:40 pm    Post subject: What's the right way to build the DTS Blob Reply with quote

Maybe I didn't Google hard enough last night, I was so close to getting the board booted I didn't want to stop and find the "right" way.

When booting a OrangePi Zero I found it needed a device tree blob. The DTS files are included in the kernel source, but need preprocessing. The steps I ran to build the blob are:

Code:

cpp -nostdinc -I include -I arch  -undef -x assembler-with-cpp  arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts /tmp/sun8i-h2-plus-orangepi-zero.dts.preprocessed
scripts/dtc/dtc -I dts -O dtb /tmp/sun8i-h2-plus-orangepi-zero.dts.preprocessed > /boot/sun8i-h2-plus-orangepi-zero.dtb


This worked fine. But given the high levels of scripting and documentation around all the rest of the processes having to suss a cpp command out of a forum post to build this blob felt very out of place. Is there a utility I didn't find that handles this?
Back to top
View user's profile Send private message
TJNII
l33t
l33t


Joined: 09 Nov 2003
Posts: 648
Location: for(;;);

PostPosted: Sun Jun 16, 2024 3:45 pm    Post subject: Reply with quote

And some breadcrumbs for search engines:

Original error:

Code:

=> ext2load mmc 0:1 42000000 boot/uImage
8319736 bytes read in 346 ms (22.9 MiB/s)
=> bootm 42000000
## Booting kernel from Legacy Image at 42000000 ...
   Image Name:   Linux-5.15.158-gentoo
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    8319672 Bytes = 7.9 MiB
   Load Address: 42000000
   Entry Point:  42000000
   Verifying Checksum ... OK
Working FDT set to 0
   Loading Kernel Image to 42000000
FDT and ATAGS support not compiled in

resetting ...


Code:
FDT and ATAGS support not compiled in
is a bit misleading, the real error is not passing a device tree address. I did the steps in my first post then booted with:

Code:

=> ext2load mmc 0:1 43000000 boot/sun8i-h2-plus-orangepi-zero.dtb
23240 bytes read in 3 ms (7.4 MiB/s)
=> setenv bootargs "console=ttyS0,115200n8 root=/dev/mmcblk0p1 rw rootfstype=ext4 mem=512M loglevel=7 single init=/bin/bash"
=> ext2load mmc 0:1 42000000 boot/uImage
8319736 bytes read in 346 ms (22.9 MiB/s)
=> bootm 42000000 - 43000000
## Booting kernel from Legacy Image at 42000000 ...
   Image Name:   Linux-5.15.158-gentoo
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    8319672 Bytes = 7.9 MiB
   Load Address: 42000000
   Entry Point:  42000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 43000000
   Booting using the fdt blob at 0x43000000
Working FDT set to 43000000
   Loading Kernel Image to 42000000
   Loading Device Tree to 49ff7000, end 49fffac7 ... OK
Working FDT set to 49ff7000

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0


The 3 args to the `bootm` U-Boot command are the address the kernel was loaded into, the initrd address (- in this case as I'm not using a initrd), and the address the dtb blob was loaded into. Note these addresses are device specific, on the SBC I'm booting 0x4000:0000 - 0xBFFF:FFFF is RAM.
Back to top
View user's profile Send private message
TJNII
l33t
l33t


Joined: 09 Nov 2003
Posts: 648
Location: for(;;);

PostPosted: Sat Jun 22, 2024 12:17 pm    Post subject: Reply with quote

Code:
make dtbs
in the kernel source tree.

Haven't learned how overlays are meant to be customized yet, I stumbled across this working on something unrelated.
Back to top
View user's profile Send private message
M95D
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jan 2020
Posts: 94

PostPosted: Wed Jul 24, 2024 9:51 pm    Post subject: Reply with quote

When you build the kernel (make), DTBs are automatically built.

The kernel and DTB addresses are not really strict. You can change them as long as you keep track where everything else is in memory. Possible mistakes would be to overwrite uboot's memory, load stuff where the devices are (UART address, emmc I/O, PCI, etc.), or load the kernel and then overwrite part of it with the dtb.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on ARM All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum