Skip to content
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

Get it working with teensyduino #35

Open
lslrt opened this issue Aug 13, 2020 · 1 comment
Open

Get it working with teensyduino #35

lslrt opened this issue Aug 13, 2020 · 1 comment
Labels
bug Something isn't working enhancement New feature or request

Comments

@lslrt
Copy link

lslrt commented Aug 13, 2020

Hello,

I'm trying to get this working with teensyduino install.
I'm using:

It almost works out of the box using release-1.1-dev branch, there is only a couple of minor issues, some of them are fixed by patching files installed by teensyduino, and one modification is needed on Arduino-CMake-Toolchain side (I made it only for Linux since I'm not able to test it for other platforms).

Arduino-CMake-Toolchain

I'll do a merge request, I've made a quick fix for Linux platform only that set an additional property (extra.time.local) that is used to define some symbols on teensy ld command line.

Arduino install modified by TeensyduinoInstaller

Teensyduino installer is not modifying the package_index_bundle.json file nor providing one, but arduino IDE correctly find the new boards.
However Arduino-CMake-Toolchain seems to only rely on information found on various json files, maybe the procedure to detect available platform need to be improved to be closest of what arduino IDE is doing...
Anyway, a way to get it working is to patch the package_index_bundle.json to add teensy information, bellow patch is working for me:

diff --git a/hardware/package_index_bundled.json b/hardware/package_index_bundled.json
index 82ac683..e95f3d5 100644
--- a/hardware/package_index_bundled.json
+++ b/hardware/package_index_bundled.json
@@ -214,6 +214,27 @@
           ]
         }
       ]
-    }
+    },
+      {
+          "name": "teensy",
+          "platforms": [
+              {
+                  "name": "Teensy AVR Boards",
+                  "architecture": "avr",
+                  "version": "1.6.23",
+                  "category": "Teensyduino",
+                  "boards": [
+                      {"name": "Teensy 3.2 / 3.1"}
+                  ],
+                  "toolsDependencies": [
+                      {
+                          "packager": "arduino",
+                          "name": "avr-gcc",
+                          "version": "7.3.0-atmel3.6.1-arduino5"
+                      }
+                  ]
+              }
+          ]
+      }
   ]
 }

An other issue is that platform.txt file provided by teensyduino installer declare some post.build hook:

recipe.hooks.postbuild.1.pattern="{compiler.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.2.pattern="{compiler.path}stdout_redirect" "{build.path}/{build.project_name}.sym" "{compiler.path}{build.toolchain}{build.command.objdump}" -t -C "{build.path}/{build.project_name}.elf"
recipe.hooks.postbuild.3.pattern="{compiler.path}teensy_post_compile" "-file={build.project_name}" "-path={build.path}" "-tools={compiler.path}" "-board={build.board}"

Hook number 1 and 2 need the elf to be produced, their are obviously postlink hook not, postbuild, again, it works correctly on arduino IDE, so maybe the official IDE is more permissive about the notion of postbuild vs postlink hook...
Those hooks are here to automatically start the tool to upload firmware to the target, so they are not necessary for now (at least for me), I've simply declared those hooks as postlink (those seems to not be handled yet by Arduino-CMake-Toolchain) and I can now build the examples.

@a9183756-gh
Copy link
Owner

Hi, Sorry for the delay in response. Firstly, thank you for your contributions in getting the Toolchain working with Teensyduino. Appreciate the effort.

To summarize, you reported 3 issues:

  1. Support for packages and platforms without JSON.

Current version of the tool only supports the new documented way of supporting 3rd party platforms and lacks some legacy features compatible with Arduino IDE. Will plan to add this specific support in the near future for Teensyduino. Suggest you to continue with the patching of package_index_bundled.json for the time being.

  1. postbuild hook getting executed at wrong time.

Do not remember if I assumed something related to postbuild hook or inspected Arduino IDE for its behavior. Will fix this soon. postlink hooks are supported and it is called linking.postlink (e.g. recipe.hooks.linking.postlink.1.pattern). Instead of postlink, I suggest you to use postobjcopy as workaround (it is called objcopy.postobjcopy e.g. recipe.hooks.objcopy.postobjcopy.1.pattern).

  1. Some properties like extra.time.local are not set.

Arduino IDE defines them and wonder where these are documented. The list of properties are extra.time.utc, extra.time.local, extra.time.zone, extra.time.dst. Thanks for the patch and I will provide the review comments in the patch.

@a9183756-gh a9183756-gh added bug Something isn't working enhancement New feature or request labels Aug 21, 2020
a9183756-gh added a commit that referenced this issue Aug 23, 2020
Post build hook execution seems incorrectly positioned at pre-link
time as reported in the issue #35. Fix is to move it after the
objcopy.
a9183756-gh added a commit that referenced this issue Sep 20, 2020
Post build hook execution seems incorrectly positioned at pre-link
time as reported in the issue #35. Fix is to move it after the
objcopy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants