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 (0x90000000)
-
indicate the size of the external flash memory
-
leave unchanged
-
in include folder, copy file:
-
z_qflash_W25QXXX.h
-
z_qflash_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_qflash_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
QSPI_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 QSPI_FLASH indicating the size of flash memory you are using.
"ORIGIN" field of QSPI_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);
} >QSPI_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);
} >QSPI_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);
} >QSPI_FLASH
FontFlashSection :
{
*(FontFlashSection FontFlashSection.*)
*(.gnu.linkonce.r.*)
. = ALIGN(0x4);
} >QSPI_FLASH
...
-
From now on, when you are in TouchGFX Designer, you can move single pictures to the external flash assigning them to the ExtFlashSection:
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:
-
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
-
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:
-
nel pacchetto TouchGFX:
-
abilitare "External Data Reader"
-
in External data reader: Memory base address
-
impostare l'indirizzo dove mappare la memoria (0x90000000)
-
indicare la dimensione della memoria flash esterna
-
lasciare come sono
-
nella cartella include, copiare il file:
-
z_qflash_W25QXXX.h
-
z_qflash_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_qflash_W25QXXX.h"
...
/* USER CODE END Includes */
...
-
Editare lo script per il linker (file ):
-
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
QSPI_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 QSPI_FLASH indicando la dimensione della memoria flash in uso.
Il campo "ORIGIN" di QSPI_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);
} >QSPI_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);
} >QSPI_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);
} >QSPI_FLASH
FontFlashSection :
{
*(FontFlashSection FontFlashSection.*)
*(.gnu.linkonce.r.*)
. = ALIGN(0x4);
} >QSPI_FLASH
...
-
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:
-
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
-
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.