Pali Rohár | 56847f3 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 1 | #!/bin/bash -e |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 2 | # SPDX-License-Identifier: GPL-2.0+ |
| 3 | # (C) 2020 Pali Rohár <pali@kernel.org> |
| 4 | |
| 5 | # External tools needed for this test: |
| 6 | echo ' |
| 7 | wget |
| 8 | git |
| 9 | truncate |
| 10 | tar |
| 11 | dpkg |
| 12 | dd |
| 13 | make |
| 14 | gcc |
| 15 | arm-linux-gnueabi-gcc |
| 16 | fakeroot (homepage http://fakeroot-ng.lingnu.com/) |
| 17 | mcopy (from mtools, homepage http://www.gnu.org/software/mtools/) |
| 18 | mformat (from mtools, homepage http://www.gnu.org/software/mtools/) |
| 19 | /usr/sbin/mkfs.ubifs (from mtd-utils, homepage http://www.linux-mtd.infradead.org/) |
| 20 | /usr/sbin/ubinize (from mtd-utils, homepage http://www.linux-mtd.infradead.org/) |
Pali Rohár | 6529823 | 2021-06-18 15:31:08 +0200 | [diff] [blame] | 21 | /lib/ld-linux.so.2 (32-bit x86 version of LD loader, needed for qflasher) |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 22 | ' | while read tool info; do |
| 23 | if test -z "$tool"; then continue; fi |
| 24 | if ! which $tool 1>/dev/null 2>&1; then |
| 25 | echo "Tool $tool was not found and is required to run this test" |
| 26 | echo "First install $tool $info" |
| 27 | exit 1 |
| 28 | fi |
| 29 | done || exit 1 |
| 30 | |
| 31 | echo |
| 32 | echo "============================================================" |
| 33 | echo "========== Compiling U-Boot for Nokia RX-51 board ==========" |
| 34 | echo "============================================================" |
| 35 | echo |
| 36 | |
Pali Rohár | 43f7b81 | 2022-09-15 20:59:48 +0200 | [diff] [blame] | 37 | # First compile u-boot-ubifs.bin binary with UBI/UBIFS support for Nokia RX-51 board according to doc/board/nokia/rx51.rst |
| 38 | make nokia_rx51_config |
| 39 | cat >> .config << EOF |
| 40 | CONFIG_CMD_UBI=y |
| 41 | CONFIG_CMD_UBIFS=y |
| 42 | CONFIG_MTD_UBI_BEB_LIMIT=10 |
| 43 | EOF |
| 44 | make olddefconfig |
| 45 | make -j4 u-boot.bin CROSS_COMPILE=arm-linux-gnueabi- |
| 46 | mv u-boot.bin u-boot-ubifs.bin |
| 47 | |
| 48 | # Then compile standard u-boot.bin binary for Nokia RX-51 board |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 49 | make nokia_rx51_config |
Pali Rohár | 92e0872 | 2022-09-04 03:29:04 +0200 | [diff] [blame] | 50 | make -j4 u-boot.bin CROSS_COMPILE=arm-linux-gnueabi- |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 51 | |
| 52 | # And then do all stuff in temporary directory |
| 53 | mkdir -p nokia_rx51_tmp |
| 54 | cd nokia_rx51_tmp |
| 55 | |
| 56 | test -f mkimage || ln -s ../tools/mkimage . |
| 57 | test -f u-boot.bin || ln -s ../u-boot.bin . |
Pali Rohár | 43f7b81 | 2022-09-15 20:59:48 +0200 | [diff] [blame] | 58 | test -f u-boot-ubifs.bin || ln -s ../u-boot-ubifs.bin . |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 59 | |
| 60 | echo |
| 61 | echo "==========================================================================" |
| 62 | echo "========== Downloading and compiling qemu from qemu-linaro fork ==========" |
| 63 | echo "==========================================================================" |
| 64 | echo |
| 65 | |
| 66 | # Download and compile linaro version qemu which has support for n900 machine |
| 67 | # Last working commit is 8f8d8e0796efe1a6f34cdd83fb798f3c41217ec1 |
| 68 | if ! test -f qemu-system-arm; then |
| 69 | test -d qemu-linaro || git clone https://git.linaro.org/qemu/qemu-linaro.git |
| 70 | cd qemu-linaro |
| 71 | git checkout 8f8d8e0796efe1a6f34cdd83fb798f3c41217ec1 |
Tom Rini | b1c2102 | 2021-06-10 10:57:36 -0400 | [diff] [blame] | 72 | ./configure --enable-system --target-list=arm-softmmu --python=/usr/bin/python2.7 --disable-sdl --disable-gtk --disable-curses --audio-drv-list= --audio-card-list= --disable-werror --disable-xen --disable-xen-pci-passthrough --disable-brlapi --disable-vnc --disable-curl --disable-slirp --disable-kvm --disable-user --disable-linux-user --disable-bsd-user --disable-guest-base --disable-uuid --disable-vde --disable-linux-aio --disable-cap-ng --disable-attr --disable-blobs --disable-docs --disable-spice --disable-libiscsi --disable-smartcard-nss --disable-usb-redir --disable-guest-agent --disable-seccomp --disable-glusterfs --disable-nptl --disable-fdt |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 73 | make -j4 |
| 74 | cd .. |
| 75 | ln -s qemu-linaro/arm-softmmu/qemu-system-arm . |
| 76 | fi |
| 77 | |
| 78 | echo |
| 79 | echo "===================================================" |
| 80 | echo "========== Downloading external binaries ==========" |
| 81 | echo "===================================================" |
| 82 | echo |
| 83 | |
| 84 | # Download qflasher and nolo images |
| 85 | # This is proprietary qemu flasher tool with first stage images, but license allows non-commercial redistribution |
| 86 | wget -c http://repository.maemo.org/qemu-n900/qemu-n900.tar.gz |
| 87 | tar -xf qemu-n900.tar.gz |
| 88 | |
| 89 | # Download Maemo script u-boot-gen-combined |
| 90 | if ! test -f u-boot-gen-combined; then |
| 91 | test -d u-boot-maemo || git clone https://github.com/pali/u-boot-maemo.git |
| 92 | chmod +x u-boot-maemo/debian/u-boot-gen-combined |
| 93 | ln -s u-boot-maemo/debian/u-boot-gen-combined . |
| 94 | fi |
| 95 | |
| 96 | # Download Maemo fiasco kernel |
| 97 | wget -c http://repository.maemo.org/pool/maemo5.0/free/k/kernel/kernel_2.6.28-20103103+0m5_armel.deb |
| 98 | dpkg -x kernel_2.6.28-20103103+0m5_armel.deb kernel_2.6.28 |
| 99 | |
| 100 | # Download Maemo libc |
| 101 | wget -c http://repository.maemo.org/pool/maemo5.0/free/g/glibc/libc6_2.5.1-1eglibc27+0m5_armel.deb |
| 102 | dpkg -x libc6_2.5.1-1eglibc27+0m5_armel.deb libc6_2.5.1 |
| 103 | |
| 104 | # Download Maemo busybox |
| 105 | wget -c http://repository.maemo.org/pool/maemo5.0/free/b/busybox/busybox_1.10.2.legal-1osso30+0m5_armel.deb |
| 106 | dpkg -x busybox_1.10.2.legal-1osso30+0m5_armel.deb busybox_1.10.2 |
| 107 | |
| 108 | echo |
| 109 | echo "=======================================" |
| 110 | echo "========== Generating images ==========" |
| 111 | echo "=======================================" |
| 112 | echo |
| 113 | |
Pali Rohár | 43f7b81 | 2022-09-15 20:59:48 +0200 | [diff] [blame] | 114 | # Generate kernel image in zImage and uImage format from FIASCO format |
| 115 | dd if=kernel_2.6.28/boot/zImage-2.6.28-20103103+0m5.fiasco of=zImage-2.6.28-omap1 skip=95 bs=1 |
| 116 | ./mkimage -A arm -O linux -T kernel -C none -a 80008000 -e 80008000 -n zImage-2.6.28-omap1 -d zImage-2.6.28-omap1 uImage-2.6.28-omap1 |
| 117 | |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 118 | # Generate rootfs directory |
| 119 | mkdir -p rootfs |
| 120 | mkdir -p rootfs/dev/ |
| 121 | mkdir -p rootfs/bin/ |
| 122 | mkdir -p rootfs/sbin/ |
| 123 | mkdir -p rootfs/lib/ |
| 124 | cp -a busybox_1.10.2/bin/busybox rootfs/bin/ |
| 125 | cp -a libc6_2.5.1/lib/ld-linux.so.3 rootfs/lib/ |
| 126 | cp -a libc6_2.5.1/lib/ld-2.5.so rootfs/lib/ |
| 127 | cp -a libc6_2.5.1/lib/libc.so.6 rootfs/lib/ |
| 128 | cp -a libc6_2.5.1/lib/libc-2.5.so rootfs/lib/ |
| 129 | cp -a libc6_2.5.1/lib/libcrypt.so.1 rootfs/lib/ |
| 130 | cp -a libc6_2.5.1/lib/libcrypt-2.5.so rootfs/lib/ |
| 131 | test -f rootfs/bin/sh || ln -sf busybox rootfs/bin/sh |
| 132 | test -f rootfs/sbin/poweroff || ln -sf ../bin/busybox rootfs/sbin/poweroff |
| 133 | cat > rootfs/sbin/preinit << EOF |
| 134 | #!/bin/sh |
| 135 | echo |
| 136 | echo "Successfully booted" |
| 137 | echo |
| 138 | /sbin/poweroff -f |
| 139 | EOF |
| 140 | chmod +x rootfs/sbin/preinit |
| 141 | |
Pali Rohár | 43f7b81 | 2022-09-15 20:59:48 +0200 | [diff] [blame] | 142 | # Generate ubifs image from rootfs directory |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 143 | # NOTE: Character device on host filesystem can be created only by root |
| 144 | # But we do not need it on host filesystem, just in ubifs image |
| 145 | # So run mknod and mkfs.ubifs commands under fakeroot program |
| 146 | # which via LD_PRELOAD simulate mknod() and stat() functions |
| 147 | # so mkfs.ubifs will see dev/console as character device and |
| 148 | # put it correctly as character device into final ubifs image |
| 149 | # Therefore we can run whole script as non-root nobody user |
| 150 | fakeroot sh -c ' |
| 151 | rm -f rootfs/dev/console; |
| 152 | mknod rootfs/dev/console c 5 1; |
| 153 | /usr/sbin/mkfs.ubifs -m 2048 -e 129024 -c 2047 -r rootfs ubifs.img; |
| 154 | ' |
Pali Rohár | 43f7b81 | 2022-09-15 20:59:48 +0200 | [diff] [blame] | 155 | |
| 156 | # Generate ubi image with rootfs on first volume |
| 157 | cat > ubi.ini << EOF |
| 158 | [rootfs] |
| 159 | mode=ubi |
| 160 | image=ubifs.img |
| 161 | vol_id=0 |
| 162 | vol_size=230MiB # 1870 LEBs |
| 163 | vol_type=dynamic |
| 164 | vol_name=rootfs |
| 165 | vol_alignment=1 |
| 166 | vol_flags=autoresize |
| 167 | EOF |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 168 | /usr/sbin/ubinize -o ubi.img -p 128KiB -m 2048 -s 512 ubi.ini |
| 169 | |
Pali Rohár | 43f7b81 | 2022-09-15 20:59:48 +0200 | [diff] [blame] | 170 | # Generate ubi image with rootfs on first volume and kernel in zImage format on second volume for UBI booting |
| 171 | cp ubi.ini ubi_with_kernel.ini |
| 172 | cat >> ubi_with_kernel.ini << EOF |
| 173 | [kernel] |
| 174 | mode=ubi |
| 175 | image=zImage-2.6.28-omap1 |
| 176 | vol_id=1 |
| 177 | vol_size=2MiB |
| 178 | vol_type=dynamic |
| 179 | vol_name=kernel |
| 180 | vol_alignment=1 |
| 181 | EOF |
| 182 | /usr/sbin/ubinize -o ubi_with_kernel.img -p 128KiB -m 2048 -s 512 ubi_with_kernel.ini |
| 183 | |
Pali Rohár | 1ce0e1c | 2020-11-29 17:15:05 +0100 | [diff] [blame] | 184 | # Generate bootmenu for U-Boot serial console testing |
| 185 | cat > bootmenu_uboot << EOF |
| 186 | setenv bootmenu_0 'Serial console test=echo; echo "Testing serial console"; echo; echo "Successfully booted"; echo; poweroff'; |
| 187 | setenv bootmenu_1; |
| 188 | setenv bootmenu_delay 1; |
| 189 | setenv bootdelay 1; |
| 190 | EOF |
| 191 | ./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_uboot -d bootmenu_uboot bootmenu_uboot.scr |
| 192 | |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 193 | # Generate bootmenu for eMMC booting (uImage) |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 194 | cat > bootmenu_emmc << EOF |
| 195 | setenv bootmenu_0 'uImage-2.6.28-omap1 from eMMC=setenv mmcnum 1; setenv mmcpart 1; setenv mmctype fat; setenv bootargs; setenv setup_omap_atag 1; setenv mmckernfile uImage-2.6.28-omap1; run trymmckernboot'; |
| 196 | setenv bootmenu_1; |
| 197 | setenv bootmenu_delay 1; |
| 198 | setenv bootdelay 1; |
| 199 | EOF |
Pali Rohár | 56847f3 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 200 | ./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_emmc -d bootmenu_emmc bootmenu_emmc.scr |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 201 | |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 202 | # Generate bootmenu for eMMC booting (zImage) |
| 203 | cat > bootmenu_emmc2 << EOF |
| 204 | setenv bootmenu_0 'zImage-2.6.28-omap1 from eMMC=setenv mmcnum 1; setenv mmcpart 1; setenv mmctype fat; setenv bootargs; setenv setup_omap_atag 1; setenv mmckernfile zImage-2.6.28-omap1; run trymmckernboot'; |
| 205 | setenv bootmenu_1; |
| 206 | setenv bootmenu_delay 1; |
| 207 | setenv bootdelay 1; |
| 208 | EOF |
| 209 | ./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_emmc2 -d bootmenu_emmc2 bootmenu_emmc2.scr |
| 210 | |
Pali Rohár | 21dc5ef | 2022-09-04 03:29:05 +0200 | [diff] [blame] | 211 | # Generate bootmenu for OneNAND booting (uImage) |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 212 | cat > bootmenu_nand << EOF |
Pali Rohár | 7506965 | 2022-09-04 03:29:02 +0200 | [diff] [blame] | 213 | setenv bootmenu_0 'uImage-2.6.28-omap1 from OneNAND=setenv bootargs; setenv setup_omap_atag 1; mtd read initfs \${kernaddr} && bootm \${kernaddr}'; |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 214 | setenv bootmenu_1; |
| 215 | setenv bootmenu_delay 1; |
| 216 | setenv bootdelay 1; |
| 217 | EOF |
Pali Rohár | 56847f3 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 218 | ./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_nand -d bootmenu_nand bootmenu_nand.scr |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 219 | |
Pali Rohár | 43f7b81 | 2022-09-15 20:59:48 +0200 | [diff] [blame] | 220 | # Generate bootmenu for UBI booting (zImage) |
| 221 | cat > bootmenu_ubi << EOF |
| 222 | setenv bootmenu_0 'zImage-2.6.28-omap1 from UBI=setenv bootargs; setenv setup_omap_atag 1; ubi part rootfs && ubi read \${kernaddr} kernel && bootz \${kernaddr}'; |
| 223 | setenv bootmenu_1; |
| 224 | setenv bootmenu_delay 1; |
| 225 | setenv bootdelay 1; |
| 226 | EOF |
| 227 | ./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_ubi -d bootmenu_ubi bootmenu_ubi.scr |
| 228 | |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 229 | # Generate bootmenu for default booting |
| 230 | cat > bootmenu_default << EOF |
| 231 | setenv bootmenu_delay 1; |
| 232 | setenv bootdelay 1; |
| 233 | EOF |
| 234 | ./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_default -d bootmenu_default bootmenu_default.scr |
| 235 | |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 236 | # Generate combined image from u-boot and Maemo fiasco kernel |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 237 | ./u-boot-gen-combined u-boot.bin zImage-2.6.28-omap1 combined_zimage.bin |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 238 | ./u-boot-gen-combined u-boot.bin uImage-2.6.28-omap1 combined_uimage.bin |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 239 | |
| 240 | # Generate combined hack image from u-boot and Maemo fiasco kernel (kernel starts at 2MB offset and qflasher puts 2kB header before supplied image) |
| 241 | cp u-boot.bin combined_hack.bin |
| 242 | dd if=uImage-2.6.28-omap1 of=combined_hack.bin bs=1024 seek=$((2048-2)) |
| 243 | |
Pali Rohár | 1ce0e1c | 2020-11-29 17:15:05 +0100 | [diff] [blame] | 244 | # Generate FAT32 eMMC image for U-Boot serial console testing |
| 245 | truncate -s 50MiB emmc_uboot.img |
| 246 | mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_uboot.img |
| 247 | mcopy bootmenu_uboot.scr ::/bootmenu.scr -i emmc_uboot.img |
| 248 | |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 249 | # Generate FAT32 eMMC image for eMMC booting (uImage) |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 250 | truncate -s 50MiB emmc_emmc.img |
| 251 | mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_emmc.img |
| 252 | mcopy uImage-2.6.28-omap1 ::/uImage-2.6.28-omap1 -i emmc_emmc.img |
| 253 | mcopy bootmenu_emmc.scr ::/bootmenu.scr -i emmc_emmc.img |
| 254 | |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 255 | # Generate FAT32 eMMC image for eMMC booting (zImage) |
| 256 | truncate -s 50MiB emmc_emmc2.img |
| 257 | mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_emmc2.img |
| 258 | mcopy zImage-2.6.28-omap1 ::/zImage-2.6.28-omap1 -i emmc_emmc2.img |
| 259 | mcopy bootmenu_emmc2.scr ::/bootmenu.scr -i emmc_emmc2.img |
| 260 | |
Pali Rohár | 21dc5ef | 2022-09-04 03:29:05 +0200 | [diff] [blame] | 261 | # Generate FAT32 eMMC image for OneNAND booting (uImage) |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 262 | truncate -s 50MiB emmc_nand.img |
| 263 | mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_nand.img |
| 264 | mcopy bootmenu_nand.scr ::/bootmenu.scr -i emmc_nand.img |
| 265 | |
Pali Rohár | 43f7b81 | 2022-09-15 20:59:48 +0200 | [diff] [blame] | 266 | # Generate FAT32 eMMC image for UBI booting (zImage) |
| 267 | truncate -s 50MiB emmc_ubi.img |
| 268 | mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_ubi.img |
| 269 | mcopy bootmenu_ubi.scr ::/bootmenu.scr -i emmc_ubi.img |
| 270 | |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 271 | # Generate FAT32 eMMC image for default booting |
| 272 | truncate -s 50MiB emmc_default.img |
| 273 | mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_default.img |
| 274 | mcopy bootmenu_default.scr ::/bootmenu.scr -i emmc_default.img |
| 275 | |
Pali Rohár | 1ce0e1c | 2020-11-29 17:15:05 +0100 | [diff] [blame] | 276 | # Generate MTD image for U-Boot serial console testing |
| 277 | rm -f mtd_uboot.img |
| 278 | ./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k u-boot.bin -m rx51 -o mtd_uboot.img |
| 279 | |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 280 | # Generate MTD image for RAM booting from bootloader nolo images, compiled image and rootfs image |
| 281 | rm -f mtd_ram.img |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 282 | ./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k combined_uimage.bin -r ubi.img -m rx51 -o mtd_ram.img |
| 283 | rm -f mtd_ram2.img |
| 284 | ./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k combined_zimage.bin -r ubi.img -m rx51 -o mtd_ram2.img |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 285 | |
| 286 | # Generate MTD image for eMMC booting from bootloader nolo images, u-boot image and rootfs image |
| 287 | rm -f mtd_emmc.img |
| 288 | ./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k u-boot.bin -r ubi.img -m rx51 -o mtd_emmc.img |
| 289 | |
| 290 | # Generate MTD image for OneNAND booting from bootloader nolo images, combined hacked image and rootfs image |
| 291 | # Kernel image is put into initfs area, but qflasher reject to copy kernel image into initfs area because it does not have initfs signature |
| 292 | # This is hack to workaround this problem, tell qflasher that kernel area for u-boot is bigger and put big combined hacked image (u-boot + kernel with correct offset) |
| 293 | rm -f mtd_nand.img |
| 294 | ./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k combined_hack.bin -r ubi.img -m rx51 -p k=4094,i=2 -o mtd_nand.img |
| 295 | |
Pali Rohár | 43f7b81 | 2022-09-15 20:59:48 +0200 | [diff] [blame] | 296 | # Generate MTD image for UBI booting from bootloader nolo images, u-boot image with UBI/UBIFS support and rootfs image with kernel volume |
| 297 | rm -f mtd_ubi.img |
| 298 | ./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k u-boot-ubifs.bin -r ubi_with_kernel.img -m rx51 -o mtd_ubi.img |
| 299 | |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 300 | echo |
| 301 | echo "======================================================" |
| 302 | echo "========== Running test images in n900 qemu ==========" |
| 303 | echo "======================================================" |
| 304 | echo |
| 305 | |
Pali Rohár | 1ce0e1c | 2020-11-29 17:15:05 +0100 | [diff] [blame] | 306 | # Run MTD image in qemu and wait for 300s if U-Boot prints testing string to serial console and poweroff |
| 307 | rm -f qemu_uboot.log |
| 308 | ./qemu-system-arm -M n900 -mtdblock mtd_uboot.img -sd emmc_uboot.img -serial /dev/stdout -display none > qemu_uboot.log & |
| 309 | qemu_pid=$! |
| 310 | tail -F qemu_uboot.log & |
| 311 | tail_pid=$! |
| 312 | sleep 300 & |
| 313 | sleep_pid=$! |
| 314 | wait -n $sleep_pid $qemu_pid || true |
| 315 | kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true |
| 316 | wait || true |
| 317 | |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 318 | # Run MTD image in qemu and wait for 300s if uImage kernel from RAM is correctly booted |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 319 | rm -f qemu_ram.log |
| 320 | ./qemu-system-arm -M n900 -mtdblock mtd_ram.img -serial /dev/stdout -display none > qemu_ram.log & |
| 321 | qemu_pid=$! |
| 322 | tail -F qemu_ram.log & |
| 323 | tail_pid=$! |
Pali Rohár | 56847f3 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 324 | sleep 300 & |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 325 | sleep_pid=$! |
Pali Rohár | 56847f3 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 326 | wait -n $sleep_pid $qemu_pid || true |
| 327 | kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true |
| 328 | wait || true |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 329 | |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 330 | # Run MTD image in qemu and wait for 300s if zImage kernel from RAM is correctly booted |
| 331 | rm -f qemu_ram2.log |
| 332 | ./qemu-system-arm -M n900 -mtdblock mtd_ram2.img -sd emmc_default.img -serial /dev/stdout -display none > qemu_ram2.log & |
| 333 | qemu_pid=$! |
| 334 | tail -F qemu_ram2.log & |
| 335 | tail_pid=$! |
| 336 | sleep 300 & |
| 337 | sleep_pid=$! |
| 338 | wait -n $sleep_pid $qemu_pid || true |
| 339 | kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true |
| 340 | wait || true |
| 341 | |
| 342 | # Run MTD image in qemu and wait for 300s if uImage kernel from eMMC is correctly booted |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 343 | rm -f qemu_emmc.log |
| 344 | ./qemu-system-arm -M n900 -mtdblock mtd_emmc.img -sd emmc_emmc.img -serial /dev/stdout -display none > qemu_emmc.log & |
| 345 | qemu_pid=$! |
| 346 | tail -F qemu_emmc.log & |
| 347 | tail_pid=$! |
Pali Rohár | 56847f3 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 348 | sleep 300 & |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 349 | sleep_pid=$! |
Pali Rohár | 56847f3 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 350 | wait -n $sleep_pid $qemu_pid || true |
| 351 | kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true |
| 352 | wait || true |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 353 | |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 354 | # Run MTD image in qemu and wait for 300s if zImage kernel from eMMC is correctly booted |
| 355 | rm -f qemu_emmc2.log |
| 356 | ./qemu-system-arm -M n900 -mtdblock mtd_emmc.img -sd emmc_emmc2.img -serial /dev/stdout -display none > qemu_emmc2.log & |
| 357 | qemu_pid=$! |
| 358 | tail -F qemu_emmc2.log & |
| 359 | tail_pid=$! |
| 360 | sleep 300 & |
| 361 | sleep_pid=$! |
| 362 | wait -n $sleep_pid $qemu_pid || true |
| 363 | kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true |
| 364 | wait || true |
| 365 | |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 366 | # Run MTD image in qemu and wait for 300s if kernel from OneNAND is correctly booted |
| 367 | rm -f qemu_nand.log |
| 368 | ./qemu-system-arm -M n900 -mtdblock mtd_nand.img -sd emmc_nand.img -serial /dev/stdout -display none > qemu_nand.log & |
| 369 | qemu_pid=$! |
| 370 | tail -F qemu_nand.log & |
| 371 | tail_pid=$! |
Pali Rohár | 56847f3 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 372 | sleep 300 & |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 373 | sleep_pid=$! |
Pali Rohár | 56847f3 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 374 | wait -n $sleep_pid $qemu_pid || true |
| 375 | kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true |
| 376 | wait || true |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 377 | |
Pali Rohár | 43f7b81 | 2022-09-15 20:59:48 +0200 | [diff] [blame] | 378 | # Run MTD image in qemu and wait for 300s if kernel from UBI is correctly booted |
| 379 | rm -f qemu_ubi.log |
| 380 | ./qemu-system-arm -M n900 -mtdblock mtd_ubi.img -sd emmc_ubi.img -serial /dev/stdout -display none > qemu_ubi.log & |
| 381 | qemu_pid=$! |
| 382 | tail -F qemu_ubi.log & |
| 383 | tail_pid=$! |
| 384 | sleep 300 & |
| 385 | sleep_pid=$! |
| 386 | wait -n $sleep_pid $qemu_pid || true |
| 387 | kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true |
| 388 | wait || true |
| 389 | |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 390 | echo |
| 391 | echo "=============================" |
| 392 | echo "========== Results ==========" |
| 393 | echo "=============================" |
| 394 | echo |
| 395 | |
Pali Rohár | 1ce0e1c | 2020-11-29 17:15:05 +0100 | [diff] [blame] | 396 | if grep -q 'Successfully booted' qemu_uboot.log; then echo "U-Boot serial console is working"; else echo "U-Boot serial console test failed"; fi |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 397 | if grep -q 'Successfully booted' qemu_ram.log; then echo "Kernel (uImage) was successfully booted from RAM"; else echo "Failed to boot kernel (uImage) from RAM"; fi |
| 398 | if grep -q 'Successfully booted' qemu_ram2.log; then echo "Kernel (zImage) was successfully booted from RAM"; else echo "Failed to boot kernel (zImage) from RAM"; fi |
| 399 | if grep -q 'Successfully booted' qemu_emmc.log; then echo "Kernel (uImage) was successfully booted from eMMC"; else echo "Failed to boot kernel (uImage) from eMMC"; fi |
| 400 | if grep -q 'Successfully booted' qemu_emmc2.log; then echo "Kernel (zImage) was successfully booted from eMMC"; else echo "Failed to boot kernel (zImage) from eMMC"; fi |
| 401 | if grep -q 'Successfully booted' qemu_nand.log; then echo "Kernel (uImage) was successfully booted from OneNAND"; else echo "Failed to boot kernel (uImage) from OneNAND"; fi |
Pali Rohár | 43f7b81 | 2022-09-15 20:59:48 +0200 | [diff] [blame] | 402 | if grep -q 'Successfully booted' qemu_ubi.log; then echo "Kernel (zImage) was successfully booted from UBI"; else echo "Failed to boot kernel (zImage) from UBI"; fi |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 403 | |
| 404 | echo |
| 405 | |
Pali Rohár | 43f7b81 | 2022-09-15 20:59:48 +0200 | [diff] [blame] | 406 | if grep -q 'Successfully booted' qemu_uboot.log && grep -q 'Successfully booted' qemu_ram.log && grep -q 'Successfully booted' qemu_ram2.log && grep -q 'Successfully booted' qemu_emmc.log && grep -q 'Successfully booted' qemu_emmc2.log && grep -q 'Successfully booted' qemu_nand.log && grep -q 'Successfully booted' qemu_ubi.log; then |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 407 | echo "All tests passed" |
| 408 | exit 0 |
| 409 | else |
| 410 | echo "Some tests failed" |
| 411 | exit 1 |
| 412 | fi |