Like many others I am looking into the possibilities of expanding the Arduino platform to more powerful microprocessors like the Cortex-M3 (STM32). I have looked at the Corduino and Xduino project, and I am planning to work in the following sequence.
Adapt the Arduino IDE to build non AVR, specifically Cortex-M3 firmware.
Create a simple firmware uploader (similar to avrdude) that can upload firmware to a STM32 target using the onchip ROM Bootloader and use this to program STM32 chips from within the Arduino IDE.
Adapt the basic wiring commands to this target.
Create a very simple STM32 DIP test module.
I have created a CompilerARM class that extends Compiler to build code using arm-none-eabi-gcc from the Codesourcery lite toolchain, and with some minor modifications to the Sketch class this can build firmware for STM32 targets.
I have also created a hardware/cores/stm32 folder with arm specific versions of wiring,c/h etc, and a new entry in boards.txt
I have not yet tested the binaries on my dev board (Olimex STM32_P103), that will be done during next week, but the build completes and both asm listings and map file looks OK.
One problem I have found is that the Library class also calls the cross compiler (avr-gcc), it would be much better if the compilation of library code was done using the target instance of the Compiler class.
I welcome comments and suggestions.
Should the proposed changes be posted here as patches or is it better to setup a separate repository ?
Sounds cool. We typically don't integrate support for non-Arduino hardware to the core distribution, but this will be a great add-on for people using ARM. I'd suggest posting the files and instructions to the Arduino playground.
Also, as of Arduino 0017, the compilation will all be done from Compiler.java (Library.java and LibraryManager.java have been removed).
I'm working on a similar project with a startup called LeafLabs. We have ported the Arduino language to the STM32 and are integrating it into the Arduino environment, and we've built a board.
Magnus, have you posted your code anywhere? I searched on the playground but didn't find it.
My friend, Pete Harrison, got the GNU-based Codesourcery ARM tool chain working under Mac OS X, but I haven't had time to integrate into the Arduino IDE, so I'd be very grateful for that.
I may have some time in September, if you need any help.
I have a couple of STM32F development boards.
The simplest development board is a STAMP-format ET-STM32 which is actually made by ETT ET-ARM STAMP STM32F103/512 in Thailand. I paid $24.90 + $4 postage to the UK from Futurelec for a 512K flash, 64K RAM board, STM32F103RET6.
The other has USB, battery backed clock, prototype area; mine came directly from ETT ET-STM32F103, but is available from Futurlec too. It is only a 128K flash, 20K RAM STM32F103RBT6.
No, not yet. I will look for a practical way of making this work available, perhaps github ?
I can build sketches using the Arduino IDE and upload them to my board using jtag+OpenOCD. The good thing about the jtag solution is that I can use gdb to debug the code, but it is not integrated in the Arduione IDE and an extra JTAG adapter is needed. The support for Timers and analog output is not complete, but digital i/o, ADC and serial ports are all usable.
Then there is the bootloader to work on.
I actually ordered a pair of STM32 stamps from Futurelec yesterday.
Pete found a boot loader, written in python by James Snyder here. AFAIK, this talks to the existing pre-installed STM32F bootloader.
I'm sorry, but I have no strong views on the best way to make your work available. As long as I can get at it from my Mac
Github would be fine for me. Google code would be fine too.
Which version of Arduino IDE are you working with for the compiler interface?
Which JTAG hardware do you use? They seem quite expensive, and I am aiming at schools, who don't have a lot of money, and teenagers who have better things to spend their money on
Those STM32F STAMPS are very good prices, especially as they have 512K/64K MCU's.
One area of potential confusion is the STM32F103RET6 has 2 Channels 12-Bit D/A Converters which run at 0.25Msamples/sec, if I remember correctly, as well as PWM. That D/A is sufficiently different from PWM that I felt like analogWrite wasn't appropriate. A small issue.
I am using v17 and I am also looking into the antipasto_arduino, here the build process is controlled by ant instead of being hardcoded into the Java code in the IDE.
I think that analogWrite should generate a pwm just and use some other command like analogDAC for the real DAC's. There are lots of opportunity for future work here but I also think it is important to keep original Wiring/Arduino comatibility.
Which includes OOCDLink, a family of JTAG links which look low-cost, and includes the Eagle CAD. It is mainly an FT2232D, which is about £4+VAT in the UK.
Both the OpenOCD and OOCDLink sites also identified Turtelizer 2, which is also open hardware.
Magnus, our postings crossed. Thanks for the comment on the home made FTD2232 dongle, that gives me a bit more confidence to make my own.
I think that analogWrite should generate a pwm just and use some other command like analogDAC for the real DAC's.
Yes, I agree, analogWrite should retain its PWM meaning. Something like analogDAC is where I'd got to, I was toying with analogAudio, or analogHifi too
There are lots of opportunity for future work here but I also think it is important to keep original Wiring/Arduino comatibility.
Yes! I completely agree. Compatibility is key to me too, partly because I use Arduino with school children and Im looking for a platform to move to for things like audio and signal processing. Using the same IDE and libraries is a very attractive approach.
This is very early, not the kind of code that should be generated from a planned software design, but rather the result of experimetally trying to bend the Wiring/Arduino code to the STM32 platform, or perhaps the opposite. It is also my first time to use Git as a revision control system.
Anyway, it can always be cleaned up after finding the worst bugs.
Adding these changes to the Arduino IDE should not change the build and upload process for normal AVR Arduinos.
I am using v17 and I am also looking into the antipasto_arduino, here the build process is controlled by ant instead of being hardcoded into the Java code in the IDE.
I had a look at the Java code in Arduino-0012, and it seemed straightforward. What benefit is there from Ant?
As I understand the changes to Arduino-0017, there is a better approach to encapsulating compilation too.
I would prefer to avoid adding extra applications (even Ant, which I have no problem with) to the install by using an ARM-compiler implementation of the IDE classes. Each application adds something more to the build environment which may clash, and requires maintenance.
I basically agree with you, every extra tool/app is potential trouble.
And in 0017 we do not have to add ARM compilation to both Compiler.java and Library.java.
Hardcoding the compiler flags and arguments in a CompilerARM, and then CompilerAVR32 ..., class is quite simple but not flexible and easy to adapt to different target specifications.
The middle road is to use toolchain names, paths and build flags as options in the core preferences files, boards.txt
The other end of the spectrum is to use Ant where we only need a very simple Compiler.java class and all build details are softcoded into the build.xml file. I would like know more about this. My problem here is that all the Illuminati/Antipasto distributions that I have seen so far, including the latest from today and git downloads, are missing the the ant build files and refuse to build any Arduino sketches on my system.
The xduino project uses "almost" Wiring/Arduino sketches, actually standard C/C++ main functions with som Wiring like library functions. And the IDE is new. Arduino sketches cannot be moved as they are.
So for the moment my preferred setup is one CompilerARM class in the standard Arduino IDE.
For high power projects with lots of interrups, DMA and high speed interrups I would write directly against the Codesourcery toolchan, use JTAG and ddd+gdb for debugging and OpenOCD as the debug link.
I have now received a new STM32 module, placed it in a breadborad, added 3.3V power and some LED's to emulate an Arduino like board. There is also a new avrdude like uploader, called stmdude. This has been integrated into the Arduino IDE so now I can build sketches, upload them to the STM32 board from the IDE and then switch to serial monitor to watch and communicate with the sketch.
Sketches that uses standard Arduino/Wiring command and does not directly access AVR hardware register mostly work out of the box. Some pin numbering can be necessary.
I assume stmdude uses the pre-installed STM32F bootloader?
I'm afraid I'll only be cheering "from the stands" for a while, I don't have time to follow at the moment, but I look forward to wiring up my ET-STAMP-STM32's and giving it a shot.
(I don't know if you tracked down the ET-STAMP-STM32 boards to their manufacturer, ett.co.th, where they are approximately ?12.80)
BTW - Future Electronics (futureelectronics.com not futurlec) are selling the STM32F105's (USB-OTG) and STM32F107's (Ethernet & USB-OTG) chips at ridiculously good prices, so I bought a few.
This is awesome, especially since it should be able to work cross platform (at the minute I am losing my mind trying to get stm32 dev running on my mac)
Hey guys... sorry for bringing this thread back from the dead, but... is there anything new about this project? I have the STM32 Discovery kit and am trying to find a way to program it with an Arduino-like tool. I've been looking into Xduino, but am not sure it'll work... if anyone has any idea about what should I try, any suggestions are welcome
Maple is based on an STM32F103RB, so not the same animal as the STM32F100 board, but a very, very close relative of the STM32F103-based board
The Maple IDE is a fork of the Arduino IDE.
Many of the Arduino examples work, or have been made to work
The tools generate and upload like an Arduino if you use the Maple bootloader.
I believe there is someone posting on the LeafLabs forum trying to get a Discovery board working.
it's a STM32F100 board, the closest thing to a Open Source IDE I've found working with it is Atollic, but while it's a powerful Eclipse-based environment, it's an overkill for me. I'm not a total newbie, but not an expert either.
I'll take a look at the LeafLabs forum, maybe it'll help. It would be really, really cool to be able to use the $10 board (actually, got it for free) with a language I feel comfortable with.