Skip to main content
Dejan Nedeljkovic
Associate III
August 5, 2019
Question

Programming external QSPI flash on a custom Board

  • August 5, 2019
  • 6 replies
  • 3925 views

Hello

I'm working with a custom board based on a STM32F767IIT MCU with the framework touchGFX. The external flash is MT25QL512ABB8ESF.

Is there any solution to load the external flash with st-link utility or another tool?

Do I have to write an external loader for st-link? If so how can this be done?

Regards

Dejan

This topic has been closed for replies.

6 replies

hansd56
Senior
August 5, 2019

Download STM32CubeProgrammer. It has some external loaders.

0690X00000983vhQAA.jpg

Dejan Nedeljkovic
Associate III
August 5, 2019

Hi @hansd56​ 

The external loaders in STM32CubeProgrammer are only for the specific ST boards.

I have already tried some loader in this tool and didn't get it working.

I think my board is only working with a customized loader.

Regards

Dejan

hansd56
Senior
August 5, 2019

Not sure if you can get the source code for the external loader.

https://mvdlande.wordpress.com/2015/10/14/building-an-custom-external-loader-for-st-link/

cameronf
Associate
August 5, 2019

If you plan on eventually writing a custom bootloader for this board you could prioritize that and use that as your primary way of flashing the external FLASH. That's what I've done in the past because I wasn't sure what options there were for custom external loaders and if it was feasible to make one with minimal effort.

Tesla DeLorean
Guru
August 5, 2019

I would definitely agree that you should write the flashing methods for your own loader first, in a way that you can thoroughly test and debug them. Whether they take data via serial/X-MODEM, or pull a file from an SD Card, having these working first will save a lot of time.

The External Loaders require a level of familiarity with the compiler, and linker, along with object files and methods used by loaders. The loaders here are very similar in construction to those used by Keil, so review/analysis of those is recommended.

Figure 1-day or 1-week of effort to write one, depending on experience.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Dejan Nedeljkovic
Associate III
August 12, 2019

Hi @Community member​ ​ 

Do you know if there are some manuals or application notes for external loaders?

I am still struggling to get it working.

Andreas Bolsch
Lead III
August 5, 2019

If you don't want to write your own loader for STLink tool, you might give openocd with this patch http://openocd.zylin.com/4321 a try. The configuration for a particular board/chip is quite simple, more or less setting up the GPIOs for the proper alternate functions. Example setups for various discovery boards are included.

I would suggest using an STLink-V3, with 24 MHz SWD-clock programming up to 1 MByte/s is possible.

Dejan Nedeljkovic
Associate III
August 14, 2019

Hi @Andreas Bolsch​ 

Do you have any example or suggestion how to set up an external flash on a stm32f767II with openocd?

Andreas Bolsch
Lead III
August 14, 2019

It *IS* supported. You need a recent version of openocd (master) and the patch indicated. Configuration files e. g. for STM32F769I-Disco (single flash) and Nucleo-F767ZI (dual flash mode) are included in the patchset. I'd suggest to start with the disco configuration file (if you use single flash mode) and adjust the GPIO setup according to your board. For the GPIO setup there's also a helper script (contrib/gpio_conf_stm32.pl), but for just one setup it's faster to do it manually, I guess.

The MT25QL512 should be auto-detected and use 4-byte addressing commands automatically. If you comment out the lines

   # 4-line qpi mode

   mww 0xA0001014 0x00003135            ;# QUADSPI_CCR: FMODE=0x3, DMODE=0x1, DCYC=0x0, ADSIZE=0x3, ADMODE=0x1, IMODE=0x1, INSTR=READ

   # 4-line memory-mapped read mode with 4-byte addresses

   mww 0xA0001014 0x0F003F13            ;# QUADSPI_CCR: FMODE=0x3, DMODE=0x1, DCYC=0x0, ADSIZE=0x3, ADMODE=0x1, IMODE=0x1, INSTR=READ

one-line mode will be used, that's better to start with.

After starting openocd with -f <config_file> you need to issue 'reset init' to setup the QSPI, then 'flash probe $a' should identify the flash chip. If succesful, you can flash the whole image (internal+external flash) by 'flash write_image'.

Dejan Nedeljkovic
Associate III
August 6, 2019

Thanks for all your responses.

I have tried to modify N25Q512A_STM32F769I-EVAL loader in Atollic TrueStudio. The build was successful and I renamed the .elf file to .stldr and copied it to the bin folder of ST Link-Utility and Cube Programmer. Both Tools are not displaying the modified external loader.

I have followed the instructions of UM2237 and the readme file of N25Q512A_STM32F769I-EVAL loader.

Has someone a hint for me?

Regards

Dejan

eng23
Senior
August 6, 2019

Hello,

How did you import N25Q512A_STM32F769I-EVAL to TrueStudio?

I've followed the readme copying to BSP folders but I couldn't get a compile project, it imports as file and not as a project.

@par How to use it ?

 - Place the folder "N25Q512A_STM32F769I-EVAL" under the following path inside the STM32F7 Cube firmware package   "STM32Cube_FW_F7_Vx.y.z" folder:

  STM32Cube_FW_F7_Vx.y.z\Projects\STM32F769I-EVAL\Examples\QSPI

 - Open your preferred toolchain

 - Rebuild all files and load your image into target memory

 - After build, the loader should be displayed in the external loaders window, ready-to-use

I've tried in TrueStudio, SW4STM32 and CubeIDE with same result.

Thanks.

Dejan Nedeljkovic
Associate III
August 6, 2019

Hi @eng23​ 

I've opened the .project file. Then created a folder "Loader" in the project and linked the c-files (as shown in the screenshot).

I got it compiling but it didn't work with the ST Link-Utility and Cube Programmer.

The ST Cube Programmer shows that it couldn't load the external loader.

0690X000009887mQAA.png