Raspberry Pi Pico

I definitely don't love the Java IDE's editor. I almost always use the "external editor" preference.

I use VisualStudio 2017 + VisualMicro for most of my work (minus TI and Microchip stuff). I like it a lot!
I fire up the Arduino IDE only for very simple stuff and trying example sketches on the fly.
 
Boards.txt and platform.txt are a nightmare to parse. Having the relevant information in a xml / json format would be much easier

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);
}
 
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.
 
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.

I will admit, at least a few times I've considered giving PlatformIO on VS Code a try, but it's always turned into "don't have time to fiddle with this right now" when how to set it up wasn't intuitive.
 
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.
 
FYI. The second core is working ok so far in micropython using _thread.

in the SDK there are multicore examples, pico-examples/multicore/
I don't have a pico yet, so I haven't tried any thing except some compiles.

attached is a UF2 of coremark for pico ... anyone want to run it for me?

Update: I've run a multicore rectangle rule and get a 1.9 speedup. The 2nd core adds about 2.8 ma (5.8 ma for micromod pico on ATP carrier).
Another test with multicore CoreMark in RAM where single core gets 249.8 iterations/sec (21.9 ma), dual core get 484.3 iterations/sec (25.3 ma). Speedup up 1.9 at a cost of 2.4 ma. See post #174 for more coremark results.
 

Attachments

  • coremark.zip
    33.9 KB · Views: 80
Last edited:
... attached is a UF2 of coremark for pico ... anyone want to run it for me?
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:
No, I posted everything that was sent to the terminal. I attached to the Pico with CoolTerm on a Mac (115200, 8 N 1).
 
I will admit, at least a few times I've considered giving PlatformIO on VS Code a try, but it's always turned into "don't have time to fiddle with this right now" when how to set it up wasn't intuitive.

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.


Lately I've been reconsidering whether to keep the Arduino IDE as Teensy's primarily supported platform, or switch to VS Code (perhaps with Luni's makefile, maybe PlatformIO, or something else....)

You would be wise to consider new options. IMO, VS Code (or similar) is the future. It's professional.
 
Last edited:
@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/latest/platforms/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/latest/librarymanager/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.
 
Went for a MMod RP2040 with stuff in my SFun cart since I'll have to get carrier boards to see the Teensy4.MMod.

There was a note once about making an rPi breakout for Teensy to work with Pi Hats?

There is this PICO Pi Hat adapter : hackster.io/news/the-pico-2-pi-adaptor-plate

Not that I have more than 1 or two of those Hat things ... But with PICO folks into rPi's that could make it handy.
 
Mine is on a FedEx truck to be delivered in town today... It will probably be several days before I go into town to pick it up.
 
RP2040.MM has a tracking number to me ... maybe next week? Hopefully by the time it arrives and unboxed the path to C/C++ building on Windows will be ready :)

SFun doesn't appear to have any unique answer yet for c/c++ just links to rPi docs and nothing Arduino?
 
RP2040.MM has a tracking number to me ... maybe next week? Hopefully by the time it arrives and unboxed the path to C/C++ building on Windows will be ready :)

SFun doesn't appear to have any unique answer yet for c/c++ just links to rPi docs and nothing Arduino?

There's an early bit of development being done for RP2040 support on Platform.io. I was able to do a basic blink application using the Arduino framework with it. Might be worth looking at and/or pitching in:

https://github.com/Wiz-IO/wizio-pico
 
Using rpi pico, I've run some circuitpython/micropython tests and run a few C benchmarks via cmake and SDK (-O3 gcc 6.3.1). Here are some coremark plots
pico.png
picoa.png
Compile options iterations/sec @125MHz, -Os 144.606175, -O 199.637605, -O2 242.092629, -O3 247.347813
(The Sparkfun ATP micromod carrier adds about 5.7ma to pico power.)


I've updated the micropython/circuitpython table (Teensy 4, STM32F405, M4, pyboard) and see pico SSL/TLS/RSAsign performance comparisons

Some other performance data points at https://github.com/manitou48/DUEZoo/blob/master/perf.txt

Update: multicore CoreMark on 125mhz pico (in RAM) achieves 484.3 iterations/sec for a 1.9 speedup on 2 cores, costing an additional 2.4 ma. A stack needs to be provided to start the 2nd core:
multicore_launch_core1_with_stack(core1_entry,(uint32_t *)536936448,100000);

Update 7/19/21: With Arduino IDE and board Nano RP2040 Connect, single core Coremark (-O3 @125MHz) gets 240.7 iterations/second, with 2 cores 434.6 (speedup 1.8). stack argument not needed in multicore_launch_core1()
 
Last edited:
For anyone who's interested, Adafruit now has their Feather Rp2040 board available. They were in stock as of a few hours ago and I just ordered a couple. Like the other Feather boards it has a reset button so you can load code without having to unplug the USB cable :)
 
Back
Top