Piu' sotto, al termine della lingua inglese trovi il testo in italiano. _
Below the English text you'll find the Italian version
Setup a TouchGFX project (following https://github.com/maudeve-it/ILI9XXX-XPT2046-STM32)
then:
-
on TouchGFX package:
-
enable "External Data Reader"
-
in External data reader: Memory base address
-
set the memory base address (leave 0x90000000 if no specific needs t ochange it)
-
indicate the size of the external flash memory
-
leave unchanged
-
in include folder, copy file:
-
z_flash_W25QXXX.h
-
z_flash_W25QXXX.c
-
Program_linker_include.txt
-
open it
modify /* USER CODE BEGIN Includes */ segment, adding the flash library include, this way:
(main.h)
...
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
...
#include "z_flash_W25QXXX.h"
...
/* USER CODE END Includes */
...
-
Edit the linker script (xxxxxxxx_FLASH.ld file):
-
Open the linker script file and open also Program_linker_include.txt.
From this last file copy the row indicating flash size and address (starting with "SPI_FLASH...").
In the linker script, in the "Memories definition" area, paste the copied row, obtaining something like this:
(xxxxxxFLASH.ld)
...
/* Memories definition */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K
SPI_FLASH (r) : ORIGIN = 0x90000000, LENGTH = 1M
}
...
Do not modify RAM configuration,FLASH one or anyother memory area defined and handled by CubeMX
Change "LENGTH" field of SPI_FLASH indicating the size of flash memory you are using
"ORIGIN" field of SPI_FLASH must be the same value registred in CubeMX TouchGFX configuration
From Program_linker_include.txt file copy rows of the ExtFlashSection
(Program_linker_include.txt)
...
ExtFlashSection :
{
*(ExtFlashSection ExtFlashSection.*)
*(-gnu-linkonce.r.*)
. = ALIGN(0x100);
} >SPI_FLASH
...
and paste them at the beginning of the SECTIONS area of the linker script. This way:
(xxxxxxFLASH.ld)
...
/* Sections */
SECTIONS
{
ExtFlashSection :
{
*(ExtFlashSection ExtFlashSection.*)
*(-gnu-linkonce.r.*)
. = ALIGN(0x100);
} >SPI_FLASH
...
This will allow to move selected images to the external flash memory.
If you want/need to move also fonts to the external memory copy also the FontFlashSection from Program_linker_include.txt and paste into linker file this way:
(xxxxxxFLASH.ld)
...
/* Sections */
SECTIONS
{
ExtFlashSection :
{
*(ExtFlashSection ExtFlashSection.*)
*(-gnu-linkonce.r.*)
. = ALIGN(0x100);
} >SPI_FLASH
FontFlashSection :
{
*(FontFlashSection FontFlashSection.*)
*(.gnu.linkonce.r.*)
. = ALIGN(0x4);
} >SPI_FLASH
...
-
From now on, when you are in TouchGFX Designer, you can move single pictures to the external flash assigning them to the ExtFlashSection:
- add the external loader to CubeIDE
-
Go to the STM32CubeIDE program folder
(right-click the program icon and choose "open file location")
once in the STM32CubeIDE program folder go to:-
plugins folder
xxxxxx.externaltools.cubeprogrammer.xxxxx folder
tools folder
bin folder
ExternalLoader folder
- configure CubeIDE to use the external loader
-
in CubeIDE go to Project->Properties->Run/Debug Settings
select the settings file and click "Edit"
go to "Debugger"
scroll to "External Loaders" and click "Add"
select, in the external loader list, the external loader to use.
Click "OK" and "Apply" until you close all the "properties" windows open.
Configurare un progetto TouchGFX (segui ad esempio https://github.com/maudeve-it/ILI9XXX-XPT2046-STM32)
poi: - in CubeMX:
-
nel pacchetto TouchGFX:
-
abilitare "External Data Reader"
-
in External data reader: Memory base address
-
impostare l'indirizzo dove mappare la memoria (lasciare 0x90000000 se non si anno specifiche esigenze diverse)
-
indicare la dimensione della memoria flash esterna
-
lasciare come sono
- su CubeIDE:
-
nella cartella include, copiare il file:
-
z_flash_W25QXXX.h
-
z_flash_W25QXXX.c
-
Program_linker_include.txt
-
aprirlo
modificare il segmento /* USER CODE BEGIN Includes */, aggiungendo la "include" per la libreria flash:
(main.h) ... /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ ... #include "z_flash_W25QXXX.h" ... /* USER CODE END Includes */ ...
- aprire lo script per il linker e aprire anche Program_linker_include.txt
- da questo ultimo file copiare la riga che indica la misura e l'indirizzo della memoria flash (inizia con "SPI_FLASH...")
- nello script linker, nell'area "Memories definition", incolla la riga copiata, ottenendo una struttura come questa:
(xxxxxxFLASH.ld) ... /* Memories definition */ MEMORY { RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K SPI_FLASH (r) : ORIGIN = 0x90000000, LENGTH = 1M } ...
Non modificare la configurazione RAM, FLASH, o qualunque altra riga si trovi qui: definita e gestita da CubeMX.
Modificare il campo "LENGTH" di SPI_FLASH indicando la dimensione della memoria flash in uso.
Il campo "ORIGIN" di SPI_FLASH deve avere lo stesso valore registrato nella configurazione TouchGFX in CubeMX.
Dal file Program_linker_include.txt copia le righe relative a ExtFlashSection.(Program_linker_include.txt) ... ExtFlashSection : { *(ExtFlashSection ExtFlashSection.*) *(-gnu-linkonce.r.*) . = ALIGN(0x100); } >SPI_FLASH ...
ed incollale all'inizio dell'area SECTIONS dello script linker. In questo modo:
(xxxxxxFLASH.ld) ... /* Sections */ SECTIONS { ExtFlashSection : { *(ExtFlashSection ExtFlashSection.*) *(-gnu-linkonce.r.*) . = ALIGN(0x100); } >SPI_FLASH ...
-
questo permette di spostare immagini selezionate verso la memoria flash esterna.
Volendo/dovendo spostrare anche i fontverso la memoria flash esterna, copia anche la sezione FontFlashSection da Program_linker_include.txt ed incollala nello script linker in questo modo:
(xxxxxxFLASH.ld) ... /* Sections */ SECTIONS { ExtFlashSection : { *(ExtFlashSection ExtFlashSection.*) *(-gnu-linkonce.r.*) . = ALIGN(0x100); } >SPI_FLASH FontFlashSection : { *(FontFlashSection FontFlashSection.*) *(.gnu.linkonce.r.*) . = ALIGN(0x4); } >SPI_FLASH ...
- aprire lo script per il linker e aprire anche Program_linker_include.txt
- on TouchGFX Designer:
-
A questo punto, in TouchGFX Designer, e' possibile spostare singole immagini verso la memoria flash esterna assegnandole a ExtFlashSection:
Volendo usare la memoria flash esterna come supporto "di default" per archiviare le immagini, impostare il suo valore in Default Image Configuration:
Se si spostano i font sulla memoria flash esterna OCCORRE SEMPRE impostare i font come "unmapped" in configurazione di TouchGFX Designer:
ATTENZIONE La memoria SPI flash esterna is MOLTO più lenta che la flash interna al uC.
Tenere in considerazione di spostare sulla flash esterna solo ciò che occorre veramente a causa dei limiti della flash interna al uC.
- aggiungere l'external loader a CubeIDE
-
andare alla cartella del programma to the STM32CubeIDE
(tasto destro del mouse sull'icona del programma e scegli "Apri percorso file")
raggiunta la cartella del programma STM32CubeIDEandare in:-
cartella plugins
cartella xxxxxx.externaltools.cubeprogrammer.xxxxx
cartella tools
cartella bin
cartella ExternalLoader
- Configurare CubeIDE per usare l'external loader:
-
in CubeIDE andare in: Project->Properties->Run/Debug Settings
cliccare "Edit"
selezionare "Debugger"
sorrere la pagina fino a "External Loaders" e cliccare "Add"
selezionare, nella lista degli external loader, il modulo da usare.
cliccare "OK" and "Apply" chidendo la finestra "Properties" aperta.

If you want use external flash as the default storage for pictures set it into the Default Image Configuration:

If you move fonts over the external flash memory, you ALWAYS MUST set fonts as "unmapped" in TouchGFX Designer configuration:

WARNING External SPI flash memory is MUCH slower than uC internal flash.
Consider to move to the flash what you really need due to the limit of the uC internal flash