cancel
Showing results for 
Search instead for 
Did you mean: 

QSPI loader with TrueStudio

patrick visser
Associate

There seems to be a problem when trying to program an external flash chip via TrueStudio.

I have created an external loader to program a QSPI chip that is connected to an STM32F469II.

My loader is working via the "STM32 ST-LINK Utility", "STM32CubeProgrammer" and STM32_Programmer_CLI.

When I try to use the loader via TrueStudio I run into the problem that the external memory is not programmed.

I have selected the external loader via the property screen of the debug configuration.

0690X0000089uS6QAI.png

When I try to program the device when the external loader is set I get the following error.

0690X0000089uSBQAY.png

the log message that I get when programming.

STMicroelectronics ST-LINK GDB server. Version 5.1.0
Copyright (c) 2018, STMicroelectronics. All rights reserved.
 
Starting server with the following options:
        Persistent Mode            : Disabled
        LogFile Name               : D:\**************************\st-link_gdbserver_log.txt
        Logging Level              : 31
        Listen Port Number         : 61234
        Status Refresh Delay       : 15s
        Verbose Mode               : Enabled
        SWD Debug                  : Enabled
 
Hardware watchpoint supported by the target 
SWD frequency = 4000 kHz
ST-LINK Firmware version : V3J0S0
Device ID: 0x434
PC: 0x800deb8
ST-LINK device status: HALT_MODE
ST-LINK detects target voltage = 3.34 V
ST-LINK device status: HALT_MODE
Run external memory initializer
ST-LINK device status: RUN_MODE
Failed to initialize external memory!
 
Error in initializing ST-LINK device.
Reason: Unknown. Please check power and cabling to target.

the log file that was created 

[0.000] initConfigParams():  Configuration flags start
[0.001] initConfigParams():  config-file                    ""
[0.001] initConfigParams():  persistent                     false
[0.001] initConfigParams():  log-file                       "D:\**************************\st-link_gdbserver_log.txt"
[0.001] initConfigParams():  log-level                      31
[0.001] initConfigParams():  port-number                    61234
[0.001] initConfigParams():  verbose                        true
[0.001] initConfigParams():  refresh-delay                  15
[0.001] initConfigParams():  verify                         true
[0.001] initConfigParams():  swd                            true
[0.001] initConfigParams():  swo-port                       61234
[0.001] initConfigParams():  cpu-clock                      8000000
[0.001] initConfigParams():  swo-clock-div                  128
[0.001] initConfigParams():  initialize-reset               false
[0.001] initConfigParams():  debuggers                      false
[0.001] initConfigParams():  serial-number                  ""
[0.001] initConfigParams():  apid                           0
[0.001] initConfigParams():  attach                         false
[0.001] initConfigParams():  shared                         false
[0.001] initConfigParams():  erase-all                      false
[0.001] initConfigParams():  memory-map                     ""
[0.001] initConfigParams():  ext-memory-loaders             false
[0.001] initConfigParams():  extload                        "S25FL128S_ECLIPSECONTROL.stldr"
[0.001] initConfigParams():  stm32cubeprogrammer-path       "C:\Program Files (x86)\Atollic\TrueSTUDIO for STM32 9.3.0\Servers\STM32CubeProgrammer\bin"
[0.001] initConfigParams():  temp-path                      ""
[0.001] initConfigParams():  preserve-temps                 false
[0.001] initConfigParams():  licenses                       false
[0.001] initConfigParams():  ignore-rest                    false
[0.001] initConfigParams():  version                        false
[0.001] initConfigParams():  help                           false
[0.001] initConfigParams():  Configuration flags end
[0.002] init():  STMicroelectronics ST-LINK GDB server. Version 5.1.0
Copyright (c) 2018, STMicroelectronics. All rights reserved.
[0.022] reset_hw_wtchpt_module():  Hardware watchpoint supported by the target 
[0.027] Device_Initialise():  SWD frequency = 4000 kHz
[0.027] Device_Initialise():  ST-LINK Firmware version : V3J0S0
[0.027] Device_Initialise():  Device ID: 0x434
[0.028] Device_Initialise():  PC: 0x800deb8
[0.028] Device_GetStatus():  ST-LINK device status: HALT_MODE
[0.028] Device_Initialise():  ST-LINK detects target voltage = 3.34 V
[0.029] Device_Initialise():  ST-LINK device status: HALT_MODE
[0.029] initExternalMemory():  Found external memory initializer at 0x200037f5
[0.030] initExternalMemory():  Writing external memory initializer seg at 0x20000004 (0 byte)
[0.105] initExternalMemory():  Writing external memory initializer seg at 0x20004348 (0 byte)
[0.108] initExternalMemory():  MSP: 0x200045a0
[0.109] initExternalMemory():  LR: 0x20004410
[0.109] initExternalMemory():  Run external memory initializer
[0.109] Device_GetStatus():  ST-LINK device status: RUN_MODE
[0.109] initExternalMemory():  pc: 0x20004411; ret: 0
[0.210] initExternalMemory():  Restore after external memory initializer
[0.210] initExternalMemory():  Init() failed returned 0x20004411 @ 0x20004411
[0.213] initExternalMemory():  r0           0x20004411
[0.213] initExternalMemory():  r1           0x20004411
[0.213] initExternalMemory():  r2           0x20004411
[0.213] initExternalMemory():  r3           0x20004411
[0.213] initExternalMemory():  r4           0x20004411
[0.213] initExternalMemory():  r5           0x20004411
[0.213] initExternalMemory():  r6           0x20004411
[0.213] initExternalMemory():  r7           0x20004411
[0.213] initExternalMemory():  r8           0x20004411
[0.213] initExternalMemory():  r9           0x20004411
[0.213] initExternalMemory():  r10          0x20004411
[0.213] initExternalMemory():  r11          0x20004411
[0.213] initExternalMemory():  r12          0x20004411
[0.213] initExternalMemory():  sp           0x20004411
[0.213] initExternalMemory():  lr           0x20004411
[0.213] initExternalMemory():  pc           0x20004411
[0.213] initExternalMemory():  xpsr         0x20004411
[0.213] initExternalMemory():  PRIMASK      0x0
[0.213] initExternalMemory():  BASEPRI      0x0
[0.213] initExternalMemory():  FAULTMASK    0x0
[0.213] initExternalMemory():  CONTROL      0x20004411
[0.213] initExternalMemory():  MSP          0x20004411
[0.213] initExternalMemory():  PSP          0x20004411
[0.214] initExternalMemory():  Stack 0x20004411 <sp+0>:  0xbe
[0.215] initExternalMemory():  Stack 0x20004415 <sp+4>:  0x1000000
[0.215] initExternalMemory():  Stack 0x20004419 <sp+8>:  0x6040302
[0.216] initExternalMemory():  Stack 0x2000441d <sp+12>: 0x90807
[0.216] initExternalMemory():  Stack 0x20004421 <sp+16>: 0x1000000
[0.217] initExternalMemory():  Stack 0x20004425 <sp+20>: 0x69040302
[0.218] initExternalMemory():  Stack 0x20004429 <sp+24>: 0xd74696e
[0.218] initExternalMemory():  Stack 0x2000442d <sp+28>: 0xd00000a
[0.219] initExternalMemory():  Stack 0x20004431 <sp+32>: 0x6174530a
[0.220] initExternalMemory():  Stack 0x20004435 <sp+36>: 0x20737574
[0.221] initExternalMemory():  Stack 0x20004439 <sp+40>: 0xd00203a
[0.221] initExternalMemory():  Stack 0x2000443d <sp+44>: 0x6e6f63
[0.223] Device_Initialise():  Failed to initialize external memory!
[0.223] initServerContext():  
Error in initializing ST-LINK device.
Reason: [0.223] initServerContext():  Unknown. Please check power and cabling to target.

When I do the programming via the commandline programmer tool I get the following :

C:\Program Files (x86)\Atollic\TrueSTUDIO for STM32 9.3.0\Servers\STM32CubeProgrammer\bin>STM32_Programmer_CLI.exe -c port=SWD -el d:\********\S25FL128S_ECLIPSECONTROL.stldr  -d d:\********\EclipseControl.hex
      -------------------------------------------------------------------
                       STM32CubeProgrammer v1.3.0
      -------------------------------------------------------------------
 
ST-LINK SN  : 003B00483137510A39383538
ST-LINK FW  : V3J1M1B1S1
Voltage     : 3.34V
SWD freq    : 24000 KHz
Connect mode: Normal
Reset mode  : Software reset
Device ID   : 0x434
Device name : STM32F469xx/F467xx
Device type : MCU
Device CPU  : Cortex-M4
 
 
 
Memory Programming ...
Opening and parsing file: d:\********\EclipseControl.hex
  File          : d:\********\EclipseControl.hex
  Size          : 329504 Bytes
  Address       : 0x08000000
 
 
Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 6]
Erasing memory corresponding to segment 1:
Erasing external memory sector 0
Download in Progress:
██████████████████████████████████████████████████ 100%
 
File download complete
Time elapsed during download operation: 00:00:08.002

When using the commandline programmer the external memory will be erased and programmed.

9 REPLIES 9
eng23
Senior

Hi @patrick visser​ ,

Did you find a solution for this?

I'm using S25FL128S too and I can't put in QUAD SPI mode. The memory works well in single mode, but in quad doesn't.

I can't write Configuration Register 1(CR1) bit 1 (QUAD) to put in quad mode.

Could you describe your memory setup code?

Regards.

Anderson

Consider not reconfiguring the core clocks in the External Loader, it might confuse the settings applied by GDB Server

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

In fact I'm not in External Loader, but in QSPI initialization.

With Micron N25Q128A in 746DISCO it is ok, but in my custom board this new part I have adapted the commands and registers that differs but when I try QUADSPI readings I always get 0x88.

Make sure you're actually using the right commands for the chip, bytes for addressing, and alternate/dummy cycles, etc.

Have you tested all those in command mode? ie SPI, SPI(Command)/QUAD(Data), QUAD modes?

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

Hi,

Now I can read the memory properly with Fast Read Command and Read Quad Out command.

I can use Read Quad Out, but what I could verify is that with Read Quad Out command I can set only up to 13MHz, if I increase more than this I always get the first bit from each nible setted, like this:

If I should read 0x01 (00000001b) I read 0x89 (10001001b), so always this bit is set with higher frequencies.

The Fast Read command works in 100MHz properly, so I don't think it could be a layout problem.

I tried to change Latency Code bits and dummy cycles according to datasheet, but without success.

0690X000009Z86KQAS.png

The strange thing is for Freq up to 50MHz the LC bits and dummy cycles don't change, so it should work at least up to 50MHz, but I could reach only 13 MHZ.

It is working with memory mapped mode well, but in 13MHz with big images the transition gets slow..

I'm using 0xEB on some Adesto FLASH parts on a F756 @ 100 MHz

You might want to review the timing/clock/phase settings on the QSPI Init side, and look to back-off the slew rates on the GPIO Init side

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

Hi,

I could get the 0xEB command working better, but the first bit set remains as a problem.

Please verify the info below:

This is written in 0x00000000 address in external flash (I read with fast read command that is working properly):

0690X000009ZZrwQAG.png

Below is what I've read with this parameters:

  /* Initialize the read command */
  s_command.InstructionMode   = QSPI_INSTRUCTION_1_LINE;
  s_command.Instruction       = QUAD_INOUT_FAST_READ_CMD; /*0xEB */
  s_command.AddressMode       = QSPI_ADDRESS_4_LINES;
  s_command.AddressSize       = QSPI_ADDRESS_24_BITS;
  s_command.Address           = ReadAddr;
 
  s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_4_LINES;
  s_command.AlternateBytesSize = QSPI_ALTERNATE_BYTES_8_BITS;
  s_command.AlternateBytes	   = 2;
 
  s_command.DataMode          = QSPI_DATA_4_LINES;
  s_command.DummyCycles       = N25Q128A_DUMMY_CYCLES_READ_QUAD; /* 1 */
  s_command.NbData            = Size;
  s_command.DdrMode           = QSPI_DDR_MODE_DISABLE;
  s_command.DdrHoldHalfCycle  = QSPI_DDR_HHC_ANALOG_DELAY;
  s_command.SIOOMode          = QSPI_SIOO_INST_EVERY_CMD;

And I got this:

0690X000009ZZt4QAG.png

But the physical signals don't represent this values, for example the first bit set in all data bytes doesn't appear in the signals, only in the code. Could it be a driver problem?

0690X000009ZZtxQAG.png

Regards

And did you get the device switched to QUAD mode? Correct pin and AF associations?

What does HAL_QSPI_Init() look like?

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

Yes, I set QUAD Mode Bit from device and Cube and Hal functions should be ok.

Well now I could get worked with 100MHz, but with different values than datasheet shows...

I needed to set LC = 11 | Mode = 2 | Dummy cycles = 1

Unfortunately according to datasheet's table above the values are others, but now works..

I can't believe that datasheet is wrong, but with different values it works..