cancel
Showing results for 
Search instead for 
Did you mean: 

External Flash Loader don't work

lhwa .1
Associate II

Hello, I am developing an external flash loader using Spi (W25Q16DV) with Stm32G070.

Yes, the operation is going well without any problems.

However, the peculiar thing is that it doesn't work when you write the user program in the internal flash and run the external flash loader.

This means that you must erase the internal flash and run the external flash loader before it works.

I'm looking for help.

Thank you.

4 REPLIES 4

I'd imagine its interfering with the peripherals, pins or interrupts.

Couple of things you might try.

You could add a delay spin-loop in the Reset_Handler to give the debugger some time to take control.

You could redirect the vector table SCB->VTOR in to the ROM

Disable SysTick or other interrupt sources at the peripherals.

Check that your code properly resets the QSPI/OCTOSPI peripheral, and things are in weird/non-reset conditions.

You can use a UART to report internal state, and perhaps learn something about the state of things in the working vs non-working cases.

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

As Tesla DeLorean (Community Member) mentioned: When internal flash is empty, the CPU will run into hard fault and halt right after reset. As soon as you've programmed the internal flash, the CPU will start initialization of peripherals, RAM etc. which certainly will interfere with the external loader.

So, if you don't want to touch your application (delay after reset), the debugger must connect under reset and halt the CPU right out of reset. And, of course, beware of watchdogs: If automatic activation after reset is enabled ...

0693W00000KdKnLQAV.png 

Thank you for your reply.

If the external flashloader is running while the User application is in internal flash, the internal flash program will be halted and remain in reset state.

However, the user application program has only clock settings as shown above.

However, it doesn't work.

There seems to be another problem.

#include "Dev_Inf.h"
 
/* This structure containes information used by ST-LINK Utility to program and erase the device */
#if defined (__ICCARM__)
__root struct StorageInfo const StorageInfo  =  {
#else
struct StorageInfo const StorageInfo  =  {
#endif
   "W25Q16JV_STM32G070-Custom", 					// Device Name + EVAL Borad name
   SPI_FLASH,                   					// Device Type
   0x00000000,                						// Device Start Address
   0x00200000,                 						// Device Size in Bytes (16MBit/2MByte)
   0x00000100,                    					// Programming Page Size 256Bytes
   0xFF,                       						// Initial Content of Erased Memory
// Specify Size and Address of Sectors (view example below)
   0x00000200, 0x00001000,     				 		// Sector Num : 512 ,Sector Size: 4KBytes
   0x00000000, 0x00000000,
}; 
int Init (void)
{
    HAL_Init();
 
    SystemClock_Config();
 
    MX_GPIO_Init();
 
    MX_SPI1_Init();
 
    MX_USART3_UART_Init();
 
    return 1;
}