XU4 - missing eth0: Uboot ${board_name} = blank

Post Reply
User avatar
mad_ady
Posts: 6155
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 121 times
Been thanked: 85 times
Contact:

XU4 - missing eth0: Uboot ${board_name} = blank

Unread post by mad_ady » Mon Nov 06, 2017 10:21 pm

I am facing a weird situation - I had a working emmc (with an updated system) that I backed-up and restored to a microsd. When I booted the microsd the system booted without an ethernet interface.
I looked into it a bit and it seems that uboot had not set a ${board_name} and that the incorrect dtb was loaded.

Regarding that - I have two questions:
1. Backup and restore copied also MBR and Uboot, but does not touch /dev/mmcblk0boot0, /dev/mmcblk0boot1 partitions. Does some part of uboot reside there as well? Is it safe for me to backup it and restore it with dd from within linux? If I'm restoring to sd card what happens to the missing data from boot0/1? I can't restore it on a microsd, yet uboot still boots without it.
I will doublecheck to see if I restored uboot correctly, but

2. The failsafe "xu4" dtb loaded failed. Here is my output from when I booted from sdcard and ${board_name} was undefined:

Code: Select all

boot.ini command = setenv bootrootfs "console=tty1 console=ttySAC2,115200n8 root=UUID=e139ce78-9841-40fe-8823-96a304a09859 rootwait ro fsck.repair=yes net.ifnames=0"
boot.ini command = fatload mmc 0:1 0x40008000 zImage
reading zImage

4794336 bytes read
boot.ini command = fatload mmc 0:1 0x42000000 uInitrd
reading uInitrd

9757478 bytes read
boot.ini command = if test "${board_name}" = "xu4"; then fatload mmc 0:1 0x44000000 exynos5422-odroidxu4.dtb; setenv fdtloaded "true"; fi
reading exynos5422-odroidxu4.dtb

61570 bytes read
boot.ini command = if test "${board_name}" = "xu3"; then fatload mmc 0:1 0x44000000 exynos5422-odroidxu3.dtb; setenv fdtloaded "true"; fi
reading exynos5422-odroidxu3.dtb

62360 bytes read
boot.ini command = if test "${board_name}" = "xu3l"; then fatload mmc 0:1 0x44000000 exynos5422-odroidxu3-lite.dtb; setenv fdtloaded "true"; fi
reading exynos5422-odroidxu3-lite.dtb

61381 bytes read
boot.ini command = if test "${fdtloaded}" != "true"; then fatload mmc 0:1 0x44000000 exynos5422-odroidxu4.dtb; fi
boot.ini command = fdt addr 0x44000000

boot.ini command = setenv hdmi_phy_control "HPD=${HPD} vout=${vout}"
boot.ini command = if test "${cecenable}" = "false"; then fdt rm /cec@101B0000; fi
boot.ini command = if test "${disable_vu7}" = "false"; then setenv hid_quirks "usbhid.quirks=0x0eef:0x0005:0x0004"; fi
boot.ini command = if test "${external_watchdog}" = "true"; then setenv external_watchdog "external_watchdog=${external_watchdog} external_watchdog_debounce=${external_watchdog_debounce}"; fi
boot.ini command = setenv bootargs "${bootrootfs} ${videoconfig} ${hdmi_phy_control} ${hid_quirks} smsc95xx.macaddr=${macaddr} ${external_watchdog} governor=${governor} ${board_name}"
boot.ini command = dmc ${ddr_freq}
Unknown command 'dmc' - try 'help'
boot.ini command = bootz 0x40008000 0x42000000 0x44000000
## Loading init Ramdisk from Legacy Image at 42000000 ...
   Image Name:   uInitrd
   Image Type:   ARM Linux RAMDisk Image (uncompressed)
   Data Size:    9757414 Bytes = 9.3 MiB
   Load Address: 00000000
   Entry Point:  00000000
## Flattened Device Tree blob at 44000000
   Booting using the fdt blob at 0x44000000
   Using Device Tree in place at 44000000, end 44011fc4
From the tests it seems that even if the test fails, the other commands are executed and all the dtbs are loaded (on top of each other). The flag fdtloaded is true so the test which checks if it is not true fails and the failsafe is not loaded. Most likely the uboot "if test" command doesn't work when the variable isn't defined at all and needs to be rewritten.
By the way, this is how I test which ${board_name} gets set: I appended ${board_name} to the end of bootargs and check it in the OS with cat /proc/cmdline:

Code: Select all

# no board name
odroid@xu4-dev:~$ cat /proc/cmdline
console=tty1 console=ttySAC2,115200n8 root=UUID=e139ce78-9841-40fe-8823-96a304a09859 rootwait ro fsck.repair=yes net.ifnames=0 HPD=true vout=hdmi usbhid.quirks=0x0eef:0x0005:0x0004 smsc95xx.macaddr=00:1e:06:61:7a:39 false governor=ondemand s5p_mfc.mem=16M

# correct board name
odroid@xu4-dev:~$ cat /proc/cmdline
console=tty1 console=ttySAC2,115200n8 root=UUID=e139ce78-9841-40fe-8823-96a304a09859 rootwait ro fsck.repair=yes net.ifnames=0  HPD=true vout=hdmi usbhid.quirks=0x0eef:0x0005:0x0004 smsc95xx.macaddr=00:1e:06:61:7a:39 false governor=ondemand xu4  s5p_mfc.mem=16M
Edit:
I've checked uboot banner messages when booting:
working (emmc): U-Boot 2017.05-15377-gedb23d4 (Aug 24 2017 - 07:09:51 -0300) for ODROID-XU4
not working (sdcard): U-Boot 2012.07-00036-g4d29c46-dirty (Dec 04 2015 - 15:52:26) for Exynos5422

So, something inside uboot was not updated... I will continue checking
Last edited by mad_ady on Mon Nov 06, 2017 10:27 pm, edited 1 time in total.

User avatar
meveric
Posts: 10269
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go, H2 (N4100), N2
Has thanked: 13 times
Been thanked: 101 times
Contact:

Re: XU4 - missing eth0: Uboot ${board_name} = blank

Unread post by meveric » Mon Nov 06, 2017 10:27 pm

I think that the "failsafe" is not working is a known issue. I've reported that months ago :)

I also encountered the problem with backup and restore of images with "current" uboot not working.
As I deliver images with Kernel 3.10 this is not much of an issue, if I update to Kernel 4.9 uboot is updated first and with that the issue is (normally) solved.
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.

User avatar
mad_ady
Posts: 6155
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 121 times
Been thanked: 85 times
Contact:

Re: XU4 - missing eth0: Uboot ${board_name} = blank

Unread post by mad_ady » Mon Nov 06, 2017 11:09 pm

I've double-checked. The Uboot on the EMMC that lives after the MBR and before the first partition is an old Uboot:

Code: Select all

$ sudo dd if=/dev/sdc of=xu4-emmc-boot bs=3M count=1
$ grep -a "Dec 04 2015" xu4-emmc-boot | strings
...
U-Boot 2012.07-00036-g4d29c46-dirty (Dec 04 2015 - 15:52:26) for Exynos5422
...
So the real bootloader lives elsewhere on the XU4 emmc. I bet it's in the secret areas. The failsafe should be fixed - you would at least get a bootable board.

User avatar
mad_ady
Posts: 6155
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 121 times
Been thanked: 85 times
Contact:

Re: XU4 - missing eth0: Uboot ${board_name} = blank

Unread post by mad_ady » Tue Nov 07, 2017 12:08 am

I've played a little bit in uboot, and things are tricky when comparing blank variables:

Code: Select all

Exynos5422 # echo $stdin
serial
Exynos5422 # if test "${stdin}" = "serial"; then echo "Test pass"; fi
Test pass
Exynos5422 # if test "${stdin}" = "serial3"; then echo "Test pass"; fi
Exynos5422 # if test "${stdin}" = "3serial"; then echo "Test pass"; fi
Exynos5422 # 
Exynos5422 # board_name=
Exynos5422 # echo $board_name

Exynos5422 # if test "$board_name" = "serial"; then echo "Test pass"; fi
Test pass
Exynos5422 # if test "$board_name" = "serial3"; then echo "Test pass"; fi
Test pass
Exynos5422 # if test "$board_name" = "anything"; then echo "Test pass"; fi
Test pass
Exynos5422 # if test "$board_name" == "anything"; then echo "Test pass"; fi
Test pass
Exynos5422 # if test "$board_name" = ""; then echo "Test pass"; fi
Exynos5422 # if test "$board_name" != ""; then echo "Test pass"; fi
Exynos5422 # 

Tests are broken in uboot for empty variables, even comparing with "".
But if you concatenate them with a known string, you can do the compare:

Code: Select all

Exynos5422 # board_name=
Exynos5422 # echo $board_name

Exynos5422 # if test "${board_name}" = ""; then echo "Test pass"; fi
Exynos5422 # if test "x${board_name}" = "x"; then echo "Test pass"; fi
Test pass
Exynos5422 # board_name=xu4
Exynos5422 # echo $board_name
xu4
Exynos5422 # if test "${board_name}" = ""; then echo "Test pass"; fi
Test pass
Exynos5422 # if test "x${board_name}" = "x"; then echo "Test pass"; fi
Exynos5422 # 

@odroid: can you update the bootini package to specifically test for an empty $board_name like above and apply the correct dtb?

User avatar
odroid
Site Admin
Posts: 31363
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 50 times
Been thanked: 184 times
Contact:

Re: XU4 - missing eth0: Uboot ${board_name} = blank

Unread post by odroid » Tue Nov 07, 2017 12:00 pm

This is the latest boot.ini file. https://github.com/mdrjr/5422_bootini/b ... #L172-L176

Code: Select all

if test "${board_name}" = "xu4"; then fatload mmc 0:1 0x44000000 exynos5422-odroidxu4.dtb; setenv fdtloaded "true"; fi
if test "${board_name}" = "xu3"; then fatload mmc 0:1 0x44000000 exynos5422-odroidxu3.dtb; setenv fdtloaded "true"; fi
if test "${board_name}" = "xu3l"; then fatload mmc 0:1 0x44000000 exynos5422-odroidxu3-lite.dtb; setenv fdtloaded "true"; fi
#failsafe
if test "${fdtloaded}" != "true"; then fatload mmc 0:1 0x44000000 exynos5422-odroidxu4.dtb; fi
The #failsafe seems to be fine even with the old u-boot.

You had to update BL0/BL1/u-boot in the eMMC hidden boot block(mmcblk0boot0) to get a proper board_name.

User avatar
odroid
Site Admin
Posts: 31363
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 50 times
Been thanked: 184 times
Contact:

Re: XU4 - missing eth0: Uboot ${board_name} = blank

Unread post by odroid » Tue Nov 07, 2017 4:21 pm

One interim version of u-boot 2017.05 might have an issue with board_name string.
Please try the latest u-boot binary package.
http://deb.odroid.in/5422-s/pool/main/u/uboot/

User avatar
mad_ady
Posts: 6155
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 121 times
Been thanked: 85 times
Contact:

Re: XU4 - missing eth0: Uboot ${board_name} = blank

Unread post by mad_ady » Tue Nov 07, 2017 4:32 pm

Clearly I have two problems.
1. After restoring a backup that was done on an emmc, I did not get the uboot stored in the hidden sectors and I had some old uboot stored before the first partition. This can be fixed by reinstalling uboot, I agree. But, this old uboot should still boot the board and allow for network access so that the user can update it manually
2. The boot.ini failsafe doesn't work with this old uboot version. The "if test" clauses return true when "${board_name}" is undefined, causing all the DTBs to be loaded (and the last one will be the valid one). This is why there should be a specific check for an empty board name (if test "x${board_name}" = "x"; then fatload mmc 0:1 0x44000000 exynos5422-odroidxu4.dtb; setenv fdtloaded "true"; fi). This will fail if $board_name is set to anything and the regular logic can continue.
I will test it on my system and report back.

User avatar
odroid
Site Admin
Posts: 31363
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 50 times
Been thanked: 184 times
Contact:

Re: XU4 - missing eth0: Uboot ${board_name} = blank

Unread post by odroid » Tue Nov 07, 2017 4:45 pm

Since the string comparison function had a serious bug in old u-boot, the failsafe logic couldn't work properly.
So that routine loads 4 dtb files sequentially because all return value was always True.
Wrongly stacked dtb files in the same memory region should make unpredictable results.

User avatar
mad_ady
Posts: 6155
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 121 times
Been thanked: 85 times
Contact:

Re: XU4 - missing eth0: Uboot ${board_name} = blank

Unread post by mad_ady » Tue Nov 07, 2017 5:45 pm

Yes, exactly! Actually, the last dtb overwrites the previous ones (are copied on top of eachother).

Ok, I've tested with this addition to boot.ini added just before the '#failsafe' statement (after the previous tests):

Code: Select all

#failsafe in case the bootloader doesn't support board_name
if test "x${board_name}" = "x"; then echo "Board Name is empty - defaulting to a XU4!"; fatload mmc 0:1 0x44000000 exynos5422-odroidxu4.dtb; setenv fdtloaded "true"; fi

The board boots fine (with the correct DTB) with an old bootloader (2012.07-00036-g4d29c46-dirty (Dec 04 2015 - 15:52:26)) and boots normally with the current (2017.05-15377-gedb23d4 (Aug 24 2017 - 07:09:51 -0300)) bootloader. Please consider adding it to bootini.

One question though - since the most noticeable difference between XU3/XU3-lite/XU4 is the different network card driver, why can't both network card statements be present in all DTBs and the driver would load only on the board which has the correct hardware (and all hardware will be eth0)? That would allow the failsafe DTB to be fine for both XU4 and XU3.

User avatar
tobetter
Posts: 3688
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: 28 times
Been thanked: 116 times
Contact:

Re: XU4 - missing eth0: Uboot ${board_name} = blank

Unread post by tobetter » Tue Nov 07, 2017 6:44 pm

I don't know if I am missing something, but if I do have a chance I would go for this instead of using multiple lines of if statements. The board name is set by U-boot and I would change "xu3l" to "xu3-lite" obviously.

Code: Select all

setenv dtb exynos5422-odroid${board_name}.dtb
fatload mmc 0:1 0x44000000 ${dtb}

User avatar
mad_ady
Posts: 6155
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 121 times
Been thanked: 85 times
Contact:

Re: XU4 - missing eth0: Uboot ${board_name} = blank

Unread post by mad_ady » Tue Nov 07, 2017 7:08 pm

That would be an optimization, but it wouldn't solve the issue. The issue is that with old uboot versions, board_name is undefined, so you would still need to catch that somehow.
But yes, your suggestion is cleaner than having a bunch of ifs. And would be compatible with overriding it via boot.ini.default if needed.

User avatar
tobetter
Posts: 3688
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: 28 times
Been thanked: 116 times
Contact:

Re: XU4 - missing eth0: Uboot ${board_name} = blank

Unread post by tobetter » Tue Nov 07, 2017 7:17 pm

mad_ady wrote:That would be an optimization, but it wouldn't solve the issue. The issue is that with old uboot versions, board_name is undefined, so you would still need to catch that somehow.
But yes, your suggestion is cleaner than having a bunch of ifs. And would be compatible with overriding it via boot.ini.default if needed.
Thanks, now I understand the root problem and your if statement is worth to add I think.

Code: Select all

if test "x${board_name}" = "x"; then setenv board_name xu4; fi
setenv dtb exynos5422-odroid${board_name}.dtb
fatload mmc 0:1 0x44000000 ${dtb}
Last edited by tobetter on Tue Nov 07, 2017 7:33 pm, edited 1 time in total.

User avatar
mad_ady
Posts: 6155
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 121 times
Been thanked: 85 times
Contact:

Re: XU4 - missing eth0: Uboot ${board_name} = blank

Unread post by mad_ady » Tue Nov 07, 2017 7:30 pm

Yeah, that would work as well, and would minimize the code in boot.ini. It's a better choice than my suggestion.

User avatar
odroid
Site Admin
Posts: 31363
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 50 times
Been thanked: 184 times
Contact:

Re: XU4 - missing eth0: Uboot ${board_name} = blank

Unread post by odroid » Fri Nov 10, 2017 8:56 am


User avatar
mad_ady
Posts: 6155
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 121 times
Been thanked: 85 times
Contact:

Re: XU4 - missing eth0: Uboot ${board_name} = blank

Unread post by mad_ady » Fri Nov 10, 2017 3:10 pm

I will test it and report back, But will it work for xu3-lite? It seems that the board name differs from dtb name...

User avatar
odroid
Site Admin
Posts: 31363
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 50 times
Been thanked: 184 times
Contact:

Re: XU4 - missing eth0: Uboot ${board_name} = blank

Unread post by odroid » Fri Nov 10, 2017 3:38 pm

You are right! we had to check xu3l != xu3lite.
We will update it soon. :(

Post Reply

Return to “Ubuntu”

Who is online

Users browsing this forum: No registered users and 3 guests