Pali Rohár | 2def741 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 1 | #!/bin/bash -e |
Pali Rohár | 80ad67b | 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/) |
| 21 | ' | while read tool info; do |
| 22 | if test -z "$tool"; then continue; fi |
| 23 | if ! which $tool 1>/dev/null 2>&1; then |
| 24 | echo "Tool $tool was not found and is required to run this test" |
| 25 | echo "First install $tool $info" |
| 26 | exit 1 |
| 27 | fi |
| 28 | done || exit 1 |
| 29 | |
| 30 | echo |
| 31 | echo "============================================================" |
| 32 | echo "========== Compiling U-Boot for Nokia RX-51 board ==========" |
| 33 | echo "============================================================" |
| 34 | echo |
| 35 | |
| 36 | # First compile u-boot.bin binary for Nokia RX-51 board |
| 37 | make nokia_rx51_config |
| 38 | make -j4 u-boot.bin ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- |
| 39 | |
| 40 | # And then do all stuff in temporary directory |
| 41 | mkdir -p nokia_rx51_tmp |
| 42 | cd nokia_rx51_tmp |
| 43 | |
| 44 | test -f mkimage || ln -s ../tools/mkimage . |
| 45 | test -f u-boot.bin || ln -s ../u-boot.bin . |
| 46 | |
| 47 | echo |
| 48 | echo "==========================================================================" |
| 49 | echo "========== Downloading and compiling qemu from qemu-linaro fork ==========" |
| 50 | echo "==========================================================================" |
| 51 | echo |
| 52 | |
| 53 | # Download and compile linaro version qemu which has support for n900 machine |
| 54 | # Last working commit is 8f8d8e0796efe1a6f34cdd83fb798f3c41217ec1 |
| 55 | if ! test -f qemu-system-arm; then |
| 56 | test -d qemu-linaro || git clone https://git.linaro.org/qemu/qemu-linaro.git |
| 57 | cd qemu-linaro |
| 58 | git checkout 8f8d8e0796efe1a6f34cdd83fb798f3c41217ec1 |
Tom Rini | c8982d2 | 2021-06-10 10:57:36 -0400 | [diff] [blame] | 59 | ./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 | 80ad67b | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 60 | make -j4 |
| 61 | cd .. |
| 62 | ln -s qemu-linaro/arm-softmmu/qemu-system-arm . |
| 63 | fi |
| 64 | |
| 65 | echo |
| 66 | echo "===================================================" |
| 67 | echo "========== Downloading external binaries ==========" |
| 68 | echo "===================================================" |
| 69 | echo |
| 70 | |
| 71 | # Download qflasher and nolo images |
| 72 | # This is proprietary qemu flasher tool with first stage images, but license allows non-commercial redistribution |
| 73 | wget -c http://repository.maemo.org/qemu-n900/qemu-n900.tar.gz |
| 74 | tar -xf qemu-n900.tar.gz |
| 75 | |
| 76 | # Download Maemo script u-boot-gen-combined |
| 77 | if ! test -f u-boot-gen-combined; then |
| 78 | test -d u-boot-maemo || git clone https://github.com/pali/u-boot-maemo.git |
| 79 | chmod +x u-boot-maemo/debian/u-boot-gen-combined |
| 80 | ln -s u-boot-maemo/debian/u-boot-gen-combined . |
| 81 | fi |
| 82 | |
| 83 | # Download Maemo fiasco kernel |
| 84 | wget -c http://repository.maemo.org/pool/maemo5.0/free/k/kernel/kernel_2.6.28-20103103+0m5_armel.deb |
| 85 | dpkg -x kernel_2.6.28-20103103+0m5_armel.deb kernel_2.6.28 |
| 86 | |
| 87 | # Download Maemo libc |
| 88 | wget -c http://repository.maemo.org/pool/maemo5.0/free/g/glibc/libc6_2.5.1-1eglibc27+0m5_armel.deb |
| 89 | dpkg -x libc6_2.5.1-1eglibc27+0m5_armel.deb libc6_2.5.1 |
| 90 | |
| 91 | # Download Maemo busybox |
| 92 | wget -c http://repository.maemo.org/pool/maemo5.0/free/b/busybox/busybox_1.10.2.legal-1osso30+0m5_armel.deb |
| 93 | dpkg -x busybox_1.10.2.legal-1osso30+0m5_armel.deb busybox_1.10.2 |
| 94 | |
| 95 | echo |
| 96 | echo "=======================================" |
| 97 | echo "========== Generating images ==========" |
| 98 | echo "=======================================" |
| 99 | echo |
| 100 | |
| 101 | # Generate rootfs directory |
| 102 | mkdir -p rootfs |
| 103 | mkdir -p rootfs/dev/ |
| 104 | mkdir -p rootfs/bin/ |
| 105 | mkdir -p rootfs/sbin/ |
| 106 | mkdir -p rootfs/lib/ |
| 107 | cp -a busybox_1.10.2/bin/busybox rootfs/bin/ |
| 108 | cp -a libc6_2.5.1/lib/ld-linux.so.3 rootfs/lib/ |
| 109 | cp -a libc6_2.5.1/lib/ld-2.5.so rootfs/lib/ |
| 110 | cp -a libc6_2.5.1/lib/libc.so.6 rootfs/lib/ |
| 111 | cp -a libc6_2.5.1/lib/libc-2.5.so rootfs/lib/ |
| 112 | cp -a libc6_2.5.1/lib/libcrypt.so.1 rootfs/lib/ |
| 113 | cp -a libc6_2.5.1/lib/libcrypt-2.5.so rootfs/lib/ |
| 114 | test -f rootfs/bin/sh || ln -sf busybox rootfs/bin/sh |
| 115 | test -f rootfs/sbin/poweroff || ln -sf ../bin/busybox rootfs/sbin/poweroff |
| 116 | cat > rootfs/sbin/preinit << EOF |
| 117 | #!/bin/sh |
| 118 | echo |
| 119 | echo "Successfully booted" |
| 120 | echo |
| 121 | /sbin/poweroff -f |
| 122 | EOF |
| 123 | chmod +x rootfs/sbin/preinit |
| 124 | |
| 125 | # Generate ubi config file for ubi rootfs image |
| 126 | cat > ubi.ini << EOF |
| 127 | [rootfs] |
| 128 | mode=ubi |
| 129 | image=ubifs.img |
| 130 | vol_id=0 |
| 131 | vol_size=160MiB |
| 132 | vol_type=dynamic |
| 133 | vol_name=rootfs |
| 134 | vol_alignment=1 |
| 135 | vol_flags=autoresize |
| 136 | EOF |
| 137 | |
| 138 | # Generate ubi rootfs image from rootfs directory |
| 139 | # NOTE: Character device on host filesystem can be created only by root |
| 140 | # But we do not need it on host filesystem, just in ubifs image |
| 141 | # So run mknod and mkfs.ubifs commands under fakeroot program |
| 142 | # which via LD_PRELOAD simulate mknod() and stat() functions |
| 143 | # so mkfs.ubifs will see dev/console as character device and |
| 144 | # put it correctly as character device into final ubifs image |
| 145 | # Therefore we can run whole script as non-root nobody user |
| 146 | fakeroot sh -c ' |
| 147 | rm -f rootfs/dev/console; |
| 148 | mknod rootfs/dev/console c 5 1; |
| 149 | /usr/sbin/mkfs.ubifs -m 2048 -e 129024 -c 2047 -r rootfs ubifs.img; |
| 150 | ' |
| 151 | /usr/sbin/ubinize -o ubi.img -p 128KiB -m 2048 -s 512 ubi.ini |
| 152 | |
Pali Rohár | 9d12a9b | 2020-11-29 17:15:05 +0100 | [diff] [blame] | 153 | # Generate bootmenu for U-Boot serial console testing |
| 154 | cat > bootmenu_uboot << EOF |
| 155 | setenv bootmenu_0 'Serial console test=echo; echo "Testing serial console"; echo; echo "Successfully booted"; echo; poweroff'; |
| 156 | setenv bootmenu_1; |
| 157 | setenv bootmenu_delay 1; |
| 158 | setenv bootdelay 1; |
| 159 | EOF |
| 160 | ./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_uboot -d bootmenu_uboot bootmenu_uboot.scr |
| 161 | |
Pali Rohár | 0a8825c | 2021-06-18 15:27:03 +0200 | [diff] [blame^] | 162 | # Generate bootmenu for eMMC booting (uImage) |
Pali Rohár | 80ad67b | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 163 | cat > bootmenu_emmc << EOF |
| 164 | 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'; |
| 165 | setenv bootmenu_1; |
| 166 | setenv bootmenu_delay 1; |
| 167 | setenv bootdelay 1; |
| 168 | EOF |
Pali Rohár | 2def741 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 169 | ./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 | 80ad67b | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 170 | |
Pali Rohár | 0a8825c | 2021-06-18 15:27:03 +0200 | [diff] [blame^] | 171 | # Generate bootmenu for eMMC booting (zImage) |
| 172 | cat > bootmenu_emmc2 << EOF |
| 173 | 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'; |
| 174 | setenv bootmenu_1; |
| 175 | setenv bootmenu_delay 1; |
| 176 | setenv bootdelay 1; |
| 177 | EOF |
| 178 | ./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_emmc2 -d bootmenu_emmc2 bootmenu_emmc2.scr |
| 179 | |
Pali Rohár | 80ad67b | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 180 | # Generate bootmenu for OneNAND booting |
| 181 | cat > bootmenu_nand << EOF |
| 182 | setenv bootmenu_0 'uImage-2.6.28-omap1 from OneNAND=mtd read initfs \${kernaddr}; setenv bootargs; setenv setup_omap_atag 1; bootm \${kernaddr}'; |
| 183 | setenv bootmenu_1; |
| 184 | setenv bootmenu_delay 1; |
| 185 | setenv bootdelay 1; |
| 186 | EOF |
Pali Rohár | 2def741 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 187 | ./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 | 80ad67b | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 188 | |
Pali Rohár | 0a8825c | 2021-06-18 15:27:03 +0200 | [diff] [blame^] | 189 | # Generate bootmenu for default booting |
| 190 | cat > bootmenu_default << EOF |
| 191 | setenv bootmenu_delay 1; |
| 192 | setenv bootdelay 1; |
| 193 | EOF |
| 194 | ./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_default -d bootmenu_default bootmenu_default.scr |
| 195 | |
Pali Rohár | 80ad67b | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 196 | # Generate combined image from u-boot and Maemo fiasco kernel |
| 197 | dd if=kernel_2.6.28/boot/zImage-2.6.28-20103103+0m5.fiasco of=zImage-2.6.28-omap1 skip=95 bs=1 |
Pali Rohár | 0a8825c | 2021-06-18 15:27:03 +0200 | [diff] [blame^] | 198 | ./u-boot-gen-combined u-boot.bin zImage-2.6.28-omap1 combined_zimage.bin |
Pali Rohár | 80ad67b | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 199 | ./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 |
Pali Rohár | 0a8825c | 2021-06-18 15:27:03 +0200 | [diff] [blame^] | 200 | ./u-boot-gen-combined u-boot.bin uImage-2.6.28-omap1 combined_uimage.bin |
Pali Rohár | 80ad67b | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 201 | |
| 202 | # Generate combined hack image from u-boot and Maemo fiasco kernel (kernel starts at 2MB offset and qflasher puts 2kB header before supplied image) |
| 203 | cp u-boot.bin combined_hack.bin |
| 204 | dd if=uImage-2.6.28-omap1 of=combined_hack.bin bs=1024 seek=$((2048-2)) |
| 205 | |
Pali Rohár | 9d12a9b | 2020-11-29 17:15:05 +0100 | [diff] [blame] | 206 | # Generate FAT32 eMMC image for U-Boot serial console testing |
| 207 | truncate -s 50MiB emmc_uboot.img |
| 208 | mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_uboot.img |
| 209 | mcopy bootmenu_uboot.scr ::/bootmenu.scr -i emmc_uboot.img |
| 210 | |
Pali Rohár | 0a8825c | 2021-06-18 15:27:03 +0200 | [diff] [blame^] | 211 | # Generate FAT32 eMMC image for eMMC booting (uImage) |
Pali Rohár | 80ad67b | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 212 | truncate -s 50MiB emmc_emmc.img |
| 213 | mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_emmc.img |
| 214 | mcopy uImage-2.6.28-omap1 ::/uImage-2.6.28-omap1 -i emmc_emmc.img |
| 215 | mcopy bootmenu_emmc.scr ::/bootmenu.scr -i emmc_emmc.img |
| 216 | |
Pali Rohár | 0a8825c | 2021-06-18 15:27:03 +0200 | [diff] [blame^] | 217 | # Generate FAT32 eMMC image for eMMC booting (zImage) |
| 218 | truncate -s 50MiB emmc_emmc2.img |
| 219 | mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_emmc2.img |
| 220 | mcopy zImage-2.6.28-omap1 ::/zImage-2.6.28-omap1 -i emmc_emmc2.img |
| 221 | mcopy bootmenu_emmc2.scr ::/bootmenu.scr -i emmc_emmc2.img |
| 222 | |
Pali Rohár | 80ad67b | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 223 | # Generate FAT32 eMMC image for OneNAND booting |
| 224 | truncate -s 50MiB emmc_nand.img |
| 225 | mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_nand.img |
| 226 | mcopy bootmenu_nand.scr ::/bootmenu.scr -i emmc_nand.img |
| 227 | |
Pali Rohár | 0a8825c | 2021-06-18 15:27:03 +0200 | [diff] [blame^] | 228 | # Generate FAT32 eMMC image for default booting |
| 229 | truncate -s 50MiB emmc_default.img |
| 230 | mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_default.img |
| 231 | mcopy bootmenu_default.scr ::/bootmenu.scr -i emmc_default.img |
| 232 | |
Pali Rohár | 9d12a9b | 2020-11-29 17:15:05 +0100 | [diff] [blame] | 233 | # Generate MTD image for U-Boot serial console testing |
| 234 | rm -f mtd_uboot.img |
| 235 | ./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k u-boot.bin -m rx51 -o mtd_uboot.img |
| 236 | |
Pali Rohár | 80ad67b | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 237 | # Generate MTD image for RAM booting from bootloader nolo images, compiled image and rootfs image |
| 238 | rm -f mtd_ram.img |
Pali Rohár | 0a8825c | 2021-06-18 15:27:03 +0200 | [diff] [blame^] | 239 | ./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k combined_uimage.bin -r ubi.img -m rx51 -o mtd_ram.img |
| 240 | rm -f mtd_ram2.img |
| 241 | ./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 | 80ad67b | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 242 | |
| 243 | # Generate MTD image for eMMC booting from bootloader nolo images, u-boot image and rootfs image |
| 244 | rm -f mtd_emmc.img |
| 245 | ./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k u-boot.bin -r ubi.img -m rx51 -o mtd_emmc.img |
| 246 | |
| 247 | # Generate MTD image for OneNAND booting from bootloader nolo images, combined hacked image and rootfs image |
| 248 | # Kernel image is put into initfs area, but qflasher reject to copy kernel image into initfs area because it does not have initfs signature |
| 249 | # 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) |
| 250 | rm -f mtd_nand.img |
| 251 | ./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 |
| 252 | |
| 253 | echo |
| 254 | echo "======================================================" |
| 255 | echo "========== Running test images in n900 qemu ==========" |
| 256 | echo "======================================================" |
| 257 | echo |
| 258 | |
Pali Rohár | 9d12a9b | 2020-11-29 17:15:05 +0100 | [diff] [blame] | 259 | # Run MTD image in qemu and wait for 300s if U-Boot prints testing string to serial console and poweroff |
| 260 | rm -f qemu_uboot.log |
| 261 | ./qemu-system-arm -M n900 -mtdblock mtd_uboot.img -sd emmc_uboot.img -serial /dev/stdout -display none > qemu_uboot.log & |
| 262 | qemu_pid=$! |
| 263 | tail -F qemu_uboot.log & |
| 264 | tail_pid=$! |
| 265 | sleep 300 & |
| 266 | sleep_pid=$! |
| 267 | wait -n $sleep_pid $qemu_pid || true |
| 268 | kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true |
| 269 | wait || true |
| 270 | |
Pali Rohár | 0a8825c | 2021-06-18 15:27:03 +0200 | [diff] [blame^] | 271 | # Run MTD image in qemu and wait for 300s if uImage kernel from RAM is correctly booted |
Pali Rohár | 80ad67b | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 272 | rm -f qemu_ram.log |
| 273 | ./qemu-system-arm -M n900 -mtdblock mtd_ram.img -serial /dev/stdout -display none > qemu_ram.log & |
| 274 | qemu_pid=$! |
| 275 | tail -F qemu_ram.log & |
| 276 | tail_pid=$! |
Pali Rohár | 2def741 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 277 | sleep 300 & |
Pali Rohár | 80ad67b | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 278 | sleep_pid=$! |
Pali Rohár | 2def741 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 279 | wait -n $sleep_pid $qemu_pid || true |
| 280 | kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true |
| 281 | wait || true |
Pali Rohár | 80ad67b | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 282 | |
Pali Rohár | 0a8825c | 2021-06-18 15:27:03 +0200 | [diff] [blame^] | 283 | # Run MTD image in qemu and wait for 300s if zImage kernel from RAM is correctly booted |
| 284 | rm -f qemu_ram2.log |
| 285 | ./qemu-system-arm -M n900 -mtdblock mtd_ram2.img -sd emmc_default.img -serial /dev/stdout -display none > qemu_ram2.log & |
| 286 | qemu_pid=$! |
| 287 | tail -F qemu_ram2.log & |
| 288 | tail_pid=$! |
| 289 | sleep 300 & |
| 290 | sleep_pid=$! |
| 291 | wait -n $sleep_pid $qemu_pid || true |
| 292 | kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true |
| 293 | wait || true |
| 294 | |
| 295 | # Run MTD image in qemu and wait for 300s if uImage kernel from eMMC is correctly booted |
Pali Rohár | 80ad67b | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 296 | rm -f qemu_emmc.log |
| 297 | ./qemu-system-arm -M n900 -mtdblock mtd_emmc.img -sd emmc_emmc.img -serial /dev/stdout -display none > qemu_emmc.log & |
| 298 | qemu_pid=$! |
| 299 | tail -F qemu_emmc.log & |
| 300 | tail_pid=$! |
Pali Rohár | 2def741 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 301 | sleep 300 & |
Pali Rohár | 80ad67b | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 302 | sleep_pid=$! |
Pali Rohár | 2def741 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 303 | wait -n $sleep_pid $qemu_pid || true |
| 304 | kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true |
| 305 | wait || true |
Pali Rohár | 80ad67b | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 306 | |
Pali Rohár | 0a8825c | 2021-06-18 15:27:03 +0200 | [diff] [blame^] | 307 | # Run MTD image in qemu and wait for 300s if zImage kernel from eMMC is correctly booted |
| 308 | rm -f qemu_emmc2.log |
| 309 | ./qemu-system-arm -M n900 -mtdblock mtd_emmc.img -sd emmc_emmc2.img -serial /dev/stdout -display none > qemu_emmc2.log & |
| 310 | qemu_pid=$! |
| 311 | tail -F qemu_emmc2.log & |
| 312 | tail_pid=$! |
| 313 | sleep 300 & |
| 314 | sleep_pid=$! |
| 315 | wait -n $sleep_pid $qemu_pid || true |
| 316 | kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true |
| 317 | wait || true |
| 318 | |
Pali Rohár | 80ad67b | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 319 | # Run MTD image in qemu and wait for 300s if kernel from OneNAND is correctly booted |
| 320 | rm -f qemu_nand.log |
| 321 | ./qemu-system-arm -M n900 -mtdblock mtd_nand.img -sd emmc_nand.img -serial /dev/stdout -display none > qemu_nand.log & |
| 322 | qemu_pid=$! |
| 323 | tail -F qemu_nand.log & |
| 324 | tail_pid=$! |
Pali Rohár | 2def741 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 325 | sleep 300 & |
Pali Rohár | 80ad67b | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 326 | sleep_pid=$! |
Pali Rohár | 2def741 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 327 | wait -n $sleep_pid $qemu_pid || true |
| 328 | kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true |
| 329 | wait || true |
Pali Rohár | 80ad67b | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 330 | |
| 331 | echo |
| 332 | echo "=============================" |
| 333 | echo "========== Results ==========" |
| 334 | echo "=============================" |
| 335 | echo |
| 336 | |
Pali Rohár | 9d12a9b | 2020-11-29 17:15:05 +0100 | [diff] [blame] | 337 | 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 | 0a8825c | 2021-06-18 15:27:03 +0200 | [diff] [blame^] | 338 | 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 |
| 339 | 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 |
| 340 | 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 |
| 341 | 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 |
| 342 | 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 | 80ad67b | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 343 | |
| 344 | echo |
| 345 | |
Pali Rohár | 0a8825c | 2021-06-18 15:27:03 +0200 | [diff] [blame^] | 346 | 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; then |
Pali Rohár | 80ad67b | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 347 | echo "All tests passed" |
| 348 | exit 0 |
| 349 | else |
| 350 | echo "Some tests failed" |
| 351 | exit 1 |
| 352 | fi |