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 |
Pali Rohár | ce0f745 | 2023-02-21 11:22:29 -0500 | [diff] [blame] | 86 | if ! test -f qflasher || ! test -f xloader-qemu.bin || ! test -f secondary-qemu.bin; then |
| 87 | test -f qemu-n900.tar.gz || wget -c http://repository.maemo.org/qemu-n900/qemu-n900.tar.gz |
| 88 | tar -xf qemu-n900.tar.gz |
| 89 | fi |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 90 | |
| 91 | # Download Maemo script u-boot-gen-combined |
| 92 | if ! test -f u-boot-gen-combined; then |
| 93 | test -d u-boot-maemo || git clone https://github.com/pali/u-boot-maemo.git |
| 94 | chmod +x u-boot-maemo/debian/u-boot-gen-combined |
| 95 | ln -s u-boot-maemo/debian/u-boot-gen-combined . |
| 96 | fi |
| 97 | |
| 98 | # Download Maemo fiasco kernel |
Pali Rohár | ce0f745 | 2023-02-21 11:22:29 -0500 | [diff] [blame] | 99 | if ! test -d kernel_2.6.28; then |
| 100 | test -f kernel_2.6.28-20103103+0m5_armel.deb || wget -c http://repository.maemo.org/pool/maemo5.0/free/k/kernel/kernel_2.6.28-20103103+0m5_armel.deb |
| 101 | dpkg -x kernel_2.6.28-20103103+0m5_armel.deb kernel_2.6.28 |
| 102 | fi |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 103 | |
| 104 | # Download Maemo libc |
Pali Rohár | ce0f745 | 2023-02-21 11:22:29 -0500 | [diff] [blame] | 105 | if ! test -d libc6_2.5.1; then |
| 106 | test -f libc6_2.5.1-1eglibc27+0m5_armel.deb || wget -c http://repository.maemo.org/pool/maemo5.0/free/g/glibc/libc6_2.5.1-1eglibc27+0m5_armel.deb |
| 107 | dpkg -x libc6_2.5.1-1eglibc27+0m5_armel.deb libc6_2.5.1 |
| 108 | fi |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 109 | |
| 110 | # Download Maemo busybox |
Pali Rohár | ce0f745 | 2023-02-21 11:22:29 -0500 | [diff] [blame] | 111 | if ! test -d busybox_1.10.2; then |
| 112 | test -f busybox_1.10.2.legal-1osso30+0m5_armel.deb || wget -c http://repository.maemo.org/pool/maemo5.0/free/b/busybox/busybox_1.10.2.legal-1osso30+0m5_armel.deb |
| 113 | dpkg -x busybox_1.10.2.legal-1osso30+0m5_armel.deb busybox_1.10.2 |
| 114 | fi |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 115 | |
| 116 | echo |
| 117 | echo "=======================================" |
| 118 | echo "========== Generating images ==========" |
| 119 | echo "=======================================" |
| 120 | echo |
| 121 | |
Pali Rohár | 43f7b81 | 2022-09-15 20:59:48 +0200 | [diff] [blame] | 122 | # Generate kernel image in zImage and uImage format from FIASCO format |
| 123 | dd if=kernel_2.6.28/boot/zImage-2.6.28-20103103+0m5.fiasco of=zImage-2.6.28-omap1 skip=95 bs=1 |
| 124 | ./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 |
| 125 | |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 126 | # Generate rootfs directory |
| 127 | mkdir -p rootfs |
| 128 | mkdir -p rootfs/dev/ |
| 129 | mkdir -p rootfs/bin/ |
| 130 | mkdir -p rootfs/sbin/ |
| 131 | mkdir -p rootfs/lib/ |
| 132 | cp -a busybox_1.10.2/bin/busybox rootfs/bin/ |
| 133 | cp -a libc6_2.5.1/lib/ld-linux.so.3 rootfs/lib/ |
| 134 | cp -a libc6_2.5.1/lib/ld-2.5.so rootfs/lib/ |
| 135 | cp -a libc6_2.5.1/lib/libc.so.6 rootfs/lib/ |
| 136 | cp -a libc6_2.5.1/lib/libc-2.5.so rootfs/lib/ |
| 137 | cp -a libc6_2.5.1/lib/libcrypt.so.1 rootfs/lib/ |
| 138 | cp -a libc6_2.5.1/lib/libcrypt-2.5.so rootfs/lib/ |
| 139 | test -f rootfs/bin/sh || ln -sf busybox rootfs/bin/sh |
| 140 | test -f rootfs/sbin/poweroff || ln -sf ../bin/busybox rootfs/sbin/poweroff |
| 141 | cat > rootfs/sbin/preinit << EOF |
| 142 | #!/bin/sh |
| 143 | echo |
| 144 | echo "Successfully booted" |
| 145 | echo |
| 146 | /sbin/poweroff -f |
| 147 | EOF |
| 148 | chmod +x rootfs/sbin/preinit |
| 149 | |
Pali Rohár | 43f7b81 | 2022-09-15 20:59:48 +0200 | [diff] [blame] | 150 | # Generate ubifs image from rootfs directory |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 151 | # NOTE: Character device on host filesystem can be created only by root |
| 152 | # But we do not need it on host filesystem, just in ubifs image |
| 153 | # So run mknod and mkfs.ubifs commands under fakeroot program |
| 154 | # which via LD_PRELOAD simulate mknod() and stat() functions |
| 155 | # so mkfs.ubifs will see dev/console as character device and |
| 156 | # put it correctly as character device into final ubifs image |
| 157 | # Therefore we can run whole script as non-root nobody user |
| 158 | fakeroot sh -c ' |
| 159 | rm -f rootfs/dev/console; |
| 160 | mknod rootfs/dev/console c 5 1; |
| 161 | /usr/sbin/mkfs.ubifs -m 2048 -e 129024 -c 2047 -r rootfs ubifs.img; |
| 162 | ' |
Pali Rohár | 43f7b81 | 2022-09-15 20:59:48 +0200 | [diff] [blame] | 163 | |
| 164 | # Generate ubi image with rootfs on first volume |
| 165 | cat > ubi.ini << EOF |
| 166 | [rootfs] |
| 167 | mode=ubi |
| 168 | image=ubifs.img |
| 169 | vol_id=0 |
| 170 | vol_size=230MiB # 1870 LEBs |
| 171 | vol_type=dynamic |
| 172 | vol_name=rootfs |
| 173 | vol_alignment=1 |
| 174 | vol_flags=autoresize |
| 175 | EOF |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 176 | /usr/sbin/ubinize -o ubi.img -p 128KiB -m 2048 -s 512 ubi.ini |
| 177 | |
Pali Rohár | 43f7b81 | 2022-09-15 20:59:48 +0200 | [diff] [blame] | 178 | # Generate ubi image with rootfs on first volume and kernel in zImage format on second volume for UBI booting |
| 179 | cp ubi.ini ubi_with_kernel.ini |
| 180 | cat >> ubi_with_kernel.ini << EOF |
| 181 | [kernel] |
| 182 | mode=ubi |
| 183 | image=zImage-2.6.28-omap1 |
| 184 | vol_id=1 |
| 185 | vol_size=2MiB |
| 186 | vol_type=dynamic |
| 187 | vol_name=kernel |
| 188 | vol_alignment=1 |
| 189 | EOF |
| 190 | /usr/sbin/ubinize -o ubi_with_kernel.img -p 128KiB -m 2048 -s 512 ubi_with_kernel.ini |
| 191 | |
Pali Rohár | 1ce0e1c | 2020-11-29 17:15:05 +0100 | [diff] [blame] | 192 | # Generate bootmenu for U-Boot serial console testing |
| 193 | cat > bootmenu_uboot << EOF |
| 194 | setenv bootmenu_0 'Serial console test=echo; echo "Testing serial console"; echo; echo "Successfully booted"; echo; poweroff'; |
| 195 | setenv bootmenu_1; |
| 196 | setenv bootmenu_delay 1; |
| 197 | setenv bootdelay 1; |
| 198 | EOF |
| 199 | ./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_uboot -d bootmenu_uboot bootmenu_uboot.scr |
| 200 | |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 201 | # Generate bootmenu for eMMC booting (uImage) |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 202 | cat > bootmenu_emmc << EOF |
| 203 | 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'; |
| 204 | setenv bootmenu_1; |
| 205 | setenv bootmenu_delay 1; |
| 206 | setenv bootdelay 1; |
| 207 | EOF |
Pali Rohár | 56847f3 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 208 | ./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] | 209 | |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 210 | # Generate bootmenu for eMMC booting (zImage) |
| 211 | cat > bootmenu_emmc2 << EOF |
| 212 | 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'; |
| 213 | setenv bootmenu_1; |
| 214 | setenv bootmenu_delay 1; |
| 215 | setenv bootdelay 1; |
| 216 | EOF |
| 217 | ./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_emmc2 -d bootmenu_emmc2 bootmenu_emmc2.scr |
| 218 | |
Pali Rohár | 21dc5ef | 2022-09-04 03:29:05 +0200 | [diff] [blame] | 219 | # Generate bootmenu for OneNAND booting (uImage) |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 220 | cat > bootmenu_nand << EOF |
Pali Rohár | 7506965 | 2022-09-04 03:29:02 +0200 | [diff] [blame] | 221 | 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] | 222 | setenv bootmenu_1; |
| 223 | setenv bootmenu_delay 1; |
| 224 | setenv bootdelay 1; |
| 225 | EOF |
Pali Rohár | 56847f3 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 226 | ./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] | 227 | |
Pali Rohár | 43f7b81 | 2022-09-15 20:59:48 +0200 | [diff] [blame] | 228 | # Generate bootmenu for UBI booting (zImage) |
| 229 | cat > bootmenu_ubi << EOF |
| 230 | 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}'; |
| 231 | setenv bootmenu_1; |
| 232 | setenv bootmenu_delay 1; |
| 233 | setenv bootdelay 1; |
| 234 | EOF |
| 235 | ./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_ubi -d bootmenu_ubi bootmenu_ubi.scr |
| 236 | |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 237 | # Generate bootmenu for default booting |
| 238 | cat > bootmenu_default << EOF |
| 239 | setenv bootmenu_delay 1; |
| 240 | setenv bootdelay 1; |
| 241 | EOF |
| 242 | ./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_default -d bootmenu_default bootmenu_default.scr |
| 243 | |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 244 | # Generate combined image from u-boot and Maemo fiasco kernel |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 245 | ./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] | 246 | ./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] | 247 | |
| 248 | # Generate combined hack image from u-boot and Maemo fiasco kernel (kernel starts at 2MB offset and qflasher puts 2kB header before supplied image) |
| 249 | cp u-boot.bin combined_hack.bin |
| 250 | dd if=uImage-2.6.28-omap1 of=combined_hack.bin bs=1024 seek=$((2048-2)) |
| 251 | |
Pali Rohár | 1ce0e1c | 2020-11-29 17:15:05 +0100 | [diff] [blame] | 252 | # Generate FAT32 eMMC image for U-Boot serial console testing |
| 253 | truncate -s 50MiB emmc_uboot.img |
| 254 | mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_uboot.img |
| 255 | mcopy bootmenu_uboot.scr ::/bootmenu.scr -i emmc_uboot.img |
| 256 | |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 257 | # Generate FAT32 eMMC image for eMMC booting (uImage) |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 258 | truncate -s 50MiB emmc_emmc.img |
| 259 | mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_emmc.img |
| 260 | mcopy uImage-2.6.28-omap1 ::/uImage-2.6.28-omap1 -i emmc_emmc.img |
| 261 | mcopy bootmenu_emmc.scr ::/bootmenu.scr -i emmc_emmc.img |
| 262 | |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 263 | # Generate FAT32 eMMC image for eMMC booting (zImage) |
| 264 | truncate -s 50MiB emmc_emmc2.img |
| 265 | mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_emmc2.img |
| 266 | mcopy zImage-2.6.28-omap1 ::/zImage-2.6.28-omap1 -i emmc_emmc2.img |
| 267 | mcopy bootmenu_emmc2.scr ::/bootmenu.scr -i emmc_emmc2.img |
| 268 | |
Pali Rohár | 21dc5ef | 2022-09-04 03:29:05 +0200 | [diff] [blame] | 269 | # Generate FAT32 eMMC image for OneNAND booting (uImage) |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 270 | truncate -s 50MiB emmc_nand.img |
| 271 | mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_nand.img |
| 272 | mcopy bootmenu_nand.scr ::/bootmenu.scr -i emmc_nand.img |
| 273 | |
Pali Rohár | 43f7b81 | 2022-09-15 20:59:48 +0200 | [diff] [blame] | 274 | # Generate FAT32 eMMC image for UBI booting (zImage) |
| 275 | truncate -s 50MiB emmc_ubi.img |
| 276 | mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_ubi.img |
| 277 | mcopy bootmenu_ubi.scr ::/bootmenu.scr -i emmc_ubi.img |
| 278 | |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 279 | # Generate FAT32 eMMC image for default booting |
| 280 | truncate -s 50MiB emmc_default.img |
| 281 | mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_default.img |
| 282 | mcopy bootmenu_default.scr ::/bootmenu.scr -i emmc_default.img |
| 283 | |
Pali Rohár | 1ce0e1c | 2020-11-29 17:15:05 +0100 | [diff] [blame] | 284 | # Generate MTD image for U-Boot serial console testing |
| 285 | rm -f mtd_uboot.img |
| 286 | ./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k u-boot.bin -m rx51 -o mtd_uboot.img |
| 287 | |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 288 | # Generate MTD image for RAM booting from bootloader nolo images, compiled image and rootfs image |
| 289 | rm -f mtd_ram.img |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 290 | ./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k combined_uimage.bin -r ubi.img -m rx51 -o mtd_ram.img |
| 291 | rm -f mtd_ram2.img |
| 292 | ./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] | 293 | |
| 294 | # Generate MTD image for eMMC booting from bootloader nolo images, u-boot image and rootfs image |
| 295 | rm -f mtd_emmc.img |
| 296 | ./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k u-boot.bin -r ubi.img -m rx51 -o mtd_emmc.img |
| 297 | |
| 298 | # Generate MTD image for OneNAND booting from bootloader nolo images, combined hacked image and rootfs image |
| 299 | # Kernel image is put into initfs area, but qflasher reject to copy kernel image into initfs area because it does not have initfs signature |
| 300 | # 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) |
| 301 | rm -f mtd_nand.img |
| 302 | ./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 |
| 303 | |
Pali Rohár | 43f7b81 | 2022-09-15 20:59:48 +0200 | [diff] [blame] | 304 | # Generate MTD image for UBI booting from bootloader nolo images, u-boot image with UBI/UBIFS support and rootfs image with kernel volume |
| 305 | rm -f mtd_ubi.img |
| 306 | ./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 |
| 307 | |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 308 | echo |
| 309 | echo "======================================================" |
| 310 | echo "========== Running test images in n900 qemu ==========" |
| 311 | echo "======================================================" |
| 312 | echo |
| 313 | |
Pali Rohár | 1ce0e1c | 2020-11-29 17:15:05 +0100 | [diff] [blame] | 314 | # Run MTD image in qemu and wait for 300s if U-Boot prints testing string to serial console and poweroff |
| 315 | rm -f qemu_uboot.log |
| 316 | ./qemu-system-arm -M n900 -mtdblock mtd_uboot.img -sd emmc_uboot.img -serial /dev/stdout -display none > qemu_uboot.log & |
| 317 | qemu_pid=$! |
| 318 | tail -F qemu_uboot.log & |
| 319 | tail_pid=$! |
| 320 | sleep 300 & |
| 321 | sleep_pid=$! |
| 322 | wait -n $sleep_pid $qemu_pid || true |
| 323 | kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true |
| 324 | wait || true |
| 325 | |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 326 | # 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] | 327 | rm -f qemu_ram.log |
| 328 | ./qemu-system-arm -M n900 -mtdblock mtd_ram.img -serial /dev/stdout -display none > qemu_ram.log & |
| 329 | qemu_pid=$! |
| 330 | tail -F qemu_ram.log & |
| 331 | tail_pid=$! |
Pali Rohár | 56847f3 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 332 | sleep 300 & |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 333 | sleep_pid=$! |
Pali Rohár | 56847f3 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 334 | wait -n $sleep_pid $qemu_pid || true |
| 335 | kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true |
| 336 | wait || true |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 337 | |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 338 | # Run MTD image in qemu and wait for 300s if zImage kernel from RAM is correctly booted |
| 339 | rm -f qemu_ram2.log |
| 340 | ./qemu-system-arm -M n900 -mtdblock mtd_ram2.img -sd emmc_default.img -serial /dev/stdout -display none > qemu_ram2.log & |
| 341 | qemu_pid=$! |
| 342 | tail -F qemu_ram2.log & |
| 343 | tail_pid=$! |
| 344 | sleep 300 & |
| 345 | sleep_pid=$! |
| 346 | wait -n $sleep_pid $qemu_pid || true |
| 347 | kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true |
| 348 | wait || true |
| 349 | |
| 350 | # 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] | 351 | rm -f qemu_emmc.log |
| 352 | ./qemu-system-arm -M n900 -mtdblock mtd_emmc.img -sd emmc_emmc.img -serial /dev/stdout -display none > qemu_emmc.log & |
| 353 | qemu_pid=$! |
| 354 | tail -F qemu_emmc.log & |
| 355 | tail_pid=$! |
Pali Rohár | 56847f3 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 356 | sleep 300 & |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 357 | sleep_pid=$! |
Pali Rohár | 56847f3 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 358 | wait -n $sleep_pid $qemu_pid || true |
| 359 | kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true |
| 360 | wait || true |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 361 | |
Pali Rohár | cc434fc | 2021-06-18 15:27:03 +0200 | [diff] [blame] | 362 | # Run MTD image in qemu and wait for 300s if zImage kernel from eMMC is correctly booted |
| 363 | rm -f qemu_emmc2.log |
| 364 | ./qemu-system-arm -M n900 -mtdblock mtd_emmc.img -sd emmc_emmc2.img -serial /dev/stdout -display none > qemu_emmc2.log & |
| 365 | qemu_pid=$! |
| 366 | tail -F qemu_emmc2.log & |
| 367 | tail_pid=$! |
| 368 | sleep 300 & |
| 369 | sleep_pid=$! |
| 370 | wait -n $sleep_pid $qemu_pid || true |
| 371 | kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true |
| 372 | wait || true |
| 373 | |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 374 | # Run MTD image in qemu and wait for 300s if kernel from OneNAND is correctly booted |
| 375 | rm -f qemu_nand.log |
| 376 | ./qemu-system-arm -M n900 -mtdblock mtd_nand.img -sd emmc_nand.img -serial /dev/stdout -display none > qemu_nand.log & |
| 377 | qemu_pid=$! |
| 378 | tail -F qemu_nand.log & |
| 379 | tail_pid=$! |
Pali Rohár | 56847f3 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 380 | sleep 300 & |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 381 | sleep_pid=$! |
Pali Rohár | 56847f3 | 2020-10-31 17:32:48 +0100 | [diff] [blame] | 382 | wait -n $sleep_pid $qemu_pid || true |
| 383 | kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true |
| 384 | wait || true |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 385 | |
Pali Rohár | 43f7b81 | 2022-09-15 20:59:48 +0200 | [diff] [blame] | 386 | # Run MTD image in qemu and wait for 300s if kernel from UBI is correctly booted |
| 387 | rm -f qemu_ubi.log |
| 388 | ./qemu-system-arm -M n900 -mtdblock mtd_ubi.img -sd emmc_ubi.img -serial /dev/stdout -display none > qemu_ubi.log & |
| 389 | qemu_pid=$! |
| 390 | tail -F qemu_ubi.log & |
| 391 | tail_pid=$! |
| 392 | sleep 300 & |
| 393 | sleep_pid=$! |
| 394 | wait -n $sleep_pid $qemu_pid || true |
| 395 | kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true |
| 396 | wait || true |
| 397 | |
Pali Rohár | 6cfd09d | 2020-05-17 14:38:22 +0200 | [diff] [blame] | 398 | echo |
| 399 | echo "=============================" |
| 400 | echo "========== Results ==========" |
| 401 | echo "=============================" |
| 402 | echo |
| 403 | |
Pali Rohár | 1ce0e1c | 2020-11-29 17:15:05 +0100 | [diff] [blame] | 404 | 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] | 405 | 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 |
| 406 | 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 |
| 407 | 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 |
| 408 | 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 |
| 409 | 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] | 410 | 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] | 411 | |
| 412 | echo |
| 413 | |
Pali Rohár | 43f7b81 | 2022-09-15 20:59:48 +0200 | [diff] [blame] | 414 | 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] | 415 | echo "All tests passed" |
| 416 | exit 0 |
| 417 | else |
| 418 | echo "Some tests failed" |
| 419 | exit 1 |
| 420 | fi |