Skip to content

Commit b957c23

Browse files
committed
Merge branch 'feature-arduino-zero' into foxy
2 parents e5c9d15 + d74754c commit b957c23

File tree

7 files changed

+135
-2
lines changed

7 files changed

+135
-2
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#include <Arduino.h>
2+
3+
extern "C"
4+
{
5+
#include <stdio.h>
6+
#include <stdbool.h>
7+
#include <sys/time.h>
8+
9+
int clock_gettime(clockid_t unused, struct timespec *tp)
10+
{
11+
(void)unused;
12+
uint64_t m = micros();
13+
tp->tv_sec = m / 1000000;
14+
tp->tv_nsec = (m % 1000000) * 1000;
15+
return 0;
16+
}
17+
18+
bool arduino_serial_platform_open()
19+
{
20+
// Place here your initialization platform code
21+
// Return true if success
22+
SerialUSB.begin(115200);
23+
return true;
24+
}
25+
26+
bool arduino_serial_platform_close()
27+
{
28+
// Place here your closing platform code
29+
// Return true if success
30+
return true;
31+
}
32+
33+
size_t arduino_serial_platform_write(uint8_t *buf, size_t len, uint8_t *errcode)
34+
{
35+
// Place here your writing bytes platform code
36+
// Return number of bytes written
37+
(void)errcode;
38+
size_t sent = SerialUSB.write(buf, len);
39+
return sent;
40+
}
41+
42+
size_t arduino_serial_platform_read(uint8_t *buf, size_t len, int timeout, uint8_t *errcode)
43+
{
44+
// Place here your reading bytes platform code
45+
// Return number of bytes read (max bytes: len)
46+
(void)errcode;
47+
SerialUSB.setTimeout(timeout);
48+
return SerialUSB.readBytes((char *)buf, len);
49+
}
50+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"names": {
3+
"tracetools": {
4+
"cmake-args": [
5+
"-DTRACETOOLS_DISABLED=ON",
6+
"-DTRACETOOLS_STATUS_CHECKING_TOOL=OFF"
7+
]
8+
},
9+
"rosidl_typesupport": {
10+
"cmake-args": [
11+
"-DROSIDL_TYPESUPPORT_SINGLE_TYPESUPPORT=ON"
12+
]
13+
},
14+
"rcl": {
15+
"cmake-args": [
16+
"-DBUILD_TESTING=OFF",
17+
"-DRCL_COMMAND_LINE_ENABLED=OFF",
18+
"-DRCL_LOGGING_ENABLED=OFF"
19+
]
20+
},
21+
"rcutils": {
22+
"cmake-args": [
23+
"-DENABLE_TESTING=OFF",
24+
"-DRCUTILS_NO_FILESYSTEM=ON",
25+
"-DRCUTILS_NO_THREAD_SUPPORT=ON",
26+
"-DRCUTILS_NO_64_ATOMIC=ON",
27+
"-DRCUTILS_AVOID_DYNAMIC_ALLOCATION=ON"
28+
]
29+
},
30+
"microxrcedds_client": {
31+
"cmake-args": [
32+
"-DUCLIENT_PIC=OFF",
33+
"-DUCLIENT_PROFILE_UDP=OFF",
34+
"-DUCLIENT_PROFILE_DISCOVERY=OFF",
35+
"-DUCLIENT_PROFILE_SERIAL=ON",
36+
"-DUCLIENT_EXTERNAL_SERIAL=ON"
37+
]
38+
},
39+
"rmw_microxrcedds": {
40+
"cmake-args": [
41+
"-DRMW_UXRCE_MAX_NODES=1",
42+
"-DRMW_UXRCE_MAX_PUBLISHERS=2",
43+
"-DRMW_UXRCE_MAX_SUBSCRIPTIONS=1",
44+
"-DRMW_UXRCE_MAX_SERVICES=0",
45+
"-DRMW_UXRCE_MAX_CLIENTS=1",
46+
"-DRMW_UXRCE_MAX_HISTORY=1",
47+
"-DRMW_UXRCE_TRANSPORT=custom_serial"
48+
]
49+
}
50+
}
51+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
SET(CMAKE_SYSTEM_NAME Generic)
2+
set(CMAKE_CROSSCOMPILING 1)
3+
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
4+
5+
set(CMAKE_C_COMPILER $ENV{TOOLCHAIN_PREFIX}gcc)
6+
set(CMAKE_CXX_COMPILER $ENV{TOOLCHAIN_PREFIX}g++)
7+
8+
SET(CMAKE_C_COMPILER_WORKS 1 CACHE INTERNAL "")
9+
SET(CMAKE_CXX_COMPILER_WORKS 1 CACHE INTERNAL "")
10+
11+
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)
12+
13+
set(CMAKE_C_FLAGS_INIT "-std=c11 ${FLAGS} -DCLOCK_MONOTONIC=0 -D'__attribute__(x)='" CACHE STRING "" FORCE)
14+
set(CMAKE_CXX_FLAGS_INIT "-std=c++14 ${FLAGS} -fno-rtti -DCLOCK_MONOTONIC=0 -D'__attribute__(x)='" CACHE STRING "" FORCE)
15+
16+
set(__BIG_ENDIAN__ 0)

extras/library_generation/library_generation.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ if [ $OPTIND -eq 1 ]; then
1313
PLATFORMS+=("opencr1")
1414
PLATFORMS+=("teensy4")
1515
PLATFORMS+=("teensy3")
16+
PLATFORMS+=("cortex_m0")
1617
fi
1718

1819
shift $((OPTIND-1))
@@ -94,6 +95,20 @@ if [[ " ${PLATFORMS[@]} " =~ " teensy4 " ]]; then
9495
cp -R firmware/build/libmicroros.a /arduino_project/src/imxrt1062/fpv5-d16-hard/libmicroros.a
9596
fi
9697

98+
######## Build for SAMD (e.g. Arduino Zero) ########
99+
if [[ " ${PLATFORMS[@]} " =~ " cortex_m0 " ]]; then
100+
rm -rf firmware/build
101+
102+
export TOOLCHAIN_PREFIX=/uros_ws/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-
103+
ros2 run micro_ros_setup build_firmware.sh /arduino_project/extras/library_generation/cortex_m0_toolchain.cmake /arduino_project/extras/library_generation/colcon_verylowmem.meta
104+
105+
find firmware/build/include/ -name "*.c" -delete
106+
cp -R firmware/build/include/* /arduino_project/src/
107+
108+
mkdir -p /arduino_project/src/cortex-m0plus
109+
cp -R firmware/build/libmicroros.a /arduino_project/src/cortex-m0plus/libmicroros.a
110+
fi
111+
97112
######## Generate extra files ########
98113
find firmware/mcu_ws/ros2 \( -name "*.srv" -o -name "*.msg" -o -name "*.action" \) | awk -F"/" '{print $(NF-2)"/"$NF}' > /arduino_project/available_ros2_types
99114
find firmware/mcu_ws/extra_packages \( -name "*.srv" -o -name "*.msg" -o -name "*.action" \) | awk -F"/" '{print $(NF-2)"/"$NF}' >> /arduino_project/available_ros2_types

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ paragraph=micro-ROS Arduino library
77
url=https://github.com/micro-ROS
88
precompiled=true
99
category=Other
10-
architectures=OpenCR,Teensyduino
10+
architectures=OpenCR,Teensyduino,samd

src/arduino_transports.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#include <stdio.h>
22
#include <stdbool.h>
33

4+
/*
45
#if defined(ARDUINO_TEENSY41) || defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY32)
56
#include "teensy_transports.c.in"
67
#elif defined(ARDUINO_ARCH_OPENCR)
78
#include "opencr_transports.c.in"
89
#else
910
#error micro-ROS Library not supported for this platform
1011
#endif
11-
12+
*/
1213

1314
// TODO: This should be fixed
1415
#if defined(ARDUINO_TEENSY32)

src/cortex-m0plus/libmicroros.a

3.87 MB
Binary file not shown.

0 commit comments

Comments
 (0)