From 14fe4fff61bf5ae5a9540bd8cb0a9933fd458119 Mon Sep 17 00:00:00 2001 From: hyphop Date: Tue, 6 Aug 2019 08:42:05 +0300 Subject: [PATCH] Tue Aug 6 08:42:05 MSK 2019 --- files/README.md | 5 ++++- files/README.txt | 5 ++++- files/boot.sd.cmd | 16 +--------------- files/boot.sd.make | 4 ++++ files/boot_detect.cmd | 8 ++++++++ files/boot_hook.c | 22 ++++++++++++++++++++++ files/boot_hook.cmd | 18 ++++++++++++++++++ scripts/prepare_sd_image_rescue | 2 ++ 8 files changed, 63 insertions(+), 17 deletions(-) create mode 100755 files/boot.sd.make create mode 100755 files/boot_hook.c create mode 100755 files/boot_hook.cmd diff --git a/files/README.md b/files/README.md index ba6d779..3ce89e4 100644 --- a/files/README.md +++ b/files/README.md @@ -4,7 +4,10 @@ + [80_user_env.txt](80_user_env.txt) - user uboot env + [boot.dhcp.cmd](boot.dhcp.cmd) - uboot script boot rescue system from DHCP+TFTP + [boot.sd.cmd](boot.sd.cmd) - uboot script boot rescue system from SD ++ [boot.sd.make](boot.sd.make) - update boot.sd.scr from boot.sd.cmd source + [boot.spi.cmd](boot.spi.cmd) - uboot script boot rescue system from spi flash -+ [boot_detect.cmd](boot_detect.cmd) - #define BOOT_DEVICE_RESERVED 0 ++ [boot_detect.cmd](boot_detect.cmd) - boot source detection example ++ [boot_hook.c](boot_hook.c) - #!script ++ [boot_hook.cmd](boot_hook.cmd) - #!script + [splash.bmp.gz.make](splash.bmp.gz.make) - smart svg -> bmp rgb565 gz converter + [splash.svg](splash.svg) - splash svg logo diff --git a/files/README.txt b/files/README.txt index 32f00ca..60daf0f 100644 --- a/files/README.txt +++ b/files/README.txt @@ -4,7 +4,10 @@ + 80_user_env.txt - user uboot env + boot.dhcp.cmd - uboot script boot rescue system from DHCP+TFTP + boot.sd.cmd - uboot script boot rescue system from SD ++ boot.sd.make - update boot.sd.scr from boot.sd.cmd source + boot.spi.cmd - uboot script boot rescue system from spi flash -+ boot_detect.cmd - #define BOOT_DEVICE_RESERVED 0 ++ boot_detect.cmd - boot source detection example ++ boot_hook.c - #!script ++ boot_hook.cmd - #!script + splash.bmp.gz.make - smart svg -> bmp rgb565 gz converter + splash.svg - splash svg logo diff --git a/files/boot.sd.cmd b/files/boot.sd.cmd index 9d03284..256a24f 100644 --- a/files/boot.sd.cmd +++ b/files/boot.sd.cmd @@ -7,21 +7,7 @@ LOADER="fatload mmc 0" -BOOT_FROM= - -#define BOOT_DEVICE_RESERVED 0 -#define BOOT_DEVICE_EMMC 1 -#define BOOT_DEVICE_NAND 2 -#define BOOT_DEVICE_SPI 3 -#define BOOT_DEVICE_SD 4 -#define BOOT_DEVICE_USB 5 - -itest.b *ff800240 == 0xf1 && BOOT_FROM=emmc -itest.b *ff800240 == 0xf3 && BOOT_FROM=spi -itest.b *ff800240 == 0xf4 && BOOT_FROM=sd -itest.b *ff800240 == 0xf5 && BOOT_FROM=usb - -echo "**KRESCUE LOAD FROM $BOOT_FROM**" +echo "**KRESCUE LOAD FROM $BOOTED**" ENV_OFFHEX=0x168000 LOGO_OFFHEX=0x168000 diff --git a/files/boot.sd.make b/files/boot.sd.make new file mode 100755 index 0000000..e52232f --- /dev/null +++ b/files/boot.sd.make @@ -0,0 +1,4 @@ +#!/bin/sh +#= update boot.sd.scr from boot.sd.cmd source +mkimage -C none -A arm -T script -d boot.sd.cmd boot.sd.scr + diff --git a/files/boot_detect.cmd b/files/boot_detect.cmd index 42f1b5a..f0a64b4 100644 --- a/files/boot_detect.cmd +++ b/files/boot_detect.cmd @@ -1,3 +1,5 @@ +# boot source detection example + BOOT_FROM= #define BOOT_DEVICE_RESERVED 0 @@ -7,9 +9,15 @@ BOOT_FROM= #define BOOT_DEVICE_SD 4 #define BOOT_DEVICE_USB 5 +md.b ff800240 1 + itest.b *ff800240 == 0xf1 && BOOT_FROM=emmc itest.b *ff800240 == 0xf3 && BOOT_FROM=spi itest.b *ff800240 == 0xf4 && BOOT_FROM=sd itest.b *ff800240 == 0xf5 && BOOT_FROM=usb +itest.b *ff800240 == 0xb1 && BOOT_FROM=emmc +itest.b *ff800240 == 0xb3 && BOOT_FROM=spi +itest.b *ff800240 == 0xb4 && BOOT_FROM=sd +itest.b *ff800240 == 0xb5 && BOOT_FROM=usb echo "**KRESCUE LOAD FROM $BOOT_FROM**" diff --git a/files/boot_hook.c b/files/boot_hook.c new file mode 100755 index 0000000..7f63156 --- /dev/null +++ b/files/boot_hook.c @@ -0,0 +1,22 @@ +/* +#!script + +# boot_hook for rescue boot if file /rescue/boot.sd.scr will be finded on SD card +# add this into uboot -> board_later_init // run_command_list(THIS_SCRIPT_STRINGS,-1,0); + +# plz dont use local vars on this stage +*/ +run_command_list("\n\ +setenv SCRIPT_ADDR 0x50000000\n\ +setenv BOOT_HOOK /rescue/boot.sd.scr\n\ +setenv POST_HOOK \"script $SCRIPT_ADDR || autoscr $SCRIPT_ADDR; sleep 1\"\n\ +if fatload mmc 0 $SCRIPT_ADDR $BOOT_HOOK; then\n + setenv bootcmd $POST_HOOK\n\ + exit 0\n\ +fi\n\ +if ext4load mmc 0 $SCRIPT_ADDR $BOOT_HOOK; then\n\ + setenv bootcmd $POST_HOOK\n\ + exit 0\n\ +fi\n" +,-1,0); + diff --git a/files/boot_hook.cmd b/files/boot_hook.cmd new file mode 100755 index 0000000..d224bd6 --- /dev/null +++ b/files/boot_hook.cmd @@ -0,0 +1,18 @@ +#!script + +# boot_hook for rescue boot if file /rescue/boot.sd.scr will be finded on SD card +# add this into uboot -> board_later_init // run_command_list(THIS_SCRIPT_STRINGS,-1,0); + +# plz dont use local vars on this stage +setenv SCRIPT_ADDR 0x50000000 +setenv BOOT_HOOK /rescue/boot.sd.scr +setenv POST_HOOK "script $SCRIPT_ADDR || autoscr $SCRIPT_ADDR; sleep 1" + +if fatload mmc 0 $SCRIPT_ADDR $BOOT_HOOK; then + setenv bootcmd $POST_HOOK + exit 0 +fi +if ext4load mmc 0 $SCRIPT_ADDR $BOOT_HOOK; then + setenv bootcmd $POST_HOOK + exit 0 +fi diff --git a/scripts/prepare_sd_image_rescue b/scripts/prepare_sd_image_rescue index fb04e6f..f89901b 100755 --- a/scripts/prepare_sd_image_rescue +++ b/scripts/prepare_sd_image_rescue @@ -77,6 +77,8 @@ CMD cp ../share/uI* $D$RESCUE CMD cp ../share/linux.dtb $D$RESCUE/uboot.dtb CMD cp ../share/splash.bmp.gz $D$RESCUE CMD cp ../files/boot.sd.cmd $D$RESCUE +CMD cp ../files/boot.sd.make $D$RESCUE +CMD mkimage -C none -A arm -T script -d $D$RESCUE/boot.sd.cmd $D$RESCUE/boot.sd.scr CMD cp ../files/80_user_env.txt $D$RESCUE ls -l1 $D/* | tee $D$RESCUE/files.list