www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Arduino and D

reply "Ty Tower" <tytower hotmail.com.au> writes:
Has anybody tapped the massive Arduino programming explosion 
using D instead of C++ ?
I got started on Arduino a few years back and it has taken the 
microprocessor popularity through the roof .
Unfortunately you download the IDE (Integrated Development 
Environment) from Arduino.cc direct and then using a $3 
development board with a 328p chip on it ,proceed to program the  
chip to do pretty much whatever you can think of including 
turning stuff on with your mobile from anywhere in the world  and 
much much more .

I wondered if someone could adapt it to D ?
Oct 25 2014
next sibling parent reply "Israel" <tl12000 live.com> writes:
On Saturday, 25 October 2014 at 21:49:53 UTC, Ty Tower wrote:
 Has anybody tapped the massive Arduino programming explosion 
 using D instead of C++ ?
 I got started on Arduino a few years back and it has taken the 
 microprocessor popularity through the roof .
 Unfortunately you download the IDE (Integrated Development 
 Environment) from Arduino.cc direct and then using a $3 
 development board with a 328p chip on it ,proceed to program 
 the  chip to do pretty much whatever you can think of including 
 turning stuff on with your mobile from anywhere in the world  
 and much much more .

 I wondered if someone could adapt it to D ?
Well it is ARM so it should be possible.
Oct 25 2014
parent "Mike" <none none.com> writes:
On Saturday, 25 October 2014 at 22:55:12 UTC, Israel wrote:
 Well it is ARM so it should be possible.
There is a significant difference between ARM and ARM Thumb. ARM (which shares the name of ARM Ltd.) is the architecture primarily used for devices like smartphones, credit card PCs (Raspberry Pi, BeagleBone Black, etc...) and other portable consumer devices. ARM Thumb, on the other hand, is the architecture used for microcontroller programming like the Arduino. ARM is a 32-bit instructions set, and ARM Thumb is 16-bit or a mixture of 16-bit and 32-bit instructions. I've only done ARM Thumb programming, so I can't elaborate on the differences well, but I also believe the two have a different exception model and many other differences. I believe the mainline druntime has pretty good support for ARM, but nothing at all for ARM Thumb. One could probably use D pretty well for the Raspberry Pi, but they're going to have to make their own druntime to program the Arduino. Mike
Oct 25 2014
prev sibling parent reply "Mike" <none none.com> writes:
On Saturday, 25 October 2014 at 21:49:53 UTC, Ty Tower wrote:
 Has anybody tapped the massive Arduino programming explosion 
 using D instead of C++ ?
 I got started on Arduino a few years back and it has taken the 
 microprocessor popularity through the roof .
 Unfortunately you download the IDE (Integrated Development 
 Environment) from Arduino.cc direct and then using a $3 
 development board with a 328p chip on it ,proceed to program 
 the  chip to do pretty much whatever you can think of including 
 turning stuff on with your mobile from anywhere in the world  
 and much much more .

 I wondered if someone could adapt it to D ?
As far as I know, none of the main D compilers (DMD, LDC, GDC) can generate code for 8-bit MCUs. I remember reading somewhere that GDC has turned on a flag that specifically disables it. However, I think it would be cool if a motivated individual would actually flip this flag and see how far they can get. I don't now if avr-gcc is part of the mainline GCC branch, though. In summary, the Atmel ATmega needs some infrastructure first. The ARM Cortex-M based Arduino boards (Arduino Due for example) can already be programmed with D using either the LDC compiler (with ARM Thumb backend) or the GDC compiler. I've encountered several bugs trying to get a bare-bones druntime compiled with the LDC compiler, but the LDC folks have been attentive and appear to be addressing them (Thank you!). A minimal "Hello World" how-to was created on the D Wiki [1] to help users get started with this. There are also instructions for building a GDC cross-compiler on a Linux host [2] (Thank you, GDC!). A presentation was also given at DConf 2014 providing an introduction to some work done on this platform [3]. Most of my work has stalled as I try to find a way to make the experience more polished, and less like patchwork. Bottom line, though, is druntime has not been ported to the ARM Cortex-M platform, so that is the barrier. The good news is that it's not necessary to have the entire druntime ported to do basic C-style programming in D. In fact, a simple object.d file with a few dummy implementations will get you quite far [4]. The current druntime isn't suited very well to bare-metal programming, and really expects an operating system to exist underneath. There have been efforts to try an change that, but they've mostly met resistance. All work on this platform currently exists outside of the main D programming language repositories. There also appears to be a more mature implementation of druntime for an STM32 MCU (ARM Cortex-M4) in minlibd [5]. I hope that gives you some of the information you were looking for. Mike [1] http://wiki.dlang.org/Minimal_semihosted_ARM_Cortex-M_%22Hello_World%22 [2] http://wiki.dlang.org/Bare_Metal_ARM_Cortex-M_GDC_Cross_Compiler [3] https://www.youtube.com/watch?v=o5m0m_ZG9e8 [4] https://github.com/JinShil/D_Runtime_ARM_Cortex-M_study/wiki/1.3-Structs [5] https://bitbucket.org/timosi/minlibd
Oct 25 2014
parent "Trass3r" <un known.com> writes:
 my work has stalled as I try to find a way to make the 
 experience more polished, and less like patchwork.
It's a shame this went nowhere: https://issues.dlang.org/show_bug.cgi?id=12270
Oct 26 2014