ARMduino - a generic implementation of Arduino on ARM Cortex-M chips

Cores are the underlying magic that make the Arduino API possible
dannyf
Posts: 167
Joined: Wed May 11, 2016 4:29 pm

ARMduino - a generic implementation of Arduino on ARM Cortex-M chips

Post by dannyf » Sat May 27, 2017 1:19 pm

All:

have been a user of STM32Duino for a while and liked its simplicity but not the IDE. Never bothered to do anything about it, however.

Only recently a friend of mine got me thinking of porting Arduino to some PIC24F/dsPIC chips and I started to take the same approach to port Arduino on STM8S chips.

Once that's done, I took it to a more modular level and got the code running on a generic Cortex-M chip - in this case, a STM32F100 chip on the STM32VLDiscovery board. Otherwise, the code should also work for STM32F10x chips.

The implementation is fairly barebone at this point, but most Arduino functions are implemented, short of serial comm, analog read/write and external interrupts.

It is implemented via a layered / compartmentalized approach where hardware dependent code is separated from hardware independent code, allowing the user to hook in different modules for his/her target mcu and the code will compile and run with no or minimum changes.

So far, I have got it running on STM32F100/103, MSP432 and LM4F120. The details / code are available here: https://dannyelectronics.wordpress.com/ ... x-m-chips/

it is not complete so watch out for updates -> the code is now at v0.11, vs. v0.10 posted, for example.

Your comments are greatly appreciated.

ChrisMicro
Posts: 308
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: ARMduino - a generic implementation of Arduino on ARM Cortex-M chips

Post by ChrisMicro » Sat May 27, 2017 3:25 pm

Hi Danny,

do you know the STM32GENERIC project? There you can easily add every board you have.

STM also started to support more MCUs:
viewtopic.php?f=48&t=2098

User avatar
Rick Kimball
Posts: 1053
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: ARMduino - a generic implementation of Arduino on ARM Cortex-M chips

Post by Rick Kimball » Sat May 27, 2017 4:23 pm

You might want to move your post to the "Cores" section so more people will see it:

http://www.stm32duino.com/viewforum.php?f=42
-rick

User avatar
Rick Kimball
Posts: 1053
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: ARMduino - a generic implementation of Arduino on ARM Cortex-M chips

Post by Rick Kimball » Sat May 27, 2017 4:28 pm

I see you have a PIC24F port, how are you going to deal with C++ libraries? Aren't those compilers 'C' only or did they add C++?
-rick

User avatar
RogerClark
Posts: 7413
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: ARMduino - a generic implementation of Arduino on ARM Cortex-M chips

Post by RogerClark » Sat May 27, 2017 9:10 pm

BTW.

Several other people and already use the name ARMduino

https://www.google.com.au/search?q=armduino

I dont think its trademarked, but it is rather confusinb if you search for that term

PS. i also moved it to Cores

PPS.

As well as @danieleff's STMGeneric core, and STMs own Cores, there is Koduino which is also an Arduino core for STM32F3 and STM32F4, plus our old faithful of Libmaple, plus several abandoned cores like the MakerlabMe core

However you core appears to be the only core that spans different manufacturers, apart from of course mbed
But mbed is not Arduino, its just a similar dev paradigm

User avatar
Kenjutsu
Posts: 134
Joined: Fri May 29, 2015 8:26 am

Re: ARMduino - a generic implementation of Arduino on ARM Cortex-M chips

Post by Kenjutsu » Sun May 28, 2017 1:50 pm

dannyf wrote:... I started to take the same approach to port Arduino on STM8S chips.
I would love to see how to do this for the STM8S ;)
Pieter

OSX: 10.12.6
Arduino IDE: 1.6.12
Blue pill STM32F103C8T6 Dev Board
Maple Mini Clones

dannyf
Posts: 167
Joined: Wed May 11, 2016 4:29 pm

Re: ARMduino - a generic implementation of Arduino on ARM Cortex-M chips

Post by dannyf » Sun May 28, 2017 3:11 pm

Chris: didn't know the stm32generic project. thanks. a lot of similarities there:

1. our approaches to gpio are identical.
2. the stm32generic project isolated the device-specific things into individual files.

we differ in that his aim is to produce a generic template for STM32, and my goal is to produce a generic template for all ARM chpis - but not writing the device-specific things myself.

but two projects are quite expandable into each other's spheres.

Rick: i'm taking a C-approach to the porting so all Cpp functions have to be replicated in C, sometimes with slightly different names. like Random(min, max) gets maxed to Random2(min, max), as the Random(max) already exists.

Ken: the STM8S project is linked on the ARMduino page but you can click it here: https://dannyelectronics.wordpress.com/ ... tm8s-mcus/

I just ported the analogWrite() and analogRead() functions but have not had the time to update the code yet. will do that later.

User avatar
Rick Kimball
Posts: 1053
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: ARMduino - a generic implementation of Arduino on ARM Cortex-M chips

Post by Rick Kimball » Sun May 28, 2017 3:44 pm

dannyf wrote:Rick: i'm taking a C-approach to the porting so all Cpp functions have to be replicated in C, sometimes with slightly different names. like Random(min, max) gets maxed to Random2(min, max), as the Random(max) already exists.
Sadly, the problem with that approach is that you miss out on all the rich libraries that people have written for the Arduino platform. I think it is unlikely people will port C++ libraries to C to work with your core. The 3rd party libraries are why people put up with the inefficient Arduino platform in the first place. At least that is how I see it.
-rick

User avatar
RogerClark
Posts: 7413
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: ARMduino - a generic implementation of Arduino on ARM Cortex-M chips

Post by RogerClark » Sun May 28, 2017 9:51 pm

Rick Kimball wrote:....

Sadly, the problem with that approach is that you miss out on all the rich libraries that people have written for the Arduino platform. I think it is unlikely people will port C++ libraries to C to work with your core. The 3rd party libraries are why people put up with the inefficient Arduino platform in the first place. At least that is how I see it.
I totally agree.

The libraries are the main reason that people use Arduino.


Most manufacturers SDKs / APIs now seem to make it fairly easy to use GPIO and SPI etc, so that less of a draw card for Arduino, but nothing else has the wealth of prewritten libraries for a massive range of hardware.

dannyf
Posts: 167
Joined: Wed May 11, 2016 4:29 pm

Re: ARMduino - a generic implementation of Arduino on ARM Cortex-M chips

Post by dannyf » Mon May 29, 2017 1:32 pm

" Sadly, the problem with that approach is"

Unfortunately true: if the compiler doesn't support cop, there is no way around that.

But if you step back and the situation may be a little different, as you have two options here:

1. Don't support Arduino as the compiler doesn't support all Arduino code. Or

2. Support at least some Arduino code (those coded in C).

I took the later approach knowing that some of the cop code will have to be rewritten.

The downside of that approach, particularly to the Arduino crowd, is that they may find it too challenging to e ven attempt.

But then you are no different from if you had taken approach 1.

So approach 2 gives you some upside but no downside.

Post Reply