After the jump to the app, the customized startup file allows the correct execution of main.c file until the start of the first task. My program gets stacked at vPortSVCHandler in the path GCC/ARM_CM4F/port.c [FreeRTOS Kernel V10.3.1, using heap_4].
I tried the solution provided in the topic
[Imx rt1024 position independent code - fail to start first task]#
to keep invariate the R9 register, but it didn’t work.
EDIT for specification: the above solution works when running the application alone from the beginning of flash, but fails when it is integrated with bootloader code.
How are you routing control to your interrupt handlers? Does VTOR point to the bootloader’s vectors? Or does VTOR point to a RAM table? Or something else perhaps?
Do you intend your RAM vectors to point directly to handlers in the application image, regardless of where you load that image into flash? If so, can you post the code that populates the RAM vector table?
How do the contents of the RAM vector table compare in these two scenarios?
If so, can you post the code that populates the RAM vector table?
Yes, the startup code is taken from a public study:
I’m trying to overcome the limitations of recent disclaimer, to be good for FreeRTOS.
How do the contents of the RAM vector table compare in these two scenarios?
Unfortunately, STM provides debugging feature only with hardcoded offset, so I’m able to use debbuger only in 1st scenario and in a slightly different version of 2nd scenario:
SUMMARY:
APP alone starting from 0x08000000: works and can be debugged
BTL+APP with this slightly difference and hardcoded offset in linker script, starting from 0x08044000: works and can be debugged
BTL+APP without hardcoded offset and put at 0x08044000: works in main.c, but fails at first task of Freertos and can’t be debugged (I used leds to look at variables’ and registers’ contents, but I couldn’t find the difference with previous scenario).
I’m sure I’m missing something about -fPIC and Freertos, which is a relatively new field for me
One essential fact that the article you linked to ignores is that the rest of interrupt vector is going to be processed by the hardware. Thus, code using that technique just can’t use interrupts at all.
Since FreeRTOS DOES use interrupt, that technique just becomes a non-starter,
In your case, you want the RAM vectors to point at functions in the application image regardless of any offset used when loading the application image into flash. I would suggest you create a small blinky application that uses interrupts but doesn’t use FreeRTOS. Once you get that working with a load offset, then come back and try to add FreeRTOS. I suspect your issue is the content of your RAM vector table.
I’m going to reach out to my teammate @aggarg and see if he has any experience with this. He has much more experience porting FreeRTOS than I do. I’ll try to get you a response tomorrow.
In the meantime I think @jefftenney has provided solid advice and would be a great launch point.
After an other week, I finally make it work! The issues stand in the .data section and static library patch of startup file, where there are some pointers (I think related to FreeRTOS) which point towards memory slot (that is equivalent to not-offseted binary image of application). So I adjust these values as with .got and .isr_vector section. Thanks to everyone for the suggestions @jefftenney@kstribrn@richard-damon@aggarg. I hope to not need further help to integrate the left (and more complex) part of my FW
I suggest you to look at the link above where there is the explaination about managment of .isr_vector section in RAM, and link to GitHub project. For the .data section, I simply added the _eidata declaration and proceeded with the same offset adjustment of .isr_vector and .got sections.
/* Used by the startup to initialize data */
_sidata = LOADADDR(.data);
_eidata = _sidata + sizeof(.data);
/* Initialized data sections into “RAM” Ram type memory /
.data :
{
. = ALIGN(4);
_sdata = .; / create a global symbol at data start / (.data) / .data sections contain also pointers of FreeRTOS Tasks declaration to be offseted if in FLASH memory range / (.data.rel) / .data.rel sections contain also pointers for relative position addressing to be offseted if in FLASH memory range */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM AT> FLASH
Below I added a section “.data_no_adj” with same structure of “.data”, where I put the left part of "(.data*). In this part, the data are not offseted (even if in FLASH memory range), because they are not referred to pointers, but to variables that assume absolute values in FLASH memory range. At least, this is the discrimination that I found and made. It worked for me.