How to change the U-boot environment

Post Reply
Sholander
Posts: 140
Joined: Wed Jun 05, 2019 1:02 am
languages_spoken: english
ODROIDs: ODROID N2
Has thanked: 0
Been thanked: 15 times
Contact:

How to change the U-boot environment

Post by Sholander » Wed Jun 05, 2019 1:15 am

Hi, this is my first post, and naturally I need help :)

I installed successfully Android Pie (20190603) since this new versions advertises possible dual boot Android on eMMC and CoreElec on uSD:

* Adding tools that can change the U-boot environment values on Android.
* The users who want to run multiple OS complained the difficulty to make ODROID-N2 boots from SD card due to the boot order that eMMC is a higher priority.

Although my installation and registration finished without any issue, I cannot find mentioned "tools" nor any other way to change U-boot environment values, so that N2 boots from uSD when inserted.
Can you help me with some hints, or explanation how to achieve this?

User avatar
mad_ady
Posts: 8142
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 566 times
Been thanked: 400 times
Contact:

Re: How to change the U-boot environment

Post by mad_ady » Wed Jun 05, 2019 2:49 am

In the long term I think Petitboot will be the key for multiboot. Though it's not there yet for android, I know Hardkernel are working on it...

User avatar
tobetter
Posts: 5206
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: 175 times
Been thanked: 543 times
Contact:

Re: How to change the U-boot environment

Post by tobetter » Wed Jun 05, 2019 8:42 am

@Shander, as @mad_ady mentioned HK is working to improve Petitboot which is in SPI and can give a more flexibility to boot multiple OS rather than push and pull the micro SD, the ETA at the moment is a mid of June for the the update.

If you have installed very recent version of Android 20190603, it has a tool "fw_setenv" which can change the U-boot env. In order to change the boot order, please do the command once you open a terminal on Android. The command will let U-boot to load boot.ini from SD on next reboot.

Code: Select all

# fw_setenv mmc_list "1 0"
Please try and let us know how it works.

Sholander
Posts: 140
Joined: Wed Jun 05, 2019 1:02 am
languages_spoken: english
ODROIDs: ODROID N2
Has thanked: 0
Been thanked: 15 times
Contact:

Re: How to change the U-boot environment

Post by Sholander » Wed Jun 05, 2019 11:31 pm

I have a working Android 20190603; open Terminal and run the command (# fw_setenv mmc_list "1 0"). There is no return info, as if variable is set,
but it does not work. Android reboots back to Android. Turning off/on does not help, N2 boots only to Android, as if the uSD is not inserted...

Is there a way to install Magisk without PC? Magisk Manager.apk (7.2.0) is installed.

User avatar
tobetter
Posts: 5206
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: 175 times
Been thanked: 543 times
Contact:

Re: How to change the U-boot environment

Post by tobetter » Wed Jun 05, 2019 11:47 pm

Sholander wrote:
Wed Jun 05, 2019 11:31 pm
I have a working Android 20190603; open Terminal and run the command (# fw_setenv mmc_list "1 0"). There is no return info, as if variable is set,
but it does not work. Android reboots back to Android. Turning off/on does not help, N2 boots only to Android, as if the uSD is not inserted...

Is there a way to install Magisk without PC? Magisk Manager.apk (7.2.0) is installed.
Can you run another command in the terminal "fw_print mmc_list"?

Sholander
Posts: 140
Joined: Wed Jun 05, 2019 1:02 am
languages_spoken: english
ODROIDs: ODROID N2
Has thanked: 0
Been thanked: 15 times
Contact:

Re: How to change the U-boot environment

Post by Sholander » Thu Jun 06, 2019 12:48 am

I get this response:- /system/bin/sh: fw_print: not found

Sholander
Posts: 140
Joined: Wed Jun 05, 2019 1:02 am
languages_spoken: english
ODROIDs: ODROID N2
Has thanked: 0
Been thanked: 15 times
Contact:

Re: How to change the U-boot environment

Post by Sholander » Sun Jun 09, 2019 12:23 am

tobetter wrote:
Wed Jun 05, 2019 11:47 pm
Sholander wrote:
Wed Jun 05, 2019 11:31 pm
I have a working Android 20190603; open Terminal and run the command (# fw_setenv mmc_list "1 0"). There is no return info, as if variable is set,
but it does not work. Android reboots back to Android. Turning off/on does not help, N2 boots only to Android, as if the uSD is not inserted...

Is there a way to install Magisk without PC? Magisk Manager.apk (7.2.0) is installed.
Can you run another command in the terminal "fw_print mmc_list"?
Since I could not get any response with "fw_print mmc_list" I run "fw_printenv mmc_list and got: Can't open /dev/block/env: Permission denied.

I then rooted the box and after running "# fw_setenv mmc_list "1 0"" i looked up /dev/block/env and there is still "mmc_list=0 1". Looks like command # fw_setenv mmc_list "1 0" does not change anything. Box still boots only to Android...

loznic89
Posts: 19
Joined: Tue May 07, 2019 8:01 am
languages_spoken: spanish
ODROIDs: Odroid N2
Has thanked: 12 times
Been thanked: 3 times
Contact:

Re: How to change the U-boot environment

Post by loznic89 » Sun Jun 09, 2019 4:33 am

trying with same results as sholander

Luke.go
Posts: 503
Joined: Mon May 30, 2016 1:55 pm
languages_spoken: english
Has thanked: 51 times
Been thanked: 52 times
Contact:

Re: How to change the U-boot environment

Post by Luke.go » Mon Jun 10, 2019 10:29 am

You can check env via fw_printenv command.

Sholander
Posts: 140
Joined: Wed Jun 05, 2019 1:02 am
languages_spoken: english
ODROIDs: ODROID N2
Has thanked: 0
Been thanked: 15 times
Contact:

Re: How to change the U-boot environment

Post by Sholander » Mon Jun 10, 2019 9:50 pm

Luke.go wrote:
Mon Jun 10, 2019 10:29 am
You can check env via fw_printenv command.
Not really:
$ fw_printenv
Can't open /dev/block/env: Permission denied
$

User avatar
tobetter
Posts: 5206
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: 175 times
Been thanked: 543 times
Contact:

Re: How to change the U-boot environment

Post by tobetter » Mon Jun 10, 2019 9:52 pm

Sholander wrote:
Mon Jun 10, 2019 9:50 pm
Luke.go wrote:
Mon Jun 10, 2019 10:29 am
You can check env via fw_printenv command.
Not really:
$ fw_printenv
Can't open /dev/block/env: Permission denied
$
Does "su" work on your Android?

Sholander
Posts: 140
Joined: Wed Jun 05, 2019 1:02 am
languages_spoken: english
ODROIDs: ODROID N2
Has thanked: 0
Been thanked: 15 times
Contact:

Re: How to change the U-boot environment

Post by Sholander » Mon Jun 10, 2019 10:05 pm

Yes, tried now first wit "su", and got env displayed.
Did not know that I have to run "su" first; will try to set the variable with : # fw_setenv mmc_list "1 0"
and let you know the result.

Edit: ckecked env file and at the end "mmc_list=1 0" was added.
Rebooted the box, and it restarted to Android again.
Turned power off/on it boots to Android again, as if no boot uSD is inserted...
These users thanked the author Sholander for the post:
loznic89 (Fri Jun 14, 2019 7:10 am)

User avatar
tobetter
Posts: 5206
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: 175 times
Been thanked: 543 times
Contact:

Re: How to change the U-boot environment

Post by tobetter » Tue Jun 11, 2019 12:38 am

Sholander wrote:
Mon Jun 10, 2019 10:05 pm
Yes, tried now first wit "su", and got env displayed.
Did not know that I have to run "su" first; will try to set the variable with : # fw_setenv mmc_list "1 0"
and let you know the result.

Edit: ckecked env file and at the end "mmc_list=1 0" was added.
Rebooted the box, and it restarted to Android again.
Turned power off/on it boots to Android again, as if no boot uSD is inserted...
Can you copy all output of fw_printenv, please? I suspect something has been changed unexpectedly.

Sholander
Posts: 140
Joined: Wed Jun 05, 2019 1:02 am
languages_spoken: english
ODROIDs: ODROID N2
Has thanked: 0
Been thanked: 15 times
Contact:

Re: How to change the U-boot environment

Post by Sholander » Tue Jun 11, 2019 1:15 am

This is my "env" from /dev/block, after running # fw_setenv mmc_list "1 0" :
https://drive.google.com/file/d/1MTp9r2 ... sp=sharing

User avatar
tobetter
Posts: 5206
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: 175 times
Been thanked: 543 times
Contact:

Re: How to change the U-boot environment

Post by tobetter » Tue Jun 11, 2019 1:46 am

Sholander wrote:
Tue Jun 11, 2019 1:15 am
This is my "env" from /dev/block, after running # fw_setenv mmc_list "1 0" :
https://drive.google.com/file/d/1MTp9r2 ... sp=sharing
I've downloaded your boot env and confirmed that "mmc_list" is properly changed as "1 0". I also have flashed the env blob to my eMMC and it works as expected, the U-boot loads the boot.ini from eMMC when SD card is detached vs from SD when it's attached. By any chance, does the boot select switch is placed to "SPI"?

Sholander
Posts: 140
Joined: Wed Jun 05, 2019 1:02 am
languages_spoken: english
ODROIDs: ODROID N2
Has thanked: 0
Been thanked: 15 times
Contact:

Re: How to change the U-boot environment

Post by Sholander » Tue Jun 11, 2019 2:04 am

No, it's properly positioned to face eMMC/uSD cards...
On my uSD card I have latest nightly from CoreElec installed. It works perfect, but maybe there is something different.
Which OS did you have on uSD when trying, CoreElec or your Ubuntu version?

IIRC CoreElec devs have reversed new boot priority that HK uses. With CoreElec installed to eMMC and uSD card, boot priority has uSD, and not eMMC as is the case with your Android, as I understand.

Tnx for taking time to help me sort out this (not really a big) problem.

Btw, I have an OLED display hooked up to GPIO pins 1, 3, 5 and 6. Could that have any influence?

Sholander
Posts: 140
Joined: Wed Jun 05, 2019 1:02 am
languages_spoken: english
ODROIDs: ODROID N2
Has thanked: 0
Been thanked: 15 times
Contact:

Re: How to change the U-boot environment

Post by Sholander » Tue Jun 11, 2019 8:22 pm

tobetter wrote:
Tue Jun 11, 2019 1:46 am
I've downloaded your boot env and confirmed that "mmc_list" is properly changed as "1 0". I also have flashed the env blob to my eMMC and it works as expected, the U-boot loads the boot.ini from eMMC when SD card is detached vs from SD when it's attached.
Well, since I had to install Ubuntu "ubuntu-18.04.2-4.9-mate-odroid-n2-20190325.img" to to solve my WiFi dongle problem, I tried to reboot from Android on eMMC to Ubuntu on uSD, and it works properly. Powering on N2 wirt both media inserted, it boots to Ubuntu on uSD card, as intended.

So, your fix works OK with Ubuntu, but does not work with CoreElec on uSD card. What should I ask devs at CoreElec to change so that reboot works also with CE?

User avatar
tobetter
Posts: 5206
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: 175 times
Been thanked: 543 times
Contact:

Re: How to change the U-boot environment

Post by tobetter » Tue Jun 11, 2019 8:38 pm

My quick guess is that there is nothing what CE team has to change when CE is sitting on uSD. This is because the U-boot will loaded from eMMC. What I understand is that CE team had changed the device order SD as 0 and eMMC as 1. Let me check CE again if their boot.ini does not work somehow when I get back to my home. What's the CE version installed on your uSD again?

"Tapatalk wishes you to have fun with ODROID"


Sholander
Posts: 140
Joined: Wed Jun 05, 2019 1:02 am
languages_spoken: english
ODROIDs: ODROID N2
Has thanked: 0
Been thanked: 15 times
Contact:

Re: How to change the U-boot environment

Post by Sholander » Tue Jun 11, 2019 9:32 pm

My present CE version is latest nightly: "https://relkai.coreelec.org/CoreELEC-Am ... 190609.tar"

User avatar
tobetter
Posts: 5206
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: 175 times
Been thanked: 543 times
Contact:

Re: How to change the U-boot environment

Post by tobetter » Tue Jun 11, 2019 10:55 pm

Sholander wrote:
Tue Jun 11, 2019 9:32 pm
My present CE version is latest nightly: "https://relkai.coreelec.org/CoreELEC-Am ... 190609.tar"
I figured out why CE does not boot up. The reason is that the boot.ini of CE does have a symbol which is not in the U-boot of Hardkernel. CE team manages their own U-boot which is derived by HK's one. Anyway...Please do add simply add a single line setenv mmc_dev ${devnum}, it would look like this.
12 setenv label "CoreELEC"
13 setenv max_freq_a73 "1800"
14 setenv max_freq_a53 "1896"
15 setenv hdmi_cec "1"
16 setenv remotewakeup "0x23dc4db2"
17 setenv decode_type "0"
18 setenv remotewakeupmask "0xffffffff"
19 setenv wol "1"
20 setenv heartbeat "1"
21 setenv emmc_timeout "0"
22 setenv coreelec "quiet"
23
24 setenv mmc_dev ${devnum}
25
26 setenv rootopt "BOOT_IMAGE=kernel.img boot=UUID=2505-2655 disk=UUID=9930cd2d-d065-4ac9-b2dd-9a60f4d87342"
27 setenv consoleopt "console=ttyS0,115200 console=tty0 no_console_suspend"
28 setenv displayopt "hdmimode=1080p60hz logo=osd0,loaded,0x3d800000"
29
30 setenv loadaddr 0x11000000
31 setenv dtb_mem_addr 0x1000000
32 setenv uenv_addr 0x13000000
33
34 fatload mmc ${mmc_dev}:1 ${loadaddr} kernel.img
35 fatload mmc ${mmc_dev}:1 ${dtb_mem_addr} dtb.img
36 if fatload mmc ${mmc_dev}:1 ${uenv_addr} config.ini; then env import -t ${uenv_addr} $filesize; fi
These users thanked the author tobetter for the post:
loznic89 (Fri Jun 14, 2019 7:11 am)

Sholander
Posts: 140
Joined: Wed Jun 05, 2019 1:02 am
languages_spoken: english
ODROIDs: ODROID N2
Has thanked: 0
Been thanked: 15 times
Contact:

Re: How to change the U-boot environment

Post by Sholander » Tue Jun 11, 2019 11:40 pm

Did that, made suggested change. Will test it a bit later, and let you know the result.

Btw, does it matter that my line 26 differs from yours?

26 setenv rootopt "BOOT_IMAGE=kernel.img boot=UUID=2104-0457 disk=UUID=4be24a7c-d0b3-4620-9038-6bf060abe46d"

Sholander
Posts: 140
Joined: Wed Jun 05, 2019 1:02 am
languages_spoken: english
ODROIDs: ODROID N2
Has thanked: 0
Been thanked: 15 times
Contact:

Re: How to change the U-boot environment

Post by Sholander » Tue Jun 11, 2019 11:51 pm

OK, was impatient and tried it now, and it WORKS :)

With added "setenv mmc_dev ${devnum}" it boots from power on to CE, and reboots from Android to CE on uSD card.

I just have to get this solution to CE devs to include this in their config.ini, because boot.ini is overwritten with every update.

Thnx very much for your support, I have sorted today two issues, uSD boot priority in CE, and my Edup wifi dongle works in Android :)
These users thanked the author Sholander for the post:
loznic89 (Fri Jun 14, 2019 7:11 am)

User avatar
tobetter
Posts: 5206
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: 175 times
Been thanked: 543 times
Contact:

Re: How to change the U-boot environment

Post by tobetter » Wed Jun 12, 2019 1:23 am

Sholander wrote:
Tue Jun 11, 2019 11:51 pm
OK, was impatient and tried it now, and it WORKS :)

With added "setenv mmc_dev ${devnum}" it boots from power on to CE, and reboots from Android to CE on uSD card.

I just have to get this solution to CE devs to include this in their config.ini, because boot.ini is overwritten with every update.

Thnx very much for your support, I have sorted today two issues, uSD boot priority in CE, and my Edup wifi dongle works in Android :)
Glad to hear you had a good day. :)
FYI, I am working on Petitboot which can manage the multiple images, not perfect yet and unfortunately, you are running two platforms that are not able to boot by Petitboot. I am trying to figure out and you will not push and pull your SD card any more if Petitboot work. ::cross-finger::
These users thanked the author tobetter for the post:
loznic89 (Wed Jun 12, 2019 8:47 am)

Sholander
Posts: 140
Joined: Wed Jun 05, 2019 1:02 am
languages_spoken: english
ODROIDs: ODROID N2
Has thanked: 0
Been thanked: 15 times
Contact:

Re: How to change the U-boot environment

Post by Sholander » Wed Jun 12, 2019 1:34 am

I read that Petitboot is under major reconstruction, and hope your wishes come true :)

Post Reply

Return to “Android”

Who is online

Users browsing this forum: No registered users and 8 guests