On 26/04/2016 03:24, Andrew Yong wrote: > "alternatively call uboot-env directly without the fw_* abstraction layer" > > Pardon the obtuse question but how would I go about doing this? It > sounds like the cleanest way to do things. > > I'd like to avoid calling uci-default earlier than it needs to be, and > potentially messing up other things in the init process. > > If there really isn't an OpenWrt-approved way to do this, I may just > advocate replacing SamKnows' u-boot entirely (writing to the same > partition every boot seems bad for flash memory anyway).
replacing uboot is not a good idea. you should try to make this work in the prei8nit step. if the fw_setenv call fails then figure out why and try to fix it. > > On Tue, Apr 26, 2016 at 12:32 AM, John Crispin <[email protected]> wrote: >> >> >> On 25/04/2016 18:01, Andrew Yong wrote: >>> diff --git a/target/linux/ramips/base-files/lib/preinit/04_handle_bootcount >>> b/target/linux/ramips/base-files/lib/preinit/04_handle_bootcount >>> new file mode 100644 >>> index 0000000..570fe16 >>> --- /dev/null >>> +++ b/target/linux/ramips/base-files/lib/preinit/04_handle_bootcount >>> @@ -0,0 +1,22 @@ >>> +#!/bin/sh >>> + >>> +# SamKnows Whitebox 8 increments a bootcount variable every boot and >>> attempts >>> +# to boot a recovery partition when bootcount > 3. We need to ensure this >>> is >>> +# reset to 0 every boot >>> + >>> +do_bootcount_reset() { >>> + . /lib/ramips.sh >>> + >>> + local board=$(ramips_board_name) >>> + >>> + case "$board" in >>> + sk-wb8) >>> + echo "Board is SamKnows Whitebox 8, resetting bootcount >>> environment variable..." >>> + fw_setenv bootcount 0 >>> + ;; >>> + esac >>> + >>> + return 0 >>> +} >>> + >>> +boot_hook_add preinit_main do_bootcount_reset >> >> >> does this actually work ? thinking about it, you might need to have >> uci-default run for it to work properly or alternatively call uboot-env >> directly without the fw_* abstraction layer >> >> John _______________________________________________ openwrt-devel mailing list [email protected] https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
