I just got my stm32 and ideally would like to program it from my Mac. Has anyone gotten this to work? I think it should be possible as of gcc 4.3, which claims to support ARMv7/Thumb2 directly.
I’ve tried compiling gcc with various --target=… and --disable-… options, but I’m basically just guessing and always run into trouble. So if anyone here has already succeeded I’d love to know your methods.
I managed to build CodeSourcery Lite 2008q1 on Leopard, and I use to to program Stellaris targets (Cortex M3)
The process to build the toolchain is nowhere near trivial, but it works in the end. You can lift most of the needed ‘configure’ options from the CodeSourcery useless build script too.
Have you installed Xcode? if I remenber correctly, when installing it there’s an option that allow installing gcc, binutils … in the standard Unix/Linux directory /usr. You must check this option.
This is because you need gcc for your platform to compile the gcc cross compiler.
The page is focused on the STM32 Primer, but the compiler-building parts will likely still apply. Linking device-specific libraries and transferring compiled code to the device in question will be a different matter.
I’ve tried building a 4.3 compiler on OS X, but kept hitting walls…I don’t think all of the Thumb2 changes have fully made it back into the official GCC releases yet. A CodeSourcery “q3” release will probably be along in a matter of weeks, and I’d be very surprised if it did not include a later GCC version. But for now the “q1” release is your best bet.
i got busy for a while, so i only just had a chance to try this again and i got it working!
one big difference is that i have an intel mac with OS X 10.5 now (previously had a G4 with 10.4) which makes building everything actually work as opposed to having endless confusing errors.
so anyway for posterity here’s everything i did to get it working:
then made an openocd.cfg file for the STM32 / ARM-USB-TINY combination, based on /usr/local/lib/openocd/interface/olimex-jtag-tiny-a.cfg and /usr/local/lib/openocd/target/stm32.cfg which were almost correct but needed the TINY’s product id and needed to specify the offset and size of the flash address bank. the resulting openocd.cfg file:
# REFERENCE: http://www.olimex.com/dev/arm-usb-tiny.html
interface ft2232
ft2232_device_desc "Olimex OpenOCD JTAG TINY A"
ft2232_layout olimex-jtag
ft2232_vid_pid 0x15ba 0x0004
# script for stm32
# jtag speed
jtag_khz 500
jtag_nsrst_delay 100
jtag_ntrst_delay 100
#use combined on interfaces or targets that can't set TRST/SRST separately
reset_config trst_and_srst
#jtag scan chain
#format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
jtag_device 4 0x1 0xf 0xe
jtag_device 5 0x1 0x1 0x1e
#target <type> <startup mode>
#target arm7tdmi <reset mode> <chainpos> <endianness> <variant>
target cortex_m3 little 0
working_area 0 0x20000000 16384 nobackup
#flash bank str7x <base> <size> 0 0 <target#> <variant>
flash bank stm32x 0x08000000 0x20000 0 0 0
# For more information about the configuration files, take a look at:
# openocd.texi
i changed the PC4 led pin in main.c to PC12 (the Olimex STM32-H103 board’s led pin), ran make, and plugged the programmer USB in as well as the board USB (for power).
finally, I ran openocd with my openocd.cfg file from above, telnetted to localhost:4444, and ran the commands:
halt
stm32x mass_erase 0
flash write_bank 0 main.bin 0
reset
And the light blinked! So, next time I have some time I can hopefully do something more substantial…
Last summer I installed the gnu gcc toolchain with openocd on a Windows box successfully, but it required Lanchon’s mods to make it work.
Am I to understand from the posts in this forum that Lanchon’s mods are no longer necessary for installation of the toolchain on a Mac? If I recall correctly, Lanchon’s mods were required for the startup code and for floating point. libcs3 sources were not available, and Lanchon created equivalent ones from scratch. Does the Codesourcery Lite distribution now contain the working code?
I will be running my code on an embedded system that starts cold, so I need startup code to set stack pointers and the like, or I need to know that I must write it.