u-boot bootcount functionality

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

u-boot bootcount functionality

ソリューションへジャンプ
2,042件の閲覧回数
AB22
Contributor III

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.

0 件の賞賛
返信
1 解決策
2,008件の閲覧回数
Manuel_Salas
NXP TechSupport
NXP TechSupport

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=2
 

I hope this can helps to you.

 

Best regards,

Salas.

 

元の投稿で解決策を見る

0 件の賞賛
返信
4 返答(返信)
2,009件の閲覧回数
Manuel_Salas
NXP TechSupport
NXP TechSupport

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=2
 

I hope this can helps to you.

 

Best regards,

Salas.

 

0 件の賞賛
返信
2,005件の閲覧回数
AB22
Contributor III
Thank you for pointing me to that file. It is quite helpful.
2,023件の閲覧回数
xacov
Contributor I

It should not be a question. 

 

 
 
 
config BOOTCOUNT_ENV
bool "Boot counter in environment"
help
  If no softreset save registers are found on the hardware
  "bootcount" is stored in the environment. To prevent a
  saveenv on all reboots, the environment variable
  "upgrade_available" is used. If "upgrade_available" is
  0, "bootcount" is always 0. If "upgrade_available" is 1,
          "bootcount" is incremented in the environment.
  So the Userspace Application must set the "upgrade_available"
  and "bootcount" variables to 0, if the system booted successfully.

 

0 件の賞賛
返信
2,004件の閲覧回数
AB22
Contributor III
That is quite helpful. I misunderstood the usage of upgrade_available. Thank you.
0 件の賞賛
返信
%3CLINGO-SUB%20id%3D%22lingo-sub-2035853%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Eu-boot%20bootcount%20%E6%A9%9F%E8%83%BD%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2035853%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3Eu-boot%E6%A7%8B%E6%88%90(Yocto%20Scarthgap%20%2F%20i.MX8M%20Plus)%E3%81%AB%E6%AC%A1%E3%81%AE%E5%A4%89%E6%9B%B4%E3%82%92%E5%8A%A0%E3%81%88%E3%81%BE%E3%81%97%E3%81%9F%E3%80%82%3C%2FP%3E%3CP%3ECONFIG_BOOTCOUNT%3Dy%3CBR%20%2F%3ECONFIG_BOOTCOUNT_LIMIT%3Dy%3CBR%20%2F%3ECONFIG_BOOTCOUNT_BOOTLIMIT%3D3%3C%2FP%3E%3CP%3Eu-boot%E3%83%97%E3%83%AD%E3%83%B3%E3%83%97%E3%83%88%E3%81%A7printenv%20bootcount%E3%82%92%E5%AE%9F%E8%A1%8C%E3%81%99%E3%82%8B%E3%81%9F%E3%81%B3%E3%81%AB%E3%80%81%E5%80%A4%E3%81%AF1%E3%81%A7%E3%81%99%E3%80%82%E3%83%96%E3%83%BC%E3%83%88%E3%83%97%E3%83%AD%E3%82%BB%E3%82%B9%E3%81%8C%E7%B9%B0%E3%82%8A%E8%BF%94%E3%81%97%E5%A4%B1%E6%95%97%E3%81%99%E3%82%8B%E5%A0%B4%E5%90%88%E3%81%AB%E3%80%81%E3%83%87%E3%83%A5%E3%82%A2%E3%83%AB%E3%82%B3%E3%83%94%E3%83%BC%E6%9B%B4%E6%96%B0(SWUpdate)%E4%B8%AD%E3%81%AB%E4%BD%9C%E6%A5%AD%E3%83%91%E3%83%BC%E3%83%86%E3%82%A3%E3%82%B7%E3%83%A7%E3%83%B3%E3%81%AB%E3%83%95%E3%82%A9%E3%83%BC%E3%83%AB%E3%83%90%E3%83%83%E3%82%AF%E3%81%99%E3%82%8B%E3%82%BF%E3%82%A4%E3%83%9F%E3%83%B3%E3%82%B0%E3%82%92%E7%A4%BA%E3%81%99%E3%81%9F%E3%82%81%E3%81%AB%E3%80%81bootcount%E6%A9%9F%E8%83%BD%E3%81%8C%E5%BF%85%E8%A6%81%E3%81%A7%E3%81%99%E3%80%82%E3%83%96%E3%83%BC%E3%83%88%E3%82%AB%E3%82%A6%E3%83%B3%E3%83%88%E3%81%8C%E5%A2%97%E5%8A%A0%E3%81%99%E3%82%8B%E3%81%AE%E3%81%AF%E3%81%A9%E3%81%AE%E3%82%88%E3%81%86%E3%81%AA%E6%9D%A1%E4%BB%B6%E3%81%A7%E3%81%99%E3%81%8B%3F%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%81%8C%E7%A0%B4%E6%90%8D%E3%81%97%E3%80%81u-boot%E3%83%97%E3%83%AD%E3%83%B3%E3%83%97%E3%83%88%E3%81%A7%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB%E3%81%8C%E7%99%BA%E7%94%9F%E3%81%99%E3%82%8B%E5%8F%AF%E8%83%BD%E6%80%A7%E3%81%8C%E3%81%82%E3%82%8A%E3%81%BE%E3%81%99%E3%81%8C%E3%80%81%E3%83%95%E3%82%A9%E3%83%BC%E3%83%AB%E3%83%90%E3%83%83%E3%82%AF%E3%82%92%E9%96%8B%E5%A7%8B%E3%81%99%E3%82%8B%E3%83%A1%E3%82%AB%E3%83%8B%E3%82%BA%E3%83%A0%E3%82%92%E6%8F%90%E4%BE%9B%E3%81%97%E3%81%A6%E3%81%84%E3%81%BE%E3%81%9B%E3%82%93%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2035853%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3Ei.MX%208%E3%83%95%E3%82%A1%E3%83%9F%E3%83%AA%20%7C%20i.MX%208QuadMax%E2%80%AF(8QM)%20%7C%208QuadPlus%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EYocto%20Project%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2036228%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20u-boot%20bootcount%20%E6%A9%9F%E8%83%BD%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2036228%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E3%81%9D%E3%82%8C%E3%81%AF%E3%81%A8%E3%81%A6%E3%82%82%E5%8A%A9%E3%81%8B%E3%82%8A%E3%81%BE%E3%81%99%E3%80%82upgrade_available%E3%81%AE%E4%BD%BF%E3%81%84%E6%96%B9%E3%82%92%E5%8B%98%E9%81%95%E3%81%84%E3%81%97%E3%81%A6%E3%81%84%E3%81%BE%E3%81%97%E3%81%9F%E3%80%82%E3%81%82%E3%82%8A%E3%81%8C%E3%81%A8%E3%81%86%E3%81%94%E3%81%96%E3%81%84%E3%81%BE%E3%81%99%E3%80%82%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2036227%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20u-boot%20bootcount%20%E6%A9%9F%E8%83%BD%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2036227%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E3%81%9D%E3%81%AE%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%82%92%E6%8C%87%E3%81%97%E7%A4%BA%E3%81%97%E3%81%A6%E3%81%84%E3%81%9F%E3%81%A0%E3%81%8D%E3%81%82%E3%82%8A%E3%81%8C%E3%81%A8%E3%81%86%E3%81%94%E3%81%96%E3%81%84%E3%81%BE%E3%81%99%E3%80%82%E3%81%9D%E3%82%8C%E3%81%AF%E3%81%8B%E3%81%AA%E3%82%8A%E5%BD%B9%E3%81%AB%E7%AB%8B%E3%81%A1%E3%81%BE%E3%81%99%E3%80%82%3C%2FLINGO-BODY%3E