1. Mirror downloads
- Use the latest Raspberry Pi image, Raspberry Pi OS Lite, kernel version 6.6.
- download link
/raspios_lite_arm64/images/raspios_lite_arm64-2024-07-04/
2. Mount the image to ubuntu
-
The Raspberry Pi image downloaded in the previous step
jun@ubuntu:$ ls
-
View the first unused loopback device
jun@ubuntu:$ losetup -f /dev/loop0
-
Associating a Raspberry Pi image to a loopback device
jun@ubuntu:$ sudo losetup /dev/loop0 [sudo] password for jun:
-
Viewing the partitions, two zones are detected, the smaller of which is the system partition and the larger is the root filesystem
jun@ubuntu:$ sudo kpartx -av /dev/loop0 add map loop0p1 (253:0): 0 1048576 linear 7:0 8192 add map loop0p2 (253:1): 0 4481024 linear 7:0 1056768
-
Creating a system partition mount directory
jun@ubuntu:$ mkdir boot
-
Creating a root filesystem mount directory
jun@ubuntu:$ mkdir rootfs
-
Mounting the system partition
jun@ubuntu:$ sudo mount /dev/mapper/loop0p1 ./boot/
-
Mounting the root filesystem
jun@ubuntu:$ sudo mount /dev/mapper/loop0p2 ./rootfs/
-
Viewing the system partition
jun@ubuntu:ig210$ ls ./boot/ fixup_x.dat start_x.elf initramfs_2712 fixup_cd.dat initramfs8 overlays start_cd.elf start_db.elf fixup_db.dat kernel_2712.img
-
Viewing the Root File System
jun@ubuntu:ig210$ ls ./rootfs/ bin boot dev etc home lib lost+found media mnt opt proc root run sbin srv sys tmp usr var
3. Customized system configuration
3.1 Enabling the Debug Serial Port
- Modify the system partition under the
$ cd boot/ boot$ sudo vi
- exist
and add the following at the end of the
enable_uart=1
3.2 Setting the user name and password
-
Set the username to
jun
The password is9
-
Execute the following command in a Raspberry Pi that is already in a terminal to get the ciphertext of the password, as follows to set the password as
9
root@jun:/home/jun# echo 9 | openssl passwd -6 -stdin $6$tSX0UC/$gqnju1u.BPjPLz1659xUok2GHViNBdcW7D4o4g4tf9xlbVFn4SU2EaV3/0Q02yquTkluWdZBi8sKrB0n3vtaC/
-
Splicing username and ciphertext
jun:$6$tSX0UC/$gqnju1u.BPjPLz1659xUok2GHViNBdcW7D4o4g4tf9xlbVFn4SU2EaV3/0Q02yquTkluWdZBi8sKrB0n3vtaC/
-
Write the splice string obtained in the previous step to the boot partition's
Papers
3.3 Setting the hostname
-
Modify the root filesystem under the
hostname
, change the hostname tojun
sudo vi rootfs/etc/hostname
-
Modify the root filesystem under the
hosts
file, which will127.0.1.1
The corresponding hostname is also changed tojun
3.4 Enabling SSH
-
exist
boot
Create an empty file in the partitionSSH
can immediately (do sth)boot$ sudo touch SSH
3.5 Enabling the IIC
-
modifications
boot/
, canceleddtparam=i2c_arm=on
comment that adds thedtparam=i2c_vc=on
-
modifications
rootfs/etc/modules
, add a linei2c-dev
jun@ubuntu:$ sudo vi rootfs/etc/modules
3.6 Enabling SPI
- modifications
boot/
, canceled#dtparam=spi=on
If you don't have it, add it.
3.7 Enabling All Serial Ports
-
modifications
boot/
, add the followingdeoverlay=uart0,txd0_pin=14,rxd0_pin=15 dtoverlay=uart2,txd2_pin=0,rxd2_pin=1 dtoverlay=uart3,txd3_pin=4,rxd3_pin=5 dtoverlay=uart4,txd4_pin=8,rxd4_pin=9 dtoverlay=uart5,txd5_pin_12,rxd5_pin=13
3.8 Adding Logo
- Show Logo when user logs in
- utilization
figlet
This tool generates point and line diagrams
- exist
rootfs/etc/profile
At the end of the document addecho
Command, Print Dot Line Logojun@ubuntu:rootfs$ sudo vi etc/profile
echo -e "\033[0;32m _____ _____ ____ _____ |_ _| | ____| / ___| |_ _| | | | _| \___ \ | | | | | |___ ___) | | | |_| |_____| |____/ |_| \033[0m\n"
4. Unmount the image
jun@ubuntu:$ ls
boot rootfs
jun@ubuntu:$ sudo umount ./boot
jun@ubuntu:$ sudo umount ./rootfs
jun@ubuntu:$ sudo losetup -d /dev/loop0
5. Mirror burning
- see documentRaspberry Pi CM4(I): Mirror Burning.