using fdt with uboot

Post Reply
User avatar
joerg
Posts: 1054
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 35 times
Been thanked: 75 times
Contact:

using fdt with uboot

Post by joerg » Mon May 18, 2020 8:59 pm

I try to add a i2c node to the device tree and add this to boot.ini, but it does not work. Note that it works when I am doing this from the uboot command line.
boot.ini:

Code: Select all

fdt rm i2c1 rtc@51
fdt mknode i2c1 rtc@68
fdt set i2c1/rtc@68 compatible "ds3231"
fdt set i2c1/rtc@68 reg "<68>"
fdt set i2c1/rtc@68 status "okay"

bootm
I see this error:

Code: Select all

Bad Linux ARM64 Image magic!
libfdt fdt_delprop():  FDT_ERR_NOTFOUND
It seems that I am missing something, or just a typing error?
I am trying this on @voodiks LineageOS 17.1, but I guess this is related to the stock uboot.

I have to rm the rtc@51, to get place to add my node.
Here some log snipsets from uboot command line:

Code: Select all

odroidc4#movi read dtbs 0 0x1000000
movi: the partiton 'dtbs' is reading...
odroidc4#fdt addr 0x1000000

odroidc4#fdt mknode i2c1 rtc@68
libfdt fdt_add_subnode(): FDT_ERR_NOSPACE

odroidc4#fdt rm i2c1/rtc@51 
odroidc4#fdt mknode i2c1 rtc@68
odroidc4#fdt set i2c1/rtc@68 compatible "ds3231"
odroidc4#fdt set i2c1/rtc@68 reg "<68>"
odroidc4#fdt set i2c1/rtc@68 status "okay"

odroidc4#fdt print i2c1
i2c@1d000 {
	compatible = "amlogic,meson-g12a-i2c";
	status = "okay";
	reg = <0x00000000 0x0001d000 0x00000000 0x00000020>;
	interrupts = <0x00000000 0x000000d7 0x00000001 0x00000000 0x0000005e 0x00000001>;
	#address-cells = <0x00000001>;
	#size-cells = <0x00000000>;
	clocks = <0x00000002 0x0000002a>;
	clock-names = "clk_i2c";
	pinctrl-names = "default", "gpio_periphs";
	pinctrl-0 = <0x0000001f>;
	pinctrl-1 = <0x00000020>;
	clock-frequency = <0x000186a0>;
	phandle = <0x000000b1>;
	rtc@68 {
		status = "okay";
		reg = <0x00000044>;
		compatible = "ds3231";
	};
};

User avatar
tobetter
Posts: 5101
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Has thanked: 160 times
Been thanked: 494 times
Contact:

Re: using fdt with uboot

Post by tobetter » Mon May 18, 2020 10:34 pm

Can you share the full boot.ini you modified?
I think somehow the kernel image is damaged after the several fdt commands.
In addition, you can use fdt resize 8192 in order to extend the memory size for FDT. This won't make the error 'FDT_ERR_NOSPACE'.
These users thanked the author tobetter for the post:
joerg (Tue May 19, 2020 12:54 am)

User avatar
joerg
Posts: 1054
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 35 times
Been thanked: 75 times
Contact:

Re: using fdt with uboot

Post by joerg » Tue May 19, 2020 12:53 am

Thank you, @tobetter!
I can see it now in the sysfs, but I guess that the DS1307 driver is not compiled into the kernel.

Code: Select all

odroidc4:/ # cat /sys/class/i2c-dev/i2c-1/device/1-0044/name
ds3231
@voodik, would you please enable it for the next release?

Code: Select all

CONFIG_RTC_DRV_DS1307=y
Working:

Code: Select all

#fdt rm i2c1 rtc@51
fdt resize 8192
fdt mknode i2c1 rtc@68
fdt set i2c1/rtc@68 compatible "ds3231"
fdt set i2c1/rtc@68 reg "<68>"
fdt set i2c1/rtc@68 status "okay"

bootm
@tobetter, the rest of boot.ini is original, except the resolution for VU7+.

User avatar
joerg
Posts: 1054
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 35 times
Been thanked: 75 times
Contact:

Re: using fdt with uboot

Post by joerg » Tue May 19, 2020 7:23 pm

There was also a typo, it must be reg <0x68>.

Code: Select all

dmesg | grep rtc                                                
[    0.995367] rtc-ds1307 1-0068: SET TIME!
[    0.999599] rtc-ds1307 1-0068: rtc core: registered ds3231 as rtc0
[    1.197552] aml_vrtc rtc: rtc core: registered aml_vrtc as rtc1
[    1.197787] input: aml_vkeypad as /devices/platform/rtc/input/input1
[    1.537088] rtc-ds1307 1-0068: setting system clock to 2000-01-01 23:42:17 UTC (946770137)
These users thanked the author joerg for the post:
tobetter (Tue May 19, 2020 7:29 pm)

Post Reply

Return to “Android”

Who is online

Users browsing this forum: No registered users and 1 guest