I have just now made a boards.txt parser in javascript that outputs a json
Code:var treeData = {}; function parse(fileData) { treeData = {}; const t0 = performance.now(); var lines = fileData.split('\n'); for (var i = 0; i < lines.length; i++) { var line = lines[i].trim(); if (line.length == 0) continue; // empty line if (line[0] == '#') continue; // comment line var lio = line.indexOf('='); if (lio == -1) continue; // invalid line var key = line.substring(0, lio); var value = line.substring(lio + 1); var keySplit = key.split('.'); var obj = treeData; for (var ksi = 0; ksi < keySplit.length; ksi++) { var keySplitKey = keySplit[ksi]; if (obj[keySplitKey] == undefined) obj[keySplitKey] = {}; if (ksi == keySplit.length - 1) obj[keySplitKey].value = value; obj = obj[keySplitKey]; } } const t1 = performance.now(); console.warn("parse took " + (t1-t0) + " milliseconds"); // around 9 milliseconds RED.main.download("tree.teensy.boards.json", JSON.stringify(treeData, null, 4)); console.warn(treeData); }
Are there any good resources to assist with using VSCode with Teensy?
Platformio is the best way, and I don't think there is any good guide how to set it up and how it works.
I was thinking the same yesterday and was planning to do a simple guide (with pictures) how to do it.
The resources on platformio is not that good and have to much information.
Maybe it was because I already had some of the necessary dependencies and tools installed, but for me it was as simple as installing the PlatformIO extension in VSCode and clicking the “new project” button. After selecting the board I wanted to use, it automatically downloaded the necessary cores and toolchains and initialized the config file and a basic main.cpp file. Everything just worked.
I already used VSCode as my main editor before, but I gave PlatformIO a try because of their debugging support. I must say it's quite impressive: I have the two SWD pins of an Arduino Nano 33 BLE connected to an ST-Link adapter, and it allows me to set breakpoints, inspect variables, single-step through the code, step through the assembly, inspect the registers (including peripheral registers with meaningful names), read any address in RAM, etc. Pretty much anything you can do with a standard (non-embedded) debugger. It already saved me a lot of time, being able to just hover over a variable name in your IDE to see its value is orders of magnitude faster than adding a print statement and recompiling+uploading every time you want to inspect a variable.
Are there any plans to include an SWD header on future Teensies? I've seen some articles about breaking out the pins on T3, but they were quite destructive, and as far as I could tell from the forum threads here, the T4 doesn't allow SWD debugging at all because of how its fuses are configured.
Given how easy it is to start a debugger with PlatformIO, and since Arduino also seems to be adding debugging support in their Arduino Pro IDE, it could be a nice feature to have on a Teensy as well.
On a related note: Raspberry Pi also boasts about the SWD debugging support on the Pico. A $4 SWD debugger sounds pretty nice.
I've tried their “Picoprobe” firmware and their fork of OpenOCD to connect to my Arduino Nano 33 BLE. It detects the Pico correctly, but it seems to crash when selecting the nRF52840 as the target (the ST-Link has no such issues), so it looks like they only support the Pico itself as a target right now, not other types of ARM chips.
visualteensy https://github.com/luni64/VisualTeensy
Sure. Here is the output:
Code:2K performance run parameters for coremark. CoreMark Size : 666 Total ticks : 12129313 Total time (secs): 12.129313 Iterations/Sec : 247.334701 Iterations : 3000 Compiler version : GCC6.3.1 20170620 Compiler flags : (flags unknown) Memory location : STACK seedcrc : 0xe9f5 [0]crclist : 0xe714 [0]crcmatrix : 0x1fd7 [0]crcstate : 0x8e3a [0]crcfinal : 0xcc42 Correct operation validated. See README.md for run and reporting rules. CoreMark 1.0 : 247.334701 / GCC6.3.1 20170620 (flags
Last edited by mlewus; 02-07-2021 at 05:46 PM. Reason: Additional info
thanks. did the program report the CPU clock speed (clk_sys)? 125mhz?
No, I posted everything that was sent to the terminal. I attached to the Pico with CoolTerm on a Mac (115200, 8 N 1).
It's completely worth your time to set up PlatformIO on VS code for the Teensy. I wouldn't do it any other way. Like really, I simply wouldn't have used the Teensy 4 on a new project if I had to use the Arduino IDE. Setup is not difficult:
Install Visual Studio Code and set up for C++/C development according to: https://code.visualstudio.com/docs/cpp/config-mingw
Install Platform IO by searching for it in the extensions search area from within VS code
Install teensy extension (platform-teensy) inside Platform IO
In the PIO Home tab, click "new project", select the board, and you're on your way!
I use VS Code for all my Python work, too. It's super flexible. Sometimes the configuration in its .json files is a little head-scratching, but at worst a few google searches have always fixed my problems. It's incredibly easy to setup and use with git, too.
You would be wise to consider new options. IMO, VS Code (or similar) is the future. It's professional.
Last edited by kingforger; 02-10-2021 at 11:06 PM.
@kingforger is right. I set up Teensy on VS Code and never looked back. It was easy to do and it is so much easier to use than Arduino, even for simple programs.
@mlewus and @mkingforger, can you comment on the process of updating your VSCode/PlatformIO environment when there is a new release of Arduino and/or TeensyDuino? I tried VSCode/PlatformIO twice, with about a year in between. I was able to get up and running and build simple projects, but decided it wasn't worth the time to adopt a platform that wasn't supported by Arduino or PJRC.
I'm still relatively new to Arduino and Teensy, and while the IDE drove me crazy at first, I'm pretty okay with it now. I figured out how to specify locations for my sketch and library folders and for Arduino's temporary folders, and that helped a lot.
Yes, it's clunky, and I'd like to have good integration with the editor, but I've learned to live with it. I use the IDE for simple sketches and testing, and switch to Notepad++ as my editor for larger projects. I plan to hold out for the new Arduino IDE, or possibly Arduino CLI and integration with Notepad++. The most important thing to me is to have a clear and simple procedure for installation and updates, and to be able to bring all existing sketches and libraries forward with new releases.
@joepasquariello, Platformio allows you to configure the version of the framework that you’re installing. Here is the doc page that shows how to use the release, or latest build, versions of teensyduino for Platformio:https://docs.platformio.org/en/lates...ms/teensy.html . The teensyduino version can be selected in the platform.ini file on a project by project basis.
You can also select whether to use the libraries in the teensyduino version you have installed, or select a different version of any library for your project. This is discussed here: https://docs.platformio.org/en/lates...ger/index.html
Thanks for the info, @mlewus. I'm sure it's just a matter of investing the time to get past the initial hurdles. One of these days I'll give it another go.