www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - ARM bare-metal programming in D

reply "Mike" <none none.com> writes:
Hello,

This is my first post here, but I've been warching D for the past 
year and a half.

I currently build small bare-metal (no OS) ARM Cortex-M1/4 
embedded system.  These targets typically have less than 1MB of 
program memory, less than 512KB of embedded RAM, and run at less 
than 200MHz.  I currently use C, C++, and assembly, but would 
very much like to add D to this mix, hopefully removing the Cs 
completely.

Language Questions:
1. Is D or WiLL D be a suitable language for these targets?
2. Is the D runtime required for bare metal programming? In other 
words, if the D runtime has not yet been ported to these targets, 
how far can one get using just D the language?

Compiler Questions:
1. What is the status of LDC & GDC for these bare-metal targets?  
Is DMD even in this game?
2. If not ARM Cortex, can any of the D compilers target Intel's 
Quark processor?

Finally, if D is not yet ready for these targets, but would like 
to be, what work remains to be done to get it there.

Looking forward to your thoughtful answers.

Mike
Oct 21 2013
next sibling parent reply "evilrat" <evilrat666 gmail.com> writes:
(from what i already know from forums)

On Monday, 21 October 2013 at 23:43:45 UTC, Mike wrote:
 Language Questions:
 1. Is D or WiLL D be a suitable language for these targets?
it is possible, but no work done to make it happens.
 2. Is the D runtime required for bare metal programming? In 
 other words, if the D runtime has not yet been ported to these 
 targets, how far can one get using just D the language?
D runtime required if you need all that cool features like slices, GC and other stuff. but you can use D without it. some runtime/phobos ports for ARM already exists but i don't know which or what status they are.
 Compiler Questions:
 1. What is the status of LDC & GDC for these bare-metal 
 targets?  Is DMD even in this game?
GCC(GDC) naturally has more platforms supported, but LLVM(LDC) at least has ARM too.
 2. If not ARM Cortex, can any of the D compilers target Intel's 
 Quark processor?
ummm... is this x86 right? so what problem? (is this actually launched in production? 0_0)
 Finally, if D is not yet ready for these targets, but would 
 like to be, what work remains to be done to get it there.

 Looking forward to your thoughtful answers.
as you can see D naturally fits for most system programming tasks. community just need more people who can bring this to D! so why no pick some ARM port and make it complete? p.s. i think the only reason D doesn't have ARM and MIPS already is because Walter don't know asm for this architectures :)
Oct 21 2013
next sibling parent Martin Nowak <code dawg.eu> writes:
On 10/22/2013 05:07 AM, evilrat wrote:
 D runtime required if you need all that cool features like slices, GC
 and other stuff. but you can use D without it. some runtime/phobos ports
 for ARM already exists but i don't know which or what status they are.
Slices don't need runtime support, they're a pointer and a length after all. Appending to slices does because it needs to allocate memory.
 p.s. i think the only reason D doesn't have ARM and MIPS already is
 because Walter don't know asm for this architectures :)
I've also used GDC on a MIPS router with linux. This should actually work (unless we broke it). There is even Fiber support on MIPS_O32.
Oct 21 2013
prev sibling parent "Joakim" <joakim airpost.net> writes:
On Tuesday, 22 October 2013 at 03:07:02 UTC, evilrat wrote:
 (from what i already know from forums)

 On Monday, 21 October 2013 at 23:43:45 UTC, Mike wrote:
 Language Questions:
2. If not ARM Cortex, can any of the D compilers target
 Intel's Quark processor?
ummm... is this x86 right? so what problem? (is this actually launched in production? 0_0)
I didn't know what Quark was either so I just looked it up: http://www.anandtech.com/show/7305/intel-announces-quark-soc-a-tiny-soc-for-tiny-devices Apparently it's Intel's play for the internet of things, an extremely tiny x86 SoC that slots under Atom even.
Oct 31 2013
prev sibling next sibling parent reply Martin Nowak <code dawg.eu> writes:
On 10/22/2013 01:43 AM, Mike wrote:
 Hello,

 This is my first post here, but I've been warching D for the past year
 and a half.

 I currently build small bare-metal (no OS) ARM Cortex-M1/4 embedded
 system.  These targets typically have less than 1MB of program memory,
 less than 512KB of embedded RAM, and run at less than 200MHz.  I
 currently use C, C++, and assembly, but would very much like to add D to
 this mix, hopefully removing the Cs completely.

 Language Questions:
 1. Is D or WiLL D be a suitable language for these targets?
I have successfully ran D programs on a STM32F1 and STM32F4.
 2. Is the D runtime required for bare metal programming? In other words,
 if the D runtime has not yet been ported to these targets, how far can
 one get using just D the language?
The compiler needs quite some runtime support functions for certain language features (GC, AA, array ops...). D is targeting OS based machines currently. A lot of druntime (GC, threads, time) is not a good fit for bare-metal targets. You can still benefit a lot from the nicer C parts of D.
 Compiler Questions:
 1. What is the status of LDC & GDC for these bare-metal targets? Is DMD
 even in this game?
DMD is not, GDC and AFAIK LDC can be compiled for ARM targets, it's somewhat involved though.
 2. If not ARM Cortex, can any of the D compilers target Intel's Quark
 processor?
Don't know about that.
 Finally, if D is not yet ready for these targets, but would like to be,
 what work remains to be done to get it there.
https://bitbucket.org/timosi/minlibd
Oct 21 2013
parent "Timo Sintonen" <t.sintonen luukku.com> writes:
On Tuesday, 22 October 2013 at 03:29:19 UTC, Martin Nowak wrote:
 On 10/22/2013 01:43 AM, Mike wrote:
Language Questions:
 1. Is D or WiLL D be a suitable language for these targets?
I have successfully ran D programs on a STM32F1 and STM32F4.
 2. Is the D runtime required for bare metal programming? In 
 other words,
 if the D runtime has not yet been ported to these targets, how 
 far can
 one get using just D the language?
The compiler needs quite some runtime support functions for certain language features (GC, AA, array ops...). D is targeting OS based machines currently. A lot of druntime (GC, threads, time) is not a good fit for bare-metal targets. You can still benefit a lot from the nicer C parts of D.
 https://bitbucket.org/timosi/minlibd
This repo contains a working environment for GDC. Just updated some documents there. The sample program is not yet complete but I have a working one and try to upload it today. I have used this in STM32F407. 64 k rom and 64 k ram is enough to run a small program.
Oct 21 2013
prev sibling parent reply Manu <turkeyman gmail.com> writes:
On 22 October 2013 09:43, Mike <none none.com> wrote:

 Hello,

 This is my first post here, but I've been warching D for the past year and
 a half.

 I currently build small bare-metal (no OS) ARM Cortex-M1/4 embedded
 system.  These targets typically have less than 1MB of program memory, less
 than 512KB of embedded RAM, and run at less than 200MHz.  I currently use
 C, C++, and assembly, but would very much like to add D to this mix,
 hopefully removing the Cs completely.

 Language Questions:
 1. Is D or WiLL D be a suitable language for these targets?
 2. Is the D runtime required for bare metal programming? In other words,
 if the D runtime has not yet been ported to these targets, how far can one
 get using just D the language?

 Compiler Questions:
 1. What is the status of LDC & GDC for these bare-metal targets?  Is DMD
 even in this game?
 2. If not ARM Cortex, can any of the D compilers target Intel's Quark
 processor?

 Finally, if D is not yet ready for these targets, but would like to be,
 what work remains to be done to get it there.

 Looking forward to your thoughtful answers.
I've run D code on bare-metal MIPS (a Sony PSP) using a GCC toolchain, and there are lots of stories of success with ARM. I'm very anxious for a Bionic (Android) druntime to surface. Work has been done.
Oct 22 2013
parent reply "Andrew" <andrew nowhere.com> writes:
I've been wrestling to get any version of a D compiler working on 
a pretty standard Debian distribution on ARM and it's a lost 
cause at the moment.

DMD doesn't support ARM,
LDC builds and can compile but any app crashes on launch,
GDC builds and can compile and can even run Hello World but 
anything that requires memory allocation crashes deep inside the 
d-runtime when it tries to jump to 0x0.

I think there is a lot of work to do to get ARM properly 
supported yet.

Regards

Andrew
Oct 23 2013
parent "David Nadlinger" <code klickverbot.at> writes:
On Wednesday, 23 October 2013 at 17:27:01 UTC, Andrew wrote:
 LDC builds and can compile but any app crashes on launch
Could you please report this issue on the LDC bugtracker (along with your system specs, ldc2 -version, ldc2 -vv helloworld.d | head -n1 and a backtrace)? You can't really expect anything to function on ARM right now, but a simple Hello World should work fine. David
Oct 23 2013