PlatformIO & Microchip SAMR34 LoRa

If anyone is interested:

Testing LoRaWAN


Great stuff! This would make an excellent addition to the existing platform-atmelsam which only has one Atmel SAM-R21 chip support. And the, CMSIS, ASF and Blink framework additions are also great.

@ivankravets and/or @valeros can check if integration will be done.

my opinion is … do not mix MCU and SiP chips
there are specific things … will complicating the normal platform
btw: SiP is SAML21+SX1276

1 Like

I have tested this platform with a RAK4260 board with minor changes (thanks Georgi) successfully sending multichannel LoRaWAN messages both with abp an ottaa.
Adding Arduino framework to these chips is a great step forward.

1 Like

First Great job @wizio
Hello @mromani
to join otaa have you changed anything other then setting the devEUI, appEUI, appKey?

1 Like

Hi @mromani, could you share what changes you did?

I can identify I need to add a new board definition (json) and a variant, at most.

Is there anything else you added? any chances to share the code?


Hi @wizio,
I am working in SAMR34 development board . with platformIO with your firmware. I have used Arduino Platform. for SAMR34 Xplained PRO DM320111 (development board) Works great . and I have built the board with ATSAMR34J18 soc and upload the hex file of the platformio code. using J_LINK lite. I doesn’t work.

The problem I found here is BARMETAL code asf_blink hex is work fine in the custom board . but LED blink Arduino code for this board in not working when it is upload to custom board . But The same LED BLINK code is working in the development broad .

I not have j-link and standalone module now ( home office ) to find what is wrong

Does anyone have worked on custom SAMR34 board & Use IDE as platform IO ?

The first post in this topic is a link to a custom platform with SAMR34 support. Does that not work?

Yes, It works fine , Also developed whole firmware in platform IO.
Now hex don’t work in custom board.
Or can you please suggest how can configure ATMEL ICE with platform IO , so I can load directly and test.

Hello, I hope I´m on the right topic.

I´m working with the BastWan board that has a RAK4260, based on the SAMR34. While I do have an ATMEL ICE programmer and could program the SAMR34 correctly in PlatformIO, but I would like to keep the USB bootloader installed and program the SAMR34 via Bossac.
When I using the ElectronicCats BastWAN in the Arduino IDE, I noticed that the Arduino IDE is using Bossac to program the SAMR34.

Documents\ArduinoData\packages\electroniccats\tools\bossac\1.0.0-electroniccats-1/bossac.exe -i -d --port=COM21 -U true -i -e -w -v

When I compiled the same code in PlatformIO and manually used Bossac to program the SAMR34 the code didn´t correctly run. Is my code compile differently in Arduino IDE than in PlatformIO?

Site to find the USB bootloader

void setup() {


void loop() {

The article you’re refering to seems to be using the Arduino packages from this page: GitHub - ElectronicCats/Arduino_Boards_Index: Electronic Cats Package Lists for the Arduino Board Manager

While this posts talks about a custom platform which uses this core implementation: framework-sam-lora/arduino at master · Wiz-IO/framework-sam-lora · GitHub

And they seem to be very different, e.g. the above doesn’t even have the bastwan variant you’re looking for.

I’ve unpacked the core given in the first link at GitHub - maxgerhardt/pio-electroniccats-samd: PlatformIO package for Electroniccats SAMD and R core and added the PlatformIO specific files to it.

I’m assuming you’re selecting “BastWAN” board which maps to this variant.

Can you please try and clone the following project: GitHub - maxgerhardt/pio-bastwan-test and see if you can build and upload it?

Sadly I don’t have the board to test, so I’m flying blind here. For me, it at least compiles, using the modified Arduino core and Atmel CMSIS headers.

Checking size .pio\build\bastwan\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   5.2% (used 2136 bytes from 40960 bytes)
Flash: [          ]   3.9% (used 9984 bytes from 253952 bytes)
================== [SUCCESS] Took 3.65 seconds ====================

Hi maxgerhardt,

I compiled the project that you put on Gitlab and was able to compile it. But I was not able to upload it via PlatformIO.
Then I tried to upload the firmware.bin file via bossac via the following line in Powershell:

.\bossac.exe -i -d --port=COM21 -U true -i -e -w -v ./firmware.bin -R

And the program started to run, thanks for the help, I didn´t add the include.

After I did have success with Bossac, I tried to upload via PlatformIO again, but without success. I did notice that the COM port that was 20, changed again to COM21 (the bootloader com). Can it be that PlatformIO uses a different Bossac configuration?

It uses a different bossac package, yes.

There could be three problem sources:

  • PlatformIO can’t reset the board into bootloader mode (via the magic 1200bps COM port open)
    • most bootloaders have the feature that a quick double-reset tap resets the board into bootloader mode. Does that help?
  • It really needs the exact BOSSAC version that the custom Arduino core uses
    • try and use the updated platformio.ini that also redirects tool-bossac from here
  • the firmware is compiled in such a way that it overwrites the bootloader or interferes with it.
    • Is upload still possible via the Arduino IDE? If yes, the bootlaoder is still there. Otherwise it needs to be reflashed.

I have been continuing to look into Bossa, it looks like Electronicscats uses a new version of Bossa.
“Basic Open Source SAM-BA Application (BOSSA) Version 1.7.0-mattairtech-3

The old version shows the following error:
“Unsupported processor”

Basic Open Source SAM-BA Application (BOSSA) Version 1.7.0
.\bossac_or.exe -i -d -U true -i -e -w -v ./firmware.bin -R
Trying to connect on COM21
Set binary mode
version()=v1.1 [Arduino:XYZ] Jul 13 2020 08:36:04
Unsupported processor
Send auto-baud
Set binary mode
version()=v1.1 [Arduino:XYZ] Jul 13 2020 08:36:04
Unsupported processor
Auto scan for device failed
Try specifying a serial port with the ‘-p’ option

Basic Open Source SAM-BA Application (BOSSA) Version 1.7.0-mattairtech-3
.\bossac.exe -i -d -U true -i -e -w -v ./firmware.bin -R
Trying to connect on COM21
Set binary mode
version()=v1.1 [Arduino:XYZ] Jul 13 2020 08:36:04
Connected at 921600 baud
Device found on COM21
Atmel SMART device 0x10810028 found
Device : ATSAMR34J18
Chip ID : 10810028
version()=v1.1 [Arduino:XYZ] Jul 13 2020 08:36:04
Version : v1.1 [Arduino:XYZ] Jul 13 2020 08:36:04
Address : 8192
Pages : 3968

Upload is still possible

I copied the newer Bossac version to the tool-bossac folder in PlatfromIO and now was able to upload my code to the SAMR34. The code did run correctly. Thanks, Maxgerhardt. :+1:

Great to hear. I’ll file a feature request in GitHub - platformio/platform-atmelsam: Atmel SAM: development platform for PlatformIO regarding this ElectronicCats Arduino core so that official support may come eventually :slight_smile:

Hm per updated platformio.ini that uses the platform_packages = tool-bossac@.. directive that shouldn’t be necessary, but your way also works.

1 Like

Feature request is open at

1 Like