Jump to content

Recommended Posts

Posted

Hi to All,

 

I decided to start this new tread for searching of the best solution for unification of the boot process from any available media.

 

Main target is Armbian next and development branches and mainline Kernel and U-Boot.

Boot device can be eMMC, SD/MMC, USB Flash/HDD and SATA HDD/SSD probed in given order.

In case of booting from eMMC, SD/MMC and USB Flash Read-Only Root FS can be used optionally.

In case of booting from SD/MMC or USB Flash eMMC and / or SATA devices can be updated automatically.

 

Some effort in this direction was done by me and described in Armbian Customization thread.

The tests was done on Olimex' A20-Olimexino-Lime2-eMMC (HW rev. E) board with following additional staff:

The current status is:

  • U-Boot is patched to:
    • recognize eMMC;
    • search a boot-able device on SATA, USB, SD/MMC, eMMC etc.;
    • boot from the boot-able device with the highest priority;
    • send to the kernel via the command line right root=PARTUUID=${uuid};
  • Kernel is patched to recognize eMMC;
  • firstrun script is modified to resize right MMC device (mmcblk0 or mmcblk1);
  • eMMC and SATA device experimental update scripts are implemented and tested;
  • it is investigated the classical and overlayfs way to run Debian on RO Root FS;
  • Described staff is working fine on latest Armbian (5.17), Kernel (4.6.3) and U-Boot (2016.05).

Not solved issues are:

  • to mount root accordingly without explicit setting in /etc/fstab;
  • to resize root partition from firstrun script in case of USB and / or SATA devices;
  • to prepare and use Read-Only Root FS on eMMC, SD/MMC and USB Flash optionally;
  • to start eMMC and /or SATA device update procedure from firstrun script if boot from SD/MMC or USB Flash.

The main use case will include following steps:

  • If the system will be setup for the first time SD/MMC has to be used for been able to install U-Boot on empty eMMC;
  • In case of next FW update USB Flash will be used to boot from by installed on eMMC U-Boot;
  • Booting from SD/MMC will be forced by pushing of user button or renaming of /boot/boot.scr file on the devices with higher priority;
  • Booting from USB Flash will be done always when present because of highest priority;
  • firstrun script will be executed always if booting from image cloned device and the system will reboot if necessary;
  • At the end of firstrun script eMMC and / or SATA device update scripts will be executed to update them from image or SD/MMC or USB Flash itself.

The following staff was used to customize Armbian:

 

Mainline U-Boot patch to enable eMMC:

 

  Reveal hidden contents

 

 

Mainline U-Boot patch to change boot order:

 

  Reveal hidden contents

 

 

Mainline U-Boot boot script:

 

  Reveal hidden contents

 

 

Mainline Kernel patch to enable eMMC:

 

  Reveal hidden contents

 

 

Change in do_expand_rootfs() function of firstrun script to recognize right MMC device to resize:

#	DEVICE="/dev/"$(lsblk -idn -o NAME | grep -w mmcblk0)
	DEVICE=$(mount|grep ' / '|cut -d' ' -f 1 | cut -dp -f1)

Reboot script and service looking for user button push:

 

  Reveal hidden contents

 

 

Experimental script to update eMMC from image:

 

  Reveal hidden contents

 

 

Experimental script to update SATA SSD from image:

 

  Reveal hidden contents

 

 

Whole customization process with more details and test results can be found on Armbian Customization thread.

Latest prototype insides and test results can be found in the attached files.

 

Any ideas, comments and references are welcome.

 

Best regards

Chris

 

post-904-0-34294200-1468531528_thumb.jpg

Lime2-rev-C-E-comp-06-p8.pdfFetching info...

Lime2-rev-C-E-comp-06-7p.pdfFetching info...

Posted

Thank you for your work on this, as per my comments in the customisation and 'debian on lime2-emmc' threads. I have my system up and working the way I like it, but it is not automated in the fashion you are doing here... I would very much like it to be, but it is low on my priority list as we have to deploy this hardware very soon. Hopefully after that I can be more useful, but I am only just now getting back to embedded Linux for the first time since 2007. :)

 
Back to the matter at hand. I have a few questions for my own understanding.
 
The u-boot and kernel patches are the same as the ones in the current Armbian release, correct? Is there a reason why the lime2-emmc hasn't been defined as a separate board so we can eventually have it mainlined? 
 
With the boot order patch, why do it this way rather than customising the boot.cmd?
 
FYI, I changed my boot.cmd to the following which boots from the SATA drive if found, if not then continues with the eMMC. If a bootable SD card is inserted, it overrides both of them. 
I see that your boot script is more robust because it tries loading the kernel image, fdt, and initramfs and falls over to another boot device if those fail, whereas mine will require hardware removal if those fail. I will be changing mine to be more like yours in that regard. 
 
boot.cmd
  Reveal hidden contents
# Check for SATA drive and boot from it if found, else boot from eMMC.
 
# eMMC: root=PARTUUID=e9b1e023-01
# SD:   root=/dev/mmcblk0p1
 
scsi scan
 
if ext4load scsi 0 0x00000000 /boot/.next
then
    echo "Booting from SATA."
    setenv bootargs "root=/dev/sda1 console=ttyS0,115200 console=tty1 rootwait rootfstype=ext4 cgroup_enable=memory swapaccount=1 sunxi_ve_mem_reserve=0 sunxi_g2d_mem_reserve=0 sunxi_no_mali_mem_reserve sunxi_fb_mem_reserve=16 hdmi.audio=EDID:0 disp.screen0_output_mode=1920x1080p60 panic=10 consoleblank=0 enforcing=0 loglevel=${verbosity}"
    setenv bootdev "scsi 0" 
else
    echo "SATA drive not found. Booting from eMMC."
    setenv bootargs "root=PARTUUID=e9b1e023-01 console=ttyS0,115200 console=tty1 rootwait rootfstype=ext4 cgroup_enable=memory swapaccount=1 sunxi_ve_mem_reserve=0 sunxi_g2d_mem_reserve=0 sunxi_no_mali_mem_reserve sunxi_fb_mem_reserve=16 hdmi.audio=EDID:0 disp.screen0_output_mode=1920x1080p60 panic=10 consoleblank=0 enforcing=0 loglevel=${verbosity}"
    setenv bootdev "mmc 0"
fi
 
ext4load ${bootdev} ${fdt_addr_r} /boot/dtb/${fdtfile}
ext4load ${bootdev} ${ramdisk_addr_r} /boot/uInitrd
ext4load ${bootdev} ${kernel_addr_r} /boot/zImage
bootz ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
 

 
(p.s. what does that setup control? Looks very nice.)
Posted (edited)
  On 7/14/2016 at 9:59 PM, chradev said:

Not solved issues are:

  • to mount root accordingly without explicit setting in /etc/fstab;

You don't have to have a rootfs entry in fstab - just pass "rw" and "rootflags" to kernel command line to mount it from kernel

setenv bootargs "root=${uuid} rw rootflags=noatime,nodiratime ..."
  On 7/15/2016 at 1:47 AM, neomanic said:

The u-boot and kernel patches are the same as the ones in the current Armbian release, correct? Is there a reason why the lime2-emmc hasn't been defined as a separate board so we can eventually have it mainlined? 

lime2-emmc is mainlined - separate DT file will be available in kernel 4.7

Edited by zador.blood.stained
Copypaste gone wrong: rootargs->rootflags
Posted

Hi Neimatic,

  On 7/15/2016 at 1:47 AM, neomanic said:

 

The u-boot and kernel patches are the same as the ones in the current Armbian release, correct? Is there a reason why the lime2-emmc hasn't been defined as a separate board so we can eventually have it mainlined? 

 
With the boot order patch, why do it this way rather than customising the boot.cmd?
 

...

 

(p.s. what does that setup control? Looks very nice.)

 

U-Boot and Kernel patches I have used are the same as in Armbian release where they are disabled.

I have already offered to add new Lime2-eMMC board in Armbian but probably this will be happened after adopting Kernel 4.7 where lime2-emmc will be mainlined in separate DT file as noted by Zador.

Boot order patch (or overwriting it with uEnv.txt) is better solution permitting boot.cmd to be kept unified, simple and robust as you mention.

If you mention "setup control" related to the user button at power on forcing boot from eMMC it is an idea used in embedded devices and routers to load factory default FW when something goes wrong.

 

@Zador,

Thanks for your notes on how to add root flags to kernel line and coming new Lime2-eMMC support in kernel 4.7.

 

Best regards

Chris

Posted

Yes, thank you @Zador! That answers my question.

 

@chradev: thank you for the answers. Re: my question, it was about your system which you answered via PM.

Posted

Thanks Zador,

  On 7/15/2016 at 9:58 AM, zador.blood.stained said:

You don't have to have a rootfs entry in fstab - just pass "rw" and "rootflags" to kernel command line to mount it from kernel

setenv bootargs "root=${uuid} rw rootflags=noatime,nodiratime ..."

lime2-emmc is mainlined - separate DT file will be available in kernel 4.7

 

It works perfect and makes possible to specify from the boot script both RO FS for eMMC and RW FS for SD and SSD in my case.

 

EDIT: Unfortunately, it works because I have used wrong rootargs instead of rootflags so kernel ignored mount options.

But after moving to right rootflags kernel crashes with followint error:

[    5.129646] EXT4-fs (mmcblk0p1): Unrecognized mount option "noatime" or missing value
[    5.138951] EXT4-fs (mmcblk0p1): Unrecognized mount option "noatime" or missing value
[    5.146924] List of all partitions:
[    5.150429] 0100            4096 ram0  (driver?)
[    5.155088] 0101            4096 ram1  (driver?)
[    5.159717] 0102            4096 ram2  (driver?)
[    5.164343] 0103            4096 ram3  (driver?)
[    5.168995] b300         3776512 mmcblk1  driver: mmcblk
[    5.174317]   b301         3582976 mmcblk1p1 16072004-01
[    5.179655] b310           16384 mmcblk1boot1  (driver?)
[    5.185003] b308           16384 mmcblk1boot0  (driver?)
[    5.190322] b318         3887104 mmcblk0  driver: mmcblk
[    5.195662]   b319         1547264 mmcblk0p1 000d62f5-01
[    5.200978] No filesystem could mount root, tried:  ext4
[    5.206328] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(179,25)

The flags sent from U-Boot to Kernel via command line are:

setenv extended_bootargs root=PARTUUID=${uuid} rootfstype=ext4 rw rootflags=noatime,nodiratime,commit=600,errors=remount-ro rootwait
setenv bootargs console=${console} ${extended_bootargs} panic=10 loglevel=${verbosity}

Any ideas about what is wrong?

 

 

Best regards

Chris

Posted

Hi to All,

 

  On 7/21/2016 at 1:00 PM, chradev said:

Thanks Zador,

 

It works perfect and makes possible to specify from the boot script both RO FS for eMMC and RW FS for SD and SSD in my case.

 

EDIT: Unfortunately, it works because I have used wrong rootargs instead of rootflags so kernel ignored mount options.

But after moving to right rootflags kernel crashes with followint error:

[    5.129646] EXT4-fs (mmcblk0p1): Unrecognized mount option "noatime" or missing value
[    5.138951] EXT4-fs (mmcblk0p1): Unrecognized mount option "noatime" or missing value
[    5.146924] List of all partitions:
[    5.150429] 0100            4096 ram0  (driver?)
[    5.155088] 0101            4096 ram1  (driver?)
[    5.159717] 0102            4096 ram2  (driver?)
[    5.164343] 0103            4096 ram3  (driver?)
[    5.168995] b300         3776512 mmcblk1  driver: mmcblk
[    5.174317]   b301         3582976 mmcblk1p1 16072004-01
[    5.179655] b310           16384 mmcblk1boot1  (driver?)
[    5.185003] b308           16384 mmcblk1boot0  (driver?)
[    5.190322] b318         3887104 mmcblk0  driver: mmcblk
[    5.195662]   b319         1547264 mmcblk0p1 000d62f5-01
[    5.200978] No filesystem could mount root, tried:  ext4
[    5.206328] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(179,25)

The flags sent from U-Boot to Kernel via command line are:

setenv extended_bootargs root=PARTUUID=${uuid} rootfstype=ext4 rw rootflags=noatime,nodiratime,commit=600,errors=remount-ro rootwait
setenv bootargs console=${console} ${extended_bootargs} panic=10 loglevel=${verbosity}

Any ideas about what is wrong?

 

 

Best regards

Chris

After reading of many posts on Internet I find that some options like 'noatime' in 'rootflags' sent via Kernel command line can cause errors.

On the other hand 'noatime' is not a valid mount option for 'ext4' fs.

That is why I leave Kernel command line as:

console=ttyS0,115200 root=PARTUUID=01c14ee2-01 rootfstype=ext4 rw rootflags=discard,errors=remount-ro rootwait panic=10 loglevel=1

and booting from SSD is OK. 'dmesg' says:

EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: discard,errors=remount-ro

which is as expected. Booting from eMMC did not cause any problems as well.

 

Note 'discard' mount option is recommended for SSD drives. That is why I added it to mount options for the second SSD partition.

 

Best regards

Chris

Posted

Hi to All,

 

I have decided to publish my posts in PM with Neomatic (Josh) answering his questions noted above in this tread.

 

Sent 17 July 2016 - 03:03 AM

 

  Reveal hidden contents

 

Sent 20 July 2016 - 04:15 PM

 

  Reveal hidden contents

 

 

Best regards

Chris

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines