2 ms·
You need to pass --gc:none when compiling so that the compiler warns you when you try to use a garbage collected type and instead of the stdlib, use the SDK fac
by mratsim 8y ago
You need to pass --gc:none when compiling so that the compiler warns you when you try to use a garbage collected type and instead of the stdlib, use the SDK facilities.
Here are some libraries for embedded you can get inspiration from[1]:
- msp430f5510 - Run Nim on MSP430f5510 micro-controller (6KB of RAM).[2]
- stm32f3 - Run Nim on STM32F3 micro-controller (16KB of RAM).[3]
- ardunimo - Nim wrapper for Arduino + LinkIt ONE SDK by Mediatek.[4]
- ardunimesp - Nim wrapper for Arduino ESP8266 framework + A tool for flash, compile and make the nim project into an Arduino project.[5]
[1] https://github.com/VPashkov/awesome-nim#embedded https://github.com/VPashkov/awesome-nim#embedded
[2] https://gitlab.com/jalexander8717/msp430f5510-nim https://gitlab.com/jalexander8717/msp430f5510-nim
[3] https://github.com/mwbrown/nim_stm32f3 https://github.com/mwbrown/nim_stm32f3
[4] https://github.com/gokr/ardunimo https://github.com/gokr/ardunimo
[5] https://gitlab.com/NetaLabTek/Arduimesp https://gitlab.com/NetaLabTek/Arduimesp
Also, yes abstracting a platform is a lot of pain but Nim accepts PR even for niche platforms like Haiku, Genode and Nintendo Switch.
Also with the upcoming destructors, the standard library will be GC-free so much more will be usable on embedded.
- rohansingh 8y agoYeah, I tried --gc:none. After some playing around, I ended up with: --gc:stack --header:"nim.h" --os:standalone --noMain --genDeps In the end I got Nim code to run and was able to do a "hello world". As a hack I also used -d:android to trigger some conditionals that reduced the reliance on various dependencies. But it wasn't enough to be usable, and it was a bit unfortunate to have to do that. Looking at those projects you linked though, clearly I didn't try hard enough! Great to see that people have had success.