flash-memory

Write on a mtd block device

岁酱吖の 提交于 2019-12-02 17:45:38
I'm trying to write on a NAND flash memory using MTD block device but I don't understand everything. As I read here mtdblockN is the read only block device N mtdN is the read/write char device N mtdNro is the read only char device N But I'd like to directly write bytes to the partition using a simple write in C and I don't understand how it works (I read somewhre that I first must erase the sectors I want to write on). Which device should I use and how to write on this device? Reading and writing from/to memory technology devices isn't really all that different than any other type of IO, with

STM32F4 Discovery - Writing / Reading Flash memory

烈酒焚心 提交于 2019-12-02 03:04:46
This is my first post here, sorry if format or something is wrong. I succeed writing and reading flash memory of the STM32F4 Discovery following the advises of our colleges here and here (both posts explain the same way): __attribute__((__section__(".user_data"))) const char userConfig[64]; [...] void Write_Flash(uint8_t data) { HAL_FLASH_Unlock(); __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGSERR ); FLASH_Erase_Sector(FLASH_SECTOR_6, VOLTAGE_RANGE_3); HAL_FLASH_Program(TYPEPROGRAM_WORD, &userConfig[0], data); HAL_FLASH_Lock();

Circular Buffer in Flash

做~自己de王妃 提交于 2019-11-30 14:02:12
I need to store items of varying length in a circular queue in a flash chip. Each item will have its encapsulation so I can figure out how big it is and where the next item begins. When there are enough items in the buffer, it will wrap to the beginning. What is a good way to store a circular queue in a flash chip? There is a possibility of tens of thousands of items I would like to store. So starting at the beginning and reading to the end of the buffer is not ideal because it will take time to search to the end. Also, because it is circular, I need to be able to distinguish the first item

Allocating memory in Flash for user data (STM32F4 HAL)

有些话、适合烂在心里 提交于 2019-11-27 18:52:57
I'm trying to use the internal flash of an STM32F405 to store a bunch of user settable bytes that remain after rebooting. I'm using: uint8_t userConfig[64] __attribute__((at(0x0800C000))); to allocate memory for the data I want to store. When the program starts, I check to see if the first byte is set to 0x42 , if not, i set it using: HAL_FLASH_Unlock(); HAL_FLASH_Program(TYPEPROGRAM_BYTE, &userConfig[0], 0x42); HAL_FLASH_Lock(); After that I check the value in userConfig[0] and I see 0x42 ... Great! When I hit reset, however, and look at the location again, it's not 0x42 anymore... Any idea