2012-03-04 06:33 PM
Hello, I am trying to get started with STM32 microcontrollers. I have a STM32F103RBT6 on a development board and I am using the gcc toolchain (target arm-elf, flags -s -Os -mthumb -mcpu=cortex-m3).
The sample code I am using toggles 2 IO pins as fast as possible, it compiles fine. However when compiled (and optimized for size) the output is quite large (about 50k), after the elf is converted to binary its still around 50k in size and is mostly empty space (zeros). When I flash the MCU with the program it does not seem to execute it (IO pins are still in the same states). I have the IO port thats being toggled enabled in code. I'm not sure what I am doing wrong (program, compiler, etc), any help would be appreciated. My code can be foundhttps://docs.google.com/open?id=0BwP0qhqyaTIIcktzWVcxS0JRNEM0Z1BhS0tlT0pyZw
(in google docs)2012-03-04 07:08 PM
The ELF file is an object file, what you need is a binary or hex file.
You could use objcopy to achieve that, and perhaps reflect on your linker script.https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/DispForm.aspx?ID=12211
https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32VLDiscovery/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32VLDiscovery/Exporting flash files from atollic&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000491D59B8574F8049B5DFA3E8B21CBA51¤tviews=965
2012-03-05 03:40 AM
I am already doing that, any other suggestions ?
Just on a sidenote, I don't have any extra scripts for linking set up. Should I have one ?2012-03-05 04:55 AM
I am already doing that, any other suggestions ? Just on a sidenote, I don't have any extra scripts for linking set up. Should I have one ?
You'll need some scripting for the linker so that it places the vectors, code and stack at the correct addresses. The code should be placed at 0x08000000, and should be relatively small, certainly smaller than you are talking about. You could use objdump to disassemble the code, or use a JTAG debugger, to understand if the generated code is viable.2012-03-24 08:59 AM
/*STM32F103 Program Linker Script*/
MEMORY
{
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
rom (rx) : ORIGIN = 0x00000000, LENGTH = 128K
}
SECTIONS
{
. = 0x0;
/* From 0x00000000 */
.text : {
*(vectors)
/* Vector table */
} >rom
. = 0x08000000;
.text : {
*(.text)
/* Program code */
*(.rodata)
/* Read only data */
} >rom
. = 0x20000000;
/* From 0x20000000 */
.data : {
*(.data)
/* Data memory */
} >ram AT > rom
.bss : {
*(.bss)
/* Zero-filled run time allocate data memory */
} >ram AT > rom
}
/*========== end of file ==========*/
my linker script is above, is it correct ? the output (50kb) is
stripped down to a binary program using objcopy.
I then program my MCU through the serial bootloader,
the program (now 2kb) gets copied to 0x8000000 .
What else needs to happen to make it work ?
2012-04-03 01:16 PM
Why are you putting your vector table at 0x00000000 but then putting everything else starting at 0x08000000. The vector table should be at 0x08000000
2012-04-03 04:02 PM