I have made the following modifications to the u-boot configuration (Yocto Scarthgap/i.MX8M Plus):
CONFIG_BOOTCOUNT=y
CONFIG_BOOTCOUNT_LIMIT=y
CONFIG_BOOTCOUNT_BOOTLIMIT=3
Every time I printenv bootcount at the u-boot prompt, the value is 1. I would like for the bootcount functionality to indicate when to fallback to a working partition during dual-copy update (SWUpdate) in the event the boot process repeatedly fails. What conditions cause the bootcount to increment? I can corrupt files and cause a stall at the u-boot prompt but nothing is providing a mechanism to initiate fallback.
已解决! 转到解答。
 Manuel_Salas
		
			Manuel_Salas
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hello @AB22
I hope you are doing very well.
You can see the bootcount_env.c file under uboot-imx/drivers/bootcount.
// SPDX-License-Identifier: GPL-2.0+
/*
 * (C) Copyright 2013
 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
 */
#include <common.h>
#include <env.h>
void bootcount_store(ulong a)
{
	int upgrade_available = env_get_ulong("upgrade_available", 10, 0);
	if (upgrade_available) {
		env_set_ulong("bootcount", a);
		env_save();
	}
}
ulong bootcount_load(void)
{
	int upgrade_available = env_get_ulong("upgrade_available", 10, 0);
	ulong val = 0;
	if (upgrade_available)
		val = env_get_ulong("bootcount", 10, 0);
	return val;
}You need to set the environment variable called upgrade_available on your U-boot.
u-boot=> setenv upgrade_available 1
After reset:
u-boot=> printenv bootcount
bootcount=2I hope this can helps to you.
Best regards,
Salas.
 Manuel_Salas
		
			Manuel_Salas
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hello @AB22
I hope you are doing very well.
You can see the bootcount_env.c file under uboot-imx/drivers/bootcount.
// SPDX-License-Identifier: GPL-2.0+
/*
 * (C) Copyright 2013
 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
 */
#include <common.h>
#include <env.h>
void bootcount_store(ulong a)
{
	int upgrade_available = env_get_ulong("upgrade_available", 10, 0);
	if (upgrade_available) {
		env_set_ulong("bootcount", a);
		env_save();
	}
}
ulong bootcount_load(void)
{
	int upgrade_available = env_get_ulong("upgrade_available", 10, 0);
	ulong val = 0;
	if (upgrade_available)
		val = env_get_ulong("bootcount", 10, 0);
	return val;
}You need to set the environment variable called upgrade_available on your U-boot.
u-boot=> setenv upgrade_available 1
After reset:
u-boot=> printenv bootcount
bootcount=2I hope this can helps to you.
Best regards,
Salas.
It should not be a question.
