seko1985 wrote on Thursday, October 28, 2010:
Hello everyone.
I am using STM32F103VB uP with CodeSourcery GCC compiler. I have following problem. I’ve developed bootloader, which is loaded at the beginning of flash (0x08000000) . This bootloader uses a SD card with FAT file system, and check if some file with new firmware exists on SD card, and then loads it to flash at address 0x08008000 and call new application using such asm code:
.thumb_func
CallApplication:
// Set the vector table address to the beginning of the application.
ldr r0, =APP_VEC_TAB_OFFSET
ldr r1, =(SCB_BASE + 8)
str r0,
// Load the initial LR as it should be after the reset.
movs lr, #0xffffffff
// Load the stack pointer from the application’s vector table.
ldr r0, =DEF_APP_ADDRESS
ldr r1,
msr msp, r1
// Load the initial PC from the application’s vector table and branch to
// the application’s entry point.
ldr r0,
bx r0
Where DEF_APP_ADDRESS is 0x08000000.
When I load in such way application that is not using FreeRTOSeverything is fine. Application is loading and than running correctly, but doing the same with application based on FreeRTOS i get the HardFault Exception before calling the main in section LoopFillZerobss of startup file:
Reset_Handler:
/* Copy the data segment initializers from flash to SRAM */
movs r1, #0
b LoopCopyDataInit
CopyDataInit:
ldr r3, =_sidata
ldr r3,
str r3,
adds r1, r1, #4
LoopCopyDataInit:
ldr r0, =_sdata
ldr r3, =_edata
adds r2, r0, r1
cmp r2, r3
bcc CopyDataInit
ldr r2, =_sbss
b LoopFillZerobss
/* Zero fill the bss segment. */
FillZerobss:
movs r3, #0
str r3, , #4
LoopFillZerobss:
ldr r3, = _ebss
cmp r2, r3
bcc FillZerobss
/* Call the clock system intitialization function.*/
bl SystemInit
/* Call the application’s entry point.*/
bl main
bx lr
.size Reset_Handler, .-Reset_Handler
Of course i change in the linker script line:
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K
to:
FLASH (rx) : ORIGIN = 0x08008000, LENGTH = (128K - 0x8000)
and in function void vSetupHardware(void) I changed line:
NVIC_SetVectorTable( NVIC_VectTab_FLASH, 0x0 );
to:
NVIC_SetVectorTable( NVIC_VectTab_FLASH, 0x8000 );
I don’t know where to find problem.