Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Nim wrapper using c2nim for Arduino and MediaTek LinkIt One development

License

NotificationsYou must be signed in to change notification settings

cfvescovo/Arduino-Nim

 
 

Repository files navigation

This is a fork of the great repo "Ardunimo". I am working on this repository to make Arduino-Nim the standard library for Arduino and LinkIt in the new Nim programming language. The main goal is to improve the already excellent Ardunimo code to make it more stable and wider compatible with Arduino boards.


This is a first stab at Arduino programming on theLinkIt ONE development board from MediaTek using the brilliantprogramming language Nim.

This project basically consists of two Makefiles, one in thewrappersubdirectory that can semi automatically generate the Nim wrapper of the Arduino and MediaTek libraries for the LinkIt ONE using the very usefulc2nim tool. The other Makefile in the root directory is for compiling a Nim program using the wrapper and the SDK from MediaTek to produce a .vxp binary file that can be dropped into the USB disk on the board.

Installing Nim, nimble and c2nim

First we need to installNim (compiler and libs),nimble (package manager) andc2nim (wrapper generator tool). I recommend following installation instructions on the github repos but if you want that information condensed, below is the recipe. And for theultra lazy there is also a VagrantFile with this shell provisioning script, so you can just dovagrant up && vagrant ssh to have a working environment.

# If in a fresh Ubuntusudo apt-get update && sudo apt-get upgradesudo apt-get install git unzip build-essential# Install Nim and bootstrap itgit clone https://github.com/nim-lang/Nim.gitcd Nimgit clone --depth 1 https://github.com/nim-lang/csourcescd csources && sh build.shcd ..bin/nim c koch./koch boot -d:release# Execute and also put the following line last in ~/.profileexport PATH="$HOME/Nim/bin:$HOME/.nimble/bin:$PATH"# Then install nimblenim e install_nimble.nims# Let it refresh the package listnimble refresh# Use nimble to install c2nimnimble install c2nim

Get Ardunimo

  1. Clone this repo to your machine (or in the vagrant box),only tested on 64 bit Ubuntu 14.04. The Makefile presumes Nim was cloned to$HOME/Nim.
  2. Download and install the needed ARM GCC and SDK by running:cd ardunimo && make sdk

Patch Nim

For the moment Ardunimo needs a patched Nim, copy the alloc.nim file to replace the one in your Nim installation:

cp wrapper/fixed/alloc.nim <whereverNimLives>/lib/system/alloc.nim

This enables GC to work using malloc.

Building blink.nim

In the repository there is a single trivial application -blink.nim, you probably recognize it. To build it and run on your LinkIt One:

  1. Runmake. If all is well it producesapp.vxp in a few seconds about 85kb big.
  2. Connect your LinkIt ONEin USB drive mode - the small switch closest to the USB cord should be towards the USB cable.
  3. Press the reset button on the side of the board (where the green LED is lit) and Ubuntu should automount it.
  4. Copyapp.vxp to the MRE directory on the device. Also make sureautostart.txt maps toapp.vxp.
  5. Flip the USB mode switch and press the reset button, no need to unplug the USB cable. This will start the application.
  6. After a few seconds the green LED on the board should start blinking.

Building some other

Just writeother.nim and make using:

make PROJECT=other.nim

Currentlyblink,blink2 andnimicro works.

Background

I begun by following these two tutorials:

Then various googling and staring at the Arduino IDE compilation log led me to produce this LinkIt ONE specific Makefile.

After messing around with c2nim for a while I put that into its own Makefile. That Makefile produces a partial Nim wrapper of the Arduino + MediaTek libraries.

NOTES:

  • The wrapper is not complete (I just did what I needed) and in many places probably downright silly, as Andreas mentioned to me. :)
  • Currently the GC can not be turned on (see nim.cfg), we don't know yet what is preventing it.
  • We compile via Nim's C++ backend since Arduino libraries are C++ based.
  • Theardunimo.nim is a hack I ended up doing so that setup/loop gets resolved properly. PRs appreciated.
  • The wrapper/src directory contains the SDK sourcesmodified for c2nim, these are not used when compiling.
  • Some modifications I didn't manage to do in the src, then I manually edited the produced nim file and put it in wrapper/fixed.

About

Nim wrapper using c2nim for Arduino and MediaTek LinkIt One development

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C62.4%
  • C++35.3%
  • Nim1.2%
  • Objective-C0.7%
  • Logos0.2%
  • Assembly0.1%
  • Other0.1%

[8]ページ先頭

©2009-2025 Movatter.jp