www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Embedded Linux really needs Dlang for the IOT market

reply dangbinghoo <dbh625 126.com> writes:
hi all,

I think the D community should make more effort to make Dlang 
more easier to use on embedded Linux(mostly are arm and mips, 
powerpc).

currently, LDC seems to be more complete, but we can only see a 
hundred words on the wiki about the cross-compiling for arm.

I'm working in a company now for IOT market. We have a lot of 
things like embedded linux systems: has a basic linux kernel, 
uclibc/eglibc system, built using buildroot or yocto.

for such a device, we need to write lost of code for dealing 
networking, web interface, database storage and sometimes data 
algorithm.

And, For most of the devices on the market, like routers, 
fiber-port routers, ethernet switches, and most of the 
termination system made by Cisco, Broadcom, Huawei and others 
running at least millions of lines of C code on the embedded 
linux system.

So, We have very big chance for spreading to these market. D is 
really syntax-clean and provides more productive.

We need tutorial for cross-compiling a whole d project for the 
ARM, MIPS linux systems, and we need the cross-compile toolchain 
ready to download.

so, any ideas?
Mar 08 2018
next sibling parent rikki cattermole <rikki cattermole.co.nz> writes:
On 09/03/2018 4:09 PM, dangbinghoo wrote:
 hi all,
 
 I think the D community should make more effort to make Dlang more 
 easier to use on embedded Linux(mostly are arm and mips, powerpc).
 
 currently, LDC seems to be more complete, but we can only see a hundred 
 words on the wiki about the cross-compiling for arm.
 
 I'm working in a company now for IOT market. We have a lot of things 
 like embedded linux systems: has a basic linux kernel, uclibc/eglibc 
 system, built using buildroot or yocto.
 
 for such a device, we need to write lost of code for dealing networking, 
 web interface, database storage and sometimes data algorithm.
 
 And, For most of the devices on the market, like routers, fiber-port 
 routers, ethernet switches, and most of the termination system made by 
 Cisco, Broadcom, Huawei and others running at least millions of lines of 
 C code on the embedded linux system.
 
 So, We have very big chance for spreading to these market. D is really 
 syntax-clean and provides more productive.
 
 We need tutorial for cross-compiling a whole d project for the ARM, MIPS 
 linux systems, and we need the cross-compile toolchain ready to download.
 
 so, any ideas?
Your best bet is to throw some developer time + money at the ldc devs. They may need more CI's or help automating builds idk, best to ask them on their issue tracker on how you can contribute. But most importantly, use it in some form.
Mar 08 2018
prev sibling next sibling parent reply Joakim <dlang joakim.fea.st> writes:
On Friday, 9 March 2018 at 03:09:16 UTC, dangbinghoo wrote:
 hi all,

 I think the D community should make more effort to make Dlang 
 more easier to use on embedded Linux(mostly are arm and mips, 
 powerpc).

 currently, LDC seems to be more complete, but we can only see a 
 hundred words on the wiki about the cross-compiling for arm.
A wiki search shows me dozens of pages that mention ARM: https://wiki.dlang.org/?search=arm Maybe you're talking about the ARM section in the main LDC page, but that links to those other pages.
 I'm working in a company now for IOT market. We have a lot of 
 things like embedded linux systems: has a basic linux kernel, 
 uclibc/eglibc system, built using buildroot or yocto.

 for such a device, we need to write lost of code for dealing 
 networking, web interface, database storage and sometimes data 
 algorithm.

 And, For most of the devices on the market, like routers, 
 fiber-port routers, ethernet switches, and most of the 
 termination system made by Cisco, Broadcom, Huawei and others 
 running at least millions of lines of C code on the embedded 
 linux system.

 So, We have very big chance for spreading to these market. D is 
 really syntax-clean and provides more productive.
You will be interested in the uClibc port that's being finished up upstream and will likely be in the upconing ldc 1.9 then, along with the betterC version of D that is supported by ldc (assuming you can't use the D runtime and garbage-collector): https://github.com/dlang/druntime/pull/2134 https://dlang.org/spec/betterc.html
 We need tutorial for cross-compiling a whole d project for the 
 ARM, MIPS linux systems, and we need the cross-compile 
 toolchain ready to download.

 so, any ideas?
You should talk to Mike and Radu, they have both expressed interest in this and are working towards taking D there: https://github.com/jinshil https://github.com/rracariu As for the cross-compile toolchain, we can make ldc work for these platforms, but you will likely always need to download the existing C cross-compilation toolchain for these embedded platforms separately, as we rely on the existing linker for these platforms to link D executables. Also, there are a few C and assembly source files in the D runtime that require a C cross-compiler to build, so we cannot just do everything in the D compiler. See these wiki pages about the ldc-build-runtime tool that comes with ldc and Android cross-compilation, which uses the C cross-compiler and linker from the Android NDK, for examples of what I'm talking about: https://wiki.dlang.org/Building_LDC_runtime_libraries https://wiki.dlang.org/Build_D_for_Android And given how many embedded toolchains are out there, I doubt we can ever cover many of them beforehand. We could probably put out a tutorial for some popular toolchain, but first we need to get it completely working, which AFAIK is still being worked on. If you'd like to chip in with that, as Rikki says, please talk to the ldc devs or Mike and Radu.
Mar 08 2018
parent dangbinghoo <dbh625 126.com> writes:
On Friday, 9 March 2018 at 05:56:50 UTC, Joakim wrote:

 [...]
And given how many embedded toolchains are out there, I doubt we can ever cover many of them beforehand. We could probably put out a tutorial for some popular toolchain, but first we need to get it completely working, which AFAIK is still being worked on. If you'd like to chip in with that, as Rikki says, please talk to the ldc devs or Mike and Radu.
thanks for your detailed explanation. maybe currently I can just use LDC arm native compiler.
Mar 08 2018
prev sibling next sibling parent reply Andre Pany <andre s-e-a-p.de> writes:
On Friday, 9 March 2018 at 03:09:16 UTC, dangbinghoo wrote:
 hi all,

 I think the D community should make more effort to make Dlang 
 more easier to use on embedded Linux(mostly are arm and mips, 
 powerpc).

 currently, LDC seems to be more complete, but we can only see a 
 hundred words on the wiki about the cross-compiling for arm.

 I'm working in a company now for IOT market. We have a lot of 
 things like embedded linux systems: has a basic linux kernel, 
 uclibc/eglibc system, built using buildroot or yocto.

 for such a device, we need to write lost of code for dealing 
 networking, web interface, database storage and sometimes data 
 algorithm.

 And, For most of the devices on the market, like routers, 
 fiber-port routers, ethernet switches, and most of the 
 termination system made by Cisco, Broadcom, Huawei and others 
 running at least millions of lines of C code on the embedded 
 linux system.

 So, We have very big chance for spreading to these market. D is 
 really syntax-clean and provides more productive.

 We need tutorial for cross-compiling a whole d project for the 
 ARM, MIPS linux systems, and we need the cross-compile 
 toolchain ready to download.

 so, any ideas?
I have a tutorial for raspberry py cross compilation from windows. It is on german but Google translator does give you a good English translation. http://d-land.sepany.de/einstieg-in-die-raspberry-pi-entwicklung-mit-ldc.html Kind regards André
Mar 08 2018
parent dangbinghoo <dbh625 126.com> writes:
On Friday, 9 March 2018 at 06:13:01 UTC, Andre Pany wrote:
 On Friday, 9 March 2018 at 03:09:16 UTC, dangbinghoo wrote:
 [...]
I have a tutorial for raspberry py cross compilation from windows. It is on german but Google translator does give you a good English translation. http://d-land.sepany.de/einstieg-in-die-raspberry-pi-entwicklung-mit-ldc.html Kind regards André
thanks for the share!
Mar 08 2018
prev sibling next sibling parent reply Jacob Carlborg <doob me.com> writes:
On Friday, 9 March 2018 at 03:09:16 UTC, dangbinghoo wrote:

 We need tutorial for cross-compiling a whole d project for the 
 ARM, MIPS linux systems, and we need the cross-compile 
 toolchain ready to download.

 so, any ideas?
LDC can cross-compile to various platforms, you just need a cross-linker and the system libraries. There's a Docker image that provides cross-compilers for various targets [1]. That image will provide a cross-linker and system libraries. I've created a Docker image based on the crossbuild image that contains LDC [2]. It targets macOS but it should be straightforward to adopt it to targeting ARM. [1] https://hub.docker.com/r/multiarch/crossbuild [2] https://github.com/jacob-carlborg/docker-ldc-darwin/blob/master/Dockerfile -- /Jacob Carlborg
Mar 08 2018
next sibling parent reply Sebastiaan Koppe <mail skoppe.eu> writes:
On Friday, 9 March 2018 at 07:56:12 UTC, Jacob Carlborg wrote:
 LDC can cross-compile to various platforms, you just need a 
 cross-linker and the system libraries. There's a Docker image 
 that provides cross-compilers for various targets [1]. That 
 image will provide a cross-linker and system libraries. I've 
 created a Docker image based on the crossbuild image that 
 contains LDC [2]. It targets macOS but it should be 
 straightforward to adopt it to targeting ARM.

 [1] https://hub.docker.com/r/multiarch/crossbuild
 [2] 
 https://github.com/jacob-carlborg/docker-ldc-darwin/blob/master/Dockerfile

 --
 /Jacob Carlborg
Awesome. Is this in a wiki somewhere? I wanted to do mips couple of months ago, and this would have definitely helped.
Mar 09 2018
parent Jacob Carlborg <doob me.com> writes:
On Friday, 9 March 2018 at 08:42:11 UTC, Sebastiaan Koppe wrote:

 Awesome. Is this in a wiki somewhere?
Not as far as I know. Feel free to add it. -- /Jacob Carlborg
Mar 09 2018
prev sibling parent Binghoo Dang <dangbinghoo gmail.com> writes:
On Friday, 9 March 2018 at 07:56:12 UTC, Jacob Carlborg wrote:
 [...]
straightforward to adopt it to targeting ARM. [1] https://hub.docker.com/r/multiarch/crossbuild [2] https://github.com/jacob-carlborg/docker-ldc-darwin/blob/master/Dockerfile -- /Jacob Carlborg
thanks for sharing!
Mar 09 2018
prev sibling next sibling parent reply Radu <void null.pt> writes:
On Friday, 9 March 2018 at 03:09:16 UTC, dangbinghoo wrote:
 hi all,

 I think the D community should make more effort to make Dlang 
 more easier to use on embedded Linux(mostly are arm and mips, 
 powerpc).

 currently, LDC seems to be more complete, but we can only see a 
 hundred words on the wiki about the cross-compiling for arm.

 I'm working in a company now for IOT market. We have a lot of 
 things like embedded linux systems: has a basic linux kernel, 
 uclibc/eglibc system, built using buildroot or yocto.

 for such a device, we need to write lost of code for dealing 
 networking, web interface, database storage and sometimes data 
 algorithm.

 And, For most of the devices on the market, like routers, 
 fiber-port routers, ethernet switches, and most of the 
 termination system made by Cisco, Broadcom, Huawei and others 
 running at least millions of lines of C code on the embedded 
 linux system.

 So, We have very big chance for spreading to these market. D is 
 really syntax-clean and provides more productive.

 We need tutorial for cross-compiling a whole d project for the 
 ARM, MIPS linux systems, and we need the cross-compile 
 toolchain ready to download.

 so, any ideas?
I'm working in BAS(Building Automation System) sector, and I use Dlang daily for some advance products targeting ARM/Mips boards. D on Glibc/Linux/ARM works great today! It is well supported and getting LDC to cross-compile is as easy as those 100 and so words say! I'm using Ubuntu shell on Windows (WSL) and this makes things even more exciting. Actually the hardest part is getting the C cross tool-chain for your system, not LDC, I find this pretty amusing. Recently I had to port the software to uClibc/Linux/ARM, hence my latest efforts on the port have followed with some patches for Druntime, Phobos and LDC. I think, minus 2 PRs, it is pretty close to complete. On my target system I've got it working including vibe.d. I suggest that you give it a try, and if you find issues contribute!
Mar 09 2018
next sibling parent reply aberba <karabutaworld gmail.com> writes:
On Friday, 9 March 2018 at 09:12:28 UTC, Radu wrote:
 On Friday, 9 March 2018 at 03:09:16 UTC, dangbinghoo wrote:
 [...]
I'm working in BAS(Building Automation System) sector, and I use Dlang daily for some advance products targeting ARM/Mips boards. D on Glibc/Linux/ARM works great today! It is well supported and getting LDC to cross-compile is as easy as those 100 and so words say! I'm using Ubuntu shell on Windows (WSL) and this makes things even more exciting. Actually the hardest part is getting the C cross tool-chain for your system, not LDC, I find this pretty amusing.
A tutorial or guide on "cross tool-chain for your system" will be very helpful. Say in ARM. Not that obvious to someone like me.
 Recently I had to port the software to uClibc/Linux/ARM, hence 
 my latest efforts on the port have followed with some patches 
 for Druntime, Phobos and LDC. I think, minus 2 PRs, it is 
 pretty close to complete. On my target system I've got it 
 working including vibe.d.
Nice. Vibe.d sound great!! Especially for IoT stuff. Get some Pi to talk to APIs and services.
 I suggest that you give it a try, and if you find issues 
 contribute!
Mar 09 2018
next sibling parent reply Radu <void null.pt> writes:
On Friday, 9 March 2018 at 11:35:58 UTC, aberba wrote:
 On Friday, 9 March 2018 at 09:12:28 UTC, Radu wrote:
 On Friday, 9 March 2018 at 03:09:16 UTC, dangbinghoo wrote:
 [...]
I'm working in BAS(Building Automation System) sector, and I use Dlang daily for some advance products targeting ARM/Mips boards. D on Glibc/Linux/ARM works great today! It is well supported and getting LDC to cross-compile is as easy as those 100 and so words say! I'm using Ubuntu shell on Windows (WSL) and this makes things even more exciting. Actually the hardest part is getting the C cross tool-chain for your system, not LDC, I find this pretty amusing.
A tutorial or guide on "cross tool-chain for your system" will be very helpful. Say in ARM. Not that obvious to someone like me.
 Recently I had to port the software to uClibc/Linux/ARM, hence 
 my latest efforts on the port have followed with some patches 
 for Druntime, Phobos and LDC. I think, minus 2 PRs, it is 
 pretty close to complete. On my target system I've got it 
 working including vibe.d.
Nice. Vibe.d sound great!! Especially for IoT stuff. Get some Pi to talk to APIs and services.
 I suggest that you give it a try, and if you find issues 
 contribute!
For LDC on ubuntu is is pretty straight forward 1. Get cross tools for ARM, let's say ARM HF (hardware floating point)
 sudo apt-get install gcc-arm-linux-gnueabihf
2. Install LDC 3. Build cross libraries for LDC From https://wiki.dlang.org/Building_LDC_runtime_libraries:
mkdir ldc-arm-linux-hf
cd ldc-arm-linux-hf
CC=arm-linux-gnueabihf-gcc ldc-build-runtime 
--dFlags="-w;-mtriple=arm-linux-gnueabihf" 
--targetSystem="Linux;UNIX"
Your cross compiled druntime and phobos libs will be the result of this step, they are located in the `/path/to/ldc-arm-linux-hf/lib` folder. 4. Compile your code
ldc2 -mtriple=arm-linux-gnueabihf -gcc=arm-linux-gnueabihf-gcc 
-L=-L/path/to/ldc-arm-linux-hf/lib awesome.d
You now have an linux arm hf binary that can run on your target device.
Mar 09 2018
parent dangbinghoo <dbh625 126.com> writes:
On Friday, 9 March 2018 at 14:30:44 UTC, Radu wrote:
 On Friday, 9 March 2018 at 11:35:58 UTC, aberba wrote:
 [...]
For LDC on ubuntu is is pretty straight forward 1. Get cross tools for ARM, let's say ARM HF (hardware floating point)
 [...]
2. Install LDC 3. Build cross libraries for LDC From https://wiki.dlang.org/Building_LDC_runtime_libraries:
[...]
Your cross compiled druntime and phobos libs will be the result of this step, they are located in the `/path/to/ldc-arm-linux-hf/lib` folder. 4. Compile your code
[...]
You now have an linux arm hf binary that can run on your target device.
wow ! this is the real tutorial! thanks!
Mar 10 2018
prev sibling parent reply Cym13 <cpicard openmailbox.org> writes:
On Friday, 9 March 2018 at 11:35:58 UTC, aberba wrote:
 On Friday, 9 March 2018 at 09:12:28 UTC, Radu wrote:
 On Friday, 9 March 2018 at 03:09:16 UTC, dangbinghoo wrote:
 [...]
I'm working in BAS(Building Automation System) sector, and I use Dlang daily for some advance products targeting ARM/Mips boards. D on Glibc/Linux/ARM works great today! It is well supported and getting LDC to cross-compile is as easy as those 100 and so words say! I'm using Ubuntu shell on Windows (WSL) and this makes things even more exciting. Actually the hardest part is getting the C cross tool-chain for your system, not LDC, I find this pretty amusing.
A tutorial or guide on "cross tool-chain for your system" will be very helpful. Say in ARM. Not that obvious to someone like me.
Looks like this gem went unnoticed for too long: https://fkromer.gitbooks.io/d-on-embedded-linux-arm/content/
Mar 10 2018
parent aberba <karabutaworld gmail.com> writes:
On Saturday, 10 March 2018 at 19:52:50 UTC, Cym13 wrote:
 On Friday, 9 March 2018 at 11:35:58 UTC, aberba wrote:
 On Friday, 9 March 2018 at 09:12:28 UTC, Radu wrote:
 [...]
A tutorial or guide on "cross tool-chain for your system" will be very helpful. Say in ARM. Not that obvious to someone like me.
Looks like this gem went unnoticed for too long: https://fkromer.gitbooks.io/d-on-embedded-linux-arm/content/
Wow!
Mar 10 2018
prev sibling parent reply Binghoo Dang <dangbinghoo gmail.com> writes:
On Friday, 9 March 2018 at 09:12:28 UTC, Radu wrote:
 [...]
I'm working in BAS(Building Automation System) sector, and I use Dlang daily for some advance products targeting ARM/Mips boards. [...]
That's great, it looks that what I need to do is just try! And, I would write a paper after I get everything working. thanks!
Mar 09 2018
parent Martin Tschierschke <mt smartdolphin.de> writes:
On Friday, 9 March 2018 at 12:41:52 UTC, Binghoo Dang wrote:
 On Friday, 9 March 2018 at 09:12:28 UTC, Radu wrote:
 [...]
I'm working in BAS(Building Automation System) sector, and I use Dlang daily for some advance products targeting ARM/Mips boards. [...]
That's great, it looks that what I need to do is just try! And, I would write a paper after I get everything working. thanks!
Yes, please write down your steps to success and place it somewhere it can be found :-) (https://wiki.dlang.org/) There is not to much documentation!
Mar 10 2018
prev sibling parent Andrea Fontana <nospam example.com> writes:
On Friday, 9 March 2018 at 03:09:16 UTC, dangbinghoo wrote:
 hi all,

 I think the D community should make more effort to make Dlang 
 more easier to use on embedded Linux(mostly are arm and mips, 
 powerpc).
My IOT server works in D. I use it for home heating and also for my room lamp. Single devices (sensor) are written in C but I hope d+better c could replace it.
Mar 11 2018