2024-02-28 03:25 PM - edited 2024-02-28 03:31 PM
Im attempting to set up A/B partitioning on an STM32MP157d-dk1 board so that it can switch between partitions when updating. The board image is built using yocto, and I have used the meta-st-stm32mp layer, and am building a modified version of core-image-full-cmdline for the image.
I have set up fw_setenv and fw_printenv using the following fw_env.config file:
# Configuration file for fw_(printenv/setenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
# Notice, that the "Number of sectors" is not required on NOR and SPI-dataflash.
# Futhermore, if the Flash sector size is omitted, this value is assumed to
# be the same as the Environment size, which is valid for NOR and SPI-dataflash
# Device offset must be prefixed with 0x to be parsed as a hexadecimal value.
# On a block device a negative offset is treated as a backwards offset from the
# end of the device/partition, rather than a forwards offset from the start.
# Block device example
/dev/mmcblk0p3 -0x2000 0x2000
/dev/mmcblk0p3 -0x4000 0x2000
This gives me access to the u-boot environment, and I can modify the bootlimit and upgrade_available variables without issue. However, bootcount is always overwritten on a reboot with its old value incremented by one, and it is incremented regardless of whether upgrade_available is set.
I have enabled bootcount in the uboot settings and have CONFIG_BOOTCOUNT_GENERIC=y set in the defconfig.
I am guessing one of two things is happening:
The bootcount variable is being altered by some other script within the image, in which case I will need some way to find what is modifying it
Or
The bootcount variable is stored elsewhere and is applied to the uboot environment on boot, in which case I need to find this location.
I have checked the U-boot configuration and found the following options for the U-boot environment:
CONFIG_ENV_OFFSET=0x480000
CONFIG_ENV_SECT_SIZE=0x40000
CONFIG_ENV_OFFSET_REDUND=0x4C0000
CONFIG_ENV_IS_NOWHERE=y
CONFIG_ENV_IS_IN_MMC=y
CONFIG_ENV_IS_IN_SPI_FLASH=y
CONFIG_ENV_IS_IN_UBI=y
CONFIG_ENV_UBI_PART="UBI"
CONFIG_ENV_UBI_VOLUME="uboot_config"
CONFIG_ENV_UBI_VOLUME_REDUND="uboot_config_r"
I am not sure how to interpret this to find where the uboot environment is, especially since the fw_env.config file above works for all variables except bootcount.
Solved! Go to Solution.
2024-02-29 02:39 PM
Setting CONFIG_BOOTCOUNT_ENV=y and CONFIG_BOOTCOUNT_LIMIT=y in the u-boot configuration before building fixes the problem. It also seems like upgrade_available is only used when CONFIG_BOOTCOUNT_ENV is set.
2024-02-29 05:33 AM
Hi @ndziura
not expert, but from BootROM/HW perspective, there is this information
https://wiki.st.com/stm32mpu/wiki/STM32MP15_backup_registers#BOOT_COUNTER
from uBoot perspective
Regards.
2024-02-29 02:39 PM
Setting CONFIG_BOOTCOUNT_ENV=y and CONFIG_BOOTCOUNT_LIMIT=y in the u-boot configuration before building fixes the problem. It also seems like upgrade_available is only used when CONFIG_BOOTCOUNT_ENV is set.