flash sharing of bootloader and app

I open up a flash shared space in app and bootloader, write values from app, bootloader read, bootloader read values such as 0xFFFFF, and not ideal values, may I ask why this is.

Based on the background of this problem, I want to customize the protocol OTA without any verification. I have correctly transferred the firmware data to bank1 through flash, and I want to modify s_dfu_setting myself to make the bootloader know that the firmware is valid and can be updated.

Parents
  • Sorry, I always fail to set breakpoints in the bootloader. I plan not to modify any code in the bootloader. This article devzone.nordicsemi.com/.../dfu-approach-from-cloud-to-esp32-to-nrf52840 explains the cloud to nrf52840 DFU approach. The original value of nrf_dfu_settings_t that I read from flash in the application is 0. After writing some values to flash, they are read correctly. However, settings_crc_ok cannot verify the CRC (i.e., the result of settings_crc_ok is 0). The value read from address 0xFF000 through nrfjprog also does not match what I wrote. I wonder why.

  • What does the settings page contain after programming the application and bootloader and resetting the device?

    Reading settings page with nrfjprog

    nrfjprog --memrd 0xFF000 --n 256

    name said:
    . However, settings_crc_ok cannot verify the CRC (i.e., the result of settings_crc_ok is 0). The value read from address 0xFF000 through nrfjprog also does not match what I wrote. I wonder why.

    Do you use the settings module to write to the settings page? This will automatically compute a new crc when you write something to it. Also, what values are you trying to change? Remember that there are several of the struct elements which the app is not permitted to change. Doing so will cause the bootloader to restore the original settings from the backup page at 0xFE000

    1. Yes, I use nrfjprog --memrd 0xFF000 to read data.
      This is the new content of the settings page I wrote. I did not use the settings module to write the settings page content, because I found that using the settings module requires adding some settings module library files in the bootloader. During the adding process, I encountered some difficulties (reporting undefined), so I wrote directly through flash. As for settings_crc_ok, it is rewritten in the application with reference to the bootloader.
      I checked the relevant background DFU examples, and the application has a settings page module. To add the settings page module, do I need to add some macros in the sdk.config of the application?
      In addition, the project originally used FDS, which involves initializing fstorage when upgrading the firmware. I don’t know if this is the reason
Reply
    1. Yes, I use nrfjprog --memrd 0xFF000 to read data.
      This is the new content of the settings page I wrote. I did not use the settings module to write the settings page content, because I found that using the settings module requires adding some settings module library files in the bootloader. During the adding process, I encountered some difficulties (reporting undefined), so I wrote directly through flash. As for settings_crc_ok, it is rewritten in the application with reference to the bootloader.
      I checked the relevant background DFU examples, and the application has a settings page module. To add the settings page module, do I need to add some macros in the sdk.config of the application?
      In addition, the project originally used FDS, which involves initializing fstorage when upgrading the firmware. I don’t know if this is the reason
Children
  • First you need to "memcpy" the original settings page to your write buffer, then you can change the struct members which the app is allowed to change. The app is *not* allowed to update .bank_0 and .bank_1, see the picture I posted earlier. You also need to update the CRC to match the new settings. You can use the settings module as a reference if you don't want to use this module in your app.

  • 我明白了,我又看了你之前的记录,结合后台的DFU例子,我理解的是在应用程序中往bank1写入bin文件数据,每次通过flash写入的时候更新setting里的进度就可以了吗?但是下面这些内容的更新我不太明白
    1. firmware_image_offset 能不能是我每次往bank1写入的固件数据的大小?
    2. command_size,command_offset,command_crc,data_object_size 能不能不更新,因为我好像不需要这些命令。

    正如你之前回答中所说,settings 会自动计算 CRC。如果我直接通过 flash 更新上面的 stttings 内容,它也会自动计算 CRC 吗?还是只有在使用 settings 模块时才会自动计算?

Related