gotty
November 24, 2009, 12:23pm
1
Hello
Is it possible to use supplied with codesourcery lite toolchain with openocd and stm32 micro?
I’ve tried without success
I’ve used generic-m.ld adapted for 20K ram. jumpers were set to run from ram.
.gdbinit
target remote :3333
monitor reset init
load
gdb session log
0x00000000 in ?? ()
JTAG tap: stm32.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3)
JTAG Tap/device matched
JTAG tap: stm32.bs tap/device found: 0x16410041 (mfg: 0x020, part: 0x6410, ver: 0x1)
JTAG Tap/device matched
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x20000108
Loading section .text, size 0x248 lma 0x20000000
Loading section .eh_frame, size 0x4 lma 0x20000248
Loading section .ARM.exidx, size 0x8 lma 0x2000024c
Loading section .rodata, size 0x34 lma 0x20000254
Loading section .data, size 0x8 lma 0x20000288
Start address 0x200000c0, load size 656
Transfer rate: 13 KB/sec, 131 bytes/write.
(gdb) c
Continuing.
Program received signal SIGTRAP, Trace/breakpoint trap.
0x200000c4 in __cs3_reset_generic_m ()
(gdb) c
Continuing.
Program received signal SIGTRAP, Trace/breakpoint trap.
0x200000c4 in __cs3_reset_generic_m ()
(gdb) c
Continuing.
Program received signal SIGTRAP, Trace/breakpoint trap.
0x200000c4 in __cs3_reset_generic_m ()
(gdb)
gdb stops on bkpt 0xAB (located at 0x200000c4) instruction and that’s all.
Any ideas?
p.s. openocd r2403-1 precompiled from ubuntu 9.10 universe repositary.
jsiei97
November 24, 2009, 3:34pm
2
Loading section .text, size 0x248 lma 0x20000000
Loading section .eh_frame, size 0x4 lma 0x20000248
Loading section .ARM.exidx, size 0x8 lma 0x2000024c
Loading section .rodata, size 0x34 lma 0x20000254
Loading section .data, size 0x8 lma 0x20000288
Is your link scripts correct?
I put my code in flash starting at 0x0,
and the rest at 0x20000000.
You seem to put all in RAM at 0x20000000.
Are you sure this is what you want?
This is a small example how I do it:
http://fun-tech.se/stm32/OlimexBlinky/mini2.php
http://fun-tech.se/stm32/OlimexBlinky/mini2/stm32.ld
gotty:
p.s. openocd r2403-1 precompiled from ubuntu 9.10 universe repositary.
This what I use my self:
http://fun-tech.se/stm32/
BR
Johan
gotty
November 25, 2009, 7:31am
3
I hope linker script is correct, I’ve taken generic-m.ld from codesourcery and slightly changed it.
MEMORY
{
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
}
onboard BOOT jumpers are set 1 (both).
So, I suppose it should run from ram correctly.
jsiei97
November 25, 2009, 7:44am
4
gotty:
I hope linker script is correct, I’ve taken generic-m.ld from codesourcery and slightly changed it.
MEMORY
{
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
}
onboard BOOT jumpers are set 1 (both).
So, I suppose it should run from ram correctly.
Maybe that could work (I don’t know).
I put code in the flash and execute there.
MEMORY
{
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
rom (rx) : ORIGIN = 0x00000000, LENGTH = 128K
}
Is there a special reason why you want everything in RAM?
BR
Johan
Did you find a solution for your problem? I am having the same problem.
I am doing
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -o application.elf teststm32.c -T generic-m.ld
The generic-m.ld has this at the beginning
GROUP(-lgcc -lc -lcs3 -lcs3unhosted -lcs3micro)
MEMORY
{
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 68K
}
but when I look at the elf the code is like this
200000c8 <__cs3_start_asm_sim>:
200000c8: a10c add r1, pc, #48 ; (adr r1, 200000fc <__cs3_heap_start_ptr>)
200000ca: 2016 movs r0, #22
200000cc: beab bkpt 0x00ab
when I reach bkpt 0x00ab it stays there forever since it is a software breakpoint instruction. I have no idea why the compiler would generate a bkpt in middle of the code. The debugger I understand but no the compiler. I dump that assembly code by using objdump -d application.elf
jsiei97 is not seeing this problem because he is not using the CodeSourcery libraries (-lcs3 -lcs3unhosted -lcs3micro) which are the libraries that have that bkpt instruction in startup code. He is also not using the generic-m.ld linker script.
gotty
September 27, 2010, 8:20am
6
orlcp440:
Did you find a solution for your problem? I am having the same problem.
The solution was to use startup code from standart peripheral library for STM32 micros, and linker script too.
What about the standard C libraries? Which one did you use? I am also now using the standard peripheral library for STM32 micros and linker scripts. However, when I try to use malloc() or any other standard C library function I get the same problem as before.
Never mind, I had _sbrk defined as a position in memory instead of a function. The CodeSourcery Libc malloc requires me to implement the _sbrk function myself. I thought that it only needed a symbol where I wanted my heap to live. I thought that symbol was _sbrk but I was wrong. Now things seem to work well. Thank you for your help.