Author Topic: Multi boot on cubieboards  (Read 12989 times)

Offline patwood

  • Linux geek
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1660
  • Karma: +129/-0
    • View Profile
Multi boot on cubieboards
« on: January 13, 2014, 12:38:04 am »
I've uploaded a basic multi-boot uInitrd: http://dl.cubieforums.com/patwood/bootselect.tar.gz

It works by booting the kernel with a ramdisk and an init program that lists the available partitions and lets you select one for booting. If it's not a linux root fs, it'll complain and ask again.

There are two versions: uInitrd.serial and uInitrd.tty1; they interact with the serial debug port and tty1, respectively.  The file uEnv.tty1 shows the lines that need to be added to uEnv.txt to enable this for tty1; note that you cannot have another root= line in uEnv.txt following the root=/dev/ram.

Here's how it works:

1. u-boot runs the uenvcmd line during startup, which loads the uInitrd.tty1 ramdisk into memory at location 0x44000000.

2. u-boot eventually gets around to running the autoboot line, which has replaced the default boot command with

 bootm 0x48000000 0x44000000

which tells the kernel there's a ramdisk at location 0x44000000.

3. the kernel boots and uses /dev/ram (the ramdisk at 0x44000000) as the root file system.

4. the kernel runs /sbin/init (one of several default locations for the boot-time init program), which is a small shell script that displays the partition selection, reads the user's response, attempts to mount it, and if successful does a chroot and runs the real /sbin/init script.

Here's what the prompt looks like:

Code: [Select]
1   /dev/nand1: SEC_TYPE="msdos" LABEL="Volumn" TYPE="vfat"
2   /dev/nand4: UUID="57f8f4bc-abf4-655f-bf67-946fc0f9f25b" TYPE="ext4"
3   /dev/nand5: UUID="57f8f4bc-abf4-655f-bf67-946fc0f9f25b" TYPE="ext4"
4   /dev/nand8: UUID="57f8f4bc-abf4-655f-bf67-946fc0f9f25b" TYPE="ext4"
5   /dev/nand9: LABEL="PRIVATE" UUID="5043-07F4" TYPE="vfat"
6   /dev/nand10: UUID="57f8f4bc-abf4-655f-bf67-946fc0f9f25b" TYPE="ext4"
7   /dev/nand11: LABEL="SUGAR" UUID="199A-07D0" TYPE="vfat"
8   /dev/mmcblk0p1: SEC_TYPE="msdos" UUID="815B-BF7D" TYPE="vfat"
9   /dev/mmcblk0p2: UUID="764506f2-95cd-48c9-8cde-a09534ff147e" TYPE="ext4"
10   /dev/sda1: LABEL="cubieboard" UUID="8dd66cca-51df-4153-8493-a44d096c1c70" TYPE="ext4"

select a root block device:

In this case, /dev/sda1 is on a USB stick.  Entering 10 produces the following:

Code: [Select]
select a root block device: 10
mounting /dev/sda1
<3>EXT3-fs (sda1): error: couldn't mount because of unsupported optional features (240)
[  130.616684] EXT3-fs (sda1): error: couldn't mount because of unsupported optional features (240)
<3>EXT2-fs (sda1): error: couldn't mount because of unsupported optional features (240)
[  130.637052] EXT2-fs (sda1): error: couldn't mount because of unsupported optional features (240)
<6>EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)
[  130.678971] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)
booting image from /dev/sda1

If you want to use the serial port for selection instead of tty1, simply replace uInitrd.tty1 with uInitrd.serial in uEnv.txt.

This currently only works with the mmc version of u-boot, so no multi-boot on nand yet; also, it requires a distro that uses /sbin/init and not some from other  location (e.g., /init).  Since the kernel has to be loaded first in order for this to interact with the HDMI or VGA port, the distro that you boot should have the corresponding modules in /lib/modules; otherwise, the only drivers you'll have are the built-in ones.

Like any initial implementation of something new, this should be considered experimental until it's been thoroughly tested.

Offline dd

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Multi boot on cubieboards
« Reply #1 on: January 13, 2014, 05:21:17 am »
Patwood,
Thanks for this  subject, and for giving  notice in the other post,
1. Please, continue with this important work, to perform nand multiboot.(I can't check it as is, because my sd bay not working.)
2. please point to suitable distros, 

Offline patwood

  • Linux geek
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1660
  • Karma: +129/-0
    • View Profile
Re: Multi boot on cubieboards
« Reply #2 on: January 13, 2014, 10:43:44 am »
Currently I've only tested with Ubuntu/lubuntu/linaro images, but I do plan on testing a Debian based image as well.  I also booted an armel distro for the mk802 from 2012.  It ran, but I couldn't modprobe the 3.4.75 modules.

Edit: I tested this with Cubian, and it boots to the point of loading the modules in /etc/modules and starting the network (it gets an IP address via dhcp and responds to pings) but doesn't start up sshd or a getty on the serial port or virtual terminals.
« Last Edit: January 13, 2014, 11:57:32 pm by patwood »

Offline patwood

  • Linux geek
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1660
  • Karma: +129/-0
    • View Profile
Re: Multi boot on cubieboards
« Reply #3 on: January 19, 2014, 11:09:42 pm »
I've uploaded a new version of http://dl.cubieforums.com/patwood/bootselect.tar.gz.  It now includes images for the CB1 (A10-multiboot-SD.img) and CB2/CT (A20-multiboot-SD.img) that allow you to select a root fs at boot time on HDMI monitor (virtual terminal 1).  It should boot any linux distro on nand, sata, or USB.  So far, I've tested it with Ubuntu, Linaro, Debian, and a very old Gentoo.  If you need any modules, you'll need to copy the appropriate (A10 or A20) ones from one of my 3.4.75 kernels.

The download also contains the initrd ramdisks for the serial and tty1 selectors and the initrd file system (it's an ext2, so you can uncompress it and mount it on most modern linux systems with "sudo mount initrd /mnt" if you want to look around in it.

ARMEL distros will boot, but the ARMEL modprobe won't load ARMHF modules, so you won't have access to any drivers that aren't compiled into the kernel.

As always, comments are requested, especially regarding distros I haven't tried or using it with a sata drive.

Offline con

  • Jr. Member
  • **
  • Posts: 84
  • Karma: +8/-0
    • View Profile
Re: Multi boot on cubieboards
« Reply #4 on: January 20, 2014, 06:46:32 am »
Tnx! Saves me some effort in changing the uEnv every time. I'll try it out later today.

Maybe something like berryboot modified for the CB is a future option? I personally prefer a commandline option but hey, fancy gets points too.

Offline patwood

  • Linux geek
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1660
  • Karma: +129/-0
    • View Profile
Re: Multi boot on cubieboards
« Reply #5 on: January 20, 2014, 04:32:40 pm »
Never used berryboot.  Does it have a curses interface like grub?

maxx

  • Guest
Re: Multi boot on cubieboards
« Reply #6 on: January 20, 2014, 05:12:37 pm »
Hi patwood,

Never used berryboot.  Does it have a curses interface like grub?

 :D - no full graphic GUI with many cool features, like edit configs, download OS, setting up netwok, boot from USB, Network, SD-Card, ...

Full noob frindly, have like to use it on my RPI very much.

Where was also a version for Allwinner A10.

But no more update for a longer time.  :'(

cu
maxx

Offline con

  • Jr. Member
  • **
  • Posts: 84
  • Karma: +8/-0
    • View Profile
Re: Multi boot on cubieboards
« Reply #7 on: January 22, 2014, 07:09:12 am »
Berry uses a very minimised distro with a gui frontend (probably a stripped X11, haven't looked in depth). It also has download features an patiotioning stuff embedded.

I now noticed there is a A10 version out already at http://www.berryterminal.com/doku.php/berryboot_a10. Maybe something to have a look at.

Offline johndoe_71rus

  • Full Member
  • ***
  • Posts: 242
  • Karma: +3/-1
    • View Profile
Re: Multi boot on cubieboards
« Reply #8 on: January 29, 2014, 12:40:41 pm »
patwood
Can be used to load a single core but with different kernel arguments? Like grub menu
Cubieboard2 / Android 4.2.2 / Cubieez 7.4@3.4.79+patwood

Offline dd

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Multi boot on cubieboards
« Reply #9 on: January 30, 2014, 08:38:51 am »
Can you look at the post  below? it's regarding berryboot for a20-

https://github.com/maxnet/berryboot/issues/79

Offline patwood

  • Linux geek
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1660
  • Karma: +129/-0
    • View Profile
Re: Multi boot on cubieboards
« Reply #10 on: January 30, 2014, 11:05:46 am »
patwood
Can be used to load a single core but with different kernel arguments? Like grub menu

Yes, essentially that's what I wrote.  Instead of a grub.cfg or menu.lst, it just uses blkid to list all the known partitions; when you select one, it checks for /dev and /proc entries before attempting to mount it as a root fs.

Offline patwood

  • Linux geek
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1660
  • Karma: +129/-0
    • View Profile
Re: Multi boot on cubieboards
« Reply #11 on: January 30, 2014, 11:06:42 am »
Can you look at the post  below? it's regarding berryboot for a20-

https://github.com/maxnet/berryboot/issues/79

I think there's an initial ramdisk that's missing the /aufs mount point.

Offline swampy

  • Newbie
  • *
  • Posts: 27
  • Karma: +1/-0
    • View Profile
Re: Multi boot on cubieboards
« Reply #12 on: January 30, 2014, 02:06:21 pm »
Tried it out and works fines on HDMI but out of range for VGA even when set low res in script.bin.
 

Offline patwood

  • Linux geek
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1660
  • Karma: +129/-0
    • View Profile
Re: Multi boot on cubieboards
« Reply #13 on: January 31, 2014, 01:56:32 am »
Tried it out and works fines on HDMI but out of range for VGA even when set low res in script.bin.

Sorry, I have no way to test on VGA.

Offline cubie pi

  • Newbie
  • *
  • Posts: 9
  • Karma: +0/-1
    • View Profile
Re: Multi boot on cubieboards
« Reply #14 on: January 31, 2014, 06:31:40 am »
Hi Pat. Just succeeded in using your multiboot to boot your Cubiuntu0.6.5c-a20.img from hard drive. Have noticed that after the partition has been expanded to full size that for some reason it takes a lot longer to boot up but once booted it works like a dream.
Many thanks.