ChibiOS crashes when my firmware is not at beginning of flash memory
Moderators: RoccoMarco, barthess
Re: ChibiOS crashes when my firmware is not at beginning of flash memory
Ok. Thanks a lot for your help Giovanni
-
- Posts: 483
- Joined: Sat Nov 19, 2011 6:47 pm
- Location: Le Mans, France
- Has thanked: 21 times
- Been thanked: 30 times
Re: ChibiOS crashes when my firmware is not at beginning of flash memory
Laurent wrote:So flash sector 0 can never contain pure data? That's annoying.You need to have a vectors table at address zero containing at least the reset address and the MSP initial value.
Sorry but I know very little about vectors table, how would I do that?
It depends on the boot pins, but most of the times no, you need the vector table at adress 0. (address 0 is mapped to flash at 0x08000000 by default)
Just put your data at the end of flash.
It probably works with the debugger since it jumps to where you flash the code.
Re: ChibiOS crashes when my firmware is not at beginning of flash memory
As I said, I need the small sectors so I can't put the data at the end (16 KB sectors vs 128 KB sectors make a huge difference for me).
I added the MSP initial value and reset handler address -- the same values that ChibiOS uses -- at the beginning of sector 0 (at address 0x80000000), and everything worked as exptected. This is not a perfect solution since these values depend on the linker script of the firmware, and thus may break if I make modifications to it, but I guess this is the only way to make it work. The good news is that it only requires 8 bytes in sector 0, the 16376 remaining bytes can still be used for pure data.
Thanks everyone, and especially Giovanni
I added the MSP initial value and reset handler address -- the same values that ChibiOS uses -- at the beginning of sector 0 (at address 0x80000000), and everything worked as exptected. This is not a perfect solution since these values depend on the linker script of the firmware, and thus may break if I make modifications to it, but I guess this is the only way to make it work. The good news is that it only requires 8 bytes in sector 0, the 16376 remaining bytes can still be used for pure data.
Thanks everyone, and especially Giovanni
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: ChibiOS crashes when my firmware is not at beginning of flash memory
You are welcome, I just did what I usually do with my students (go read the documentation), ask RoccoMarco about this lol.
I can only recommend, before changing defaults of a complex systems, to ask beforehand about the possible consequences, just reporting a crash afterwards is not very helpful. I have to make assumptions/guesses, see bootloader etc.
Giovanni
I can only recommend, before changing defaults of a complex systems, to ask beforehand about the possible consequences, just reporting a crash afterwards is not very helpful. I have to make assumptions/guesses, see bootloader etc.
Giovanni
-
- Posts: 483
- Joined: Sat Nov 19, 2011 6:47 pm
- Location: Le Mans, France
- Has thanked: 21 times
- Been thanked: 30 times
Re: ChibiOS crashes when my firmware is not at beginning of flash memory
Just be careful to rewrite the vectors table after you erase the page, or use another one.
You can also change the linker script to handle updating it but you will loose the data you stored after each update.
There's no perfect solution here.
You can also change the linker script to handle updating it but you will loose the data you stored after each update.
There's no perfect solution here.
Re: ChibiOS crashes when my firmware is not at beginning of flash memory
I think you'll crash if you get an interrupt while the page is blanked. You need to disable interrupt while erasing and refilling the page. (the interrupt will hang on the flash access, but resume before you're done writing all the vectors).
The problem that remains is that power might fail after (or even during) erasing and before reprogramming the vectors. Then your CPU might not boot at all anymore. IMHO, I think you should just use the first page for vectors/boot code only.
The problem that remains is that power might fail after (or even during) erasing and before reprogramming the vectors. Then your CPU might not boot at all anymore. IMHO, I think you should just use the first page for vectors/boot code only.
Re: ChibiOS crashes when my firmware is not at beginning of flash memory
Hi Sir,
Currently my chibios code is starting from sector 0(0x08000000). But I want my code to start from sector 5 (0x08020000).
I have changed the following info in my STM32f407xg.ld file
flash0 : org = 0x08020000, len = 512k /* flash0 : org = 0x08000000, len = 1M */
After compiling my code I flashed it in sector 5. But the code is not getting started.
I have my bootloader code at sector 0(0x08000000),which contains a vector offset that points to sector 5.
Do I need to make some other changes in chibios code. I am using STM32F407 controller.
Thanks
Kalpesh
Currently my chibios code is starting from sector 0(0x08000000). But I want my code to start from sector 5 (0x08020000).
I have changed the following info in my STM32f407xg.ld file
flash0 : org = 0x08020000, len = 512k /* flash0 : org = 0x08000000, len = 1M */
After compiling my code I flashed it in sector 5. But the code is not getting started.
I have my bootloader code at sector 0(0x08000000),which contains a vector offset that points to sector 5.
Do I need to make some other changes in chibios code. I am using STM32F407 controller.
Thanks
Kalpesh
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: ChibiOS crashes when my firmware is not at beginning of flash memory
You need to jump at the address contained at offset +4 in the vectors table you placed at 0x08020000.
From what you wrote I understood you are jumping at the vectors table.
Giovanni
From what you wrote I understood you are jumping at the vectors table.
Giovanni
Re: ChibiOS crashes when my firmware is not at beginning of flash memory
Giovanni wrote:You need to jump at the address contained at offset +4 in the vectors table you placed at 0x08020000.
From what you wrote I understood you are jumping at the vectors table.
Giovanni
kalpesh wrote:
Hi ,
I am actually jumpimg to address contained at offset +4 only.
JumpAddress = (__IO uint32_t) (ApplicationAddress + 4);
My bootloader is able to read the data of sector 5 address. But the code present in sector 5 is not getting started.
My bootloader code contains read and Jump functions.
After compiling my chibios code my ch.map file flash0 points to sector 5 address with the required size.
ch.map file:
Name Origin Length Attributes
flash0 0x08020000 0x00080000
Thanks
Kalpesh
Re: ChibiOS crashes when my firmware is not at beginning of flash memory
Hi,
In chibios is it neessary to set the following macro.
#define CORTEX_VTOR_INIT 0x00020000 /* For Sector5 */
This macro is not present in my chibios code . Is there any alternate macro for this.
My bootloader code is able to start a sample Led application code(HAL) , but not he chibios code.
Thanks
In chibios is it neessary to set the following macro.
#define CORTEX_VTOR_INIT 0x00020000 /* For Sector5 */
This macro is not present in my chibios code . Is there any alternate macro for this.
My bootloader code is able to start a sample Led application code(HAL) , but not he chibios code.
Thanks
Who is online
Users browsing this forum: No registered users and 13 guests