AnsweredAssumed Answered

Problems regarding Interrupt Vector Relocation with STM32F030CC

Question asked by Francisco SinapseEnergia on Oct 19, 2017
Latest reply on Oct 19, 2017 by Clive One

Hello all!.

 

I have problems loading one application program using one bootloader main program. I have tested and debugged that bootloader program takes entire bin application program right with all bytes right at starting at 0x8008000 FLASH position (This is the position for any application client program, bootloader is beginning at 0x8000000). I suppose problem is when application program is loaded with bootloading, into last calling from bootloader in order to execute application client. I post here all changes made from one normal application client that runs by itself when it is transformed to one application program that depends from one bootloader to be loaded.

 

 

 

Changes made into one application client:

 

into MAIN.C has been declared this variable for application vector table:

 

volatile uint32_t VectorTable[48] __attribute__((section(".RAMVectorTable")));

 

into MAIN.C, first line has following call:

int main()

{

 

remapMemToSRAM();

 

HAL_Init();


/* Configure the system clock */
SystemClock_Config();


/* USER CODE BEGIN SysInit */

/* USER CODE END SysInit */

/* Initialize all configured peripherals */
MX_GPIO_Init();
while (1)
HAL_GPIO_WritePin(GPIOX13_GPIO_Port, GPIOX13_Pin, GPIO_PIN_SET);  /// LED ON;

 

}

 

void remapMemToSRAM( void )
{
uint32_t vecIndex = 0;
__disable_irq();

for(vecIndex = 0; vecIndex < 48; vecIndex++){
VectorTable[vecIndex] = *(volatile uint32_t*)(FW_START_ADDR + (vecIndex << 2));
}

__HAL_SYSCFG_REMAPMEMORY_SRAM();

__enable_irq();
}

 

FW_START_ADDR = 0x8008000

 

into STM32F030CC_FLASH.ld (or linker script) I have this:

 

MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
FLASH (rx) : ORIGIN = 0x8008000, LENGTH = 256K-32K
}

 

inside sections I have included this ram segment for application vector table:

 

.RAMVectorTable(NOLOAD):
{
KEEP(*(.RAMVectorTable))
} > VTRAM

....

 

Debugging bootloader program I have hardfault at this point when I try to launch application program with function:

 

Boot_StartApplication();

 

Where Boot_StartApplication is implemented as:

 

uint8_t Boot_StartApplication(void)
{
uint32_t startAddress, applicationStack;
pFunction applicationEntry;

//The address where the application is written
startAddress = BOOT_APPLICATION_ADDR;

//Retrieve values
applicationStack = (uint32_t) (volatile unsigned int) (startAddress);
applicationEntry = (pFunction) (volatile unsigned int) (startAddress + 4);

/*Set a valid stack pointer for the application */
__set_MSP(*(__IO uint32_t *)BOOT_APPLICATION_ADDR);

/*Start the application */
applicationEntry(); // executing this point i have Hard_Fault error

 

return 1; // OK (but in real app should never reach this point)
}

 

when applicationEntry(); is executed I can watch following:

 

0x8008004
later-> <signal handler called>() at 0xfffffff9
HardFault_Handler() at stm32f0xx_it.c:67 0x8006408

 

 

 

 

 

If iin linker file I substitute :

 

MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 256K
}

 

And I comment the first line for remapping.

 

int main()

{

 

//remapMemToSRAM();

 

HAL_Init();


/* Configure the system clock */
SystemClock_Config();


/* USER CODE BEGIN SysInit */

/* USER CODE END SysInit */

/* Initialize all configured peripherals */
MX_GPIO_Init();
while (1)
HAL_GPIO_WritePin(GPIOX13_GPIO_Port, GPIOX13_Pin, GPIO_PIN_SET);  /// LED ON;

 

}

 

LED is on and application program works without bootloader, but using bootloader I have thes HardFault error.

 

Please, I would be very grateful if you can indicate where is problem, maybe some problem from compiler?. I use gcc GNU-ARM integrated into Atollic TrueStudio.

 

Thanks a lot!

Outcomes