cancel
Showing results for 
Search instead for 
Did you mean: 

Access External W25Q32 as internal memory

Joshin Joy
Associate

Hai Friends,

I have a application with small 320x240 ILI9341 TFT. I have interfaced it with STM32F103C8 with my custom Board with a Winbond W25Q32 4MB Memory. Every thing is good I made a library for ILI9341. Display is working good. I store lots of images in W25Q32 and is accessed it using the SPI2. I am using STMCubeIDE with CubeMX.

I would like to know is there a way to program the W25Q32 also with STlink when programming the controller. so I could write image array in include files and don't worry about programing the flash memory separately.

Why I asked this because in my previous project using TouchGFX I have seen in the build analazer of cubeide there where a extflash section.

Please can someone explain how this done and how I can go with it.

Thankyou

3 REPLIES 3
Andreas Bolsch
Lead II

CubeIDE uses OpenOCD internally, hence you could build a version including the patch at http://openocd.zylin.com/#/c/4760/

and replace the original version. There is a sample config file 'cmspi_nucleo-f103rb.cfg' included in the patchset.

Joshin Joy
Associate

It seems interesting. but i not getting a starting point. can you explain little more. how to do it?

your help is appreciated.

Thank you

Andreas Bolsch
Lead II

Suppose NCS, CLK, IO1/MISO, IO0/MOSI (note order!) are on pins PA06, PB01, PC03, PC04 respectively. Executing the perl script "contrib/cmspi_gpio/gpio_conf_stm32.pl" (comes with the patch) like:

('-t' for STM32F1 family, '0x40000000' GPIO base address, 'PP' push-pull, 'INUP' input with pull-up, 'H', 'M' for high and medium speed)

./contrib/cmspi_gpio/gpio_conf_stm32.pl -t -b 0x40000000 -c "PA06:PP:M,PB01:PP:H,PC03:INUP:H,PC04:INUP:H"

prints

       0x3FC 0x4000000C 6 0x4000040C 1 \

       0x4000080C 3 0x3F4 0x3F4 0x0000B000 0x4000080C 4 0x3F4 0x3F4 0x000B0000

       # PA06:PP:M, PB01:PP:H, PC04:INUP:H, PC03:INUP:H

       # Port A: PA06:PP:M

       mmw 0x40000000 0x01000000 0x0E000000   ;# CRL

       # Port B: PB01:PP:H

       mmw 0x40000400 0x00000010 0x000000E0   ;# CRL

       # Port C: PC04:INUP:H, PC03:INUP:H

       mmw 0x40000800 0x00044000 0x000BB000   ;# CRL

       mmw 0x4000080C 0x00000018 0x00000000   ;# ODR/PUPDR

The first two lines are used to setup the flash bank and to tell the driver about the pins like (note the backslashes at line end!):

# W25Q32

set a [llength [flash list]]

flash bank $_CHIPNAME.w25q32 cmspi 0x90000000 0 0 0 $_TARGETNAME \

       0x3FC 0x4000000C 6 0x4000040C 1 \

       0x4000080C 3 0x3F4 0x3F4 0x0000B000 0x4000080C 4 0x3F4 0x3F4 0x000B0000

The base address 0x90000000 is somewhat arbitrary, of course it shouldn't conflict with anything else. When you build your binary, the contents

of the external flash must be located there, but at runtime it has no meaning at all.

The remaining part does the GPIO setup for the individual pins, this goes into the proc cmspi_init, which is called upon target initalization.

Enabling the clocks for the GPIO ports and reasonable clock setup for the CPU is a different matter. Therefore, I'd suggest you take the

file 'cmspi_nucleo-f103rb.cfg', rename it and replace the parts for the W25Q256 ... FM25V02 with the respective parts (above) for your flash device.

Place it where it is searched for by openocd, some subdir of /opt/st/stm32cubeide_1.3.0/plugins/com.st.stm32cube.ide.mcu.debug.openocd_1.3.0.202002181050/resources/openocd/st_scripts

and make sure this config file is used (can't tell you how to do this in CubeIDE, but there is certainly a menu where you can select the config file for your board). If this doesn't work out for you, the last resort would be to append the contents (except the beginning up to 'source ...') into target/stm32f1x.cfg

(not nice, but ST integrated OpenOCD's configs in a rather strange way ...).

The last part is somewhat obscure, I'm afraid. That's because OpenOCD is hidden inside CubeIDE, with a stand-alone version it would be more obvious.