2010-10-09 05:51 AM
has anyone succeeded in configuring a foss toolchain for stm32f100 (discovery board chip)?
I have installed the latest codesourcery, and tried/public/STe2ecommunities/mcu/Lists/ARM%20CortexM3%20STM32/flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/ARM CortexM3 STM32/STM32 CC%2B%2B build environment using CodeSourcery Sourcery G%2B%2B¤tviews=19379
(compile lib, compile main code) but it's rather old and uses fwlib v1.0. Which I wouldn't mind, but after compiling it, I flash it to the board using the stlink utility, and it doesn't start. I've started hacking through it, changing output pins, enabling more peripherals, just to get something working, alas, nothing. Then i've resorted to trying something simpler, while keeping the original linkerscript and lib in effect. This code was found on http://gostm32.blogspot.com. I used this for main.{ int button; int n; RCC->APB2ENR |= 0x10 | 0x04; /* Enable the GPIOA (bit 2) and GPIOC (bit 8) */ GPIOC->CRH = 0x11; /* Set GPIOC Pin 8 and Pin 9 to outputs */ GPIOA->CRL = 0x04; /* Set GPIOA Pin 0 to input floating */
while(1) { delay(); /* A short delay */ button = ((GPIOA->IDR & 0x1) == 0); /* Read the button - the button pulls down PA0 to logic 0 */ n++; /* Count the delays */ if (n & 1) { /* Copy bit 0 of counter into GPIOC:Pin 8 */ GPIOC->BSRR = 1<<8 ; } else { GPIOC->BSRR = 1<<24; } if ((n & 4) && button) { /* Copy bit 4 of counter into GPIOC:Pin 9 if button pressed */ GPIOC->BSRR = 1<<9 ; } else { GPIOC->BSRR = 1<<25; } }} All nice and simple, direct register access, should work, right? Nope, it still doesn't work. I flash it, reset the core, then run the code, and nothing happens. So I've decided to try the whole blinky deal, located , which compiled right, and works after flashing. I was able to make changes to the files, and see the results on the board, and most importantly, I wasn't forced to use those horrible IDEs by attolic/keil/whatever. But I can't use the fwlib and for now I really don't feel like writing my own libraries to set IO direction/speed/etc (although the default ones seem rather cpu hungry). Does anyone have a working, demo project (flash a led, read the button, etc) that succesfully uses fwlib and works with a free toolchain? Thanks. null2010-10-09 05:06 PM
it is fairly simple to set up the project, as long as you do NOT follow the steps outlined by ST, in one of their instruction manuals.
how you set it up will depend on your directory structure. two key things:
1) you will need to define a few macros for the preprocessor;
2) you will need to include a few header / configuration files in the project directory.
take a look at one of the Keil samples and go through its project set-up page by page and implement the equivalent of it in your ide.
a 15 minute job if you are doing it the first time.
2010-10-15 05:48 PM
I think you misunderstood me. I'm not talking about setting up an IDE. I'm talking about using a correct linkerscript and compiling the fwlib for use with a makefile.
I don't want an IDE (atollic, keil, iar) - they are very bad as editors, they are limited, and they only work with stlink, not to mention there's no way to export a flash image (hex/bin/etc). I want vim and make, which I use for pretty much every other project, in every other language. Why change my IDE now? I have done some work on stm32f103 from futurlec, (tiny stamp board) where i succesfully compiled code via the gcc toolchain, linked against fwlib3. I tried using the same linkerscripts fro stm32f100, but it keeps failing. Something is obviously compiled or linked wrong, since the code doesn't start at all. I've tried it on windows and various linuxes, with codesourcery and a custom-compiled arm-elf crosscompiler suite. Has anyone succesfully compiled against fwlib with gcc? If yes, please post results! Best regards, Richard2010-10-15 10:09 PM
Has anyone succesfully compiled against fwlib with gcc? If yes, please post results!
Well, I've used an older WinARM release (WinARM_20080331_testing.zip) to build for an STM32F103, I've just ported in the whole VL firmware library (3.3.0 + CMSIS), fixed the makefile and linker script. It seems to work just fine, took me a couple of hours, and I'm not even a GNU/GCC geek. I have built the Examples/GPIOToggle/main.c from the VL source, I have downloaded main.bin to the board with the ST-LINK/Utilities and it runs and blinks both LED's without a problem. I've posted the top level code here, will post the whole thing if feedback suggests the binary works elsewhere. I suspect one problem you might have had is the linker script needs to clearly define the memory sizes, and to keep the stack within the available RAM. Also, last I checked the Keil/uVision IDE is quite capable of creating .HEX files. It works fine with the U-Link and J-Link JTAG pods, and currently somewhat buggy with the ST-LINK.2010-10-16 07:03 AM
I'm trying to compile your example, but startup_stm32f10x_ld_vl.s fails, I keep getting an error for every line in the file:
lib/src/startup_stm32f10x_ld_vl.s:203: Error: bad instruction `export RCC_IRQHandler[WEAK]'
lib/src/startup_stm32f10x_ld_vl.s:204: Error: bad instruction `export EXTI0_IRQHandler[WEAK]' lib/src/startup_stm32f10x_ld_vl.s:205: Error: bad instruction `export EXTI1_IRQHandler[WEAK]' lib/src/startup_stm32f10x_ld_vl.s:206: Error: bad instruction `export EXTI2_IRQHandler[WEAK]' lib/src/startup_stm32f10x_ld_vl.s:207: Error: bad instruction `export EXTI3_IRQHandler[WEAK]' lib/src/startup_stm32f10x_ld_vl.s:208: Error: bad instruction `export EXTI4_IRQHandler[WEAK]' lib/src/startup_stm32f10x_ld_vl.s:209: Error: bad instruction `export DMA1_Channel1_IRQHandler[WEAK]' lib/src/startup_stm32f10x_ld_vl.s:210: Error: bad instruction `export DMA1_Channel2_IRQHandler[WEAK]' The command executed is:arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -c -o lib/src/startup_stm32f10x_ld_vl.o lib/src/startup_stm32f10x_ld_vl.s
Apparently it's not parsing it as an assembler file, but the .s extensions should make it read it/assemble it like so?2010-10-16 08:07 AM
Does the binary work?
I'm using arm-eabi-gcc and the compiler options expressed in the makefile. C:\WinARM\examples\STM32VL>arm-eabi-gcc -dumpversion 4.3.0 The assembler file came from the RIDE tree (ie the GCC compatible one) within the FW library. Make's out looks like this: arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o main.o main.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o stm32f10x_it.o stm32f10x_it.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/stm32f10x_adc.o lib/src/stm32f10x_adc.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/stm32f10x_bkp.o lib/src/stm32f10x_bkp.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/stm32f10x_can.o lib/src/stm32f10x_can.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/stm32f10x_cec.o lib/src/stm32f10x_cec.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/stm32f10x_crc.o lib/src/stm32f10x_crc.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/stm32f10x_dac.o lib/src/stm32f10x_dac.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/stm32f10x_dbgmcu.o lib/src/stm32f10x_dbgmcu.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/stm32f10x_dma.o lib/src/stm32f10x_dma.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/stm32f10x_exti.o lib/src/stm32f10x_exti.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/stm32f10x_flash.o lib/src/stm32f10x_flash.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/stm32f10x_fsmc.o lib/src/stm32f10x_fsmc.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/stm32f10x_gpio.o lib/src/stm32f10x_gpio.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/stm32f10x_i2c.o lib/src/stm32f10x_i2c.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/stm32f10x_iwdg.o lib/src/stm32f10x_iwdg.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/stm32f10x_pwr.o lib/src/stm32f10x_pwr.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/stm32f10x_rcc.o lib/src/stm32f10x_rcc.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/stm32f10x_rtc.o lib/src/stm32f10x_rtc.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/stm32f10x_spi.o lib/src/stm32f10x_spi.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/stm32f10x_tim.o lib/src/stm32f10x_tim.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/stm32f10x_usart.o lib/src/stm32f10x_usart.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/stm32f10x_wwdg.o lib/src/stm32f10x_wwdg.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/core_cm3.o lib/src/core_cm3.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/misc.o lib/src/misc.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/system_stm32f10x.o lib/src/system_stm32f10x.c arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -c -o lib/src/startup_stm32f10x_ld_vl.o lib/src/startup_stm32f10x_ld_vl.s arm-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -g -Os -I . -I lib/inc -c -o lib/src/stm32vldiscovery.o lib/src/stm32vldiscovery.c arm-eabi-ar cr lib/libstm32.a lib/src/stm32f10x_adc.o lib/src/stm32f10x_bkp.o lib/src/stm32f10x_can.o lib/src/stm32f10x_cec.o lib/src/stm32f10x_crc.o lib/src/stm32f10x_dac.o lib/src/stm32f10x_dbgmcu.o lib/src/stm32f10x_dma.o lib/src/stm32f10x_exti.o lib/src/stm32f10x_flash.o lib/src/stm32f10x_fsmc.o lib/src/stm32f10x_gpio.o lib/src/stm32f10x_i2c.o lib/src/stm32f10x_iwdg.o lib/src/stm32f10x_pwr.o lib/src/stm32f10x_rcc.o lib/src/stm32f10x_rtc.o lib/src/stm32f10x_spi.o lib/src/stm32f10x_tim.o lib/src/stm32f10x_usart.o lib/src/stm32f10x_wwdg.o lib/src/core_cm3.o lib/src/misc.o lib/src/system_stm32f10x.o lib/src/startup_stm32f10x_ld_vl.o lib/src/stm32vldiscovery.o arm-eabi-gcc -Wl,--gc-sections,-Map=main.elf.map,-cref,-u,Reset_Handler -I . -I lib/inc -L lib -T stm32.ld main.o stm32f10x_it.o lib/libstm32.a --output main.elf arm-eabi-objcopy -O binary main.elf main.bin arm-eabi-objdump -h -S -C -D main.elf > main.lss2010-10-16 08:15 AM
Hi,
I think the file you picked isn't for gcc's assembler. This one, from the value line firmware package, works for me with gcc: Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/gcc_ride7/startup_stm32f10x_ld_vl.s Edit: clive1 answered while I was typing.2010-10-16 08:27 AM
Here's my whole source tree, with the libraries, and minimal edits to the original source files to have it port successfully to WinARM and the STM32VL Discovery board.
2010-10-17 10:58 AM
Thanks, worked like a charm. I ran your binary, then modified the makefile to suit my local environment, cleaned and it compiled. And after burning, it worked. I'm using codesourcery on windows - btw, and will later try it on linux under the custom-built crosscompiler.
2010-10-18 10:25 PM
Updated attachment to reflect the part on the VL Discovery is a Medium Density part.