[英]STM32F4 read memory flash per pages
How can I read flash memory per page? 如何读取每页的闪存? I have not been able to read it by sector.
我无法按部门阅读。
I have to read 2 memory sectors (2*16kbytes). 我必须读取2个内存扇区(2 * 16kbytes)。
I am under FreeRtos and I am using STM32F401RE. 我在FreeRtos下,正在使用STM32F401RE。
I am using pointer, I just need to read two sectors of memory flash. 我正在使用指针,我只需要读取闪存的两个扇区。
uint32_t data_store0[4096] = {0};
uint32_t data_store1[4096] = {0};
uint32_t *words0 = (uint32_t *) BASE_ADDR_SECTOR_0;
uint32_t *words1 = (uint32_t *) BASE_ADDR_SECTOR_1;
unsigned int buffer_firmware[8192] = {0};
unsigned char firmware[32768] = {0};
int k, m, i, j = 0;
int count_time = 0;
for(int i=0; i<4096; i++)
{
data_store0[i] += words0[i];
buffer_firmware[i] = data_store0[i];
}
for(int j=0; j<4096; j++)
{
data_store1[j] += words1[j];
}
for(m = 0, k = 4096; k < 8192 && m < 4096; m++, k++)
{
buffer_firmware[k] = data_store1[m];
}
SHA256Input(&ctx, (const uint8_t *) buffer_firmware, 8192);
First of all, you must use volatile keyword while accessing memory map, furthermore, while reading the two page if you accept it is 4096 bytes, then have to use uint8_t because it has 4096 bytes. 首先,在访问内存映射时,必须使用volatile关键字;此外,如果您接受两个页面,则在读取两个页面时必须使用volatile关键字,这是4096字节,然后必须使用uint8_t,因为它具有4096字节。 However, you want to access it a uint32_t pointer then the max value of for loop must be 4096/4 since it has 4096/4 words.
但是,您要访问它的uint32_t指针,则for循环的最大值必须为4096/4,因为它具有4096/4个字。
uint8_t buffer_firmware[4096]
uint8_t *words0 = (volatile uint8_t *) BASE_ADDR_SECTOR_0;
uint8_t *words1 = (volatile uint8_t *) BASE_ADDR_SECTOR_1;
for(uint16_t i=0; i<4096; i++){
buffer_firmware[i] = words0[i];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.