First of all, thanks for the great platform! I’m new to PlatformIO but already got an example up and running — it’s been a great experience with the framework and the VS Code integration!
In my example, I’m using the Arduino Nano ESP32 but I’d like to also migrate another project from Arduino IDE over to PlatformIO: that one is using an Arduino Nano Matter board. My understanding looking at
Seems like at least the platform modification part (to platform-siliconlabsefm32) was started a year ago, but the builder script was never started or finished. I’ll step in there and finish it up.
Do you have a Sparkfun ThingPlus Matter? I have it to the point where I can at least build for that single board in a single configuration (Matter stack activated) and have the uploaders (JLink, Simplicity Commander, OpenOCD) in place.
If you have the hardware, please download + build + try to upload to the board. Check if the LED blinks and if the “Monitor” tasks outputs the expected serial text.
I’ve updated support for the actual Arduino Nano Matter. The project above now has a arduino_nano_matter environment. You can use the project environment switcher to select it. Does it upload and work?
@maxgerhardt, first of all, thank you so much for your help, I appreciate it so much!
I cloned your repo, selected the environment (VS Code shows env:arduino-nano-matter (pio-sparkfun-thingplusmatter-test) in the lower blue bar), did a clean build via PlatformIO: Clean, and then a PlatformIO: Upload. Here’s the output:
* Executing task: platformio run --target upload --environment arduino_nano_matter
Processing arduino_nano_matter (board: arduino_nano_matter; platform: https://github.com/maxgerhardt/platform-siliconlabsefm32.git#silabs-arduino; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tool Manager: Installing git+https://github.com/maxgerhardt/tool-simplicitycommander.git#windows_x64
git version 2.39.5 (Apple Git-154)
Cloning into '/Users/hbf/.platformio/.cache/tmp/pkg-installing-hl8ds39w'...
remote: Enumerating objects: 83, done.
remote: Counting objects: 100% (83/83), done.
remote: Compressing objects: 100% (69/69), done.
remote: Total 83 (delta 13), reused 79 (delta 13), pack-reused 0 (from 0)
Receiving objects: 100% (83/83), 33.89 MiB | 20.96 MiB/s, done.
Resolving deltas: 100% (13/13), done.
Tool Manager: tool-simplicitycommander@1.16.4+sha.aecc51f has been installed!
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/siliconlabsefm32/arduino_nano_matter.html
PLATFORM: Silicon Labs EFM32 (10.0.0+sha.0ce1f09) > Arduino Nano Matter
HARDWARE: CORTEX-M33 39MHz, 256KB RAM, 1.50MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, jlink)
PACKAGES:
- framework-arduino-silabs @ 2.2.0+sha.49583ff
- tool-openocd-silabs @ 3.1200.0+sha.65d7bde
- toolchain-gccarmnoneeabi @ 1.120301.0 (12.3.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 11 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/arduino_nano_matter/src/main.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduinoVariant/arduino_i2c_config.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduinoVariant/arduino_serial_config.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduinoVariant/arduino_spi_config.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduinoVariant/arduino_variant.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/Interrupt.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/Serial.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/Tone.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/WMath.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/adc.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/api/CanMsg.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/api/CanMsgRingbuffer.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/api/Common.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/api/IPAddress.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/api/PluggableUSB.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/api/Print.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/api/Stream.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/api/String.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/avr/dtostrf.c.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/dac.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/main.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/pinToIndex.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/pwm.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/silabs_additional.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/silabs_eeprom.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/silabs_stubs.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/stdlib_noniso.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/wiring.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/wiring_analog.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/wiring_digital.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/wiring_pulse.cpp.o
Compiling .pio/build/arduino_nano_matter/FrameworkArduino/wiring_shift.cpp.o
Archiving .pio/build/arduino_nano_matter/libFrameworkArduinoVariant.a
Indexing .pio/build/arduino_nano_matter/libFrameworkArduinoVariant.a
Archiving .pio/build/arduino_nano_matter/libFrameworkArduino.a
Indexing .pio/build/arduino_nano_matter/libFrameworkArduino.a
Linking .pio/build/arduino_nano_matter/firmware.elf
/Users/hbf/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: /Users/hbf/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/lib/thumb/v8-m.main+fp/hard/libc_nano.a(libc_a-closer.o): in function `_close_r':
(.text._close_r+0xc): warning: _close is not implemented and will always fail
/Users/hbf/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: /Users/hbf/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/lib/thumb/v8-m.main+fp/hard/libc_nano.a(libc_a-fstatr.o): in function `_fstat_r':
(.text._fstat_r+0xe): warning: _fstat is not implemented and will always fail
/Users/hbf/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: /Users/hbf/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/lib/thumb/v8-m.main+fp/hard/libc_nano.a(libc_a-signalr.o): in function `_getpid_r':
(.text._getpid_r+0x0): warning: _getpid is not implemented and will always fail
/Users/hbf/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: /Users/hbf/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/lib/thumb/v8-m.main+fp/hard/libc_nano.a(libc_a-isattyr.o): in function `_isatty_r':
(.text._isatty_r+0xc): warning: _isatty is not implemented and will always fail
/Users/hbf/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: /Users/hbf/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/lib/thumb/v8-m.main+fp/hard/libc_nano.a(libc_a-signalr.o): in function `_kill_r':
(.text._kill_r+0xe): warning: _kill is not implemented and will always fail
/Users/hbf/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: /Users/hbf/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/lib/thumb/v8-m.main+fp/hard/libc_nano.a(libc_a-lseekr.o): in function `_lseek_r':
(.text._lseek_r+0x10): warning: _lseek is not implemented and will always fail
/Users/hbf/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: /Users/hbf/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/lib/thumb/v8-m.main+fp/hard/libc_nano.a(libc_a-readr.o): in function `_read_r':
(.text._read_r+0x10): warning: _read is not implemented and will always fail
/Users/hbf/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: /Users/hbf/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/lib/thumb/v8-m.main+fp/hard/libc_nano.a(libc_a-writer.o): in function `_write_r':
(.text._write_r+0x10): warning: _write is not implemented and will always fail
Checking size .pio/build/arduino_nano_matter/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [======= ] 66.9% (used 175492 bytes from 262144 bytes)
Flash: [===== ] 53.7% (used 844868 bytes from 1572864 bytes)
Configuring upload protocol...
AVAILABLE: cmsis-dap, jlink, simplicitycommander
CURRENT: upload_protocol = cmsis-dap
Uploading .pio/build/arduino_nano_matter/firmware.elf
Open On-Chip Debugger 0.12.0+dev-01514-g21fa2de70 (2024-02-07-19:03)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 1
efm32s2_dci_read_se_status
[efm32s2.cpu] halted due to debug-request, current mode: Thread
xPSR: 0xf9000000 pc: 0x08000170 msp: 0x20001008
[efm32s2.cpu] halted due to debug-request, current mode: Thread
xPSR: 0xf9000000 pc: 0x08000170 msp: 0x20001008
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **
Error: [efm32s2.cpu] clearing lockup after double fault
shutdown command invoked
========================================================================== [SUCCESS] Took 20.62 seconds ==========================================================================
Environment Status Duration
------------------- -------- ------------
arduino_nano_matter SUCCESS 00:00:20.624
=========================================================================== 1 succeeded in 00:00:20.624 ===========================================================================
* Terminal will be reused by tasks, press any key to close it.
The halted due to debug-request made me think I had a breakpoint set somewhere but I think I don’t (warning: I’m not a VS Code expert): I did a cmd-shift-P and selected Disable All Breakpoints, assuming this applies to PlatformIO and retried, with the same result.
The output looks good, the “halted due to debug-request” from OpenOCD is perfectly normal during the flashing procedure.
But the firmware is indeed not looking like it’s working, clearing lockup after double fault means it just immediately crashed. I’ll have a closer look with a binary analysis of the produced firmware and the reference firmware.
folders and re-upload the project to the Arduino Nano Matter? There now should also no more flood of warnings during the last step of the build (“x is not implemented and will always fail”).
Looks like now. When I click in the PlatformIO sidebar the Debug → Start Debugging action and afterwards Debug → Toggle Debug Console, I see:
Reading symbols from /Users/kaspar_fischer/dev/pio-sparkfun-thingplusmatter-test/.pio/build/arduino_nano_matter/firmware.elf...
Warning: 'set target-async', an alias for the command 'set mi-async', is deprecated.
Use 'set mi-async'.
PlatformIO Unified Debugger -> https://bit.ly/pio-debug
PlatformIO: debug_tool = cmsis-dap
PlatformIO: Initializing remote target...
Open On-Chip Debugger 0.12.0+dev-01514-g21fa2de70 (2024-02-07-19:03)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
efm32s2_dci_read_se_status
Info : tcl server disabled
Info : telnet server disabled
Info : Using CMSIS-DAPv2 interface with VID:PID=0x2341:0x0072, serial=8A483241
Info : CMSIS-DAP: SWD supported
Info : CMSIS-DAP: FW Version = 2.0.0
Info : CMSIS-DAP: Serial# = 8A483241
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 1000 kHz
Info : SWD DPIDR 0x6ba02477
Info : [efm32s2.cpu] Cortex-M33 r0p4 processor detected
Info : [efm32s2.cpu] target has 8 breakpoints, 4 watchpoints
Info : [efm32s2.cpu] Examination succeed
Info : starting gdb server for efm32s2.cpu on pipe
Info : accepting 'gdb' connection from pipe
Warn : [efm32s2.cpu] target was in unknown state when halt was requested
Info : detected part: MG24B210, rev 19
Info : flash size = 1536 KiB
Info : flash page size = 8192 B
Info : detected part: MG24B210, rev 19
Info : flash size = 1536 KiB
Info : flash page size = 8192 B
0x08000170 in ?? ()
[efm32s2.cpu] halted due to debug-request, current mode: Thread
xPSR: 0xf9000000 pc: 0x08000170 msp: 0x20001008
Info : SWD DPIDR 0x6ba02477
Error: Failed to write memory at 0x5003003c
Info : SWD DPIDR 0x6ba02477
Error: Failed to read memory at 0x5003000c
Error: Failed to enable MSC write
Error: failed erasing sectors 3 to 106
Error: flash_erase returned -4
.pioinit:15: Error in sourced command file:
I also tried Run and Debug (Shift-cmd-D) in the left-most VS Code bar and then clicking PIO Debug (pio-sparkfun-thingplusmatter-test). When I do that, I get this output
Processing arduino_nano_matter (board: arduino_nano_matter; platform: https://github.com/maxgerhardt/platform-siliconlabsefm32.git#silabs-arduino; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/siliconlabsefm32/arduino_nano_matter.html
PLATFORM: Silicon Labs EFM32 (10.0.0+sha.86a44e1) > Arduino Nano Matter
HARDWARE: CORTEX-M33 39MHz, 256KB RAM, 1.50MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, jlink)
PACKAGES:
- framework-arduino-silabs @ 2.2.0+sha.49583ff
- toolchain-gccarmnoneeabi @ 1.120301.0 (12.3.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 11 compatible libraries
Scanning dependencies...
No dependencies
Building in debug mode
Checking size .pio/build/arduino_nano_matter/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [======= ] 67.5% (used 176924 bytes from 262144 bytes)
Flash: [===== ] 53.9% (used 847144 bytes from 1572864 bytes)
================================================ [SUCCESS] Took 0.75 seconds ================================================
Environment Status Duration
------------------- -------- ------------
arduino_nano_matter SUCCESS 00:00:00.747
================================================ 1 succeeded in 00:00:00.747 ================================================
* Terminal will be reused by tasks, press any key to close it.
and the same output as above in the Debug Console.
Interesting, on my Arduino Nano Matter, it uploads and ruins normally, continuously. But when debugging encounters the same MSC erase error. I’ll have to further look into this.
Adding Serial.println("Setup..."); to the above program’s setup() still works. However, adding Serial.begin(9600); Serial.println("Setup..."); instead again results in no blinking.
I also tried:
Serial.begin(9600); while (!Serial) {};
Serial.begin(9600); delay(5000);
but neither caused the LED to blink.
(I don’t think this matters but I also tried 3 different Apple USB-C cables and all 3 ports of my MacBook M1 — without success.)
The on-board SAMD11 chip which has a CMSIS-DAP debugger firmware flashed onto it should 100% suffice, no external J-Link needed. But for me, debugging also doesn’t work in the Arduino 2.0. Need to check that further.
works well, up to where the Arduino loop() exits back to main() and calls handle_serial_events().
There, it goes into lockup:
S
tarting target CPU...
.
..Target halted (DBGRQ, PC = 0xEFFFFFFE)
R
eading common registers:
Read register 'r0' (4 b
ytes) from hardware: 0x304E0120
Read register 'r1' (4 byte
s) from hardware: 0x03087047
Read
register 'r2' (4 bytes) from hardware: 0x000000
00
Read register 'r3' (4 bytes)
from hardware: 0x00000000
Read
register 'r4' (4 bytes) from hardware:
0x182C0120
Read register 'r
5' (4 bytes) from hardware:
0x182C0120
Read
register 'r6' (4 bytes
) from hardware: 0x060
60606
Read register
'r7' (4 bytes) from ha
rdware: 0x07070707
R
ead register 'r8' (4 bytes) from
hardware: 0x08080808
Read register 'r9' (4 bytes) from
hardware: 0x09090909
Read register 'r10' (4 bytes) from hardwar
e: 0x10101010
Rea
d register 'r11' (4 bytes) from
hardware: 0x11111111
Read register 'r12' (4 bytes) from
hardware: 0x
AC4F0120
Read register
'sp' (4 bytes) from hardware
: 0x98110020
Read reg
ister 'lr' (4 bytes) from hardware:
0xFDFFFFFF
Read register
'pc' (4 bytes) from hardware: 0xFE
FFFFEF
Read register '
xpsr' (4 bytes) from hardware: 0x0300
0021
Program
received signal SIGTRAP, Trace/breakpoint trap.
<signal handler called>
R
eading register 'msp' = 0x20001198
Reading regi
ster 'psp' = 0x20014E30
R
eading register 'msp_ns' = 0x00000000
R
eading register 'psp_ns' = 0xFFFFFFF
C
R
eading register '
msp_s' =
0x20001198
R
eading register '
psp_s' = 0x20014E
30
R
eading register 'primask' =
0x00000000
R
eading register 'basepri'
= 0x0000
0000
R
eading register 'faultmas
k' = 0x00000000
R
eading register 'co
ntrol' = 0x
00000000
R
eading register 'apsr' = 0x20000
0
00
R
eading register 'epsr' = 0
x010000
00
R
eading register 'ip
sr' = 0x00000003
R
eading register 'iapsr' = 0x200000
03
R
eading register 'eapsr' = 0x21000000
R
eading register 'iepsr
' = 0x01000003
R
eading register 'mspl
im' = 0x20000008
R
eading register 'psplim' = 0x20012EC0
R
eading register 'msplim_s' = 0
x20000008
R
eading register 'msplim_ns' = 0x00000000
R
eading register 'psplim_s' = 0x20012EC0
R
eading register 'psplim_ns' = 0x0000
0000
R
eading register 'fpscr' = 0x00000000
R
eading register 's0'
= 0x00000000
R
eading register 's1' = 0x00000
000
R
eading register 's2' =
0x00000000
R
eading register 's3' = 0x0000000
0
R
eading register 's4' = 0
x00000000
R
eading register 's5' =
0x00000000
R
eading register 's6
' = 0x00000000
R
eading register 's7' =
0x00000000
R
eading register 's8' = 0x000000
00
R
eading register 's9' = 0x
00000000
R
eading register 's10' = 0x00000000
R
eading register 's11' = 0
x000000
00
R
eading register 's12'
= 0x000
00000
R
eading register 's13' = 0x00000000
R
eading register 's14' = 0
x00000000
R
eading register 's15' = 0x00000000
R
eading register 's16' = 0x00000000
R
eading register 's17' = 0x00000000
R
eading register 's18' = 0x00000000
R
eading register
's19' = 0x00000000
R
eading register 's20' =
0x00000000
R
eading register '
s21' = 0x00000
000
R
eading register 's22
' = 0x00000000
Reading
register 's23' = 0x00000000
R
eading register 's24' = 0x00000000
R
eading register 's25' = 0x00000000
R
eading register 's26' = 0x000000
00
R
eading register 's27' = 0x00000000
R
eading register 's28' =
0x00000000
R
eading register 's2
9' = 0x00000000
R
eading regis
ter 's30' = 0
x00000000
R
eading register 's31' = 0x0000
0000
R
eading register 'd0'
= 0x
00000000
R
eading register 'd1' = 0
x00000000
R
eading register 'd2'
= 0x00000000
R
eading register 'd3' = 0x00
000000
R
eading register 'd
4' = 0x000000
00
R
eading register 'd
5' = 0x00000000
R
eading register 'd6
' = 0x
00000000
R
eading register 'd7' = 0x000
00000
R
eading register
'd8' = 0x00
000000
R
eading register 'd9' = 0x000
00000
R
eading register 'd10' = 0x0
0000000
R
eading register 'd11
' = 0x00000000
R
eading register 'd12' = 0
x00000000
R
eading register 'd13' = 0
x00000000
R
eading register 'd14' =
0x000000
00
R
eading register 'd15
' = 0x00000000
warning: ARM M in lockup state, stack unwinding terminated.
And THANK YOU @maxgerhardt !!! I could get the board working on Arduino IDE, and SiLabs Simplicity Studio, but this is the first time I’m making progress on getting it to work on PlatformIO!
– And as far as I can tell - the J-Link debugger works superb on the SparkFun Thing Plus Matter MGM240P.