Differences

This shows you the differences between two versions of the page.

Link to this comparison view

ass:labs-2025:04:tasks:02 [2025/08/07 14:50]
florin.stancu
ass:labs-2025:04:tasks:02 [2026/07/16 15:08] (current)
florin.stancu
Line 1: Line 1:
-==== 02. Disk image & Debian ====+==== 02. Bootstrapping ​Debian ====
  
-You’ll be running scripts in ''​./​scripts'',​ either one by one or all together via ''​./​run-all.sh''​. +=== 2.1. Install Debian into directory ===
- +
-**The scripts are templates** — you may need to complete missing parts (search for ''​TODO''​s)! +
- +
-=== 2.1. Install Debian into an empty directory ===+
  
 Yes, really, you can easily do this! Yes, really, you can easily do this!
Line 11: Line 7:
 You will use the [[https://​wiki.debian.org/​Debootstrap|debootstrap]] official tool to install a minimal Debian (you can also install deb-based derivatives like Ubuntu!) base system. You will use the [[https://​wiki.debian.org/​Debootstrap|debootstrap]] official tool to install a minimal Debian (you can also install deb-based derivatives like Ubuntu!) base system.
  
-📄 Edit the ''​05-debootstrap.sh''​ script.+📄 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 [[https://​www.qemu.org/​|qemu]] which will help us to just that! 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 [[https://​www.qemu.org/​|qemu]] which will help us to just that!
  
-Finally, we need to obtain the ''​artifacts/​debrootfs.tar.gz''​ archive with the contents of our newly-created Aarch64 Debian. Use ''​tar''​ to ''​c''​reate a g''​z''​ipped archive, and be sure to ''​p''​reserve permissions!+Finally, we need to obtain the ''​debian-rootfs.tar.gz''​ archive with the contents of our newly-created Aarch64 Debian. Use ''​tar''​ to ''​c''​reate a g''​z''​ipped archive, and be sure to ''​p''​reserve permissions:
  
-The final results should be something like: +<​code ​bash
-<​code>​ +sudo tar czpf debian-rootfs.tar.gz ​-C debian-rootfs/​ .
--rw-r--r-- ​ 1 root  root  148M 2025-08-07 14:23 debrootfs.tar.gz+
 </​code>​ </​code>​
  
-=== 2.2. Create the base disk image ===+Note: each time you chroot and install / modify your rootfs on your local machine, make sure to rebuild the ''​tar.gz''​ archive!
  
-📄 File: ''​10-create-base-disk.sh''​+=== 2.1. Installing kernel modules ===
  
-Your task:+We must install our kernel'​s external modules onto our new Debian rootfs.
  
-  ​Use ''​truncate''​ or ''​dd''​ to allocate the image with the desired size; +As noted in [[:ass:labs-2025:03|Lab 3]], it's quite simple, actually (adapt if paths don't match):
-  - Modify the ''​parted''​ invocation (script)+
-  - Add partitions for: +
-    - rootfsA (ext4) +
-    - rootfsB (ext4) +
-    - data (ext4)+
  
-<​note ​warning+<code bash> 
-Keep the partition ​labels as commented!+# 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 
 +</​code>​ 
 + 
 +=== 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: 
 +<code bash> 
 +# in chroot, you are root, so set up a "​secure"​ password 
 +# (joking, you can use '​1234'​) 
 +passwd 
 +</​code>​ 
 + 
 +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 ​hint
 +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!
 </​note>​ </​note>​
  
-=== 2.3. Populate ​the rootfs partitions ===+After modification,​ run the script to obtain the disk image.
  
-📄 File: ''​25-populate-base-disk.sh''​+But before booting the board, we must do some minor re-configuration to our u-boot...
  
-Subtasks:+=== 2.5. Bootloader [re]configuration ===
  
-  ​Mount the partitions created previously ​(already in script); +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 archiveto build & properly reconfigure a full Firmware Image Package. 
-  Extract ​the previously-obtained Debian ​''​debrootfs.tar.gz''​ on each rootfs A/B partition (simple ​''​tar xf''​ will suffice);+ 
 +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''​! 
 + 
 +<note warning>​ 
 +**Now pay attention:​** after testing it using ''​uuu -b spl''​ ,make 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''​! 
 +</​note>​
  
  
ass/labs-2025/04/tasks/02.1754567446.txt.gz · Last modified: 2025/08/07 14:50 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