We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Problem Code:
/* main.c */ uint8_t testBuf[] = {1, 2, 3, 4, 5}, FILE * fwr = fopen("tst1.txt", "w"); fwrite(testBuf, sizeof(uint8_t), sizeof(testBuf), fwr); fflush(fwr); fclose(fwr); /* flash_cmsis_driver.c */ int32_t ARM_Flash_ProgramData(uint32_t addr, const void *data, uint32_t cnt) { /* Problem: cnt is 8 while it should be 5 */ /* cnt is next nearest multiple of 4 */ }
/* Driver Capabilities */ static const ARM_FLASH_CAPABILITIES DriverCapabilities = { 1, /* Supports event ready status */ 0, /* data_width = 0:8-bit, 1:16-bit, 2:32-bit */ 0, /* Don't support chip erase */ 0U /* Reserved */ }; /* Flash Information */ static ARM_FLASH_INFO FlashInfo = { FLASH_SECTOR_INFO, FLASH_SECTOR_COUNT, FLASH_SECTOR_SIZE, 8, /* FLASH_PAGE_SIZE */ 1, /*FLASH_PROGRAM_UNIT */ 0xFF, /* FLASH_ERASED_VALUE */ { 0U, 0U, 0U } /* Reserved */ };
Thanks for the answers Vladimir, I will accept your answer after reply to the following.As you said, I do acknowledge that it is preferable to write in large chunks considering the overhead of 8-bytes/allocation record.To summarise and confirm the answer:
Is that right?
Yes, this is correct for EFS.And just to clarify to avoid potential confusion for future readers: "Smallest programmable unit" configuration is part of CMSIS-Driver Flash (see ARM_FLASH_INFO) and should therefore be correctly handled in the Flash driver.