Skip to main content
LCris.1
Associate III
March 30, 2022
Question

What is the routine used by STM32Programmer when I click on read button?

  • March 30, 2022
  • 4 replies
  • 1790 views

Hi,

I created one external loader to write and erase one NOR FLASH and works well (STM32H7A3 with S29GL512S11).

When I try to access the memory in my application code the memory returns 0xFFFF every time. When I try to read the memory the first time when external loader is loaded to microcontroller, I read the same values. But if I click second time in Read button the STM32Programmer read the memory correctly.

My question is, what are the commands sent to microcontroller when Read Button is clicked? In my custom external loader I don't have any function to read, and the read task is executed by STM32Programmer and works fine.

Best regards,

Luis Cristóvão

This topic has been closed for replies.

4 replies

Tesla DeLorean
Guru
March 30, 2022

It generally expects the Init() function to memory-map the QSPI/OCTOSPI device into the 0x90000000 address space, and then the debug interface reads that directly.​

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
LCris.1
LCris.1Author
Associate III
March 30, 2022

Thanks for your fast reply,

First of all I don't use QSPI or OCTOSPI, because my memory don't use it. When i try to read the memory address 0x60000000 (my first bank address FMC) is returned 0xFFFF. When I read the device ID and other this with commands works fine, only doesn't work when I try to access directly to address. My thought is, have any configuration sent by STM32Programmer before read all memory address?

Best regards,

Luis Cristóvão

Tesla DeLorean
Guru
March 30, 2022

It should call Init() to setup clocks​, peripheral, pins and memory.

SPI_FLASH class devices would need a Read() function.

I've seen STM32 Cube Programmer fumble the first round read of memory, the app is buggy and poorly tested.

Set Verbose logging to 3, make sure ​it calls Init()

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
LCris.1
LCris.1Author
Associate III
March 30, 2022

Sorry, but i don't use any SPI_FLASH device in my custom board. I use one NOR FLASH connected to FMC Bank 1 and PSRAM connected to FMC Bank 2. The PSARM I can read and write and all works fine. Only the NOR FLASH I can't read the correct values.

I use this code to read:

 uint16_t verify[3]={0};
 
 verify[0]=*(__IO uint16_t *)(NOR_MEMORY_ADRESS1);
 verify[1]=*(__IO uint16_t *)(NOR_MEMORY_ADRESS1+2);
 verify[2]=*(__IO uint16_t *)(NOR_MEMORY_ADRESS1+4);

Tesla DeLorean
Guru
March 30, 2022

Fine, but using the "SPI_FLASH" class in the loader structures lets you dictate how the memory is accessed via the Read/Write API, it could be QSPI, FMC, SPI, NAND, eMMC or whatever, the programmer software doesn't touch the memory device directly.

Is your complaint that your application side code isn't reading the NOR FLASH properly, but the External Loader is? If that's the case your initialization code isn't right, and you'll need to review the clocks, timing, pins, etc

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
LCris.1
LCris.1Author
Associate III
March 30, 2022

Ok, but I can read without problems the internal registers of the memory like CommandSet, DeviceID, Size, Manufacture, etc. How and where I can add SPI_FLASH for dictate how the memory is accessed via the Read/Write API?

Thanks for help I'm very noob in this mater of external memories.

LCris.1
LCris.1Author
Associate III
March 30, 2022

On debug after all configurations I try to see the sections of memory that controller have and I read this:

>info mem
Using memory regions provided by the target.
Num Enb Low Addr High Addr Attrs 
0 y 	0x00000000 0x08000000 rw nocache 
1 y 	0x08000000 0x08080000 flash blocksize 0x2000 nocache 
2 y 	0x08080000 0x100000000 rw nocache 

Is it possible the STM32Programmer when I try to read the memory by the button declare a new section and that way I can read the memory?

In my linker file only have

/* Specify the memory areas */
MEMORY
{
DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
RAM (xrw) : ORIGIN = 0x24000000, LENGTH = 1024K
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
FLASH1 (rx) : ORIGIN = 0x8000000, LENGTH = 512K
FLASH2 (rx) : ORIGIN = 0x8100000, LENGTH = 512K
NOR1 (xrw) : ORIGIN = 0x60000000, LENGTH = 64M
SRAM (xrw) : ORIGIN = 0x64000000, LENGTH = 4M
}