:: [maemo-leste] [PATCH 1/2] Nokia RX-…
Forside
Slet denne besked
Besvar denne besked
Skribent: Pali Rohár
Dato:  
Til: Lokesh Vutla
CC: Ivaylo Dimitrov, Merlijn Wajer, maemo-leste, u-boot
Nye-emner: [maemo-leste] [PATCH 2/2] Nokia RX-51: Load bootmenu also from uSD card
Emne: [maemo-leste] [PATCH 1/2] Nokia RX-51: Add support for booting kernel in zImage format
Enable U-Boot bootz command and update env scripts to try loading also
zImage file and to try booting via bootz command.

Update also lowlevel_init.S code for checking validity of zImage magic to
correctly relocate kernel in zImage format.

This change allows U-Boot to directly boot Linux kernel without need for
converting kernel image into U-Boot uImage format.

Signed-off-by: Pali Rohár <pali@???>
---
 board/nokia/rx51/lowlevel_init.S | 12 ++++-
 configs/nokia_rx51_defconfig     |  1 +
 doc/README.nokia_rx51            | 10 +++--
 include/configs/nokia_rx51.h     | 11 +++--
 test/nokia_rx51_test.sh          | 76 +++++++++++++++++++++++++++-----
 5 files changed, 91 insertions(+), 19 deletions(-)


diff --git a/board/nokia/rx51/lowlevel_init.S b/board/nokia/rx51/lowlevel_init.S
index 1466d976fc4b..11c2cbef89a6 100644
--- a/board/nokia/rx51/lowlevel_init.S
+++ b/board/nokia/rx51/lowlevel_init.S
@@ -27,6 +27,9 @@ imagesize:        /* maximal size of image */
 ih_magic:        /* IH_MAGIC in big endian from include/image.h */
     .word 0x56190527


+z_magic:        /* LINUX_ARM_ZIMAGE_MAGIC */
+    .word 0x016f2818
+
 /*
  * Routine: save_boot_params (called after reset from start.S)
  * Description: Copy attached kernel to address KERNEL_ADDRESS
@@ -75,6 +78,12 @@ copy_kernel_start:
     ldr    r4, [r0]    /* r4 - 4 bytes header of kernel */
     ldr    r5, ih_magic    /* r5 - IH_MAGIC */
     cmp    r4, r5
+    beq    copy_kernel_loop
+
+    /* check for valid kernel zImage */
+    ldr    r4, [r0, #36]    /* r4 - 4 bytes header of kernel at offset 36 */
+    ldr    r5, z_magic    /* r5 - LINUX_ARM_ZIMAGE_MAGIC */
+    cmp    r4, r5
     bne    copy_kernel_end    /* skip if invalid image */


copy_kernel_loop:
@@ -85,7 +94,8 @@ copy_kernel_loop:

 copy_kernel_end:
     mov    r5, #0
-    str    r5, [r0]    /* remove 4 bytes header of kernel */
+    str    r5, [r0]    /* remove 4 bytes header of kernel uImage */
+    str    r5, [r0, #36]    /* remove 4 bytes header of kernel zImage */



/* Fix u-boot code */
diff --git a/configs/nokia_rx51_defconfig b/configs/nokia_rx51_defconfig
index 061f5c357c46..981e6f95cb1f 100644
--- a/configs/nokia_rx51_defconfig
+++ b/configs/nokia_rx51_defconfig
@@ -18,6 +18,7 @@ CONFIG_CONSOLE_MUX=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PROMPT="Nokia RX-51 # "
# CONFIG_CMD_BDI is not set
+CONFIG_CMD_BOOTZ=y
# CONFIG_BOOTM_NETBSD is not set
# CONFIG_BOOTM_PLAN9 is not set
# CONFIG_BOOTM_RTEMS is not set
diff --git a/doc/README.nokia_rx51 b/doc/README.nokia_rx51
index 84d1912ddd2b..7f22ed49bd75 100644
--- a/doc/README.nokia_rx51
+++ b/doc/README.nokia_rx51
@@ -11,13 +11,14 @@ a kernel. In order to transparently boot the original kernel, it will be
appended to u-boot.bin at 0x40000. NOLO will load the entire image into
(random) memory and execute u-boot, which saves hw revision, boot reason
and boot mode ATAGs set by NOLO. Then the bootscripts will attempt to load
-uImage or boot.scr from a fat, ext2/ext3 or ext4 filesystem in external
+uImage, zImage or boot.scr from a fat or ext2/3/4 filesystem on external
SD card or internal eMMC memory. If this fails or keyboard is closed then
the appended kernel image will be booted using some generated and some
stored ATAGs (see boot order).

-For generating combined image of u-boot and kernel there is a simple script
-called u-boot-gen-combined. It is available in following repository:
+For generating combined image of u-boot and kernel (either in uImage or zImage
+format) there is a simple script called u-boot-gen-combined. It is available in
+following repository:

https://github.com/pali/u-boot-maemo

@@ -41,7 +42,8 @@ Boot from SD or eMMC in this order:
  * 1.
    * 1.1 find boot.scr on first fat partition
    * 1.2 find uImage on first fat partition
-   * 1.3 same order for 2. - 4. fat partition
+   * 1.3 find zImage on first fat partition
+   * 1.4 same order for 2. - 4. fat partition
  * 2. same as 1. but for ext2/3 partition
  * 3. same as 1. but for ext4 partition


diff --git a/include/configs/nokia_rx51.h b/include/configs/nokia_rx51.h
index fe991ea03991..742c1a646545 100644
--- a/include/configs/nokia_rx51.h
+++ b/include/configs/nokia_rx51.h
@@ -129,12 +129,14 @@ int rx51_kp_getc(struct stdio_dev *sdev);
     "scriptboot=echo Running ${mmcscriptfile} from mmc " \
         "${mmcnum}:${mmcpart} ...; source ${scriptaddr}\0" \
     "kernboot=echo Booting ${mmckernfile} from mmc " \
-        "${mmcnum}:${mmcpart} ...; bootm ${kernaddr}\0" \
+        "${mmcnum}:${mmcpart} ...; bootm ${kernaddr} || " \
+            "bootz ${kernaddr}\0" \
     "kerninitrdboot=echo Booting ${mmckernfile} ${mmcinitrdfile} from mmc "\
-        "${mmcnum}:${mmcpart} ...; bootm ${kernaddr} ${initrdaddr}\0" \
+        "${mmcnum}:${mmcpart} ...; bootm ${kernaddr} ${initrdaddr} || " \
+            "bootz ${kernaddr} ${initrdaddr}\0" \
     "attachboot=echo Booting attached kernel image ...;" \
         "setenv setup_omap_atag 1;" \
-        "bootm ${attkernaddr};" \
+        "bootm ${attkernaddr} || bootz ${attkernaddr};" \
         "setenv setup_omap_atag\0" \
     "trymmcscriptboot=if run switchmmc; then " \
             "if run scriptload; then " \
@@ -154,7 +156,8 @@ int rx51_kp_getc(struct stdio_dev *sdev);
             "fi; " \
         "fi\0" \
     "trymmcpartboot=setenv mmcscriptfile boot.scr; run trymmcscriptboot;" \
-        "setenv mmckernfile uImage; run trymmckernboot\0" \
+        "setenv mmckernfile uImage; run trymmckernboot;" \
+        "setenv mmckernfile zImage; run trymmckernboot\0" \
     "trymmcallpartboot=setenv mmcpart 1; run trymmcpartboot;" \
         "setenv mmcpart 2; run trymmcpartboot;" \
         "setenv mmcpart 3; run trymmcpartboot;" \
diff --git a/test/nokia_rx51_test.sh b/test/nokia_rx51_test.sh
index ee45e8d6dd58..176719e28b7e 100755
--- a/test/nokia_rx51_test.sh
+++ b/test/nokia_rx51_test.sh
@@ -159,7 +159,7 @@ setenv bootdelay 1;
 EOF
 ./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_uboot -d bootmenu_uboot bootmenu_uboot.scr


-# Generate bootmenu for eMMC booting
+# Generate bootmenu for eMMC booting (uImage)
cat > bootmenu_emmc << EOF
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';
setenv bootmenu_1;
@@ -168,6 +168,15 @@ setenv bootdelay 1;
EOF
./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_emmc -d bootmenu_emmc bootmenu_emmc.scr

+# Generate bootmenu for eMMC booting (zImage)
+cat > bootmenu_emmc2 << EOF
+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';
+setenv bootmenu_1;
+setenv bootmenu_delay 1;
+setenv bootdelay 1;
+EOF
+./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_emmc2 -d bootmenu_emmc2 bootmenu_emmc2.scr
+
# Generate bootmenu for OneNAND booting
cat > bootmenu_nand << EOF
setenv bootmenu_0 'uImage-2.6.28-omap1 from OneNAND=mtd read initfs \${kernaddr}; setenv bootargs; setenv setup_omap_atag 1; bootm \${kernaddr}';
@@ -177,10 +186,18 @@ setenv bootdelay 1;
EOF
./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_nand -d bootmenu_nand bootmenu_nand.scr

+# Generate bootmenu for default booting
+cat > bootmenu_default << EOF
+setenv bootmenu_delay 1;
+setenv bootdelay 1;
+EOF
+./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_default -d bootmenu_default bootmenu_default.scr
+
# Generate combined image from u-boot and Maemo fiasco kernel
dd if=kernel_2.6.28/boot/zImage-2.6.28-20103103+0m5.fiasco of=zImage-2.6.28-omap1 skip=95 bs=1
+./u-boot-gen-combined u-boot.bin zImage-2.6.28-omap1 combined_zimage.bin
./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
-./u-boot-gen-combined u-boot.bin uImage-2.6.28-omap1 combined.bin
+./u-boot-gen-combined u-boot.bin uImage-2.6.28-omap1 combined_uimage.bin

# Generate combined hack image from u-boot and Maemo fiasco kernel (kernel starts at 2MB offset and qflasher puts 2kB header before supplied image)
cp u-boot.bin combined_hack.bin
@@ -191,24 +208,37 @@ truncate -s 50MiB emmc_uboot.img
mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_uboot.img
mcopy bootmenu_uboot.scr ::/bootmenu.scr -i emmc_uboot.img

-# Generate FAT32 eMMC image for eMMC booting
+# Generate FAT32 eMMC image for eMMC booting (uImage)
truncate -s 50MiB emmc_emmc.img
mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_emmc.img
mcopy uImage-2.6.28-omap1 ::/uImage-2.6.28-omap1 -i emmc_emmc.img
mcopy bootmenu_emmc.scr ::/bootmenu.scr -i emmc_emmc.img

+# Generate FAT32 eMMC image for eMMC booting (zImage)
+truncate -s 50MiB emmc_emmc2.img
+mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_emmc2.img
+mcopy zImage-2.6.28-omap1 ::/zImage-2.6.28-omap1 -i emmc_emmc2.img
+mcopy bootmenu_emmc2.scr ::/bootmenu.scr -i emmc_emmc2.img
+
# Generate FAT32 eMMC image for OneNAND booting
truncate -s 50MiB emmc_nand.img
mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_nand.img
mcopy bootmenu_nand.scr ::/bootmenu.scr -i emmc_nand.img

+# Generate FAT32 eMMC image for default booting
+truncate -s 50MiB emmc_default.img
+mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_default.img
+mcopy bootmenu_default.scr ::/bootmenu.scr -i emmc_default.img
+
# Generate MTD image for U-Boot serial console testing
rm -f mtd_uboot.img
./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k u-boot.bin -m rx51 -o mtd_uboot.img

# Generate MTD image for RAM booting from bootloader nolo images, compiled image and rootfs image
rm -f mtd_ram.img
-./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k combined.bin -r ubi.img -m rx51 -o mtd_ram.img
+./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k combined_uimage.bin -r ubi.img -m rx51 -o mtd_ram.img
+rm -f mtd_ram2.img
+./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k combined_zimage.bin -r ubi.img -m rx51 -o mtd_ram2.img

# Generate MTD image for eMMC booting from bootloader nolo images, u-boot image and rootfs image
rm -f mtd_emmc.img
@@ -238,7 +268,7 @@ wait -n $sleep_pid $qemu_pid || true
kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true
wait || true

-# Run MTD image in qemu and wait for 300s if kernel from RAM is correctly booted
+# Run MTD image in qemu and wait for 300s if uImage kernel from RAM is correctly booted
rm -f qemu_ram.log
./qemu-system-arm -M n900 -mtdblock mtd_ram.img -serial /dev/stdout -display none > qemu_ram.log &
qemu_pid=$!
@@ -250,7 +280,19 @@ wait -n $sleep_pid $qemu_pid || true
kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true
wait || true

-# Run MTD image in qemu and wait for 300s if kernel from eMMC is correctly booted
+# Run MTD image in qemu and wait for 300s if zImage kernel from RAM is correctly booted
+rm -f qemu_ram2.log
+./qemu-system-arm -M n900 -mtdblock mtd_ram2.img -sd emmc_default.img -serial /dev/stdout -display none > qemu_ram2.log &
+qemu_pid=$!
+tail -F qemu_ram2.log &
+tail_pid=$!
+sleep 300 &
+sleep_pid=$!
+wait -n $sleep_pid $qemu_pid || true
+kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true
+wait || true
+
+# Run MTD image in qemu and wait for 300s if uImage kernel from eMMC is correctly booted
rm -f qemu_emmc.log
./qemu-system-arm -M n900 -mtdblock mtd_emmc.img -sd emmc_emmc.img -serial /dev/stdout -display none > qemu_emmc.log &
qemu_pid=$!
@@ -262,6 +304,18 @@ wait -n $sleep_pid $qemu_pid || true
kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true
wait || true

+# Run MTD image in qemu and wait for 300s if zImage kernel from eMMC is correctly booted
+rm -f qemu_emmc2.log
+./qemu-system-arm -M n900 -mtdblock mtd_emmc.img -sd emmc_emmc2.img -serial /dev/stdout -display none > qemu_emmc2.log &
+qemu_pid=$!
+tail -F qemu_emmc2.log &
+tail_pid=$!
+sleep 300 &
+sleep_pid=$!
+wait -n $sleep_pid $qemu_pid || true
+kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true
+wait || true
+
# Run MTD image in qemu and wait for 300s if kernel from OneNAND is correctly booted
rm -f qemu_nand.log
./qemu-system-arm -M n900 -mtdblock mtd_nand.img -sd emmc_nand.img -serial /dev/stdout -display none > qemu_nand.log &
@@ -281,13 +335,15 @@ echo "============================="
echo

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
-if grep -q 'Successfully booted' qemu_ram.log; then echo "Kernel was successfully booted from RAM"; else echo "Failed to boot kernel from RAM"; fi
-if grep -q 'Successfully booted' qemu_emmc.log; then echo "Kernel was successfully booted from eMMC"; else echo "Failed to boot kernel from eMMC"; fi
-if grep -q 'Successfully booted' qemu_nand.log; then echo "Kernel was successfully booted from OneNAND"; else echo "Failed to boot kernel from OneNAND"; fi
+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
+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
+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
+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
+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

echo

-if grep -q 'Successfully booted' qemu_uboot.log && grep -q 'Successfully booted' qemu_ram.log && grep -q 'Successfully booted' qemu_emmc.log && grep -q 'Successfully booted' qemu_nand.log; then
+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
     echo "All tests passed"
     exit 0
 else
-- 
2.20.1