diff --git a/luckfox-sdk-patches/uboot/patches/0003-flare-ab-slots.patch b/luckfox-sdk-patches/uboot/patches/0003-flare-ab-slots.patch index 4432949..83ecf6e 100644 --- a/luckfox-sdk-patches/uboot/patches/0003-flare-ab-slots.patch +++ b/luckfox-sdk-patches/uboot/patches/0003-flare-ab-slots.patch @@ -142,10 +142,10 @@ index 52cd612d1..a81071566 100644 obj-$(CONFIG_AUTOBOOT) += autoboot.o diff --git a/sysdrv/source/uboot/u-boot/common/flare_ab.c b/sysdrv/source/uboot/u-boot/common/flare_ab.c new file mode 100644 -index 000000000..903f5b66f +index 000000000..2b41ab8ca --- /dev/null +++ b/sysdrv/source/uboot/u-boot/common/flare_ab.c -@@ -0,0 +1,673 @@ +@@ -0,0 +1,709 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * flare-edge A/B slot boot for U-Boot proper. @@ -175,6 +175,9 @@ index 000000000..903f5b66f +#include +#include +#include ++#if defined(CONFIG_DRM_ROCKCHIP) ++#include ++#endif + +/* + * Per-power-session boot-attempt escalation (warehouse deployment). @@ -553,7 +556,12 @@ index 000000000..903f5b66f + return other; + } + -+ printf("FLARE-AB: both committed slots failed this power session, recovery\n"); ++ if (slot_is_bootable(&ab_data.slots[other]) && ++ ab_data.slots[other].successful_boot) ++ printf("FLARE-AB: both committed slots failed this power session, recovery\n"); ++ else ++ printf("FLARE-AB: slot %s failed %d attempts this session, no committed alternative, recovery\n", ++ pref ? "_b" : "_a", FLARE_AB_SLOT_TRIES); + flare_ab_force_recovery = 1; + return pref; +} @@ -731,6 +739,36 @@ index 000000000..903f5b66f + udelay(100000); +} + ++/* ++ * USB download: the terminal state of every failed boot with no slot or ++ * recovery FIT left (decision 2026-11-06, flare-edge#3118 cause 3). ++ * ++ * The sad-face screen is logo_recovery.bmp. rockchip_show_bmp() can fail ++ * (-ENOMEM when the heap cannot hold the decode scratch after the failed FIT ++ * loads), and do_download() ignores that return, so the splash would stay up ++ * with no serial line saying why. The draw is made here and its result is ++ * logged. do_download() paints the same image again as its first step. ++ * ++ * `download` serves rockusb and is not expected to return. If it does (the ++ * USB session ended), the screen is painted again and download is re-entered ++ * after a pause, so the unit stays USB-flashable and never stops silently at ++ * the splash. This function does not return. ++ */ ++static void flare_ab_usb_download(void) ++{ ++ int rc; ++ ++ for (;;) { ++#if defined(CONFIG_DRM_ROCKCHIP) ++ rc = rockchip_show_bmp("logo_recovery.bmp"); ++ printf("FLARE-AB: logo_recovery.bmp shown=%d\n", rc); ++#endif ++ rc = run_command("download", 0); ++ printf("FLARE-AB: download returned %d, re-entering\n", rc); ++ udelay(1000000); ++ } ++} ++ +void flare_ab_boot_failed(void) +{ + if (!flare_ab_enabled()) @@ -747,8 +785,7 @@ index 000000000..903f5b66f + * it over the existing USB port. + */ + printf("FLARE-AB: recovery FIT unbootable, entering USB download\n"); -+ run_command("download", 0); -+ hang(); ++ flare_ab_usb_download(); + } + + /* @@ -771,8 +808,7 @@ index 000000000..903f5b66f + * USB plug, logo_recovery.bmp), where a host can reflash the unit. + */ + printf("FLARE-AB: reset did not take, entering USB download\n"); -+ run_command("download", 0); -+ hang(); ++ flare_ab_usb_download(); +} + +void flare_ab_update_root_partition(void) @@ -872,7 +908,7 @@ index 182c03771..ad73662eb 100644 return -1; diff --git a/sysdrv/source/uboot/u-boot/include/flare_ab.h b/sysdrv/source/uboot/u-boot/include/flare_ab.h new file mode 100644 -index 000000000..d009525e0 +index 000000000..6e51b405e --- /dev/null +++ b/sysdrv/source/uboot/u-boot/include/flare_ab.h @@ -0,0 +1,73 @@