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.
工具与软件:
我们发现 IN-SDK mcuboot 端口有多个错误、尤其是我们在 mcuboot_config.h 中定义#define MCUBOOT_SWAP_USE_MOVE 1以启用插槽交换(无 A/B 乒乓开关)时。
错误:
1. assert()问题
在示例文件中(实际上针对每个项目): mspm0_sdk_2_02_00_05/examples/nortos/LP_MSPM0G3507/boot_manager/boot_application/flash_map_backend/flash_map_backend.c
#define assert(x)
不符合传统的要求 . 通常、如果 x 不为零、则它应继续执行。
此外、我看到以下源代码中有混合用途、例如:
/* check if read is within bounds */ assert((write_start_addr + len) > (fa->fa_off + fa->fa_size)) /* check that the start address is aligned properly TODO: remove*/ assert((write_start_addr % 4) == 0) /* check that the length written is in 32 bits */ assert((len % 4) == 0)
第一个满足你当地的期望,但第二个和第三个不。
2.未对齐的访问
相同的文件,在函数 FLASH_ARIA_WRITE()中
DL_FlashCTL_programMemoryBlocking ()期望 uint32_t *作为输入数据指针。 但是,我追溯了 FLASH_area_write ()的所有引用。
大多数调用方函数 将本地缓冲区定义为 uint_8数组。 除非使用 __attribute__((aligned (sizeof (uint32_t)))、否则不能保证地址对齐为4。
可能只有 boot_WRITE_enc_key()才能摆脱它、因为结构成员偏移量满足4字节对齐。
解决方案:如果要保持效率、请更改所有调用方函数、以使用属性确保它们对齐为4、或定义为 uint32。 否则、不需要假设地址为4对齐。
此外、SDK 的建议:
您能否使用原型更改所有请求数据输入只读访问的功能 常量 ?
例如、
bool DL_FlashCTL_programMemoryBlocking(FLASHCTL_Regs *flashctl, uint32_t address, uint32_t *data, uint32_t dataSize, DL_FLASHCTL_REGION_SELECT regionSelect)
使用 const uint32_t *数据是更适合的声明。 这会避免用户强制将指针从只读(RO)转换为 RW。 因为从本质上讲、某些指针来自闪存本身。
这将强制执行"最小特权"经验法则。
您好、Tiger、
感谢您的通知。 我将创建与此相关的 JIRA。
此致、
Diego Abad