cancel
Showing results for 
Search instead for 
Did you mean: 

How to run parts of the program from external QSPI

I would to use the cheap STM32F750N8-DISCO evaluation board to run a ETH/I2C/SPI/IR/encoder/touch-screen application but the 64K of flash is very little for my program.

Now my program run a STM32F746G-DISCO with 1Mbit of flash and it use about 450K.

I use also the QSPI N25Q128A to store the static images.

Is possible boot the program from QSPI or move part of the program in QSPI to save flash space ?

For the images I use this following method.

#include <stdint.h>
 
#pragma pack(push, 1)
 
typedef struct Center2_tagBITMAPFILEHEADER {
  uint16_t   bfType;
  uint32_t   bfSize;
  uint16_t   bfReserved1;
  uint16_t   bfReserved2;
  uint32_t   bfOffBits;
} Center2_BITMAPFILEHEADER; // size is 14 bytes
 
typedef struct Center2_tagBITMAPINFOHEADER {
  uint32_t  biSize;
  uint32_t  biWidth;
  uint32_t  biHeight;
  uint16_t  biPlanes;
  uint16_t  biBitCount;
  uint32_t  biCompression;
  uint32_t  biSizeImage;
  uint32_t  biXPelsPerMeter;
  uint32_t  biYPelsPerMeter;
  uint32_t  biClrUsed;
  uint32_t  biClrImportant;
} Center2_BITMAPINFOHEADER; // size is 40 bytes
 
typedef struct Center2_tag_Struct {
  // offset 0, size 14
  Center2_BITMAPFILEHEADER fileHeader;
  // offset 14, size 40
  Center2_BITMAPINFOHEADER infoHeader;
  // offset 54, size 129600 words
  uint16_t data[129600];
} Center2_Struct;
 
#ifndef IMG_NO_DATA
#if defined ( __ICCARM__ )
#pragma location = ".textqspi"
#else
__attribute__((section(".textqspi")))
#endif
 
const Center2_Struct Center2 = {
...
}
 
#else
extern const Center2_Struct Center2;
#endif
 
#pragma pack (pop)

1 ACCEPTED SOLUTION

Accepted Solutions

I don't work for any of the involved parties, and it's more than a 5 minute task.

Set your linker script or scatter file to pull all the Read-Only code and data in the QSPI address space, ie 0x90000000 +32MB, or whatever.

Find ISP and BSP examples for the control transfer, and memory bring-up, and do hand-off to the stand-alone image in QSPI. Don't reinitialize the clocks, or memory, lest you cut off the legs you're standing on.

STM32Cube_FW_H7_V1.8.0\Projects\STM32H750B-DK\Examples\QSPI\QSPI_MemoryMappedDual

STM32Cube_FW_H7_V1.8.0\Projects\STM32H743I-EVAL\Examples\QSPI\QSPI_ExecuteInPlace

STM32Cube_FW_H7_V1.8.0\Drivers\BSP\STM32H750B-DK\stm32h750b_discovery_qspi.c

STM32Cube_FW_H7_V1.8.0\Projects\STM32H750B-DK\Applications\USB_Host\MSC_Standalone\readme.txt

"In this application, the code is executed from QSPI external memory while data are in internal SRAM memory."

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

6 REPLIES 6

The die has 1MByte so I wouldn't worry too much for testing ideas, etc.

No, you can't boot from QSPI as you have to get the clocks, pins and interface aligned to the specifics of the board, and chips involved, but the "boot loader" can be very thin.

I would get the loader tasked with bringing up all the clocks, PLLs memories (QSPI, SDRAM, etc), and then transfer control into an image held in QSPI, and not repeat the bring-up exercise again.

The Vector Table can be relocated via SCB->VTOR, and could be in RAM

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

ok, I cannot boot from QSPI but can I move part of the my program in QSPI to save flash space like I do for the images ?

Yes, the design supports execute-in-place

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Could you show me a sample ?

I don't work for any of the involved parties, and it's more than a 5 minute task.

Set your linker script or scatter file to pull all the Read-Only code and data in the QSPI address space, ie 0x90000000 +32MB, or whatever.

Find ISP and BSP examples for the control transfer, and memory bring-up, and do hand-off to the stand-alone image in QSPI. Don't reinitialize the clocks, or memory, lest you cut off the legs you're standing on.

STM32Cube_FW_H7_V1.8.0\Projects\STM32H750B-DK\Examples\QSPI\QSPI_MemoryMappedDual

STM32Cube_FW_H7_V1.8.0\Projects\STM32H743I-EVAL\Examples\QSPI\QSPI_ExecuteInPlace

STM32Cube_FW_H7_V1.8.0\Drivers\BSP\STM32H750B-DK\stm32h750b_discovery_qspi.c

STM32Cube_FW_H7_V1.8.0\Projects\STM32H750B-DK\Applications\USB_Host\MSC_Standalone\readme.txt

"In this application, the code is executed from QSPI external memory while data are in internal SRAM memory."

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I see that using this modification the function go in QSPI and the flash used is reduced.

Is this correct ?

static void Page1(void);
// void Page1(void);
 
 
main()
{
...
Page1();
...
}
 
 
static void __attribute__((section(".textqspi"), noinline)) Page1(void)
//void Page1()
{
 
...
 
}

 In any case I see that it possible pass in the QSPI only some user parts of code because other parts like the graphic lib must run in flash.

0693W00000JNu1lQAD.jpg0693W00000JNtx2QAD.jpg0693W00000JNu1MQAT.jpg