Skip to main content
ranran
Senior
Mar 11, 2019 9:02 AM UTC
Solved

Isn't external NOR Flash memory mapped in write too ?

Hello,

I tried to access external nor flash in stm32h743 eval board.

After configuring it I can view the memory in debugger (IAR).

But it fails when trying to access it from debugger memory view (0x60000000) - after erasing the sector.

I see that the HAL API for accessing the NOR flash HAL_NOR_Program is setting the address in HAL driver:

 /* Send program data command */
 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST), NOR_CMD_DATA_FIRST);
 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SECOND), NOR_CMD_DATA_SECOND);
 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_THIRD), NOR_CMD_DATA_PROGRAM);

Probably these address setting can explains why trying to access it like a regular memory in write - does not work.

Is it correct that flash NOR is not memory mapped in write ?

Thanks

This topic has been closed for replies.
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
Mar 11, 2019 12:12 PM UTC

Writing to the NOR requires magic sequences like those used by HAL_NOR_Program, you can't just write variables or memcpy​() into it.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..

5 replies

Tesla DeLorean
Guru
Mar 11, 2019 10:55 AM UTC

You can't read/execute from it concurrently with write/erase as the device returns status information rather than data.​

​

The mapping for read/write should be identical, but caching and buffering should not be used.​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
ranran
ranranAuthor
Senior
Mar 11, 2019 11:52 AM UTC

Hi,

I don;t try to do it concurrently., I just tried to write.

writing directly (as if it is a memory mapped device) does not work. Only writing using the HAL API for nor works.

I just mentioned that reading directly (not concurrently, but in other times) , works just fine.

Thanks

Tesla DeLorean
Guru
Mar 11, 2019 11:57 AM UTC

Ok, but the debugger is​ trying too, and you specifically cite it as being problematic.

I wouldn't recommend single stepping this code with the debugger probing the same memory space.

Pretty confident the state machine in the NOR Flash will malfunction.​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
ranran
ranranAuthor
Senior
Mar 11, 2019 12:02 PM UTC

I also tried to do the writing without debugger. It also does not work. Only if I'll use the HAL function HAL_NOR_Program  then writing does work.

Yet, reading is memory-mapped (not only in debugger).

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
Mar 11, 2019 12:12 PM UTC

Writing to the NOR requires magic sequences like those used by HAL_NOR_Program, you can't just write variables or memcpy​() into it.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..