eMMC dual Linux boot

Post Reply
rezzonics
Posts: 25
Joined: Sat Jul 07, 2018 6:54 am
languages_spoken: english
ODROIDs: C2
Has thanked: 1 time
Been thanked: 4 times
Contact:

eMMC dual Linux boot

Post by rezzonics »

What I was fearing has finally happened, I have largely exceeded the maximum number of insertions of eMMC Flash connector, as a consequence I have Flash read errors.
I really need to change the way I work but I don't know how to do it.
This is the way I was working until know. I am developing some Linux sound drivers for a specific audio codec. I develop on a PC with Ubuntu Linux and I use Yocto/Open embedded meta-meson to compile a whole Linux Image with mainline bootloader for Odroid-C2. Compilation generates a .wic image file that I burn into eMMC flash using Balena etcher and USB eMMC module writer.
I have made hundreds of modifications and tests, which means that every time I have to unplug Flash from Odroid C2, plug into the UWB writer, flash image, unplug and plug into Odroid-C2 again.
I think that the maximum number of insertions assured by those eMMC connectors is in the order of 50 or so, so I have largely exceeded that number and now I have errors.
I really need to work without unplugging the eMMC Flash. I would appreciate any help on how to do it.
I think that I could have two partitions on the eMMC with a Linux image on each partition, one working image and one image for testing changes, and I could have a variable on bootloader that allows to boot from working image or test image. I have to be able then to write the test image from PC Linux into test partition on eMMC flash while Odroid is running on working partition, via TFTP maybe? For that, working Linuw have to be able to access the test partition for writing. I have to be able to change boot address on Bootloader (how?) to boot from test image. If test image is broken and does not boot, I have to be able to revert to working image, and change bot address on bootloader.
Can anybody give me hints on how to implement this or any other solution that could allow debugging SW without unplugging eMMC flash?

igorpec
Posts: 699
Joined: Sat Dec 12, 2015 4:34 pm
languages_spoken: english,german,slovene
ODROIDs: XU4, HC1, C2, C1+
Has thanked: 34 times
Been thanked: 98 times
Contact:

Re: eMMC dual Linux boot

Post by igorpec »

rezzonics wrote:
Fri Sep 04, 2020 3:24 am
Can anybody give me hints on how to implement this or any other solution that could allow debugging SW without unplugging eMMC flash?
We are developing universal solution. Currently at a second prototype. Goal is to support automated testings, but its also handy for development.
https://github.com/armbian/mpads

v1.
https://github.com/armbian/mpads/raw/ma ... s/mpads.jp

v2
Image

More info in forums: https://forum.armbian.com/topic/10841-t ... ng-thread/
ARMBIAN
Linux for ARM development boards

Download latest images for Odroids | Build them from sources | Donate to support development

User avatar
tobetter
Posts: 5878
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: Many
Location: Paju, South Korea
Has thanked: 248 times
Been thanked: 718 times
Contact:

Re: eMMC dual Linux boot

Post by tobetter »

Can anybody give me hints on how to implement this or any other solution that could allow debugging SW without unplugging eMMC flash?
@rezzonics, if you are running the stock U-boot from Hardkernel and not need to update frequently but needs to update the file system in eMMC, you can consider using ums feature from the U-boot. This feature allows you to connect your ODROID-C2 using micro USB cable and the memory card - eMMC or SD card - can be treated as a USB storage from your PC. Please refer to the link some users had tried.
viewtopic.php?p=280660#p280660

L67GS
Posts: 166
Joined: Wed Apr 22, 2020 3:02 pm
languages_spoken: english
ODROIDs: XU4, C1+,(3) C0's, and a whole big pile of accessories, VU7A Plus,, ect....
Has thanked: 55 times
Been thanked: 24 times
Contact:

Re: eMMC dual Linux boot

Post by L67GS »

Can we boot from SD card and run etcher to flash an eMMC?
That would be super cool.

User avatar
tobetter
Posts: 5878
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: Many
Location: Paju, South Korea
Has thanked: 248 times
Been thanked: 718 times
Contact:

Re: eMMC dual Linux boot

Post by tobetter »

L67GS wrote:
Fri Sep 04, 2020 7:21 am
Can we boot from SD card and run etcher to flash an eMMC?
That would be super cool.
When eMMC has the bootloader and it's not compromised, ODROID-C2 cannot be booted from SD. UMS command from U-boot does not matter where U-boot is booted from.

L67GS
Posts: 166
Joined: Wed Apr 22, 2020 3:02 pm
languages_spoken: english
ODROIDs: XU4, C1+,(3) C0's, and a whole big pile of accessories, VU7A Plus,, ect....
Has thanked: 55 times
Been thanked: 24 times
Contact:

Re: eMMC dual Linux boot

Post by L67GS »

tobetter wrote:
Fri Sep 04, 2020 9:07 am
L67GS wrote:
Fri Sep 04, 2020 7:21 am
Can we boot from SD card and run etcher to flash an eMMC?
That would be super cool.
When eMMC has the bootloader and it's not compromised, ODROID-C2 cannot be booted from SD. UMS command from U-boot does not matter where U-boot is booted from.
Then that method could work on a SBC where boot is hardware selectable like XU4?

User avatar
tobetter
Posts: 5878
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: Many
Location: Paju, South Korea
Has thanked: 248 times
Been thanked: 718 times
Contact:

Re: eMMC dual Linux boot

Post by tobetter »

L67GS wrote:
Sat Sep 05, 2020 12:23 am
tobetter wrote:
Fri Sep 04, 2020 9:07 am
L67GS wrote:
Fri Sep 04, 2020 7:21 am
Can we boot from SD card and run etcher to flash an eMMC?
That would be super cool.
When eMMC has the bootloader and it's not compromised, ODROID-C2 cannot be booted from SD. UMS command from U-boot does not matter where U-boot is booted from.
Then that method could work on a SBC where boot is hardware selectable like XU4?
No, as I explained not able to change the boot order between eMMC and uSD. This is not software issue, CPU itself does so.

rezzonics
Posts: 25
Joined: Sat Jul 07, 2018 6:54 am
languages_spoken: english
ODROIDs: C2
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: eMMC dual Linux boot

Post by rezzonics »

Is not possible to have 3 partitions?
  • bootloader,
  • root file system 1 = mmcblk1p1,
  • root file system 2=mmcblk1p2,
The issue then is how to select mmcblk1p1 or mmcblk1p2 as root on bootloader in an interactive fashion.
I usually connect to my Odroid-C2 via Ethernet with an ssh session, while bootloader output is redirected to UART (ttyAML0)
Is it possible to redirect the console to a ssh session?

User avatar
tobetter
Posts: 5878
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: Many
Location: Paju, South Korea
Has thanked: 248 times
Been thanked: 718 times
Contact:

Re: eMMC dual Linux boot

Post by tobetter »

rezzonics wrote:
Sat Sep 05, 2020 2:11 am
Is not possible to have 3 partitions?
  • bootloader,
  • root file system 1 = mmcblk1p1,
  • root file system 2=mmcblk1p2,
The issue then is how to select mmcblk1p1 or mmcblk1p2 as root on bootloader in an interactive fashion.
I usually connect to my Odroid-C2 via Ethernet with an ssh session, while bootloader output is redirected to UART (ttyAML0)
Is it possible to redirect the console to a ssh session?
If you have UART, then you can give a command to load boot.ini or boot.scr from any partition. Please google the command mmc in U-boot for detail. For example, you can use this command if you like to read a file - boot.ini - from the 2nd partition of your SD card.

Code: Select all

load mmc 1:2 ${loadaddr} boot.ini
What's the version of your U-boot?

rezzonics
Posts: 25
Joined: Sat Jul 07, 2018 6:54 am
languages_spoken: english
ODROIDs: C2
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: eMMC dual Linux boot

Post by rezzonics »

U-Boot version is v2019.07
On meta-meson yocto project there is a script to generate uboot variables and commands:

Code: Select all

setenv kernel_loadaddr "0x11000000"
setenv initrd_loadaddr "0x13000000"
setenv dtb_mem_addr "0x1000000"
setenv bootargs "console=ttyAML0,115200n8 console=tty0 no_console_suspend consoleblank=0 root=/dev/mmcblk1p2 rootwait"
if fatload mmc 0 ${kernel_loadaddr} uImage; then if fatload mmc 0 ${dtb_mem_addr} ##DTB## ; then bootm ${kernel_loadaddr} - ${dtb_mem_addr} ; fi ; fi
if fatload mmc 1 ${kernel_loadaddr} uImage; then if fatload mmc 1 ${dtb_mem_addr} ##DTB## ; then bootm ${kernel_loadaddr} - ${dtb_mem_addr} ; fi ; fi

User avatar
tobetter
Posts: 5878
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: Many
Location: Paju, South Korea
Has thanked: 248 times
Been thanked: 718 times
Contact:

Re: eMMC dual Linux boot

Post by tobetter »

rezzonics wrote:
Sat Sep 05, 2020 5:36 am
U-Boot version is v2019.07
On meta-meson yocto project there is a script to generate uboot variables and commands:

Code: Select all

setenv kernel_loadaddr "0x11000000"
setenv initrd_loadaddr "0x13000000"
setenv dtb_mem_addr "0x1000000"
setenv bootargs "console=ttyAML0,115200n8 console=tty0 no_console_suspend consoleblank=0 root=/dev/mmcblk1p2 rootwait"
if fatload mmc 0 ${kernel_loadaddr} uImage; then if fatload mmc 0 ${dtb_mem_addr} ##DTB## ; then bootm ${kernel_loadaddr} - ${dtb_mem_addr} ; fi ; fi
if fatload mmc 1 ${kernel_loadaddr} uImage; then if fatload mmc 1 ${dtb_mem_addr} ##DTB## ; then bootm ${kernel_loadaddr} - ${dtb_mem_addr} ; fi ; fi
I believe you can use 0:1, 0:2, 1:1 and 1:2 to read a file from your memory cards.
What's missing now?

rezzonics
Posts: 25
Joined: Sat Jul 07, 2018 6:54 am
languages_spoken: english
ODROIDs: C2
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: eMMC dual Linux boot

Post by rezzonics »

I think I need to change the environment variable bootdelay to be able to stop uboot from booting default OS, and switch to the other OS, right?
something like

Code: Select all

setenv bootdelay 3

User avatar
tobetter
Posts: 5878
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: Many
Location: Paju, South Korea
Has thanked: 248 times
Been thanked: 718 times
Contact:

Re: eMMC dual Linux boot

Post by tobetter »

rezzonics wrote:
Sat Sep 05, 2020 6:22 am
I think I need to change the environment variable bootdelay to be able to stop uboot from booting default OS, and switch to the other OS, right?
something like

Code: Select all

setenv bootdelay 3
Well...I don't think so...boot delay is soley delay to execute the next command and it gives you a chance to get a U-boot command prompt. I guess you can use the command gpio if you have spare GPIO pins so based on the GPIO input "H" / "L", you can run mmc command on boot.

rezzonics
Posts: 25
Joined: Sat Jul 07, 2018 6:54 am
languages_spoken: english
ODROIDs: C2
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: eMMC dual Linux boot

Post by rezzonics »

My first test failed, well almost worked, but the issue it is not what I expected. This is what I did:
I created an ext4 partition (seen as /dev/sdf2 on Linux PC) on a working eMMC flash (that previously contained /dev/sdf -> /dev/sdf1)
/dev/sdf1 is mounted as /media/user/root
/dev/sdf2 is mounted as /media/user/root2
I mounted an Odroid C2 Ubuntu minimal image on Linux PC.
I copied /rootfs tree into /media/user/root2 (the new partition /dev/sdf2)
On the existing working partition, I edited /root/boot/extlinux.conf which must be the equivalent of boot.ini and I changed /dev/mmcblk0p1 by /dev/mmcblk0p2 to boot onto the new partition.
I didn't change Image nor dtb files on this second partition, but I renamed the dtb file to match the name on the first partition.
I deleted aafirstboot file because I think it messes with partitions.
Odroid C2 booted, blue LED blinks at a normal pace. TUX penguins logo appears very breafly and I get a blinking prompt, but no login prompt.
I can ping Odroid C2, if I try to open an ssh session it asks for a password but it does not allow any login, root or odroid.
So the concept seems to work but for some reason I cannot login.
Anybody knows what's going wrong?

rezzonics
Posts: 25
Joined: Sat Jul 07, 2018 6:54 am
languages_spoken: english
ODROIDs: C2
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: eMMC dual Linux boot

Post by rezzonics »

Using my own custom kernel linux it worked!
I have also solved how to transfer root file system from Linux PC to eMMC flash partition 2
Using the following command I can transfer via SSH the compressed tar.bz2 file with root file system from Linux PC to Odroid-C2 and decompress it at destination:

Code: Select all

ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@192.168.1.xx "cd /media/root2 && tar -jxvv" <   amlogic-image-headless-sd-hardkernel-odroidc2.tar.bz2 
Odroid-C2 has to boot on partition 1. Partition 2 has to be previously mounted. Previous existing root file system on partition 2 has to be deleted first.
In the example above, /media/root2 is the mounting point of partition 2 on Odroid-C2
amlogic-image-headless-sd-hardkernel-odroidc2.tar.bz2 is the compressed root file system local to PC Linux.
Once root file system has been transfered and decompressed on partition 2, bootloader configuration file has to be changed to boot on partition2.

If the root file system on partition 2 boots and runs properly I can switch and boot from partition 1 or 2 by editing the bootloader configuration file on partition 1 and selecting /dev/mmcblk0p1 or /dev/mmcblk0p2

I think I have now a debug and test environment without the need of plugging / unplugging eMMC flash and using USB writer.
I have a secure working root file system on partition 1 and a root file system on partition 2 for experimentation, debug and testing.
I guess if partition 2 gets corrupted and does not boot I will have to connect console on UART connector and stop U-BOOT to switch to partition 1, but for now I have something that works.
These users thanked the author rezzonics for the post:
odroid (Mon Sep 07, 2020 10:39 am)

Post Reply

Return to “Issues”

Who is online

Users browsing this forum: No registered users and 0 guests