Multi-booting on ODROID-N2: Add The Ability to Select Multiple Operating Systems From A Single Disk

The ODROID-N2 is a single board computer (SBC) made by Hardkernel, which was released in February 2019 and that runs with Amlogic’s S922X (4xA73@1.8GHz and 2xA53@1.9GHz). One of the new features on the ODROID-N2 is an 8MB SPI flash memory. Obviously, onboard SPI flash memory is not a new technology at all and some SBC already have it for using with certain purposes. Usually, the SPI flash memory has a bootloader and loads OS image from larger storage like uSD or USB storage

The SPI flash memory on the ODROID-N2 can be bootable and 8MB is a pretty large space for a bootloader which is usually under 1MB. Besides it’s very small for the Linux kernel image which is usually 8~9MB for the compressed image for ODROID-N2. We want to improve the usage of the small storage rather than just install a bootloader.

There have been many demands to manage multiple OS and many SBC users had tried to run multiple OS installed in eMMC, uSD and USB storage and, as such, instructions were introduced with a script or Linux commands, as well. Many users succeeded with it but the instructions are not simple for users who are not familiar with the Linux system. We want to help new users who wish to use two OS but having trouble to set up multiple OS environments.

For the two reasons above, my workmate Joy and I started to study the Petitboot which is an operating system bootloader based on Linux kexec. We had to struggle to build a complete image to fit in 8MB, specifically, we had to customize the Linux kernel in order to reduce the size smaller than 3.8MB which is more than half the size of the generic Linux kernel. At the same time, since Petitboot is an application running on Linux userspace, we had to build a tiny root file system that could fit in 3.2MB. Otherwise, we were not able to fit the whole tiny Linux system into 8MB. Here is the memory map of the image to boot Petitboot in 8MB.

Figure 01 - memory map of the image to boot Petitboot in 8MB.

After jumping multiple hurdles, we’ve successfully built the bootable tiny Linux system including U-boot in 8MB and ODROID-N2 can run Petitboot from SPI flash memory. But the first version just displayed the Petitboot menus and boot entry manually configured for an OS since there were boot formats such as Grub or PXE boot which were not supported by the ODROID-N2.

Figure 02 - petitboot menu

Since I wanted to help users to boot an OS without any setting up effort, I had to add a component which can recognize the OS image contributed by the open source community. All OS images for ODROID SBC have a special boot script a.k.a boot.ini that contains the bootloader commands for setting the kernel parameters, which kernel must be loaded, and so on. Otherwise, a user has to learn the new boot config format for the Petitboot and assign the boot files manually.

I’ve written the code to parse the boot.ini file and I was able to make Petitboot read the OS image from the attached storage on the ODROID-N2 and show up on the display such that the user can select a boot entry using an attached USB keyboard or IR remote control. I believe that this is a big achievement and allows the user to easily select an OS installed and attached to ODROID-N2.

I’ve also managed the version of Petitboot for ODROID-N2 throughout June 2019 and, eventually, I was able to fix the major bugs and improved more features which were usually done by U-boot in order to boot an OS. Still, it’s not a perfect solution. Since I am not able to fully occupy myself on this Petitboot task, the current Petitboot is not fully functioning as much as I expected and dreamed but it will be improved and released from time to time.

Figure 03 - Petitboot menu

Figure 04 - Petitboot menu

The current version can do the following:

  • Recognize different OS images from open source community as is, which means ideally you are able to boot the OS image as booted from eMMC or uSD slot without any change. I’ve discovered that Armbian has changed its file system structure, so a bit of change is required.
  • Easily can boot from USB storage. Many SoC for SBC do not boot from USB storage other than uSD or eMMC and this is the same on ODROID-N2. ODROID-N2 is more capable to boot from USB easily selecting the boot entry of USB storage rather than using a command line.
  • Boot device order can be set in the menu, you can choose uSD as a first priority boot media or USB.
  • Boot automatically to the high priority booting media in second unit.

The current version has some limitations:

  • The boot configuration must be stored into uSD, which is awkward. This is because of the limitation of SoC feature but I’m thinking of a workaround.
  • Still, this is WIP project and having some issues working in the legacy booting from uSD or eMMC. Because some of the work which was done in U-boot is moving to Petitboot and all features are not moved and compatible.
  • Boot from network media such as PXE is not supported but have put this into my TODO list.
  • Not offering fancy UX due to the small capacity of SPI flash memory, 8MB is the edge for storing the mandatory BLOBs, only.

I was happy to see more users are trying to use Petitboot on their ODROID-N2 and many of them are happy with it since they are able to boot an OS for a different purpose. I maintain an ODROID forum thread at https://forum.odroid.com/viewtopic.php?f=182&t=33873, and will keep updating the version whenever I have made corrections and/or improvements. For comments, questions, and suggestions, please visit the original article at https://medium.com/@tobetter/multiple-os-on-odroid-n2-3a5f3a14a726.

Be the first to comment

Leave a Reply