Skip to content

Latest commit

 

History

History

4_TouchGFX_mapping

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Piu' sotto, al termine della lingua inglese trovi il testo in italiano. _
Below the English text you'll find the Italian version



4) "How to" setup a TouchGFX project mapping an external flash memory

Setup a TouchGFX project (following https://github.com/maudeve-it/ILI9XXX-XPT2046-STM32)
then:

  • on CubeMX:
      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)
          in External data reader: Memory size
            indicate the size of the external flash memory
          other parameters
            leave unchanged
      generate "c" code.
  • on CubeIDE:
      in include folder, copy file:
        z_flash_W25QXXX.h
      in src folder, copy file:
        z_flash_W25QXXX.c
      in root folder, copy files:
        Program_linker_include.txt
      Edit file main.h:
        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
        
        ...
  • on TouchGFX Designer:

      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:




      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



    • 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
        copy here the external loader you previously made following above instructions
    • 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.


      Back to the home page







      "How to" come configurare un progetto TouchGFX mappando una memoria flash esterna

      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)
            in External data reader: Memory size
              indicare la dimensione della memoria flash esterna
            altri parametri
              lasciare come sono
        generare il "codice c".
    • su CubeIDE:
        nella cartella include, copiare il file:
          z_flash_W25QXXX.h
        nella cartella src, copiare il file:
          z_flash_W25QXXX.c
        nella cartella root, copiare i file:
          Program_linker_include.txt
        Modificare il file main.h:
          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 */
            ...

      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
          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
          
          ...
    • 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
        copiare qui l'external loader precedentemente creato seguendo following le istruzioni indicate sopra.
    • 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.



      Torna alla home page