You really should have a serial connection to your M1S, because it makes things a lot easier when something wents wrong. And using my advice may turn things terribly wrong, so don't blame me when you brick your device! Although it's not so easy to really brick your device, it's still possible. Check Recovery steps.
- Arch Linux on Odroid M1S
Check INSTALL.md.
All steps are executed as root. Use sudo
when necessary or sudo su
if you're lazy
like me.
On Debian systems:
apt-get install -y gcc-12 gcc-12-aarch64-linux-gnu python3-pyelftools confget libgnutls28-dev uuid-dev
Create symlinks:
ln -sf aarch64-linux-gnu-cpp-12 /usr/bin/aarch64-linux-gnu-cpp
ln -sf aarch64-linux-gnu-gcc-12 /usr/bin/aarch64-linux-gnu-gcc
ln -sf aarch64-linux-gnu-gcc-ar-12 /usr/bin/aarch64-linux-gnu-gcc-ar
ln -sf aarch64-linux-gnu-gcc-nm-12 /usr/bin/aarch64-linux-gnu-gcc-nm
ln -sf aarch64-linux-gnu-gcc-ranlib-12 /usr/bin/aarch64-linux-gnu-gcc-ranlib
ln -sf aarch64-linux-gnu-gcov-12 /usr/bin/aarch64-linux-gnu-gcov
ln -sf aarch64-linux-gnu-gcov-dump-12 /usr/bin/aarch64-linux-gnu-gcov-dump
ln -sf aarch64-linux-gnu-gcov-tool-12 /usr/bin/aarch64-linux-gnu-gcov-tool
Create a file named build.source
with the following content:
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
Source the file to set the environment variables:
source build.source
Fork jonesthefox/u-boot-build, it's a
fork
from github.com/Kwiboo u-boot-build modified
to only
generate binaries for the M1S. Run the Action, set rk3xxx-2024.10
as u-boot ref,
master
as rkbin ref and let it generate the artifact rk3566-odroid-m1s.zip
. Continue
with Flash to eMMC (via UMS)
Info: There is a github_workflow_to_build_uboot.yml you can use in your CI
Warning: Going this route, you should definitely connect a serial console to the uart pins on your Odroid M1S!
Configure and use the script in scripts/build/u-boot
named build_u-boot.sh
. See the README.md on how to
use it, it's super simple!
Info: It should be possible to flash it from the running OS on the Odroid M1S
-
Using the script above will produce the file
u-boot-rockchip.bin
in/usr/src/u-boot-rockchip/
(Except you fiddled withROOTPATH
). -
Using the GitHub workflow generates the artifact
rk3566-odroid-m1s.zip
Extract it and you get theu-boot-rockchip.bin
. -
Flash that:
Replace sdX with the actual device that your OS presents you for the attached USB mass storage.
Let's assume it's /dev/sdc
. Note that we don't set a partition number like /dev/sdc1
!
The u-boot bootloader will be written in the first 16MB on the emmc of your M1S.
dd if=u-boot-rockchip.bin of=/dev/sdX bs=32k seek=1 conv=fsync
Create two partitions: BOOT
and rootfs
. The BOOT partition starts at 16MB to allow
room for the U-Boot blob.
-
Use the following
gdisk
commands to create the partitions (i.E.gdisk /dev/sdX
):d # Delete partition 1 d # Delete partition 2 (if present) n # Create a new partition 1 # Partition number 1 32768 # Start sector at 16MB so we won't overwrite u-boot +256M # Size of the first partition 8300 # Set type to Linux filesystem n # Create a new partition 2 # Partition number 2 557056 # Start sector (right after the first partition) <Enter> # End sector (uses the remaining space) 8300 # Set type to Linux filesystem p # Display the current partition table (for verification) w # Save the changes and exit fdisk
-
Create filesystems:
mkfs.ext4 /dev/<your usb storage device partition 1> -L BOOT mkfs.ext4 /dev/<your usb storage device partition 2> -L rootfs
It's recommended to build the kernel on a powerful computer since building on the M1S itself may take a long time.
Clone the Linux kernel repository:
Note: When i was working on that, the patches were accepted in the kernel repo, but not yet merged. The kernel version I used was v6.11-rc5-54-g4f4c35cc85fd
git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
cd linux
Ensure you have sourced build.source!
Copy the kernel configuration file config-odroid-m1s to
.config
in the kernel source directory and edit it using make menuconfig
.
Apply the patches from kernel/patches/v2/:
git am 0001-Correct-vendor-prefix-for-ODROID-M1.patch
git am 0002-Correct-vendor-prefix-in-dts-file.patch
git am 0003-Add-support-for-ODROID-M1S-in-dt-bindings.patch
git am 0004-Add-support-for-ODROID-M1S-in-dts.patch
Set INSTALL_MOD_PATH
to prevent cluttering the module directory of the cross
compiler host during compilation:
make -j$(nproc)
make modules -j$(nproc)
make dtbs -j$(nproc)
make INSTALL_MOD_PATH=/usr/src/linux/arch/arm64/boot/modules modules_install
Copy the compiled kernel files to your boot partition:
cp <compile cow>/usr/src/linux/arch/arm64/boot/Image <odroid mmcblk0p1>/Image
cp <compile cow>/usr/src/linux/arch/arm64/boot/dts/rockchip/rk3566-odroid-m1s.dtb <odroid mmcblk0p1>/odroid-m1s.dtb
Copy the kernel modules:
rm <compile cow>/usr/src/linux/arch/arm64/boot/modules/lib/modules/6.11.0-rc5-odroid-arm64+/build
cp -r <compile cow>/usr/src/linux/arch/arm64/boot/modules/lib/modules/6.11.0-rc5-odroid-arm64+ <odroid mmcblk0p2>/lib/modules
Install mkinitcpio
:
pacman -S mkinitcpio
Build /initramfs-linux.img
:
mkinitcpio -k 6.11.0-rc5-odroid-arm64+ -g /boot/initramfs-linux.img
Convert it to a format supported by U-Boot:
mkimage -A arm -T ramdisk -C gzip -d /boot/initramfs-linux.img <odroid>/mmcblk0p1/uInitrd
WARNING: You WILL need serial console access.
Access the U-Boot console by pressing CTRL-C
or the any key
rapidly after powering
on the Odroid.
# Not needed, our initrd is smaller
# setenv fdt_addr_r 0x08000000
load mmc 0:1 ${kernel_addr_r} Image
load mmc 0:1 ${ramdisk_addr_r} /uInitrd
load mmc 0:1 ${fdt_addr_r} rk3566-odroid-m1s.dtb
setenv bootargs root=/dev/mmcblk0p2 console=ttyS2,1500000
booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
Note: We mount the root filesystem as read-write because we can, and it's a deliberate choice. With an initrd in place (we use one),
fsck
can and will run properly from there. We acknowledge the risk of eMMC wear, which is acceptable given the expected device lifespan.
Install u-boot-tools apt-get install u-boot-tools
Create the file boot.cmd and generate boot.scr:
mkimage -C none -A arm -T script -d boot.cmd boot.scr
cp boot.scr <odroid mmcblk0p1>/
First, clean empty space:
Info: Repeat this step for every partition.
mount /dev/sdX /mnt
dd if=/dev/zero of=/mnt/tmpfile bs=1M status=progress || true
sync
rm /mnt/partition/tmpfile
umount /mnt
Then write the image file.
dd if=/dev/sdX of=/path/to/full_device_image.img bs=4M conv=sparse status=progress
sync
gzip /path/to/image.img
To write the image file back to the emmc:
gzip -dc /path/to/full_device_image.img.gz | dd of=/dev/sdX bs=4M status=progress
- Flash
ODROID-M1S_EMMC2UMS.img
onto an SD card. You find it here: wiki.odroid.com - Insert the SD card into the M1S.
- Reboot the M1S while shorting the mask ROM pin with GND for a few seconds.
The last thing i started fiddling with, was TPM, OP-TEE (Truested Execution Environment), UKI and stuff.. You'll find a
starting point in the build_u-boot.sh
script, but i never really continued on that. But it should be possible
to add this stuff as well.