Skip to content

Latest commit

 

History

History

2_ExternalLoader

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



2) Creating a low-RAM-demanding EXTERNAL LOADER for STM32CubeProgrammer and STM32CubeIDE

External Loader is a plug-in for STM32CubeProgrammer/CubeIDE allowing to read/write an external memory through an STM32 uC.
Following the below instruction you can create an External Loader for a W25Q connected to a QuadSPI, adding it then to CubeProgrammer and CubeIDE.

"How to" create an External Loader for a specific project:

    After defining the CubeMX configuration details of your project with a flash memory via QuadSPI (e.g., having already set the QuadSPI mode and other details for managing the flash memory)

  • Create a new project in CubeIDE.
    Give the project a name with this format:
    "external flash used"_"uC or board name"_"oprional: other info, if any, - e.g. QSPI port, mode, bank, etc."
    (having character "_" dividing the three fields, must non be used elsewhere)
    Here some examples for a valid project name:
      W25Q80_STM32F411_QSPI-BANK1
      W25Q80_WEACT-H750 (third field is optional and here it is not used)
      etc.
  • in CubeMX:
    • setup the QuadSPI port for your flash memory, as per youe project.
      Warning:
      I always recommend to setup the External Loader with a low QuadSPI port speed (e.g. lower than 2Mbit/s)

    • enable CRC (you just need to set "Activated" checkbox)
    • If on your board, you have available a led connected to a uC pin (GPIO_Output): you can use it in the External Loader. Useful for troubleshooting.
      give the uC led pin the name: LED.
    • in "Project Manager"->"Code Generator", mark "Generate peripheral initialization as a pair of '.c/.h' files per peripheral" to have peripheral initializing files separated by main.c
    • generate "c" code.
  • in CubeIDE:
    • in include folder, copy files:
        z_qflash_W25QXXX.h
        Dev_Inf.h
    • in src folder, copy files:
        z_qflash_W25QXXX.c
        Dev_Inf.c
        Loader_Src.c
    • in root folder, copy files:
        EL_linker.ld
        Post-Build command.txt
    • Setup "z_qflash_W25QXXX.h"
        registering flash chip characteristics (see above the setup of "z_flash_W25QXXX.h" Step 1 to 4)
    • Setup Loader_Src.c:
        follow inside file: Step1, Step2, Step3
    • Setup Dev_Inf.c:
        update first struct field assigning a name to the External Loader: copy here the project name
        update third struct field indicating address where external flash is mapped
        leave unchanged other fields.
    • open file "Post-Build command.txt"
        copy the text row and paste it into the field in
        project->properties->C/C++ Build->settings->Build Steps->Post-Build Steps->Command
        click "Apply and Close"
    • edit EL_linker.ld
      • set the memory origin and size as per uC available RAM:
        around line 30 you find text:
        (EL_linker.ld)
        ...
        RAM_LOADER (xrw)      : ORIGIN = 0x20000004, LENGTH = 8M-4
        ...

        change value "0x20000004" to "0x24000004" if using an H7 uC
        change value "8M" after "LENGTH =" indicating the uC RAM size (refer to the current active .ld file for correct information about the RAM configuration of your uC)
      • save changes
      • in project->properties->C/C++ Build->settings->Tool Setting->MCU GCC Linker->General->linker script:
          1 change the name of the .ld file into "EL_linker.ld". Parameter should become: ${workspace_loc:/${ProjName}/EL_linker.ld}
          2 click "Apply and Close"

PLEASE NOTE:
This is a "compact" version of EL: you don't need to unmark flag Discard Unused Sections in Project->Properties as indicated in my youtube video "Part One".
Characteristics and needs of this library are described in "Part Two".


Now "Compile" project: If everithing goes fine you'll find the file project_name.stldr into the project root folder

THIS IS THE EXTERNAL LOADER

"How to" add External Loader to STM32CubeProgrammer

  • Go to the STM32CubeProgrammer program folder
    (right-click the program icon and choose "open file location")
  • once in the STM32CubeProgrammer program folder go into "ExternalLoader" subfolder
  • copy here the External Loader created (.stldr file)

    Opening STM32CubeProgrammer program you can select the new External Loader to access the external flash memory.

"How to" add External Loader to STM32CubeIDE

  • Go to the STM32Cubeide program folder
    (right-click the program icon and choose "open file location")
  • once in the STM32CubeProgrammer program folder go subfolder: ./plugins/xxxxxx.externaltools.cubeprogrammer.xxxxx/tools/bin/ExternalLoader
  • copy here the External Loader created (.stldr file)

    Now the External Loader is available to CubeIDE and can be selected in "Run/Debug Settings":
    in CubeIDE, go to Project->Properties->Run/Debug Settings
    select the launch configuration 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







creare un EXTERNAL LOADER a basso utilizzo di RAM per STM32CubeProgrammer e STM32CubeIDE

External Loader e' un plug-in per STM32CubeProgrammer per leggere e/o programmare un chip di memoria gestito attraverso da un uC STM32.
Attraverso la libreria di funzioni indicata sopra e' possibile creare un external loader per un progetto STM32 che ha una memoria QuadSPI Flash Winbond esterna .
Lo stesso plugin puo' essere utilizzato in STM32CubeIDE per programmare la memoria Flash direttamente durante la creazione di un progetto: CubeIDE usa i moduli CubeProgrammer per programmare la memoria flash interna od esterna del uC.

"How to" come creare an External Loader relativo ad un progetto:

    Dopo aver definito i dettagli di configurazione CubeMX del tuo progetto con una memoria flash via QuadSPI (ad esempio avendo già definito il QuadSPI mode, e gli altri dettagli necessari per la gestione della memoria Flash

  • Crea un nuovo progetto in CubeIDE.
    Assegna al progetto un nome con questa forma:
    "external flash in uso"_"nome uC o board in uso"_"eventuali altre informazioni - es. Porta QuadSPI, mode, bank, ecc."
    (il carattere "_" separa i tre campi e non deve essere utilizzato nel nome se non per questa separazione)
    Esempi di nomi di progetto protrebbero essere:
      W25Q80_STM32H750_QSPI-BANK1
      W25Q80_WEACT-H750 (il terzo campo è opzionale e qui non c'e')
      ecc.
  • in CubeMX:
    • configura una porta QuadSPI per la memoria flash, seguendo il tuo progetto
      Attenzione:
      E' sempre consigliabile configurare una velocià ridotta in un External Loader (es. inferiore a 2Mbit/s)

    • abilita CRC (devi solo spuntare "Activated")
    • Se hai un led a disposizione sulla scheda, puoi usarlo nell'External Loader (utile nel troubleshooting)
      dai al pin del led il nome: LED
    • in "Project Manager"->"Code Generator", spunta "Generate peripheral initialization as a pair of '.c/.h' files per peripheral" per avere i file di inizializzazione separati da main.c
    • genera il codice.
  • in CubeIDE:
    • copiare in include folder
        z_qflash_W25QXXX.h
        Dev_Inf.h
    • copiare in src folder
        z_qflash_W25QXXX.c
        Dev_Inf.c
        Loader_Src.c
    • copiare in root folder
        EL_linker.ld
        Post-Build command.txt
    • definire i parametri in "z_qflash_W25QXXX.h"
        definire le caratteristiche della memoria (vedi piu' sopra la configurazione di "z_qflash_W25QXXX.h" da Step 1 a 4)
    • configurare Loader_Src.c:
        seguire gli step di configurazione: Step1, Step2, Step3
    • configurare Dev_Inf.c:
        aggiorna il primo campo della struct assegnando il nome all'External Loader: deve essere "rif alla flash" _ "rif alla board" _ "altre info (es versione)" (copiare il nome del progetto)
        aggiorna il terzo campo della struct indicando l'indirizzo su cui e' mappata la flash
        non modificare gli altri campi
    • aprire il file "Post-Build command.txt"
        copiare il contenuto e incollarlo nel campo in
        project->properties->C/C++ Build->settings->Build Steps->Post-Build Steps->Command
        scegliere "Apply and Close"
    • modificare EL_linker.ld
      • modificare origine e dimensione della memoria indicando la RAM disponibile sul uC:
        attorno alla riga 30 trovi il testo:
        (EL_linker.ld)
        ...
        RAM_LOADER (xrw)      : ORIGIN = 0x20000004, LENGTH = 8M-4
        ...

        cambia il valore "0x20000004" in "0x24000004" se il uC in uso è un H7
        modifica il valore "8M" dopo "LENGTH =" specificando la dimensione della RAM (fai riferimento al file .ld attualmente attivo per la corretta informazione sulla configurazione RAM del uC in uso)
      • salvare il tutto
      • in project->properties->C/C++ Build->settings->Tool Setting->MCU GCC Linker->General->linker script:
          1 cambiare il nome del file .ld in "EL_linker.ld": dovrebbe essere: ${workspace_loc:/${ProjName}/EL_linker.ld}
          2 cliccare "Apply and Close"

NOTA BENE:
Non hai bisogno di deselezionare il flag Discard Unused Sections in Project->Properties, come indicato nel mio video "Prima Parte".
Le caratteristiche e le necessità di questa libreria sono descritte in "Seconda Parte"
.


"Compila" il progetto: se tutto e' andato bene trovi il file "nomeprogetto".stldr nella cartella di root

Questo e' l'external loader

"How to": come aggiungere un External Loader a STM32CubeProgrammer

  • Andare nel folder del programma STM32CubeProgrammer
    (ad esempio click-destro del mouse sull'icona del programma e scegliere "Apri percorso file")
  • raggiunta la cartella di STM32CubeProgrammer, scegliere la cartella "ExternalLoader"
  • copiare qui il file .stldr creato

    Aprendo STM32CubeProgrammer si puo' selezionare il nuovo External Loader per accedere alla memoria Flash esterna

"How to" add External Loader to STM32CubeIDE

  • Andare nel folder del programma STM32CubeIDE
    (ad esempio click-destro del mouse sull'icona del programma e scegliere "Apri percorso file")
  • Raggiunta la cartella di STM32CubeIDE, andare nella sottocartella: ./plugins/xxxxxx.externaltools.cubeprogrammer.xxxxx/tools/bin/ExternalLoader
  • Copiare qui il file .stldr creato

    Ora l'External Loader è disponibile in CubeIDE e puo' essere selezionato in "Run/Debug Settings":
    in CubeIDE andare in: Project->Properties->Run/Debug Settings
    selezionare il file di configurazione run e 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