This is an old revision of the document!


02. Bootstrapping Debian

2.1. Install Debian into a directory

Yes, really, you can easily do this!

You will use the debootstrap official tool to install a minimal Debian (you can also install deb-based derivatives like Ubuntu!) base system.

📄 Edit the mk-debian-rootfs.sh script, read the code and fill the TODOs.

Since we need to install the Debian binaries executable on a 64-bit ARM architecture, we will need to split the installation into two stages: first, the .deb (Debian install packages) are downloaded from a Debian mirror server and unpacked into the target rootfs directory. Afterwards, since Debian will need to run some scripts to setup its distro system, we must emulate the target architecture. Enter qemu which will help us to just that!

Finally, we need to obtain the debian-rootfs.tar.gz archive with the contents of our newly-created Aarch64 Debian. Use tar to create a gzipped archive, and be sure to preserve permissions!

The final results should be something like:

-rw-r--r--  1 root  root  213M 2026-07-26 14:23 debian-rootfs.tar.gz

Note: each time you chroot and install / modify your rootfs on your local machine, make sure to rebuild the tar.gz archive!

2.1. Installing kernel modules

We must install our kernel's external modules onto our new Debian rootfs.

As noted in Lab 3, it's quite simple, actually (adapt if paths don't match):

# navigate to Linux's source directory
cd linux/
# ensure compiled the modules
make ARCH=arm64 modules
# install the modules inside debian-rootfs (hope you put it in parent dir):
sudo make ARCH=arm64 INSTALL_MOD_PATH="../debian-rootfs/" modules_install

2.2. Entering the rootfs

If you wish to enter your newly bootstrapped Debian rootfs, you can readily use the chroot-enter.sh script (read its code to see its arguments!)

There's one critical thing to do if we want to be able to use our rootfs live: set up a login password! So:

# in chroot, you are root, so set up a "secure" password
# (joking, you can use '1234')
passwd

You can even run apt install in there ;) try it out (we'll use it later to install RAUC packages + configuration files).

Let's also check something.. while still inside the chroot, try to ls -l /lib/modules/*. The kernel modules you installed in the previous step should be listed in there for your kernel version!

2.3. Re-build linux.itb

Since we'll be running the rootfs on a separate partition from now on, we eliminated the Bootstrap CPIO (initrd nodes) from the Linux uImage. Check out staging/linux-noinitrd.its and use the staging/Makefile included inside the skeleton to rebuild the .itb!

2.4. Create the base disk image for testing

📄 File: mk-disk-image.sh: modify it, set a bigger image size (e.g., 1500 MB) and configure it to unpack the debian-rootfs.tar on the second partition.

Note: you have two versions mk-disk-image.sh scripts! For now, we'll just use the first version (having a simple fat32+ext4 partition layout), when we get to run RAUC, we'll use the second one!

After modification, run the script to obtain the disk image.

But before booting the board, we must do some minor re-configuration to our u-boot…

2.5. Bootloader [re]configuration

You'll need the mainline u-boot for this task. Simply delete your u-boot directory (do backup your configs, if you want) and use the Makefile provided for lab02 (also found inside today's archive) to build & properly reconfigure a full Firmware Image Package.

Note the new configuration options inside uboot-extra.config and the default environment variables in new-default.env.

Now we can power up the board! Use uuu -b spl flash.bin and enter U-Boot. Let fastboot 0 start and use fastboot flash 0:0 disk.img to quickly burn the image. After the flashing finishes, use Ctrl+C on u-boot to exit fastboot mode and run linux!

Now pay attention: after testing it using uuu -b spl ,make a backup of this flash.bin file! You'll need it later to start the board with RAUC autoboot disabled, as the one you'll build in the following section will not work (it will override the boot command and become unable to use fastboot / ums!). E.g., copy & name this file as flash_spl.bin!

ass/labs-2025/04/tasks/02.1784202520.txt.gz · Last modified: 2026/07/16 14:48 by florin.stancu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0