Skip to content

Commit

Permalink
Fix teensy patch and compiler (#1482) (#1483)
Browse files Browse the repository at this point in the history
* Update teensy compiler and platform fix

Signed-off-by: acuadros95 <acuadros1995@gmail.com>

* Update Readme and CI

Signed-off-by: acuadros95 <acuadros1995@gmail.com>

* set specific version to teensy CI

Signed-off-by: acuadros95 <acuadros1995@gmail.com>

---------

Signed-off-by: acuadros95 <acuadros1995@gmail.com>
(cherry picked from commit 69ca6d8)

Co-authored-by: Antonio Cuadros <49162117+Acuadros95@users.noreply.github.com>
  • Loading branch information
mergify[bot] and Acuadros95 committed Jul 27, 2023
1 parent 4f1ba1b commit 084242c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ jobs:
additional_urls:
- https://raw.githubusercontent.com/ROBOTIS-GIT/OpenCR/master/arduino/opencr_release/package_opencr_index.json
- https://github.com/espressif/arduino-esp32/releases/download/2.0.2/package_esp32_index.json
- https://www.pjrc.com/teensy/td_156/package_teensy_index.json
- https://www.pjrc.com/teensy/package_teensy_index.json
- https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json''' > arduino-cli.yaml
curl -fsSL https://raw.githubusercontent.com/ROBOTIS-GIT/OpenCR/master/arduino/opencr_release/package_opencr_index.json -o /github/home/.arduino15/package_opencr_index.json
curl -fsSL https://github.com/espressif/arduino-esp32/releases/download/2.0.2/package_esp32_index.json -o /github/home/.arduino15/package_esp32_index.json
curl -fsSL https://www.pjrc.com/teensy/td_156/package_teensy_index.json -o /github/home/.arduino15/package_teensy_index.json
curl -fsSL https://www.pjrc.com/teensy/package_teensy_index.json -o /github/home/.arduino15/package_teensy_index.json
curl -fsSL https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json -o /github/home/.arduino15/package_seeeduino_boards_index.json
export PATH=$PATH:/github/workspace/bin:/__w/micro_ros_arduino/micro_ros_arduino/bin
arduino-cli core install OpenCR:OpenCR -v
arduino-cli core install arduino:samd -v
arduino-cli core install arduino:sam -v
arduino-cli core install arduino:mbed -v
arduino-cli core install esp32:esp32 -v
arduino-cli core install teensy:avr -v
arduino-cli core install teensy:avr@1.58.0 -v
arduino-cli core install Seeeduino:samd -v
#
# PATCHING TEENSY AND SAM
cat checkout/extras/patching_boards/platform_teensy.txt > /github/home/.arduino15/packages/teensy/hardware/avr/1.57.2/platform.txt
cat checkout/extras/patching_boards/platform_teensy.txt > /github/home/.arduino15/packages/teensy/hardware/avr/1.58.0/platform.txt
# remove when https://github.com/arduino/ArduinoCore-sam/pull/115 merged
cat checkout/extras/patching_boards/platform_arduinocore_sam.txt > /github/home/.arduino15/packages/arduino/hardware/sam/1.6.12/platform.txt
#
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ Supported boards are:
| [Arduino Portenta H7 M7 Core](https://store.arduino.cc/portenta-h7) | v1.8.5 | Supported | Official Arduino support | `colcon.meta` |
| [Arduino Nano RP2040 Connect](https://docs.arduino.cc/hardware/nano-rp2040-connect) | v1.8.5 | Supported | Official Arduino support | `colcon_verylowmem.meta` |
| [OpenCR](https://emanual.robotis.com/docs/en/parts/controller/opencr10/) | v1.4.16 | Supported | [Based on custom board](https://emanual.robotis.com/docs/en/parts/controller/opencr10/#arduino-ide) | `colcon.meta` |
| [Teensy 4.0](https://www.pjrc.com/store/teensy40.html) | v1.8.5 | Not tested | [Based on Teensyduino](https://www.pjrc.com/arduino-ide-2-0-0-teensy-support/) | `colcon.meta` |
| [Teensy 4.1](https://www.pjrc.com/store/teensy41.html) | v1.8.5 | Supported | [Based on Teensyduino](https://www.pjrc.com/arduino-ide-2-0-0-teensy-support/) | `colcon.meta` |
| [Teensy 3.2/3.1](https://www.pjrc.com/store/teensy32.html) | v1.8.5 | Supported | [Based on Teensyduino](https://www.pjrc.com/arduino-ide-2-0-0-teensy-support/) | `colcon_lowmem.meta` |
| [Teensy 3.5](https://www.pjrc.com/store/teensy35.html) | v1.8.5 | Not tested | [Based on Teensyduino](https://www.pjrc.com/arduino-ide-2-0-0-teensy-support/) | `colcon_lowmem.meta` |
| [Teensy 3.6](https://www.pjrc.com/store/teensy36.html) | v1.8.5 | Supported | [Based on Teensyduino](https://www.pjrc.com/arduino-ide-2-0-0-teensy-support/) | `colcon_lowmem.meta` |
| [Teensy 4.0](https://www.pjrc.com/store/teensy40.html) | v1.8.5 | Not tested | [Based on Teensyduino (1.58.x)](https://www.pjrc.com/arduino-ide-2-0-0-teensy-support/) | `colcon.meta` |
| [Teensy 4.1](https://www.pjrc.com/store/teensy41.html) | v1.8.5 | Supported | [Based on Teensyduino (1.58.x)](https://www.pjrc.com/arduino-ide-2-0-0-teensy-support/) | `colcon.meta` |
| [Teensy 3.2/3.1](https://www.pjrc.com/store/teensy32.html) | v1.8.5 | Supported | [Based on Teensyduino (1.58.x)](https://www.pjrc.com/arduino-ide-2-0-0-teensy-support/) | `colcon_lowmem.meta` |
| [Teensy 3.5](https://www.pjrc.com/store/teensy35.html) | v1.8.5 | Not tested | [Based on Teensyduino (1.58.x)](https://www.pjrc.com/arduino-ide-2-0-0-teensy-support/) | `colcon_lowmem.meta` |
| [Teensy 3.6](https://www.pjrc.com/store/teensy36.html) | v1.8.5 | Supported | [Based on Teensyduino (1.58.x)](https://www.pjrc.com/arduino-ide-2-0-0-teensy-support/) | `colcon_lowmem.meta` |
| [ESP32 Dev Module](https://docs.espressif.com/projects/arduino-esp32/en/latest/boards/ESP32-DevKitC-1.html) | v1.8.5 | Supported | [Arduino core for the ESP32 (v2.0.2)](https://github.com/espressif/arduino-esp32/releases/tag/2.0.2) | `colcon.meta` |

Community contributed boards are:
Expand Down Expand Up @@ -99,12 +99,14 @@ You can [configure many parameters](https://micro.ros.org/docs/tutorials/advance
Go inside your Arduino + Teensyduino installation and replace `platform.txt`:

```bash
export TEENSYDUINO_VERSION=[Your Teensyduino library version, e.g: 1.57.2]
export TEENSYDUINO_VERSION=[Your Teensyduino library version, e.g: 1.58.0]
export ARDUINO_PATH=[Your Arduino + Teensyduino path]
cd $ARDUINO_PATH/hardware/avr/$TEENSYDUINO_VERSION/
curl https://raw.githubusercontent.com/micro-ROS/micro_ros_arduino/main/extras/patching_boards/platform_teensy.txt > platform.txt
```

The patch applies the changes detailed on the first two sections of this post: [Solution for adding support for pre-compiled Libraries](https://forum.pjrc.com/threads/63256-Solution-for-adding-support-for-pre-compiled-Libraries)

### Patch SAM

Go inside your Arduino installation and replace `platform.txt`:
Expand Down
12 changes: 6 additions & 6 deletions extras/library_generation/library_generation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ fi
if [[ " ${PLATFORMS[@]} " =~ " teensy32 " ]]; then
rm -rf firmware/build

export TOOLCHAIN_PREFIX=/uros_ws/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-
export TOOLCHAIN_PREFIX=/uros_ws/teensy-compile/tools/arm/bin/arm-none-eabi-
ros2 run micro_ros_setup build_firmware.sh /project/extras/library_generation/teensy32_toolchain.cmake /project/extras/library_generation/colcon_lowmem.meta

find firmware/build/include/ -name "*.c" -delete
Expand All @@ -131,7 +131,7 @@ fi
if [[ " ${PLATFORMS[@]} " =~ " teensy35 " ]]; then
rm -rf firmware/build

export TOOLCHAIN_PREFIX=/uros_ws/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-
export TOOLCHAIN_PREFIX=/uros_ws/teensy-compile/tools/arm/bin/arm-none-eabi-
ros2 run micro_ros_setup build_firmware.sh /project/extras/library_generation/teensy35_toolchain.cmake /project/extras/library_generation/colcon_lowmem.meta

find firmware/build/include/ -name "*.c" -delete
Expand All @@ -150,7 +150,7 @@ if [[ " ${PLATFORMS[@]} " =~ " teensy36 " ]]; then
if [[ " ${PLATFORMS[@]} " =~ " teensy35 " ]]; then
ln /project/src/mk64fx512/fpv4-sp-d16-hard/libmicroros.a /project/src/mk66fx1m0/fpv4-sp-d16-hard/libmicroros.a
else
export TOOLCHAIN_PREFIX=/uros_ws/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-
export TOOLCHAIN_PREFIX=/uros_ws/teensy-compile/tools/arm/bin/arm-none-eabi-
ros2 run micro_ros_setup build_firmware.sh /project/extras/library_generation/teensy35_toolchain.cmake /project/extras/library_generation/colcon_lowmem.meta

find firmware/build/include/ -name "*.c" -delete
Expand All @@ -164,7 +164,7 @@ fi
if [[ " ${PLATFORMS[@]} " =~ " teensy4 " ]]; then
rm -rf firmware/build

export TOOLCHAIN_PREFIX=/uros_ws/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-
export TOOLCHAIN_PREFIX=/uros_ws/teensy-compile/tools/arm/bin/arm-none-eabi-
ros2 run micro_ros_setup build_firmware.sh /project/extras/library_generation/teensy4_toolchain.cmake /project/extras/library_generation/colcon.meta

find firmware/build/include/ -name "*.c" -delete
Expand Down Expand Up @@ -237,8 +237,8 @@ popd > /dev/null

apt -y install rsync
for var in ${INCLUDE_ROS2_PACKAGES}; do
rsync -r /project/src/${var}/${var}/* /project/src/${var}/
rm -rf /project/src/${var}/${var}/
rsync -r /project/src/${var}/${var}/* /project/src/${var}/ > /dev/null 2>&1
rm -rf /project/src/${var}/${var}/ > /dev/null 2>&1
done

######## Generate extra files ########
Expand Down
17 changes: 15 additions & 2 deletions extras/patching_boards/platform_teensy.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# https://www.pjrc.com/teensy/td_download.html
# https://arduino.github.io/arduino-cli/latest/platform-specification/
# https://arduino.github.io/arduino-cli/0.30/platform-specification/

name=Teensyduino
version=1.8.5
rewriting=disabled
Expand All @@ -11,6 +15,15 @@ compiler.path={runtime.tools.teensy-compile.path}/
teensytools.path={runtime.tools.teensy-tools.path}/


## Debugger - Experimental
#debug.executable={build.path}/{build.project_name}.elf
#debug.toolchain=gcc
#debug.toolchain.path={compiler.path}{build.toolchain}
#debug.toolchain.prefix=arm-none-eabi-
#debug.server=openocd
#debug.server.openocd.path={teensytools.path}tdebug
#debug.server.openocd.scripts_dir=unused
#debug.server.openocd.script=toolspath:{teensytools.path}:buildpath:{build.path}:name:{build.project_name}:board:{build.board}

## EEPROM Data
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
Expand Down Expand Up @@ -44,7 +57,7 @@ recipe.S.o.pattern="{compiler.path}{build.toolchain}{build.command.gcc}" -c {bui
recipe.ar.pattern="{compiler.path}{build.toolchain}{build.command.ar}" rcs "{archive_file_path}" "{object_file}"

## Link
recipe.c.combine.pattern="{compiler.path}{build.toolchain}{build.command.linker}" {build.flags.optimize} {build.flags.ld} {build.flags.ldspecs} {build.flags.cpu} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" {compiler.libraries.ldflags} "-L{build.path}" {build.flags.libs}
recipe.c.combine.pattern="{compiler.path}{build.toolchain}{build.command.linker}" {build.flags.optimize} {build.flags.ld} {build.flags.ldspecs} {build.flags.cpu} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} "{build.path}/{archive_file}" "-L{build.path}" {build.flags.libs}

## Patch ELF - TODO: not supported by modern Arduino... :(
recipe.elfpatch.pattern="{teensytools.path}/{build.elfpatch}" -mmcu={build.mcu} "{build.path}/{build.project_name}.elf" "{sketch_path}/disk"
Expand All @@ -67,7 +80,7 @@ recipe.hooks.postbuild.3.pattern="{teensytools.path}teensy_size" "{build.path}/{
# objdump to create .lst file is VERY SLOW for huge files
# https://forum.pjrc.com/threads/68121?p=288306&viewfull=1#post288306
#
# recipe.hooks.postbuild.4.pattern="{teensytools.path}stdout_redirect" "{build.path}/{build.project_name}.lst" "{compiler.path}{build.toolchain}{build.command.objdump}" -d -S -C "{build.path}/{build.project_name}.elf"
recipe.hooks.postbuild.4.pattern="{teensytools.path}stdout_redirect" "{build.path}/{build.project_name}.lst" "{compiler.path}{build.toolchain}{build.command.objdump}" -d -S -C "{build.path}/{build.project_name}.elf"


## Compute size
Expand Down

0 comments on commit 084242c

Please sign in to comment.