This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/BEAGLEBK: Enable u-boot bootcount

Part Number: BEAGLEBK

Tool/software: Linux

Hi,

I have a question about how to enable the u-boot bootcount so that it will boot from altbootcmd if the bootcount exceeds bootlimit. The following is what I did:

1. Enable CONFIG_BOOTCOUNT in u-boot configuration.
2. Define CONFIG_BOOTCOUNT_LIMIT in the board configuration header.

3. Add bootlimit and upgrade_available in CONFIG_EXTRA_ENV_SETTINGS.

After doing these, u-boot behavior is not quite what I expect. Here are my questions:

1. My understanding is only when upgrade_available is 1, bootcount will increase after a system reboot (without power cycle the board). However, I saw bootcount increases when upgrade_available is set to 0. Is this expected? If not, what did I miss?

2. I have environment variables stored in uboot.env on a eMMC FAT partition (1:1). However, I see different bootcount values when I do "printenv" in u-boot and "fw_printenv" in user space. Also, bootcount is reset back to 1 after a power cycle (not rebooting) of the system. Maybe the bootcound is not stored in the eMMC? What I may have missed?

Please help. Thank you.

  • Hello Matt,

    Matt Tsai52 said:
    1. Enable CONFIG_BOOTCOUNT in u-boot configuration.
    2. Define CONFIG_BOOTCOUNT_LIMIT in the board configuration header.

    You do not want to enable these. By default you have the CONFIG_BOOTCOUNT_AM33XX macro defined in <Processor SDK>/board-support/u-boot-<version>/include/configs/am335x_evm.h which enables the bootcount driver for RTC IP block. This driver writes the bootcount to RTC_SCRATCH2_REG register. You can read that register with => md.b 0x44e3e068 from U-Boot and root@am335x-evm:~# devmem2 0x44e3e068 w from Linux.


    Matt Tsai52 said:
    1. My understanding is only when upgrade_available is 1, bootcount will increase after a system reboot (without power cycle the board). However, I saw bootcount increases when upgrade_available is set to 0. Is this expected? If not, what did I miss?

    upgrade_available is active only with CONFIG_BOOTCOUNT_ENV, not with CONFIG_BOOTCOUNT_AM33XX or any other.


    Matt Tsai52 said:
    2. I have environment variables stored in uboot.env on a eMMC FAT partition (1:1). However, I see different bootcount values when I do "printenv" in u-boot and "fw_printenv" in user space. Also, bootcount is reset back to 1 after a power cycle (not rebooting) of the system. Maybe the bootcound is not stored in the eMMC? What I may have missed?

    To save the bootcount in U-Boot environment, you need to change the #define CONFIG_BOOTCOUNT_AM33XX to #define CONFIG_BOOTCOUNT_ENV in <Processor SDK>/board-support/u-boot-<version>/include/configs/am335x_evm.h. In his way the bootcount in U-Boot and "fw_printenv" in user space will be the same and bootcount will not reset back to 1 after a power cycle. If you want to save the bootcount to a file on EXT filesystem. Comment out the #define CONFIG_SYS_BOOTCOUNT_ADDR    0x44E3E000 line in <Processor SDK>/board-support/u-boot-<version>/include/configs/ti_am335x_common.h and #define CONFIG_BOOTCOUNT_AM33XX in <Processor SDK>/board-support/u-boot-<version>/include/configs/am335x_evm.h, run the ARCH=arm make menuconfig and enter these settings in Device Drivers  ---> Boot count support  ---> [*]   Boot counter on EXT filesystem


    Best regards,
    Kemal

  • Hi Kemal,

    Thank you. I had it working with BOOTCOUNT_ENV. Just checking with you, if I choose to use BOOTCOUNT_AM33XX, the altbootmcd still works the same way as using BOOTCOUNT_ENV, with CONFIG_BOOTCOUNT_LIMIT defined. Is this correct?

    Thank you.
  • Yes, altbootmcd works the same way, it just keeps the bootcount in RTC_SCRATCH2_REG register instead of uboot.env.