Jump to content

Boot Armbian vanilla kernel (4.7.2) from FAT boot partition?


Christian

Recommended Posts

I want to have a "dual boot" system with Openelec for video and Armbian for the rest :-)

 

The boot files are named different except 'boot.scr'. So the idea is to rename it, so the right one is used and then do a reboot. Not the PC dual boot with a menu, but good enough for me :-D

 

So I copied the files from the /boot folder to an existing FAT partition and copied the rest to a newly created ext4 partition (mmcblk0p3).

 

I modified 'boot.scr' to this:



gpio set PL10
gpio set PG11
setenv machid 1029
setenv bootm_boot_mode nonsec
if fatload mmc 0 0x00000000 /boot/.verbose
then
setenv verbosity 7
else
setenv verbosity 1
fi
setenv bootargs "console=tty1 root=/dev/mmcblk0p3 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 panic=10 consoleblank=0 enforcing=0 loglevel=${verbosity}"
fatload mmc 0 ${fdt_addr_r} /dtb/${fdtfile} || ext4load mmc 0 ${fdt_addr_r} /boot/dtb/${fdtfile}
fatload mmc 0 ${ramdisk_addr_r} uInitrd || ext4load mmc 0 ${ramdisk_addr_r} /boot/uInitrd || setenv ramdisk_addr_r "-"
fatload mmc 0 ${kernel_addr_r} zImage || ext4load mmc 0 ${kernel_addr_r} /boot/zImage
bootz ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}


It's removing/replacing 'ext4load' from the original at some places and changing the partition where root resides.

 

It doesn't boot. What do I do wrong? Or does the boot files have to be on a ext4 partition. How else could I create a "dual boot" withe Openelec?

 

Thanks!

 

Christian

Link to comment
Share on other sites

You have to be more specific, i.e. provide logs from serial console or at least display output if there is any.

 

Booting from fat /boot partition is possible, but there are different stages where it may break after converting existing ext4 installation.

Well, I don't have a serial console and HDMI doesn't work :-D

 

But booting get's very far, so I assume it's not a bootloader problem except that maybe I have to change another parameter. I have attached all relevant logs -- I have deleted all but the last boot. The times are "jumping", but I guess I tell you nothing new here.

 

Maybe it's just a strange ssh problem. Is it possible to enable telnet?

armbian-booted-from-fat.zip

Link to comment
Share on other sites

In your u-boot does not support file upload command (ext4load) of partition ext4 ?

 

I tried to add the the Openelec files to the ext4 partition, but this didn't work either. I had the following 'boot.scr':

gpio set PL10
gpio set PG11
setenv machid 1029
setenv bootm_boot_mode nonsec
if ext4load mmc 0 0x00000000 /boot/.verbose
then
setenv verbosity 7
else
setenv verbosity 1
fi
if ext4load mmc 0 0x00000000 /boot/.next
then
# sunxi mainline kernel
#------------------------------------------------------------------------------------------
setenv bootargs "console=tty1 root=/dev/mmcblk0p1 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 panic=10 consoleblank=0 enforcing=0 loglevel=${verbosity}"
ext4load mmc 0 ${fdt_addr_r} /boot/dtb/${fdtfile} || fatload mmc 0 ${fdt_addr_r} /dtb/${fdtfile} || ext4load mmc 0 ${fdt_addr_r} /dtb/${fdtfile}
ext4load mmc 0 ${ramdisk_addr_r} /boot/uInitrd || fatload mmc 0 ${ramdisk_addr_r} uInitrd || ext4load mmc 0 ${ramdisk_addr_r} uInitrd || setenv ramdisk_addr_r "-"
ext4load mmc 0 ${kernel_addr_r} /boot/zImage || fatload mmc 0 ${kernel_addr_r} zImage || ext4load mmc 0 ${kernel_addr_r} zImage
bootz ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
#------------------------------------------------------------------------------------------
else
# openelec
#------------------------------------------------------------------------------------------
setenv bootargs console=ttyS0,115200 boot=/dev/mmcblk0p1 disk=/dev/mmcblk0p2 consoleblank=0
ext4load mmc 0 0x43000000 /boot/script.bin
ext4load mmc 0 0x42000000 KERNEL
bootm 0x42000000

I copied the command in the second part from the Openelec 'boot.scr'

Link to comment
Share on other sites

If Your version of OE has a utility fw_setenv all easy to solve, using one add env variable in u-boot. If utilities do not, all can be realized through the creation of the file. IMHO you should start with debugging separate options systems. After You check each system individually. Enough to combine their logical connection check the value of a variable or file exists. An example implementation of the selective startup of different systems depending on the value of a variable (which is set of OE) can be viewed here. By the way, to start (with serial key check values of variables) is not limited number of systems and not only with the internal memory and external media. Sorry for my English, I use machine translation. If not clear, write, I will try to describe in detail with examples.

 

https://github.com/150balbes/Amlogic_s905/blob/master/script/S905_LIBREELEC/s905_libreelec_v7/s905_autoscript.txt

 

https://github.com/150balbes/LibreELEC.tv/blob/Amlogic-S905-kszaq/projects/S905/filesystem/usr/sbin/rebootfromrecovery

 

https://github.com/150balbes/LibreELEC.tv/blob/Amlogic-S905-kszaq/projects/S905/filesystem/usr/sbin/rebootfromrecovery

Link to comment
Share on other sites

Which U-Boot do you use? from OpenELEC or from Armbian? If I remember correctly, THS needs patched U-Boot to work correctly and it is not included in OpenELECs U-Boot.

I use the u-boot of "your" Openelec. I created a new ext4 partition, copied Armbian there and the boot files additionally to the root folder of the FAT partion.

 

Before I tried to add Openelec to Armbian by creating a new partition for /storage and modified 'boot.scr' as described in

http://forum.armbian.com/index.php/topic/2042-boot-armbian-vanilla-kernel-472-from-fat-boot-partition/#entry15642

 

In that case I use the Armbian u-boot, but then Armbian started, but Openelec did not. Maybe it's because "your" 'boot.scr' contains absolute addresses, which are not compatible with Armbian's u-boot?

 

Would

ext4load mmc 0 ${fdt_addr_r} /boot/script.bin
ext4load mmc 0 ${kernel_addr_r} /boot/KERNEL
bootz ${kernel_addr_r}
work and have SYSTEM in both the /boot and the root folder of the ext4 partition.

 

Update: I tried it and it didn't work :-( So I assume Openelec needs to start from a FAT partition. Which MBR records do I have to copy (and then replace) to get the Armbian u-boot? I hope boot.scr of Openelec works with this new u-boot.

Thanks for your great work and support!

Link to comment
Share on other sites

What I would try to do is to take Armbian image as a base, add FAT partition and additional ext4 partition for OpenELEC & Kodi data and settings. FAT partition is by default 512 MB in size, but I think 256 MB should work just fine. EXT4 partition for OpenELEC must be more than 32MB in size, but if you would like to install some plugins or have a buffer, I suggest much more, at least 1 GB. So everything is natural for it's system. OpenELEC will boot from FAT partition and Armbian from ext4. After that, only U-Boot needs to be fine tuned. I will take a look tomorrow what needs to be done exactly.

Link to comment
Share on other sites

To continue my proposed method:

 

All you need to do in U-Boot is to overwrite bootcmd command, which gets automatically executed at boot. Default bootcmd command is universal and starts to scan all available storage devices for partitions marked as bootable. Then it checks if boot script is available and runs it.

 

If you are ok with less universal way, then dual boot should be simple. You must somehow decide if you would like to boot Armbian and OpenELEC and run proper variant of the following command:

load mmc <devnum>:<distro_bootpart> ${scriptaddr} <prefix>/boot.scr; source ${scriptaddr}

where:

<devnum> is 0 for sd card and 1 for eMMC

<distro_bootpart> is the number of the boot partition for OS. For example, number of the FAT partition for OpenELEC. Numbers can be listed with "part list mmc <devnum>"

<prefix> is path to boot.scr. In case of Armbian it is /boot and in case of OpenELEC it is empty.

 

For example, you could set bootcmd to something like this:

bootcmd=if test -e mmc 0:2 /bootOE; then load mmc 0:1 ${scriptaddr} /boot.scr;else load mmc 0:2 ${scriptaddr} /boot/boot.scr;fi

which tests for existence of bootOE file on Armbian partition. If it is found , then OpenELEC version of load is run, otherwise Armbian version is run. Please note that above command was not tested. I would suggest that you first test above command with setting it and then using "boot" command to test it. When you are satisfied, you should save it with "saveenv".

 

Unfortunatelly, above method needs U-Boot access, which is currently possible only through serial console. You can buy such cable, it's cheap and you will be able to troubleshoot boot problems. However, there is another possibility. Don't mark FAT partition as bootable. This will ensure that only Armbian's boot.scr will be loaded. Inside it, you can add decision making, if you want run OpenELEC or Armbian. For Armbian, just let default script do it's job. For OpenELEC, you should run command, which is explained above (load mmc ...).

 

Hope it helps.

 

EDIT: boot.scr for OpenELEC must also be fixed. Partition names won't match. Until this is the only FAT partition on SD card, the rest of the script will work ok.

Link to comment
Share on other sites

load mmc <devnum>:<distro_bootpart> ${scriptaddr} <prefix>/boot.scr; source ${scriptaddr}

[...]

Hope it helps.

 

EDIT: boot.scr for OpenELEC must also be fixed. Partition names won't match. Until this is the only FAT partition on SD card, the rest of the script will work ok.

As without serial console, I tried to integrate
load mmc ... into the Armbian boot script. Didn't work also with ext4load or putting it in separate lines
 
but ...
 
with the information of your posting how to access partitions I just copied the contents of the Openelec boot script into the Armbian one:
setenv bootm_boot_mode sec
setenv bootargs console=ttyS0,115200 boot=/dev/mmcblk0p3 disk=/dev/mmcblk0p2 consoleblank=0
fatload mmc 0:3 0x43000000 script.bin
fatload mmc 0:3 0x42000000 KERNEL
bootm 0x42000000

And this did work :-) :-) :-)

 
Thanks for providing the "hint"!
 
I had this nearly before, but with those two files on the Armbian partition and it didn't work.
 
I'll write a how-to, as I guess others are interested in this "dual boot" also.
Link to comment
Share on other sites

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

Important Information

Terms of Use - Privacy Policy - Guidelines