|
| 1 | +Build Debian11 RootFS |
| 2 | +==================================================================================== |
| 3 | + |
| 4 | +## Setup parameters |
| 5 | + |
| 6 | +```console |
| 7 | +shell$ apt-get install qemu-user-static debootstrap binfmt-support |
| 8 | +shell$ export targetdir=debian11-rootfs |
| 9 | +shell$ export distro=bullseye |
| 10 | +``` |
| 11 | + |
| 12 | +## Build Debian RootFS first-step in $targetdir(=debian11-rootfs) |
| 13 | + |
| 14 | +```console |
| 15 | +shell$ mkdir $PWD/$targetdir |
| 16 | +shell$ sudo chown root $PWD/$targetdir |
| 17 | +shell$ sudo debootstrap --arch=arm64 --foreign $distro $PWD/$targetdir |
| 18 | +shell$ sudo cp /usr/bin/qemu-aarch64-static $PWD/$targetdir/usr/bin |
| 19 | +shell$ sudo cp /etc/resolv.conf $PWD/$targetdir/etc |
| 20 | +shell$ sudo cp scripts/build-debian11-rootfs-with-qemu.sh $PWD/$targetdir |
| 21 | +shell$ sudo cp linux-image-5.4.0-xlnx-v2020.2-zynqmp-fpga_5.4.0-xlnx-v2020.2-zynqmp-fpga-3_arm64.deb $PWD/$targetdir |
| 22 | +shell$ sudo cp linux-image-5.10.0-xlnx-v2021.1-zynqmp-fpga_5.10.0-xlnx-v2021.1-zynqmp-fpga-4_arm64.deb $PWD/$targetdir |
| 23 | +```` |
| 24 | + |
| 25 | +## Build Debian RootFS second-step with QEMU |
| 26 | + |
| 27 | +### Change Root to debian11-rootfs |
| 28 | + |
| 29 | +```console |
| 30 | +shell$ sudo chroot $PWD/$targetdir |
| 31 | +``` |
| 32 | + |
| 33 | +There are two ways |
| 34 | + |
| 35 | +1. run build-debian11-rootfs-with-qemu.sh (easy) |
| 36 | +2. run this chapter step-by-step (annoying) |
| 37 | + |
| 38 | +### Run debootstrap second stage |
| 39 | + |
| 40 | +```console |
| 41 | +debian11-rootfs# distro=bullseye |
| 42 | +debian11-rootfs# export LANG=C |
| 43 | +debian11-rootfs# /debootstrap/debootstrap --second-stage |
| 44 | +``` |
| 45 | + |
| 46 | +#### NOTE |
| 47 | + |
| 48 | +If the version of qemu-user-static is old, you may get the following error. |
| 49 | + |
| 50 | +```console |
| 51 | +debian11-rootfs# /debootstrap/debootstrap --second-stage |
| 52 | +W: Failure trying to run: /sbin/ldconfig |
| 53 | +W: See //debootstrap/debootstrap.log for details |
| 54 | +``` |
| 55 | + |
| 56 | +In this case, please update qemu-user-static. |
| 57 | +I used 'qemu-user-static_6.1+dfsg-8_amd64.deb'. |
| 58 | + |
| 59 | +### Setup APT |
| 60 | + |
| 61 | +```console |
| 62 | +debian11-rootfs# cat <<EOT > /etc/apt/sources.list |
| 63 | +deb http://ftp.jp.debian.org/debian bullseye main contrib non-free |
| 64 | +deb-src http://ftp.jp.debian.org/debian bullseye main contrib non-free |
| 65 | +deb http://ftp.jp.debian.org/debian bullseye-updates main contrib non-free |
| 66 | +deb-src http://ftp.jp.debian.org/debian bullseye-updates main contrib non-free |
| 67 | +deb http://security.debian.org bullseye-security main contrib non-free |
| 68 | +deb-src http://security.debian.org bullseye-security main contrib non-free |
| 69 | +EOT |
| 70 | +``` |
| 71 | + |
| 72 | +```console |
| 73 | +debian11-rootfs# cat <<EOT > /etc/apt/apt.conf.d/71-no-recommends |
| 74 | +APT::Install-Recommends "0"; |
| 75 | +APT::Install-Suggests "0"; |
| 76 | +EOT |
| 77 | +``` |
| 78 | + |
| 79 | +```console |
| 80 | +debian11-rootfs# apt-get update -y |
| 81 | +``` |
| 82 | + |
| 83 | +### Install applications |
| 84 | + |
| 85 | +```console |
| 86 | +debian11-rootfs# apt-get install -y locales dialog |
| 87 | +debian11-rootfs# dpkg-reconfigure locales |
| 88 | +debian11-rootfs# apt-get install -y net-tools openssh-server ntpdate resolvconf sudo less hwinfo ntp tcsh zsh file |
| 89 | +``` |
| 90 | + |
| 91 | +### Setup hostname |
| 92 | + |
| 93 | +```console |
| 94 | +debian11-rootfs# echo debian-fpga > /etc/hostname |
| 95 | +``` |
| 96 | + |
| 97 | +### Setup root password |
| 98 | + |
| 99 | +```console |
| 100 | +debian11-rootfs# passwd |
| 101 | +``` |
| 102 | + |
| 103 | +This time, we set the "admin" at the root' password. |
| 104 | + |
| 105 | +To be able to login as root from ZynqMP serial port. |
| 106 | + |
| 107 | +```console |
| 108 | +debian11-rootfs# cat <<EOT >> /etc/securetty |
| 109 | +# Serial Port for Xilinx ZynqMP |
| 110 | +ttyPS0 |
| 111 | +ttyPS1 |
| 112 | +EOT |
| 113 | +``` |
| 114 | + |
| 115 | +### Add a new guest user |
| 116 | + |
| 117 | +```console |
| 118 | +debian11-rootfs# adduser fpga |
| 119 | +``` |
| 120 | + |
| 121 | +This time, we set the "fpga" at the fpga'password. |
| 122 | + |
| 123 | +```console |
| 124 | +debian11-rootfs# echo "fpga ALL=(ALL:ALL) ALL" > /etc/sudoers.d/fpga |
| 125 | +``` |
| 126 | + |
| 127 | +### Setup sshd config |
| 128 | + |
| 129 | +```console |
| 130 | +debian11-rootfs# sed -i -e 's/#PasswordAuthentication/PasswordAuthentication/g' /etc/ssh/sshd_config |
| 131 | +``` |
| 132 | + |
| 133 | +### Setup Time Zone |
| 134 | + |
| 135 | +```console |
| 136 | +debian11-rootfs# dpkg-reconfigure tzdata |
| 137 | +``` |
| 138 | + |
| 139 | +or if noninteractive set to Asia/Tokyo |
| 140 | + |
| 141 | +```console |
| 142 | +debian11-rootfs# echo "Asia/Tokyo" > /etc/timezone |
| 143 | +debian11-rootfs# dpkg-reconfigure -f noninteractive tzdata |
| 144 | +``` |
| 145 | + |
| 146 | + |
| 147 | +### Setup fstab |
| 148 | + |
| 149 | +```console |
| 150 | +debian11-rootfs# cat <<EOT > /etc/fstab |
| 151 | +none /config configfs defaults 0 0 |
| 152 | +EOT |
| 153 | +```` |
| 154 | + |
| 155 | +### Setup Network |
| 156 | + |
| 157 | +```console |
| 158 | +debian11-rootfs# apt-get install -y ifupdown |
| 159 | +debian11-rootfs# cat <<EOT > /etc/network/interfaces.d/eth0 |
| 160 | +allow-hotplug eth0 |
| 161 | +iface eth0 inet dhcp |
| 162 | +EOT |
| 163 | +```` |
| 164 | + |
| 165 | +### Setup /lib/firmware |
| 166 | + |
| 167 | +```console |
| 168 | +debian11-rootfs# mkdir /lib/firmware |
| 169 | +debian11-rootfs# mkdir /lib/firmware/ti-connectivity |
| 170 | +debian11-rootfs# mkdir /lib/firmware/mchp |
| 171 | +``` |
| 172 | + |
| 173 | +### Install Development applications |
| 174 | + |
| 175 | +```console |
| 176 | +debian11-rootfs# apt-get install -y build-essential |
| 177 | +debian11-rootfs# apt-get install -y git git-lfs |
| 178 | +debian11-rootfs# apt-get install -y u-boot-tools device-tree-compiler |
| 179 | +debian11-rootfs# apt-get install -y libssl-dev |
| 180 | +debian11-rootfs# apt-get install -y socat |
| 181 | +debian11-rootfs# apt-get install -y ruby rake ruby-msgpack ruby-serialport |
| 182 | +debian11-rootfs# apt-get install -y python3 python3-dev python3-setuptools python3-wheel python3-pip |
| 183 | +debian11-rootfs# apt-get purge -y python3-pkg-resources |
| 184 | +debian11-rootfs# apt-get install -y python3-pkg-resources |
| 185 | +debian11-rootfs# apt-get install -y python3-numpy |
| 186 | +debian11-rootfs# pip3 install msgpack-rpc-python |
| 187 | +debian11-rootfs# apt-get install -y flex bison pkg-config |
| 188 | +``` |
| 189 | + |
| 190 | +### Install Wireless tools and firmware |
| 191 | + |
| 192 | +```console |
| 193 | +debian11-rootfs# apt-get install -y wireless-tools |
| 194 | +debian11-rootfs# apt-get install -y wpasupplicant |
| 195 | +debian11-rootfs# apt-get install -y firmware-realtek |
| 196 | +debian11-rootfs# apt-get install -y firmware-ralink |
| 197 | +``` |
| 198 | + |
| 199 | +```console |
| 200 | +debian11-rootfs# git clone git://git.ti.com/wilink8-wlan/wl18xx_fw.git |
| 201 | +debian11-rootfs# cp wl18xx_fw/wl18xx-fw-4.bin /lib/firmware/ti-connectivity |
| 202 | +debian11-rootfs# rm -rf wl18xx_fw/ |
| 203 | +``` |
| 204 | + |
| 205 | +```console |
| 206 | +debian11-rootfs# git clone git://git.ti.com/wilink8-bt/ti-bt-firmware |
| 207 | +debian11-rootfs# cp ti-bt-firmware/TIInit_11.8.32.bts /lib/firmware/ti-connectivity |
| 208 | +debian11-rootfs# rm -rf ti-bt-firmware |
| 209 | +``` |
| 210 | + |
| 211 | +```console |
| 212 | +debian11-rootfs# git clone git://github.com/linux4wilc/firmware linux4wilc-firmware |
| 213 | +debian11-rootfs# cp linux4wilc-firmware/*.bin /lib/firmware/mchp |
| 214 | +debian11-rootfs# rm -rf linux4wilc-firmware |
| 215 | +``` |
| 216 | + |
| 217 | +### Install Other applications |
| 218 | + |
| 219 | +```console |
| 220 | +debian11-rootfs# apt-get install -y samba |
| 221 | +debian11-rootfs# apt-get install -y avahi-daemon |
| 222 | +``` |
| 223 | + |
| 224 | +### Install haveged for Linux Kernel 4.19 |
| 225 | + |
| 226 | +```console |
| 227 | +debian11-rootfs# apt-get install -y haveged |
| 228 | +``` |
| 229 | + |
| 230 | +### Install Linux Modules |
| 231 | + |
| 232 | +```console |
| 233 | +debian11-rootfs# dpkg -i linux-image-5.4.0-xlnx-v2020.2-zynqmp-fpga_5.4.0-xlnx-v2020.2-zynqmp-fpga-3_arm64.deb |
| 234 | +debian11-rootfs# dpkg -i linux-image-5.10.0-xlnx-v2021.1-zynqmp-fpga_5.10.0-xlnx-v2021.1-zynqmp-fpga-4_arm64.deb |
| 235 | +``` |
| 236 | + |
| 237 | +### Clean Cache |
| 238 | + |
| 239 | +```console |
| 240 | +debian11-rootfs# apt-get clean |
| 241 | +``` |
| 242 | + |
| 243 | +### Create Debian Package List |
| 244 | + |
| 245 | +```console |
| 246 | +debian11-rootfs# dpkg -l > dpkg-list.txt |
| 247 | +``` |
| 248 | + |
| 249 | +### Finish |
| 250 | + |
| 251 | +```console |
| 252 | +debian10-rootfs# exit |
| 253 | +shell$ sudo rm -f $PWD/$targetdir/usr/bin/qemu-aarch64-static |
| 254 | +shell$ sudo rm -f $PWD/$targetdir/build-debian11-rootfs-with-qemu.sh |
| 255 | +shell$ sudo rm -f $PWD/$targetdir/linux-image-5.4.0-xlnx-v2020.2-zynqmp-fpga_5.4.0-xlnx-v2020.2-zynqmp-fpga-3_arm64.deb |
| 256 | +shell$ sudo rm -f $PWD/$targetdir/linux-image-5.10.0-xlnx-v2021.1-zynqmp-fpga_5.10.0-xlnx-v2021.1-zynqmp-fpga-4_arm64.deb |
| 257 | +shell$ sudo mv $PWD/$targetdir/dpkg-list.txt files/debian11-dpkg-list.txt |
| 258 | +``` |
| 259 | + |
| 260 | +## Build debian11-rootfs-vanilla.tgz |
| 261 | + |
| 262 | +```console |
| 263 | +shell$ cd $PWD/$targetdir |
| 264 | +shell$ sudo tar cfz ../debian11-rootfs-vanilla.tgz * |
| 265 | +``` |
| 266 | + |
0 commit comments