Yeah I think that wants a RW filesystem, haha. My apologies in advance to all other ramips devices, then, I’ll add an init.d script for ./target/linux/ramips/base-files/etc/init.d/S99bootcount to do this.
On Tue, Apr 26, 2016 at 2:35 PM, John Crispin <blo...@openwrt.org> wrote: > ok, this might not work, just move it to the init.d folder > > > On 26/04/2016 08:31, Andrew Yong wrote: >> Alright. >> >> Is it acceptable to call `. /lib/functions/uci-defaults.sh` in a preinit >> file? >> >> If it does not violate the sanctity of any OpenWrt init conventions, >> I’ll do that and test drive it. >> >> On Tue, Apr 26, 2016 at 2:06 PM, John Crispin <j...@phrozen.org> wrote: >>> >>> >>> 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 <j...@phrozen.org> 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 >> openwrt-devel@lists.openwrt.org >> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel >> > _______________________________________________ > openwrt-devel mailing list > openwrt-devel@lists.openwrt.org > https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel