ChibiOS crashes when my firmware is not at beginning of flash memory

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

kalpesh
Posts: 19
Joined: Mon Dec 09, 2019 11:53 am

Re: ChibiOS crashes when my firmware is not at beginning of flash memory

Post by kalpesh »

Hi,

Any update on the above issue (for relocating chibios to different sector).
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ChibiOS crashes when my firmware is not at beginning of flash memory

Post by Giovanni »

I don't have information to give a meaningful suggestion.

Others have implemented a similar bootloader so there must something wrong is some minor detail.

Giovanni
kalpesh
Posts: 19
Joined: Mon Dec 09, 2019 11:53 am

Re: ChibiOS crashes when my firmware is not at beginning of flash memory

Post by kalpesh »

Hi,

After changing the following info in STM32F407xG.ld file, my vector in ch.list file now points to sector 5 which I think is correct. But still the code is not getting started.

STM32F407xG.ld file :
flash0 : org = 0x08020000, len = 512k

ch.list file :

Disassembly of section .vectors:

08020000 <_vectors>:
8020000: 20000400 .word 0x20000400
8020004: 080202d9 .word 0x080202d9
8020008: 080202db .word 0x080202db

Someone shared that "set CORTEX_VTOR_INIT to the new offset". But I did not find this Macro in my chibios code.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ChibiOS crashes when my firmware is not at beginning of flash memory

Post by Giovanni »

If you are using the latest version then VTOS is set in startup files, no need for that option.

Giovanni
kalpesh
Posts: 19
Joined: Mon Dec 09, 2019 11:53 am

Re: ChibiOS crashes when my firmware is not at beginning of flash memory

Post by kalpesh »

Hi,

I am using the following version of chibios. In this version is it necessary to set CORTEX_VTOR_INIT
/*
* @brief ChibiOS version string.
*/
#define CH_VERSION "19.1.2"

Thanks
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ChibiOS crashes when my firmware is not at beginning of flash memory

Post by Giovanni »

It is not necessary.

Giovanni
kalpesh
Posts: 19
Joined: Mon Dec 09, 2019 11:53 am

Re: ChibiOS crashes when my firmware is not at beginning of flash memory

Post by kalpesh »

Hi,

Any inputs from your side for relocating the chibios to different sector(Any extra changes to be made in code).

Thanks
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ChibiOS crashes when my firmware is not at beginning of flash memory

Post by Giovanni »

No changes, you just need to change the LD file and make sure that you enter ChibiOS under the same conditions you have after exiting a reset (interrupts disabled, peripherals in their reset state etc).

Giovanni
kalpesh
Posts: 19
Joined: Mon Dec 09, 2019 11:53 am

Re: ChibiOS crashes when my firmware is not at beginning of flash memory

Post by kalpesh »

Hi,

I carried out some test and got the results. This might help in getting a clear idea why chibios is not able to relocate to different sector.

For example : I made a bootloader code in HAL and a simple application code in HAL, then it is working.

Bootloader code Application code Result

1. HAL HAL Working
2. Chibios Chibios Working
3. HAL Chibios Not Working
4. Chibios HAL Not Working

Any idea from your side. The final application code is chibios.

Thanks
User avatar
wurstnase
Posts: 121
Joined: Tue Oct 17, 2017 2:24 pm
Has thanked: 43 times
Been thanked: 30 times

Re: ChibiOS crashes when my firmware is not at beginning of flash memory

Post by wurstnase »

I successfully jump from HAL bootloader to ChibiOS main application.

Be sure that you will set VTOR, MSP etc. correctly AND jump before halInit and chInit etc.
Post Reply