Device Tree Overlay (Odroid C4) inactive?

Having issues with your DietPi installation or found a bug? Post it here.
bruz
Posts: 10
Joined: Tue Feb 02, 2021 11:06 am

Re: Device Tree Overlay (Odroid C4) inactive?

Post by bruz »

Hi,

I just started experimenting with DietPi on an Odroid N2 (recent image + updates). Currently I'm trying to activate i2c-0.
MichaIng wrote: Sat Oct 24, 2020 12:36 am I just found that indeed the default boot.ini on Odroid C4 (same as N2) does not yet incorporate the dtoverlays nicely. Will be done for next DietPi release. Good that you already found the command to do that manually for now, we'll implement it a way that you can add overlays via simple dtoverlay= (or similar) setting in boot.ini and add some of them via dietpi-config, e.g. toggle for I2C and SPI and probably a few others where applicable.
While searching for some hints I found this thread and was wondering if the dtoverlays are supported in the meantime?

The dtb files seem to be there, but I couldn't find the right place to define the overlays to be used. Do you have any advise?

Thanks in advance!
bruz
Posts: 10
Joined: Tue Feb 02, 2021 11:06 am

Re: Device Tree Overlay (Odroid C4) inactive?

Post by bruz »

Just did some reverse engineering on the original hardkernel ubuntu image and copied the following lines (from boot.ini and config.ini) to /boot/boot.ini (this color + adapted the path to the overlay files (this color):

...
# Set load addresses
setenv dtb_loadaddr "0x1000000"
setenv k_addr "0x1100000"
setenv loadaddr "0x1B00000"
setenv initrd_loadaddr "0x3700000"

setenv dtbo_addr_r "0x11000000"

# Device Tree Overlay
overlay_resize=16384
overlay_profile=
overlays="spi0 i2c0 i2c1 uart0"


# Load kernel, dtb and initrd
fatload mmc ${devno}:1 ${k_addr} Image.gz
fatload mmc ${devno}:1 ${dtb_loadaddr} meson64_odroidn2.dtb
fatload mmc ${devno}:1 ${initrd_loadaddr} uInitrd
fdt addr ${dtb_loadaddr}

if test "x{overlays}" != "x"; then
fdt resize ${overlay_resize}
for overlay in ${overlays}; do
load mmc ${devno}:1 ${dtbo_addr_r}
overlays/odroidn2/${overlay}.dtbo \
&& fdt apply ${dtbo_addr_r}
done
fi


# unzip the kernel
unzip ${k_addr} ${loadaddr}

# boot
booti ${loadaddr} ${initrd_loadaddr} ${dtb_loadaddr}


This patch seems to work fine. But I think, there needs to be a little more for a proper implementation "in the DietPi way"...
User avatar
MichaIng
Site Admin
Posts: 2628
Joined: Sat Nov 18, 2017 6:21 pm

Re: Device Tree Overlay (Odroid C4) inactive?

Post by MichaIng »

That looks actually pretty fine. I'm just not sure if this memory address is common, it looks too large, actually :?.

But otherwise, resizing the device tree, looping through the device-specific overlay dir and loading what has been added to the config file looks fine. I like the check if there is any overlay defined, before resizing the device tree. E.g. Armbian resizes it regardless if the variable is empty or not. I'm not sure if this causes additional RAM usage, but at least it is an unnecessary step in that case.
User avatar
MichaIng
Site Admin
Posts: 2628
Joined: Sat Nov 18, 2017 6:21 pm

Re: Device Tree Overlay (Odroid C4) inactive?

Post by MichaIng »

Ah lol, did you check our current image? It seems Meveric was busy and added overlay loading already:

Code: Select all

# Device Tree Overlay
# Overlay profiles
# default = "spi0 i2c0 i2c1 uart0"
# hktft32 = "hktft32" // 3.2" TFT from HardKernel
# hktft32 = "hktft32" // 3.5" TFT from HardKernel
# custom // load your own set of overlays -> use overlay_custom to specify
setenv overlay_resize "16384"
setenv overlay_profile "default"
setenv overlay_custom "i2c0 i2c1"
...
# Set load addresses
setenv dtb_loadaddr "0x1000000"
setenv dtbo_addr_r "0x11000000"
setenv k_addr "0x1100000"
setenv loadaddr "0x1B00000"
setenv initrd_loadaddr "0x3700000"

# Load kernel, dtb and initrd
fatload mmc ${devno}:1 ${k_addr} Image.gz
if test "x${variant}" != "x"; then
	fatload mmc ${devno}:1 ${dtb_loadaddr} meson64_odroid${variant}.dtb
else
	fatload mmc ${devno}:1 ${dtb_loadaddr} meson64_odroidc4.dtb
fi
fatload mmc ${devno}:1 ${initrd_loadaddr} uInitrd
fdt addr ${dtb_loadaddr}

if test "x{overlays}" != "x"; then
	fdt resize ${overlay_resize}
	for overlay in ${overlays}; do
		fatload mmc ${devno}:1 ${dtbo_addr_r} overlays/${board}/${overlay}.dtbo && fdt apply ${dtbo_addr_r}
	done
fi
Apart from the implemented overlay profiles, it is pretty much a copy of what you did, means a copy of the Hardkernel config ;).
bruz
Posts: 10
Joined: Tue Feb 02, 2021 11:06 am

Re: Device Tree Overlay (Odroid C4) inactive?

Post by bruz »

MichaIng wrote: Tue Feb 02, 2021 5:38 pm Ah lol, did you check our current image?
Actually I thought, I was using the latest. But looking at the image I downloaded from here: https://dietpi.com/#download -> N2 (https://dietpi.com/downloads/images/Die ... -Buster.7z), it seems not to be the latest (it's timestamped with 'Mon 9 Mar 14:43:47 CET 2020'). Is there any other location where the images can be downloaded (kind of an archive)?

I did the update and my installation is at version 6.34.3, but the files at the boot partition don't seem to got updated. At least I couldn't find the code you've mentioned (it's expected to be in boot.ini, right?) and the latest entry in /boot/dietpi-CHANGELOG.txt is for version 6.28.

Is there anything else I might have missed to proceed besides running dietpi-update in order to get the files of the boot partition updated as well?
User avatar
MichaIng
Site Admin
Posts: 2628
Joined: Sat Nov 18, 2017 6:21 pm

Re: Device Tree Overlay (Odroid C4) inactive?

Post by MichaIng »

Ah sorry, I mixed it up with the threads name that it was Odroid C4. Indeed the N2 doesn't have it yet. But good about it is that your method is then very close to what the N2 will get from Meverics pre-images side. We'll probably create very own boot.ini/boot.cmd configs. I think those overlay_profile stuff is actually not required if one can add the exact required overlays to a custom list instead, so I like your slimmer implementation more.
bruz
Posts: 10
Joined: Tue Feb 02, 2021 11:06 am

Re: Device Tree Overlay (Odroid C4) inactive?

Post by bruz »

@MichaIng: Allright, thanks! But you didn't answer my question: Is there any other location where the images can be downloaded (kind of an archive)?

If it's mentioned somewehre else already, plz just point me there (I didn't find it yet... still new to DietPi and learning...). Thanks!
User avatar
Joulinar
Posts: 3822
Joined: Sat Nov 16, 2019 12:49 am

Re: Device Tree Overlay (Odroid C4) inactive?

Post by Joulinar »

there is no real archive. All images are stored at one place at https://dietpi.com/downloads/images/
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
bruz
Posts: 10
Joined: Tue Feb 02, 2021 11:06 am

Re: Device Tree Overlay (Odroid C4) inactive?

Post by bruz »

Joulinar wrote: Fri Feb 05, 2021 10:50 pm there is no real archive. All images are stored at one place at https://dietpi.com/downloads/images/
OK, thanks! So it looks like you only keep the lates version of the images, right?
User avatar
Joulinar
Posts: 3822
Joined: Sat Nov 16, 2019 12:49 am

Re: Device Tree Overlay (Odroid C4) inactive?

Post by Joulinar »

yes because even if you would flash an old image, you will be updated to latest version on first boot.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Post Reply