-
Notifications
You must be signed in to change notification settings - Fork 128
Add support for Arduino Due and Arduino Zero #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bd86253
d0533d4
912b1be
2975572
f76ded8
d74754c
5dd5049
b957c23
ee7308c
ebcaadc
bdcad0b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include <Arduino.h> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would love to be able to change the transport in the project instead of the library. MCUs usually have multiple UARTs that users may switch to, or to other protocols, SPI, I2C, and CAN. Also, we can benefit from Arduino's libraries to interact with those protocols. Defining transport in the project would be super handy. However, in that case, we need to include the same transport file in all examples which is not the best solution. Let me know if you have any suggestions. |
||
|
||
extern "C" | ||
{ | ||
#include <stdio.h> | ||
#include <stdbool.h> | ||
#include <sys/time.h> | ||
|
||
int clock_gettime(clockid_t unused, struct timespec *tp) | ||
{ | ||
(void)unused; | ||
uint64_t m = micros(); | ||
tp->tv_sec = m / 1000000; | ||
tp->tv_nsec = (m % 1000000) * 1000; | ||
return 0; | ||
} | ||
|
||
bool arduino_serial_platform_open() | ||
{ | ||
// Place here your initialization platform code | ||
// Return true if success | ||
SerialUSB.begin(115200); | ||
return true; | ||
} | ||
|
||
bool arduino_serial_platform_close() | ||
{ | ||
// Place here your closing platform code | ||
// Return true if success | ||
return true; | ||
} | ||
|
||
size_t arduino_serial_platform_write(uint8_t *buf, size_t len, uint8_t *errcode) | ||
{ | ||
// Place here your writing bytes platform code | ||
// Return number of bytes written | ||
(void)errcode; | ||
size_t sent = SerialUSB.write(buf, len); | ||
return sent; | ||
} | ||
|
||
size_t arduino_serial_platform_read(uint8_t *buf, size_t len, int timeout, uint8_t *errcode) | ||
{ | ||
// Place here your reading bytes platform code | ||
// Return number of bytes read (max bytes: len) | ||
(void)errcode; | ||
SerialUSB.setTimeout(timeout); | ||
return SerialUSB.readBytes((char *)buf, len); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,10 @@ RUN git clone https://github.com/micro-ROS/micro-ros-build.git src/micro-ros-bui | |
&& rm -rf gcc-arm-none-eabi-5_4-2016q2-20160622-linux.tar.bz2 gcc-arm-none-eabi-5_4-2016q2/share/doc \ | ||
&& wget https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q3-update/+download/gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2 \ | ||
&& tar -xvf gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2 \ | ||
&& rm -rf gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2 gcc-arm-none-eabi-5_4-2016q3/share/doc | ||
&& rm -rf gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2 gcc-arm-none-eabi-5_4-2016q3/share/doc \ | ||
&& wget https://launchpad.net/gcc-arm-embedded/4.8/4.8-2014-q1-update/+download/gcc-arm-none-eabi-4_8-2014q1-20140314-linux.tar.bz2 \ | ||
&& tar -xvf gcc-arm-none-eabi-4_8-2014q1-20140314-linux.tar.bz2 \ | ||
&& rm -rf gcc-arm-none-eabi-4_8-2014q1-20140314-linux.tar.bz2 gcc-arm-none-eabi-4_8-2014q1/share/doc | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't test, but probably we can recycle the same compiler for multiple platforms. I picked a safe route and took the same compiler that Arduino uses for the corresponding cores. |
||
|
||
COPY ./entrypoint.sh /entrypoint.sh | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"names": { | ||
"tracetools": { | ||
"cmake-args": [ | ||
"-DTRACETOOLS_DISABLED=ON", | ||
"-DTRACETOOLS_STATUS_CHECKING_TOOL=OFF" | ||
] | ||
}, | ||
"rosidl_typesupport": { | ||
"cmake-args": [ | ||
"-DROSIDL_TYPESUPPORT_SINGLE_TYPESUPPORT=ON" | ||
] | ||
}, | ||
"rcl": { | ||
"cmake-args": [ | ||
"-DBUILD_TESTING=OFF", | ||
"-DRCL_COMMAND_LINE_ENABLED=OFF", | ||
"-DRCL_LOGGING_ENABLED=OFF" | ||
] | ||
}, | ||
"rcutils": { | ||
"cmake-args": [ | ||
"-DENABLE_TESTING=OFF", | ||
"-DRCUTILS_NO_FILESYSTEM=ON", | ||
"-DRCUTILS_NO_THREAD_SUPPORT=ON", | ||
"-DRCUTILS_NO_64_ATOMIC=ON", | ||
"-DRCUTILS_AVOID_DYNAMIC_ALLOCATION=ON" | ||
] | ||
}, | ||
"microxrcedds_client": { | ||
"cmake-args": [ | ||
"-DUCLIENT_PIC=OFF", | ||
"-DUCLIENT_PROFILE_UDP=OFF", | ||
"-DUCLIENT_PROFILE_DISCOVERY=OFF", | ||
"-DUCLIENT_PROFILE_SERIAL=ON", | ||
"-DUCLIENT_EXTERNAL_SERIAL=ON" | ||
] | ||
}, | ||
"rmw_microxrcedds": { | ||
"cmake-args": [ | ||
"-DRMW_UXRCE_MAX_NODES=1", | ||
"-DRMW_UXRCE_MAX_PUBLISHERS=2", | ||
"-DRMW_UXRCE_MAX_SUBSCRIPTIONS=1", | ||
"-DRMW_UXRCE_MAX_SERVICES=0", | ||
"-DRMW_UXRCE_MAX_CLIENTS=1", | ||
Comment on lines
+42
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without these changes, I wasn't able to fit the library into Arduino Zero. Ideally, we would also be able to change these parameters from an Arduino project (without changing and recompiling the library), but I didn't know how to solve it. |
||
"-DRMW_UXRCE_MAX_HISTORY=1", | ||
"-DRMW_UXRCE_TRANSPORT=custom_serial" | ||
] | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
SET(CMAKE_SYSTEM_NAME Generic) | ||
set(CMAKE_CROSSCOMPILING 1) | ||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) | ||
|
||
set(CMAKE_C_COMPILER $ENV{TOOLCHAIN_PREFIX}gcc) | ||
set(CMAKE_CXX_COMPILER $ENV{TOOLCHAIN_PREFIX}g++) | ||
|
||
SET(CMAKE_C_COMPILER_WORKS 1 CACHE INTERNAL "") | ||
SET(CMAKE_CXX_COMPILER_WORKS 1 CACHE INTERNAL "") | ||
|
||
set(FLAGS "-O2 -fsingle-precision-constant -ffunction-sections -fdata-sections -fno-exceptions -mcpu=cortex-m0 -nostdlib -mthumb -D'RCUTILS_LOG_MIN_SEVERITY=RCUTILS_LOG_MIN_SEVERITY_NONE'" CACHE STRING "" FORCE) | ||
|
||
set(CMAKE_C_FLAGS_INIT "-std=c11 ${FLAGS} -DCLOCK_MONOTONIC=0 -D'__attribute__(x)='" CACHE STRING "" FORCE) | ||
set(CMAKE_CXX_FLAGS_INIT "-std=c++14 ${FLAGS} -fno-rtti -DCLOCK_MONOTONIC=0 -D'__attribute__(x)='" CACHE STRING "" FORCE) | ||
|
||
set(__BIG_ENDIAN__ 0) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
SET(CMAKE_SYSTEM_NAME Generic) | ||
set(CMAKE_CROSSCOMPILING 1) | ||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) | ||
|
||
set(CMAKE_C_COMPILER $ENV{TOOLCHAIN_PREFIX}gcc) | ||
set(CMAKE_CXX_COMPILER $ENV{TOOLCHAIN_PREFIX}g++) | ||
|
||
SET(CMAKE_C_COMPILER_WORKS 1 CACHE INTERNAL "") | ||
SET(CMAKE_CXX_COMPILER_WORKS 1 CACHE INTERNAL "") | ||
|
||
set(FLAGS "-O2 -ffunction-sections -fdata-sections -fno-exceptions -mcpu=cortex-m3 -nostdlib -DARDUINO=10813 -mthumb --param max-inline-insns-single=500 -DF_CPU=84000000L -D'RCUTILS_LOG_MIN_SEVERITY=RCUTILS_LOG_MIN_SEVERITY_NONE'" CACHE STRING "" FORCE) | ||
|
||
set(CMAKE_C_FLAGS_INIT "-std=c11 ${FLAGS} -DCLOCK_MONOTONIC=0 -D'__attribute__(x)='" CACHE STRING "" FORCE) | ||
set(CMAKE_CXX_FLAGS_INIT "-std=c++11 ${FLAGS} -fno-rtti -DCLOCK_MONOTONIC=0 -D'__attribute__(x)='" CACHE STRING "" FORCE) | ||
|
||
set(__BIG_ENDIAN__ 0) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,11 +5,8 @@ | |
#include "teensy_transports.c.in" | ||
#elif defined(ARDUINO_ARCH_OPENCR) | ||
#include "opencr_transports.c.in" | ||
#else | ||
#error micro-ROS Library not supported for this platform | ||
#endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The transport is defined in the Arduino project and we don't need these files here. Should we move the OpenCR and Teensy transport files? |
||
|
||
|
||
// TODO: This should be fixed | ||
#if defined(ARDUINO_TEENSY32) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI tests are missing here as the upstream version of Arduino Due core doesn't support static libraries. Here is a relevant PR:
arduino/ArduinoCore-sam#115
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'm curious to know why they allow precompiled linking and dont have to support in their own boards