Ondrej Famera - top logo

Pre-build Gentoo image on Odroid-M1S (aarch64)

Guide for installing pre-build Gentoo on Odroid-M1S board (8GB version) into eMMC/NVMe/SD card.

This guide will provide steps for downloading and installing the pre-build Gentoo onto Odroid-M1S.

If you prefer installing Gentoo more traditional way check the Gentoo on Odroid-M1S (aarch64) with upstream 6.6.x kernel post.

Odroid-M1S boot sequence

Odroid-M1S at the time of writing (2024-08-20) features onboard eMMC memory, SD card slot and M.2 slot for NVMe drives. Odroid-M1S Boot sequence is looking first into eMMC and then into SD card to find SPL and subsequently the U-Boot both located in the beginning of eMMC or SD card as described in Odroid-M1S partition table. Note that it is NOT looking onto NVMe or other places before SPL+U-Boot are loaded.

Odroid-M1S U-Boot

At time of writing (2024-08-20) Odroid-M1S is shipped with Hardkernels custom u-boot ‘2017.09’. Additionally there is also Hardkernels custom u-boot ‘2024.01’ that features very brand new version of U-Boot but feature wise is less supported as the stock 2017.09 one according to the (forum.odroid.com) Mainline U-Boot for ODROID-M1S.

This guide and the pre-build image will be using the ‘2024.01’ version of U-Boot as its one major advantage is ability to boot from NVMe without need for additional bootloader such as petitboot after U-Boot (which is needed with stock 2017.09 U-Boot version).

Pre-build Gentoo installation checklist

Procedure to get pre-build Gentoo running will take around 10-30 minutes to complete. The shortest/fastest is installation on SD card. For all cases I assume you are starting at Linux computer that is NOT the Odroid-M1S (where the Gentoo is going to be installed).

Checklist for installing pre-build Gentoo on eMMC

Checklist for installing pre-build Gentoo on SD card

  • Odroid-M1S board (tested on 8GB version, should work on 4GB as well)
  • SD card (tested on 32G one, at least 16GB one is needed)
  • mine pre-build Gentoo image(649 MB)
  • 5GB of free space on your Linux computer for downloaded and decompressed files

Checklist for installing pre-build Gentoo on NVMe

Installing pre-build Gentoo for Odroid-M1S

Based on your decision on where to install the Gentoo follow only the steps that have marking for your chosen destination. For example if you want to install Gentoo on SD card, then follow steps with (SD card) markings, for installation on internal eMMC follow (eMMC) markings and for the installation on NVMe follow the (NVMe) markings in the steps below.

  • Firstly download the needed files (255 MB ~ 1GB of space needed)
    • (SD card), (eMMC), (NVMe) - download pre-build Gentoo system image
      # curl -O https://kr.famera.cz/large_files/sd_card_systemd-2024-08-26.img.xz
      # curl -O https://kr.famera.cz/large_files/sd_card_systemd-2024-08-26.img.xz.sha256sum.txt
      
    • (eMMC), (NVMe) - download Hardkernels ubuntu-2024-server image
      # curl -O https://dn.odroid.com/RK3566/ODROID-M1S/Ubuntu/ubuntu-20.04-server-odroidm1s-20231030.img.xz
      # curl -O https://dn.odroid.com/RK3566/ODROID-M1S/Ubuntu/ubuntu-20.04-server-odroidm1s-20231030.img.xz.md5sum
      
  • Verify the integrity of downloaded files
    • (SD card), (eMMC), (NVMe) - verify integrity of pre-build Gentoo image
      # sha256sum -c sd_card_systemd-2024-08-26.img.xz.sha256sum.txt
      sd_card_systemd-2024-08-26.img.xz: OK
      
    • (eMMC), (NVMe) - verify integrity of Hardkernels ubuntu-2024-server image
      # md5sum -c ubuntu-20.04-server-odroidm1s-20231030.img.xz.md5sum
      ubuntu-20.04-server-odroidm1s-20231030.img.xz: OK
      
  • Decompress the images
    • (SD card), (eMMC), (NVMe) - decompress pre-build Gentoo image
      # unxz sd_card_systemd-2024-08-26.img.xz
      
      # du -BM sd_card_systemd-2024-08-26.img
      3512M   sd_card_systemd-2024-08-26.img
      
    • (eMMC), (NVMe) - decompress Hardkernels ubuntu-2024-server image
      # unxz ubuntu-20.04-server-odroidm1s-20231030.img.xz
      
      # du -BM ubuntu-20.04-server-odroidm1s-20231030.img
      1246M	ubuntu-20.04-server-odroidm1s-20231030.img
      
  • Write the uncompressed image to SD card - below examples assumes your Linux system presents the SD card as /dev/mmcblk1 device to you (adjust that accordingly to your system). WARNING: This will overwrite existing data on SD card!
    • (SD card) - write uncompressed pre-build Gentoo image onto SD card
      # dd if=sd_card_systemd-2024-08-26.img of=/dev/mmcblk1 bs=4M oflag=direct status=progress
      2400+0 records in
      2400+0 records out
      10066329600 bytes (10 GB, 9.4 GiB) copied, xxx.xxx s, xx.x MB/s
      
    • (eMMC), (NVMe) - write uncompressed ubuntu-2024-server image onto SD card
      # dd if=ubuntu-20.04-server-odroidm1s-20231030.img of=/dev/mmcblk1 bs=4M oflag=direct status=progress
      451+1 records in
      451+1 records out
      1894343680 bytes (1.9 GB, 1.8 GiB) copied, xxx.xxx s, xx.x MB/s
      
  • Verify that image was written onto SD card where you can see partition table with 2 partitions.
    • (SD card) - Gentoo pre-build image should be visible on DOS style partition table
      # fdisk -l /dev/mmcblk1
      Disk /dev/mmcblk1: 29.45 GiB, 31609323520 bytes, 61736960 sectors
      Units: sectors of 1 * 512 = 512 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      Disklabel type: dos
      Disk identifier: 0x3cfb0910
          
      Device         Boot  Start      End  Sectors  Size Id Type
      /dev/mmcblk1p1       16384   540671   524288  256M 83 Linux
      /dev/mmcblk1p2      540672 18874367 18333696  8.8G 83 Linux
      
    • (eMMC), (NVMe) - ubuntu-2024-server image should be visible on DOS style partition table
      # fdisk -l /dev/mmcblk1
      Disk /dev/mmcblk1: 29.45 GiB, 31609323520 bytes, 61736960 sectors
      Units: sectors of 1 * 512 = 512 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      Disklabel type: dos
      Disk identifier: 0x8cdbf051
          
      Device         Boot  Start     End Sectors  Size Id Type
      /dev/mmcblk1p1        6144  530431  524288  256M 83 Linux
      /dev/mmcblk1p2      530432 3699889 3169458  1.5G 83 Linux
      
  • Resize the second partition and file system on it.
    • (SD card) - skip this step
    • (eMMC), (NVMe) -
      # parted /dev/mmcblk1 resizepart 2 8G
      Information: You may need to update /etc/fstab.
      
      # resize2fs /dev/mmcblk1p2
      resize2fs 1.45.5 (07-Jan-2020)
      Resizing the filesystem on /dev/mmcblk1p2 to 1886821 (4k) blocks.
      The filesystem on /dev/mmcblk1p2 is now 1886821 (4k) blocks long.
      
  • Mount the system partition of ubuntu-2024-server.
    • (SD card) - skip this step
    • (eMMC), (NVMe) -
      # mount /dev/mmcblk1p2 /mnt
      
      # df -h /mnt
      Filesystem      Size  Used Avail Use% Mounted on
      /dev/mmcblk1p2  7.1G  1.2G  5.6G  18% /mnt
      
  • Copy the uncompressed pre-build gentoo image into /mnt.
    • (SD card) - skip this step
    • (eMMC), (NVMe) -
      # cp --sparse=always sd_card_systemd-2024-08-26.img /mnt/
      
      # df -h /mnt
      Filesystem      Size  Used Avail Use% Mounted on
      /dev/mmcblk1p2  7.1G  4.6G  2.2G  69% /mnt
      
  • Unmount the /mnt.
    • (SD card) - skip this step
    • (eMMC), (NVMe) -
      # umount /mnt
      
  • (SD card), (eMMC), (NVMe) - Disconnect SD card from your Linux computer and insert it into powered off Odroid-M1S.

  • Power on Odroid-M1S while this SD card is inserted.
    • (SD card) enjoy your Gentoo booting. Login with user root with password testtest. Installation of pre-build Gentoo onto SD card ends here. Example output seen on UART console when booting:
      ...
      U-Boot 2024.01-00003-gcd797f0899e (Jan 25 2024 - 17:28:44 +0900)
          
      Model: Hardkernel ODROID-M1S
      DRAM:  8 GiB (effective 7.7 GiB)
      ...
      ** Booting bootflow 'mmc@fe2b0000.bootdev.part_1' with script
      Failed to load '/config.ini'
      57736 bytes read in 9 ms (6.1 MiB/s)
      Working FDT set to a100000
      21968904 bytes read in 1809 ms (11.6 MiB/s)
      Error: Bad gzipped data
      21968904 bytes read in 1808 ms (11.6 MiB/s)
      3336216 bytes read in 283 ms (11.2 MiB/s)
      Booting Gentoo 6.6.47-gentoo-arm64 from mmc 1:1...
      ...
      Starting kernel ...
          
      [    0.000000] Booting Linux on physical CPU 0x0000000000 [0x412fd050]
      [    0.000000] Linux version 6.6.47-gentoo-arm64 (root@gnome-desktop) (aarch64-unknown-linux-gnu-gcc (Gentoo 13.3.1_p20240614 p17) 13.3.1 20240614, GNU ld (Gentoo 2.42 p3) 2.42.0) #1 SMP Mon Aug 26 13:58:30 -00 2024
      [    0.000000] Machine model: Hardkernel ODROID-M1S
      ...
      >> Genkernel 4.3.10 (2024-08-26 14:17:51 UTC). Linux kernel 6.6.47-gentoo-arm64 
      >> Activating udev ... 
      >> Determining root device (trying UUID=caac7d37-7ea2-46e8-94fa-7630bbb6f611) ...
      >> Root device detected as /dev/mmcblk1p2! 
      >> Mounting /dev/mmcblk1p2 as root ... 
      ...
      [   16.139430] fbcon: Taking over console
      [   16.154252] Console: switching to colour frame buffer device 320x90
          
      This is localhost (Linux aarch64 6.6.47-gentoo-arm64) 14:18:30
          
      localhost login: 
      
      localhost login: root
      Password: testtest
      root@localhost ~ #
      
    • (eMMC), (NVME) wait for ubuntu-2024-server to start and login as user odroid with password odroid and then change into root account using same password odroid.
      ...
      Booting Debian 5.10.0-odroid-arm64 from mmc 1:1...
      ...
      Ubuntu 20.04.6 LTS server ttyFIQ0
      
      server login: odroid
      Password: odroid
      Welcome to Ubuntu 20.04.6 LTS (GNU/Linux 5.10.0-odroid-arm64 aarch64)
      ...
      
      odroid@server:~$ sudo -i
      [sudo] password for odroid: odroid
      root@server:~#
      
  • Check the storage layout to identify where to install pre-build Gentoo. The existing partition table (if it exists) will be overwritten from pre-build image.
    • (eMMC)
      # lsblk /dev/mmcblk0
      NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
      mmcblk0     179:0    0 58.2G  0 disk
      ├─mmcblk0p1 179:1    0  256M  0 part
      └─mmcblk0p2 179:2    0   58G  0 part
      
    • (NVMe)
      # lsblk /dev/nvme0n1
      NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
      nvme0n1     259:0    0 13.4G  0 disk 
      
  • Write the pre-build Gentoo image into target storage. WARNING: This will overwrite existing data on eMMC/NVMe!
    • (eMMC)
      # dd if=/sd_card_systemd-2024-08-26.img of=/dev/mmcblk0 bs=4M oflag=direct status=progress
      2400+0 records in
      2400+0 records out
      10066329600 bytes (10 GB, 9.4 GiB) copied, xxx.xxx s, xx.x MB/s
      
    • (NVMe)
      # dd if=/sd_card_systemd-2024-08-26.img of=/dev/nvme0n1 bs=4M oflag=direct status=progress
      2400+0 records in
      2400+0 records out
      10066329600 bytes (10 GB, 9.4 GiB) copied, xxx.xx s, xx.x MB/s
      
  • Verify the written image to confirm we see 2 partition on DOS style partition table.
    • (eMMC)
      # fdisk -l /dev/mmcblk0
      Disk /dev/mmcblk0: 58.25 GiB, 62537072640 bytes, 122142720 sectors
      Units: sectors of 1 * 512 = 512 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      Disklabel type: dos
      Disk identifier: 0x3cfb0910
          
      Device         Boot  Start      End  Sectors  Size Id Type
      /dev/mmcblk0p1       16384   540671   524288  256M 83 Linux
      /dev/mmcblk0p2      540672 18874367 18333696  8.8G 83 Linux
      
    • (NVMe)
      # fdisk -l /dev/nvme0n1
      Disk /dev/nvme0n1: 13.42 GiB, 14403239936 bytes, 28131328 sectors
      Units: sectors of 1 * 512 = 512 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      Disklabel type: dos
      Disk identifier: 0x3cfb0910
          
      Device         Boot  Start      End  Sectors  Size Id Type
      /dev/nvme0n1p1       16384   540671   524288  256M 83 Linux
      /dev/nvme0n1p2      540672 18874367 18333696  8.8G 83 Linux
      
  • Install 2024.01 U-Boot SPL and U-Boot on eMMC to allow boot from NVMe.
    • (NVMe) U-Boot SPL must start at 64th sector
      # dd if=/dev/nvme0n1 of=/dev/mmcblk0 bs=512 seek=64 skip=64 count=1000 oflag=direct status=progress
      1000+0 records in
      1000+0 records out
      512000 bytes (512 kB, 500 KiB) copied, 0.112205 s, 4.6 MB/s
      
    • (NVMe) U-Boot must start at 2048th sector
      # dd if=/dev/nvme0n1 of=/dev/mmcblk0 bs=512 seek=2048 skip=2048 count=4000 oflag=direct status=progress
      4000+0 records in
      4000+0 records out
      2048000 bytes (2.0 MB, 2.0 MiB) copied, 0.445862 s, 4.6 MB/s
      
  • Verify that U-Boot SPL and U-Boot images are present in expected version (2024.01) on eMMC.
    • (eMMC), (NVMe)
      # dd if=/dev/mmcblk0 skip=64 count=560 status=none|grep -abE -o ".{0,0}U-Boot SPL 20.{0,24}"
      164458:U-Boot SPL 2024.01-00003-gcd797f0899e
      
      # dd if=/dev/mmcblk0 count=4096 status=none | grep -abE -o ".{0,0}U-Boot 20.{0,24}"
      1771651:U-Boot 2024.01-00003-gcd797f0899e
      
  • Power off the Odroid-M1S, remove the SD card and then power on the Odroid-M1S to enjoy your Gentoo booting. Login with user root with password testtest. Installation onto eMMC and NVMe ends here.
    • (eMMC) example output seen on UART console when booting:
      U-Boot SPL 2024.01-00003-gcd797f0899e (Jan 25 2024 - 17:28:44 +0900)
      ...
      U-Boot 2024.01-00003-gcd797f0899e (Jan 25 2024 - 17:28:44 +0900)
          
      Model: Hardkernel ODROID-M1S
      DRAM:  8 GiB (effective 7.7 GiB)
      ...
      ** Booting bootflow 'mmc@fe310000.bootdev.part_1' with script
      Failed to load '/config.ini'
      57736 bytes read in 9 ms (6.1 MiB/s)
      Working FDT set to a100000
      21968904 bytes read in 289 ms (72.5 MiB/s)
      Error: Bad gzipped data
      21968904 bytes read in 290 ms (72.2 MiB/s)
      3336216 bytes read in 59 ms (53.9 MiB/s)
      Booting Gentoo 6.6.47-gentoo-arm64 from mmc 0:1...
      ...
      Starting kernel ...
          
      [    0.000000] Booting Linux on physical CPU 0x0000000000 [0x412fd050]
      [    0.000000] Linux version 6.6.47-gentoo-arm64 (root@gnome-desktop) (aarch64-unknown-linux-gnu-gcc (Gentoo 13.3.1_p20240614 p17) 13.3.1 20240614, GNU ld (Gentoo 2.42 p3) 2.42.0) #1 SMP Mon Aug 26 13:58:30 -00 2024
      [    0.000000] Machine model: Hardkernel ODROID-M1S
      ...
      >> Genkernel 4.3.10 (2024-08-26 14:17:51 UTC). Linux kernel 6.6.47-gentoo-arm64
      >> Activating udev ...
      >> Determining root device (trying UUID=caac7d37-7ea2-46e8-94fa-7630bbb6f611) ...
      >> Root device detected as /dev/mmcblk0p2!
      >> Mounting /dev/mmcblk0p2 as root ...
      ...
      [   15.449947] fbcon: Taking over console
      [   15.461252] Console: switching to colour frame buffer device 320x90
          
          
      This is localhost (Linux aarch64 6.6.47-gentoo-arm64) 15:10:05
          
      localhost login:
      
      localhost login: root
      Password: testtest
      root@localhost ~ #
      
    • (NVMe) example output seen on UART console when booting:
      U-Boot SPL 2024.01-00003-gcd797f0899e (Jan 25 2024 - 17:28:44 +0900)
      ...
      U-Boot 2024.01-00003-gcd797f0899e (Jan 25 2024 - 17:28:44 +0900)
          
      Model: Hardkernel ODROID-M1S
      DRAM:  8 GiB (effective 7.7 GiB)
      ...
      ** Booting bootflow 'nvme#0.blk#1.bootdev.part_1' with script
      Failed to load '/config.ini'
      57736 bytes read in 1 ms (55.1 MiB/s)
      Working FDT set to a100000
      21968904 bytes read in 60 ms (349.2 MiB/s)
      Error: Bad gzipped data
      21968904 bytes read in 59 ms (355.1 MiB/s)
      3336216 bytes read in 10 ms (318.2 MiB/s)
      Booting Gentoo 6.6.47-gentoo-arm64 from nvme 0:1...
      ...
      Starting kernel ...
          
      [    0.000000] Booting Linux on physical CPU 0x0000000000 [0x412fd050]
      [    0.000000] Linux version 6.6.47-gentoo-arm64 (root@gnome-desktop) (aarch64-unknown-linux-gnu-gcc (Gentoo 13.3.1_p20240614 p17) 13.3.1 20240614, GNU ld (Gentoo 2.42 p3) 2.42.0) #1 SMP Mon Aug 26 13:58:30 -00 2024
      [    0.000000] Machine model: Hardkernel ODROID-M1S
      ...
      >> Genkernel 4.3.10 (2024-08-26 14:17:51 UTC). Linux kernel 6.6.47-gentoo-arm64
      >> Activating udev ...
      >> Determining root device (trying UUID=caac7d37-7ea2-46e8-94fa-7630bbb6f611) ...
      >> Root device detected as /dev/nvme0n1p2!
      >> Mounting /dev/nvme0n1p2 as root ...
      ...
      [   15.379569] fbcon: Taking over console
      [   15.392779] Console: switching to colour frame buffer device 320x90
          
          
      This is localhost (Linux aarch64 6.6.47-gentoo-arm64) 14:59:54
          
      localhost login:
      
      localhost login: root
      Password: testtest
      root@localhost ~ #
      

Post-installation notes

  • Portage tree and distfiles used during installation were removed from image to reduce its size. You will need to download portage tree to be able to install packages - for simplicity you can use emerge-webrsync to get initial portage tree.
  • You will need to configure networking by hand before you install some more sophisticated solution that suits your needs - to bring up networking manually you can use commands below to configure static IP, GW and DNS to your current system.
    # ip a add x.x.x.x/xx dev end1
    # ip l set up dev end1
    # ip r add default via y.y.y.y
    # echo 'nameserver z.z.z.z' >> /etc/resolv.conf
    
  • Linux kernel sources were kept after build in /usr/src/linux without modifications, you can use genkernel to customize and compile kernel.
  • You may wish to increase size of second partition to expand the / file system. One used now was again rather smaller to allow better packaging of the pre-build image.
  • By default the outputs from kernel and system boot are shown on UART console (seen as ttyS2 from Gentoo). If not using the UART and just using HDMI as only output be patient after reboot - it may take 10-20 seconds to get some output on HDMI and in the end you should see the login prompt.

Additional resources

Final thoughts

I hope that above pre-build image and procedure would be useful to someone wanting to try the Gentoo on Odroid-M1S without need to go through quite time consuming approach of installing it from scratch.

Update: Guide for manual installation of Gentoo on Odroid-M1S is now published and contains the part describining pre-build image creation.

In case you got stuck in the above procedure at some point feel free to drop me an email.

Last change .