/* Specify the memory areas */
MEMORY
{
/* APP从300KB开始,且总的APP区域 700KB */
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
m_flash_config (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x000AF000 - 0x00000410
/* 标定参数区域从0x000AF000开始,且总的标定参数区域 64KB */
m_calibration_rom (RX) : ORIGIN = 0x000AF000, LENGTH = 0x00010000
/* SRAM_L */
/* 从SRAM_L区域中划分标定参数区域 */
m_data (RW) : ORIGIN = 0x1FFE0000, LENGTH = 0x00020000 - 0x00010000
m_calibration_ram (RW) : ORIGIN = 0x1FFE0000 + 0x00020000 - 0x00010000, LENGTH = 0x00010000
/* SRAM_U */
m_data_2 (RW) : ORIGIN = 0x20000000, LENGTH = 0x0001F000
}
/* 定义标定参数ROM区 */
.calibration_rom :
{
. = ALIGN(4);
calibration_data_rom_start = .; /* ROM区域起始地址 */
*(.calibration_rom)
calibration_data_rom_end = .; /* ROM区域结束地址 */
. = ALIGN(4);
} > m_calibration_rom
/* 定义标定参数RAM区 */
.calibration :
{
. = ALIGN(4);
calibration_data_ram_start = .; /* RAM区域起始地址 */
*(.calibration)
calibration_data_ram_end = .; /* RAM区域结束地址 */
. = ALIGN(4);
} > m_calibration_ram AT > m_calibration_rom
calibration_data_rom_end = calibration_data_rom_start + (calibration_data_ram_end - calibration_data_ram_start);测试代码
uint32_t test_addr = 0x000AF000;
// S32K148的FLASH_DRV_EraseSector最小擦除扇区大小是 4KB
status = FLASH_DRV_EraseSector(&g_flash_ssd_config, test_addr, 4096);
// 验证擦除
status = FLASH_DRV_VerifySection(&g_flash_ssd_config, test_addr, 4096 / 16, 1u);
uint8_t data[8] = {0x07,0x77,0,0,0,0,0,0};
// S32K148的FLASH_DRV_Program最小可写大小是8B
status = FLASH_DRV_Program(&g_flash_ssd_config, test_addr, 8, data);
// S32K148的FLASH_DRV_ProgramSection最小可写大小是1KB
//flashResult = FLASH_DRV_ProgramSection(&g_flash_ssd_config, CANID_private_addr, 4096 / 16);
uint32_t failAddr = 0;
// 验证写数据
status = FLASH_DRV_ProgramCheck(&g_flash_ssd_config, test_addr, 8, data, &failAddr, 1u);如上,我想通过flash驱动擦除m_calibration_rom(0xAF000)区域,但是无法擦除。同样的擦除函数我可以擦除0xBF000区域(0xAF000 + 0x10000后的地址),请问各位大佬有何解决想法。我使用的MCU是S32K148。
Hi @wanghaitao,
Can you read the error flags right after the FTFC command is finished (CCIF = 1)?
Regards,
Daniel