Skip to main content

Building NAOS

This page builds a complete image with the full-image path: U-Boot, the kernel, the encrypted root filesystem and the Rockchip firmware package.

Get the source​

Build host
git clone https://github.com/mixtile-rockchip/naos.git
cd naos

Build in the container​

The repository includes a build container with the required toolchain and image tools.

Build host
docker build -t ubuntu-22.04-build-env misc-tools/build-env/
docker run --privileged -it \
-v $PWD:/workspace \
-v /dev:/dev \
ubuntu-22.04-build-env

Inside the container, the source is at /workspace. Build the image for your board:

Container
cd /workspace
./build.sh --target all --board mixtile-core3588e-nano

Replace mixtile-core3588e-nano with the board name from Supported boards.

Build on the host​

To build directly on an Ubuntu 22.04 x86_64 host, install the packages listed in misc-tools/build-env/Dockerfile, then run:

Build host
sudo ./build.sh --target all --board mixtile-core3588e-nano

The component scripts call sudo and chroot themselves. The outer sudo keeps the run consistent when the build is started from a normal user account.

What the build does​

StepScriptOutput
U-Bootscripts/build_uboot.shMiniLoaderAll.bin, uboot.img
Kernelscripts/build_kernel.shImage, <board>.dtb, resource.img
Ramdiskscripts/build_ramdisk.shramdisk.img, misc.img
FIT boot imagebuild_fit_boot in build.shboot.img
Signed boot imagebuild_sign_boot in build.shsigned boot.img
Alpine root filesystemscripts/build_alpinefs_base.sh or a board scriptbuild/alpine/
Root filesystem imagescripts/build_rootfs.shrootfs.img
Encrypted imagesscripts/build_encryption.shencrypted.img, encrypted_userdata.img
Firmware packagescripts/build_update.shupdate.img

The build downloads U-Boot, rkbin and the kernel sources from GitHub on the first run, together with the Alpine minirootfs and packages.

Output​

The build writes to build/output/:

build/output/
├── MiniLoaderAll.bin
├── uboot.img
├── boot.img
├── ramdisk.img
├── rootfs.img
├── encrypted.img
├── encrypted_userdata.img
├── misc.img
└── update.img

update.img is the complete Rockchip firmware package. Write it to the device eMMC with Rockchip Flash Tool. The MaskROM entry procedure depends on the carrier board; use the board's hardware documentation for the correct button or jumper. The NAOS repository does not include a board-specific flashing guide.

To build a full-disk image from the firmware package:

Build host
sudo ./build.sh --target raw --board mixtile-core3588e-nano

raw.img is created from an existing update.img, so run --target all first.

Build packages for the image generator​

To build artifacts without the final image:

Build host
sudo ./build.sh --target packages --board mixtile-core3588e-nano

This writes MiniLoaderAll.bin, uboot.img, boot.img, ramdisk.img, misc.img and alpine-rootfs.tar.gz to build/output/. Package them as APKs and upload them to your APK repository, as described in APK Packages and Image Generation.

First boot and login​

The debug UART runs at 1500000 baud. Boot messages and the IPv4 address of eth0 are printed to it; the print-ip service prints Network Ready - eth0 IP: <address> after DHCP completes.

Serial login is disabled in the default image. SSH password login is also disabled: sshd accepts certificates signed by the CA whose public key is installed at packages/alpine/etc/ssh/ssh_ca_key.pub.

Sign a user key with your CA and connect as root:

Build host
ssh-keygen -s ssh_ca_key \
-I dev-cert-001 \
-n root \
-V always:+3650d \
~/.ssh/id_ed25519.pub

ssh -i ~/.ssh/id_ed25519 root@<device-ip>

ssh_ca_key is the CA private key you generated. The certificate is written next to your public key as ~/.ssh/id_ed25519-cert.pub. Replace the repository CA public key with your own before building, as described in Prerequisites.

warning

Do not log in as root over an untrusted network without a certificate policy you control. Replace the development SSH CA key and use short-lived certificates for production.

To re-enable serial login for debugging, remove the two sed lines in the root filesystem build script (scripts/build_alpinefs_base.sh, or the board-specific script for your board) that delete the tty and console entries from /etc/inittab, then rebuild. Use this only on a device you control; it reopens the console login path.