spectraphilic / wsn_riot

RIOT OS for WSN application at UiO
0 stars 0 forks source link

Arduino drivers #10

Closed jdavid closed 1 year ago

jdavid commented 3 years ago

Many drivers we need are not natively supported by RIOT. One option is to use an Arduino driver. Apparently this is possible, see https://github.com/RIOT-OS/RIOT/pull/12518

But first we need our boards to provide the arduino feature, and this is not supported by any of our boards, for example:

$ CONTINUE_ON_EXPECTED_ERRORS=1 BOARD=waspmote-pro make -C tests/sys_arduino
make: Entering directory '/home/jdavid/sandboxes/UiO/wsn_riot/RIOT/tests/sys_arduino'
There are unsatisfied feature requirements: arduino
[...]
In file included from /home/jdavid/sandboxes/UiO/wsn_riot/RIOT/sys/arduino/base.cpp:28:
/home/jdavid/sandboxes/UiO/wsn_riot/RIOT/sys/arduino/include/arduino.hpp:27:10: fatal error: arduino_board.h: No such file or directory
   27 | #include "arduino_board.h"
[...]

Looking for arduino_board.h we see there are already a number of boards that support the arduino feature, including some with a non-AVR MCU. But none of our boards does: waspmote-pro, remote-revb and feather-m0.

Also, from what I've read the arduino module allows to run unmodified Arduino sketches. While the arduino_lib pseudomodule allows to use Arduino libraries from RIOT applications, and that's exactly what we want. See https://github.com/RIOT-OS/RIOT/pull/12180

In order to validate this approach we need to:

  1. [x] Package an Arduino library
  2. [x] Test the library with Arduino Uno
  3. [ ] Add support for packages out of RIOT tree, see https://github.com/RIOT-OS/RIOT/issues/15309
  4. [x] Add arduino support to the waspmote-pro, see https://github.com/RIOT-OS/RIOT/issues/15232
  5. [x] Add arduino support to the remote-revb board, see https://github.com/RIOT-OS/RIOT/pull/15678
  6. [x] Fix print float in arduno, see https://github.com/RIOT-OS/RIOT/pull/15314

On hold:

jdavid commented 3 years ago

See boards/common/arduino-atmega/include/arduino_board.h for an example.

jdavid commented 3 years ago

Follow https://github.com/RIOT-OS/RIOT/issues/15232

jdavid commented 3 years ago

Add Arduino support to a board https://doc.riot-os.org/group__sys__arduino.html#sec_boardsupport

ArcticSnow commented 3 years ago

Arduino drivers for the Feather boards in ArduinoIDE can be found here: https://github.com/adafruit/ArduinoCore-samd

pin map is defined in this file: https://github.com/adafruit/ArduinoCore-samd/blob/master/cores/arduino/WVariant.h

jdavid commented 3 years ago

I've packaged Sparkfun's BME280 Arduino library and added a test app, see apps/test-arduino. And tested it with Arduino Uno. The main purpose of this issue was to evaluate whether we could use or not Arduino libraries, and that's done.

There's one caveat though, RIOT doesn't support packages out of their tree. So to test it I did a symbolic link from their tree to ours, such as:

$ cd RIOT/pkg
$ ln -s ../../pkg/arduino_sparkfun_bme280
$ cd ../..
$ BOARD=arduino-uno make -C apps/test-arduino/ flash term

I've opened an issue to fix this, see https://github.com/RIOT-OS/RIOT/issues/15309

I'm going to update the check list in the description of this issue.

jdavid commented 3 years ago

I've added the arduino feature to the feather-m0 board in our RIOT fork, in the feather-m0-arduino branch, see https://github.com/spectraphilic/RIOT/tree/feather-m0-arduino

But I cannot submit a PR to RIOT upstream because Serial.print doesn't work. From what I've read we need first the following PR to be merged (pending confirmation):

jdavid commented 3 years ago

I've made a PR for the arduino feature in the remote-revb, https://github.com/RIOT-OS/RIOT/pull/15678

By the way there's already an I2C device in the remote-revb, the RTC at address 0x69, see https://github.com/spectraphilic/wsn_riot/issues/8

jdavid commented 1 year ago

This can be closed. Latest board with Arduino support is lora-e5-dev We also have support for SDI-12 through an Arduino library.