Loading...
 

STM32MP1 support available in SW4STM32

   With System Workbench for Linux, Embedded Linux on the STM32MP1 family of MPUs from ST was never as simple to build and maintain, even for newcomers in the Linux world.
And, if you install System Workbench for Linux in System Workbench for STM32 you can seamlessly develop and debug asymmetric applications running partly on Linux, partly on the Cortex-M4; you can download a short video showcasing this on the ac6-tools website (registration required).

System Workbench for STM32


Load other .text section with gdb

Dear ST support,

I’m working on STM32L476 and free AC6 toolchain.

I’m trying to create jump table and created dedicated sections in flash to hold the redirection:
please find below a description of what I did:

Exemple is to create a jump table from _mdelay to mdelay function

Assembly file :

.extern mdelay
.section .text.jtable_core_api,”ax”,%progbits
.globl _mdelay
.type _mdelay, %function
_mdelay:
ldr r6,=mdelay
bx r6
.size _mdelay, .-_mdelay

linker script:
MEMORY
{
...
ROM_JTABLE_ (rx) : ORIGIN = 0x8078000, LENGTH = 1K
...
}

SECTIONS
{

...
.jtable_core_api :
{
. = ALIGN(8);
KEEP(*(.text.jtable_core_api))
KEEP(*(.text.jtable_core_api*))

. = ALIGN(8);
_ejt_core = .; /* define a global symbols at end of code */
} >ROM_JTABLE_APP

....
}


This works fine and the elf file holds the data at address 0x08078000 as expected (checkable in .map file)

map file:

.jtable_core_api
0x08077c00 0x60
0x08077c00 . = ALIGN (0x8)
*(.text.jtable_core_api)
.text.jtable_core_api
0x08077c00 0x5c src/projects/micropos_app/api/app_api/app_api.o
0x08077c00 _mdelay
*(.text.jtable_core_api*)
0x08077c60 . = ALIGN (0x8)
*fill* 0x08077c5c 0x4
0x08077c60 _ejt_core = .


Nevertheless, the section jtable_core_api is not loaded when launching a debug session and I figure I must configure gdb to take this section into account and process it as a casual text section.

All the more the gdb console says:

976,804 ~”Loading section .jtable_core_api, size 0x60 lma 0x8077c00\n”
976,804 19+download,{section=”.jtable_core_api”,section-size=”96”,total-size=”2804945”}

Looking at the memory at address 0x08077C00, only 0xFFFFFFFF can be found :_(

Can someone help ?
Thanks for your help,
Regards,

Sylvain

strange normaly by collecting your extra section into text section shall do
the default ld is something like
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */

// add here your extra section
*(.my_section_name)

maybe you already tryied something like this ?
Soemtime KEEP statement like
KEEP (*(.init))

can help if section is scraped by linker cos not referecend anywhere.


Hi Diablo,

I want my text section to be at a specific address and that all the mapping is included in the linker script.
Creating a new section held by a new memory area allows to have such a mapping fully included in the linker script.

Creating a sub section in the casual text area does NOT allow me to set the address in the linker script, does it ?

By the way, the solution I described works quite fine for the .elf generation.
The issue is that my extra text sections are not loaded by GDB when going to debug mode.

Thanks for your help,
Regards,
Sylvain


Hello Sylvain,

In the debug configuration, under the “Debugger” tab, can you add -d3 to the OpenOCD command line and then check if there are any error messages in the OpenOCD console ?

Best Regards,

Pascale


Hi Pascale,

please find the log related to the section loading with -d3 option

515,617 &”load C:\\projects\\project_L4\\Debug\\project_L4.elf \n”
515,617 ~”Loading section .ram2_bss, size 0x7ef4 lma 0x10000000\n”
515,617 19+download,{section=”.ram2_bss”,section-size=”32500”,total-size=”2646205”}
515,617 19+download,{section=”.ram2_bss”,section-sent=”4096”,section-size=”32500”,total-sent=”4096”,\
total-size=”2646205”}
515,914 20-list-thread-groups i1
516,320 19+download,{section=”.ram2_bss”,section-sent=”16384”,section-size=”32500”,total-sent=”16384\
“,total-size=”2646205”}
517,007 19+download,{section=”.ram2_bss”,section-sent=”28672”,section-size=”32500”,total-sent=”28672\
“,total-size=”2646205”}
522,414 ~”Loading section .isr_vector, size 0x188 lma 0x8000000\n”
522,429 19+download,{section=”.isr_vector”,section-size=”392”,total-size=”2646205”}
522,429 ~”Loading section .rodata, size 0x27e0 lma 0x8000188\n”
522,429 19+download,{section=”.rodata”,section-size=”10208”,total-size=”2646205”}
522,429 ~”Loading section .ARM, size 0x8 lma 0x8002968\n”
522,429 19+download,{section=”.ARM”,section-size=”8”,total-size=”2646205”}
522,429 ~”Loading section .init_array, size 0x8 lma 0x8002970\n”
522,429 19+download,{section=”.init_array”,section-size=”8”,total-size=”2646205”}
522,429 ~”Loading section .fini_array, size 0x8 lma 0x8002978\n”
522,429 19+download,{section=”.fini_array”,section-size=”8”,total-size=”2646205”}
522,429 ~”Loading section .data, size 0x8e0 lma 0x8002980\n”
522,429 19+download,{section=”.data”,section-size=”2272”,total-size=”2646205”}
522,429 ~”Loading section .text, size 0x2e0c0 lma 0x8003260\n”
522,429 19+download,{section=”.text”,section-size=”188608”,total-size=”2646205”}
522,429 ~”Loading section .jtable_xxxxx_api, size 0x60 lma 0x8077c00\n”
522,429 19+download,{section=”.jtable_xxxx_api”,section-size=”96”,total-size=”2646205”}
522,429 ~”Loading section .jtable_xxx_api, size 0x150 lma 0x8078000\n”
522,429 19+download,{section=”.jtable_xxx_api”,section-size=”336”,total-size=”2646205”}
529,367 ~”Start address 0x80045b0, load size 234436\n”
529,367 ~”Transfer rate: 16 KB/sec, 8372 bytes/write.\n”
529,367 19^done


jtable_xxxx_api and jtable_xxx_api are my two jump tables.

So no additional error appeared.

Were you able to reproduce the issue ?

I read in the gdb doc that a configuration file should be somewhere to select which sections must be loaded, but can’t find it ...

Thanks for your help,
Best Regards

Sylvain


Hello Sylvain,

Which mcu exactly are you working with ?

Can you post a zip of your project so we can reproduce the issue ?


Best Regards,

Pascale


Hi Pascale,

I’m currently working on STM32L476 but the issue should appear on any STM32 if you use a linkerscript written the same “style” than mine.

I unfortunately can’t give you the project I’m working on.

Creating a project to reproduce the issue should take about an hour which I really don’t have now.

Well, I’m sorry to say but the support is very slow on this and this issue is critical in our last steps to finish the project in time.
I will create a test project as you don’t give me the choice and come back to you ....

thanks for your help,
Best regards,
Sylvain


Hi Pascale,

Please find attached a project which reproduce the issue.

The function _fct_table implements a jump to fct_table.
_fct_table is located in section ROM_JTABLE_APP.

I added a screenshot of the project in debug mode which shows that the _fct_table section is NOT loaded into memory.
Executing 0xFFFFFFFF instruction the program will crash.

I hope this helps,
feel free to ask for more information,

Thanks for your help
Best regards,
Sylvain


Hello Sylvain,

Can you at least send us the full linker script and the full part number of your mcu (the letters and digits after STM32L476, which give in particular the memory size of the mcu) ?

Best Regards,

Pascale


Hi Pascale,

the project I attached is complete and provide the linker script and everythong that’s needed to reproduce the issue (as far I know)

thanks
Sylvain


My post crossed yours...thanks ! We were able to reproduce your issue and are investigating the Openocd flash driver, the problem may be there.

Pascale


Hello Pascale,

Thanks for your quick responses.

Do you have an estimated time for the bug troubleshoot ?

If the time to solve the issue is unknown, would you maybe have a workaround ?

I’m looking for something allowing me to declare my jump table section in the assembly at a given address but in the casual .text section instead of in a section in the linker script.
Or maybe I could use a sub section ?

Any ideas ?
Thanks again for your help,
Best regards
Sylvain


Hello Sylvain,

Afer investigation, we confirm there is a bug in Openocd L4 flash driver. I can’t tell when it will be fixed as it is not an obvious issue.

But we have found an easy workaround : before launching the debugger, you shoud erase the memory : select the project in the Project Explorer, right click, select “Target” and then “Erase Chip”.

Let us know if this works,

Best Regards,

Pascale


Hello Pascale,

thanks for the info.

I can’t find the “target > erase” command right clicking the project in the C/C++ project explorer (in using eclipse).

Maybe I’m not looking for the option in the right menu or view ?

Thanks for your help,
best regards,
Sylvain


You probably don’t have the latest version of SW4STM32 : in the Help menu, select “Check for Updates” and download the latest versions of AC6 plugins.

Best Regards,

Pascale


Hello Pascale,

I’ve updated my framework.

Starting any debug session the following error occurs:
OpenOCD Binary not found.

Moreover I can’t see the menu “target” right clicking a project even after the update.

I tried to reinstall the whole eclipse framewok without any behavior change.

What should I do ?

Thanks for your help,
best regards,
Sylvain


Hello Pascale,

the frmaework is wroking again at my deck, thanks !!

I couldn’t find the “erase” option from eclipse after a full update but was able to run the “erase” from stm32 utility.

The workaround seems to work fine and the jump tables are loaded in debug mode !

Thanks for your help,
Best Regards,
Sylvain