Arduino MKR1000 does not boot

Hi,

I am in the process of moving form Arduino IDE to PlatformIO. I wrote a simple main.cpp and it compiles without any issues. For completion, the code:

#include "Arduino.h"

void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(115200);
  Serial.println("Hello there");
}

void loop()
{
  Serial.println("Still works");
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);
}

platformio.ini

[env:mkr1000USB]
platform = atmelsam
board = mkr1000USB
framework = arduino
monitor_speed = 115200

(There are some more .c and .h files in the source folder, but they also build fine and are not referenced by the main.cpp → the linker ignores them)

I can upload this code to my MKR1000 but i cannot see an LED flashing or any serial output. If i write the code in the Arduino IDE my board acts as expected. I feel like my description is close to this thread. Does anyone has pointers where i could have gone wrong? I suspect that there is some reset missing to trigger the board to restart. I am also not able to trigger this manually with the reset button (the board switches to the bootloader immediately). Further, i don’t get any connection to the host until i press the rest again aka PlatformIO cannot find a port for the serial monitor.

Any help is appreciated.
Cheers,
Johnny

Have you tried renaming them to .txt files regardless to they won’t get compiled?

Can you show a screenshot of the Arduino IDE with all the board settings visible?

Can you post the exact output of what appears when you do a Project Tasks → Upload and Monitor?

Hey,

Thanks for the quick answer. I removed all the unnecessary .c and .h files from the project and did a clean build. This did not change anything.

Do you mean these settings?


I also updated the boards firmware to the newest available release (19.6.1) some days ago and the firmware now reports correctly as well.

Here is the log from Project Tasks → Upload and Monitor

> Executing task in folder mkr1000-client: C:\Users\Sinthoras\.platformio\penv\Scripts\pio.exe run --target upload --target monitor --environment mkr1000USB <

Processing mkr1000USB (platform: atmelsam; board: mkr1000USB; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelsam/mkr1000USB.html
PLATFORM: Atmel SAM (5.0.2) > Arduino MKR1000
HARDWARE: SAMD21G18A 48MHz, 32KB RAM, 256KB Flash
DEBUG: Current (atmel-ice) External (atmel-ice, blackmagic, jlink)
PACKAGES:
 - framework-arduino-samd 1.8.9
 - framework-cmsis 1.40500.0 (4.5.0)
 - framework-cmsis-atmel 1.2.0
 - tool-bossac 1.10700.190624 (1.7.0)
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 12 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio\build\mkr1000USB\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   6.8% (used 2244 bytes from 32768 bytes)
Flash: [          ]   2.6% (used 6820 bytes from 262144 bytes)
Configuring upload protocol...
AVAILABLE: atmel-ice, blackmagic, jlink, sam-ba
CURRENT: upload_protocol = sam-ba
Looking for upload port...
Auto-detected: COM5
Forcing reset using 1200bps open/close on port COM5
Waiting for the new upload port...
Uploading .pio\build\mkr1000USB\firmware.bin
Atmel SMART device 0x10010005 found
Erase flash
done in 0.843 seconds

Write 6820 bytes to flash (107 pages)

[=================             ] 59% (64/107 pages)
[==============================] 100% (107/107 pages)
done in 0.057 seconds

Verify 6820 bytes of flash with checksum.
Verify successful
done in 0.007 seconds
CPU reset.
========================================================================== [SUCCESS] Took 10.67 seconds ==========================================================================
--- Available filters and text transformations: colorize, debug, default, direct, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at http://bit.ly/pio-monitor-filters

--- Available ports:
--- Enter port index or full name:

Thanks for your time!

Hm well uploading looks good but the device didn’t re-initialize its USB CDC (Serial) interface directly / quick enough after uploading so PlatformIO finds nothing.

Can you please try the following two things:

  • after Serial.begin(115200); add a delay(3000);. Then execute “Upload” and after that execute “Monitor”. Does the text appear?
  • replace delay(3000); with the code while(!Serial) {}. This should make the chip wait until a serial connection has been established. Do separate Upload and then Monitor task executions again.

;tldr: Nothing did anything that indicates a change to me. Further, even an “only upload” command triggers the monitor immediately after. Could this be related to the platformio.ini monitor_speed = 115200? I will leave the baudrade default and try again. Will post my results in a minute.

delay(3000); console logs
Upload:

> Executing task in folder mkr1000-client: C:\Users\Sinthoras\.platformio\penv\Scripts\pio.exe run --target upload --environment mkr1000USB <

Processing mkr1000USB (platform: atmelsam; board: mkr1000USB; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelsam/mkr1000USB.html
PLATFORM: Atmel SAM (5.0.2) > Arduino MKR1000
HARDWARE: SAMD21G18A 48MHz, 32KB RAM, 256KB Flash
DEBUG: Current (atmel-ice) External (atmel-ice, blackmagic, jlink)
PACKAGES:
 - framework-arduino-samd 1.8.9
 - framework-cmsis 1.40500.0 (4.5.0)
 - framework-cmsis-atmel 1.2.0
 - tool-bossac 1.10700.190624 (1.7.0)
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 12 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio\build\mkr1000USB\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   6.8% (used 2244 bytes from 32768 bytes)
Flash: [          ]   2.6% (used 6820 bytes from 262144 bytes)
Configuring upload protocol...
AVAILABLE: atmel-ice, blackmagic, jlink, sam-ba
CURRENT: upload_protocol = sam-ba
Looking for upload port...
Auto-detected: COM4
Forcing reset using 1200bps open/close on port COM4
Waiting for the new upload port...
Uploading .pio\build\mkr1000USB\firmware.bin
Atmel SMART device 0x10010005 found
Erase flash
done in 0.847 seconds

Write 6820 bytes to flash (107 pages)

[=================             ] 59% (64/107 pages)
[==============================] 100% (107/107 pages)
done in 0.063 seconds

Verify 6820 bytes of flash with checksum.
Verify successful
done in 0.007 seconds
CPU reset.
=========================================================================== [SUCCESS] Took 6.49 seconds ===========================================================================
Terminal will be reused by tasks, press any key to close it.

> Executing task in folder mkr1000-client: C:\Users\Sinthoras\.platformio\penv\Scripts\pio.exe run --target upload --environment mkr1000USB <

Processing mkr1000USB (platform: atmelsam; board: mkr1000USB; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelsam/mkr1000USB.html
PLATFORM: Atmel SAM (5.0.2) > Arduino MKR1000
HARDWARE: SAMD21G18A 48MHz, 32KB RAM, 256KB Flash
DEBUG: Current (atmel-ice) External (atmel-ice, blackmagic, jlink)
PACKAGES:
 - framework-arduino-samd 1.8.9 
 - framework-cmsis 1.40500.0 (4.5.0)
 - framework-cmsis-atmel 1.2.0
 - tool-bossac 1.10700.190624 (1.7.0)
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 12 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio\build\mkr1000USB\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   6.8% (used 2244 bytes from 32768 bytes)
Flash: [          ]   2.6% (used 6820 bytes from 262144 bytes)
Configuring upload protocol...
AVAILABLE: atmel-ice, blackmagic, jlink, sam-ba
CURRENT: upload_protocol = sam-ba
Looking for upload port...
Auto-detected: COM6
Forcing reset using 1200bps open/close on port COM6
Waiting for the new upload port...
Uploading .pio\build\mkr1000USB\firmware.bin
Atmel SMART device 0x10010005 found
Erase flash
done in 0.844 seconds

Write 6820 bytes to flash (107 pages)

[=================             ] 59% (64/107 pages)
[==============================] 100% (107/107 pages)
done in 0.062 seconds

Verify 6820 bytes of flash with checksum.
Verify successful
done in 0.007 seconds
CPU reset.
========================================================================== [SUCCESS] Took 10.72 seconds ==========================================================================

Terminal will be reused by tasks, press any key to close it.

> Executing task in folder mkr1000-client: C:\Users\Sinthoras\.platformio\penv\Scripts\pio.exe run --target upload --environment mkr1000USB <

Processing mkr1000USB (platform: atmelsam; board: mkr1000USB; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelsam/mkr1000USB.html
PLATFORM: Atmel SAM (5.0.2) > Arduino MKR1000
HARDWARE: SAMD21G18A 48MHz, 32KB RAM, 256KB Flash
DEBUG: Current (atmel-ice) External (atmel-ice, blackmagic, jlink)
PACKAGES:
 - framework-arduino-samd 1.8.9
 - framework-cmsis 1.40500.0 (4.5.0)
 - framework-cmsis-atmel 1.2.0
 - tool-bossac 1.10700.190624 (1.7.0)
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 12 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\mkr1000USB\src\main.cpp.o
Linking .pio\build\mkr1000USB\firmware.elf
Checking size .pio\build\mkr1000USB\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   6.8% (used 2244 bytes from 32768 bytes)
Flash: [          ]   2.6% (used 6820 bytes from 262144 bytes)
Configuring upload protocol...
AVAILABLE: atmel-ice, blackmagic, jlink, sam-ba
CURRENT: upload_protocol = sam-ba
Looking for upload port...
Error: Please specify `upload_port` for environment or use global `--upload-port` option.
For some development platforms it can be a USB flash drive (i.e. /media/<user>/<device name>)
*** [upload] Explicit exit, status 1
=========================================================================== [FAILED] Took 3.06 seconds ===========================================================================
The terminal process "C:\Users\Sinthoras\.platformio\penv\Scripts\pio.exe 'run', '--target', 'upload', '--environment', 'mkr1000USB'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

> Executing task in folder mkr1000-client: C:\Users\Sinthoras\.platformio\penv\Scripts\pio.exe run --target upload --environment mkr1000USB <

Processing mkr1000USB (platform: atmelsam; board: mkr1000USB; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelsam/mkr1000USB.html
PLATFORM: Atmel SAM (5.0.2) > Arduino MKR1000
HARDWARE: SAMD21G18A 48MHz, 32KB RAM, 256KB Flash
DEBUG: Current (atmel-ice) External (atmel-ice, blackmagic, jlink)
PACKAGES:
 - framework-arduino-samd 1.8.9
 - framework-cmsis 1.40500.0 (4.5.0) 
 - framework-cmsis-atmel 1.2.0
 - tool-bossac 1.10700.190624 (1.7.0)
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 12 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio\build\mkr1000USB\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   6.8% (used 2244 bytes from 32768 bytes)
Flash: [          ]   2.6% (used 6820 bytes from 262144 bytes)
Configuring upload protocol...
AVAILABLE: atmel-ice, blackmagic, jlink, sam-ba
CURRENT: upload_protocol = sam-ba
Looking for upload port...
Auto-detected: COM6
Forcing reset using 1200bps open/close on port COM6
Waiting for the new upload port...
Uploading .pio\build\mkr1000USB\firmware.bin
Atmel SMART device 0x10010005 found
Erase flash
done in 0.847 seconds

Write 6820 bytes to flash (107 pages)

[=================             ] 59% (64/107 pages)
[==============================] 100% (107/107 pages)
done in 0.057 seconds

Verify 6820 bytes of flash with checksum.
Verify successful
done in 0.006 seconds
CPU reset.
========================================================================== [SUCCESS] Took 10.75 seconds ==========================================================================

Terminal will be reused by tasks, press any key to close it.

> Executing task in folder mkr1000-client: C:\Users\Sinthoras\.platformio\penv\Scripts\pio.exe run --target upload --environment mkr1000USB <

Processing mkr1000USB (platform: atmelsam; board: mkr1000USB; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelsam/mkr1000USB.html
PLATFORM: Atmel SAM (5.0.2) > Arduino MKR1000
HARDWARE: SAMD21G18A 48MHz, 32KB RAM, 256KB Flash
DEBUG: Current (atmel-ice) External (atmel-ice, blackmagic, jlink)
PACKAGES:
 - framework-arduino-samd 1.8.9
 - framework-cmsis 1.40500.0 (4.5.0)
 - framework-cmsis-atmel 1.2.0
 - tool-bossac 1.10700.190624 (1.7.0)
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 12 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\mkr1000USB\src\main.cpp.o
Linking .pio\build\mkr1000USB\firmware.elf
Checking size .pio\build\mkr1000USB\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   6.8% (used 2244 bytes from 32768 bytes)
Flash: [          ]   2.6% (used 6820 bytes from 262144 bytes)
Configuring upload protocol...
AVAILABLE: atmel-ice, blackmagic, jlink, sam-ba
CURRENT: upload_protocol = sam-ba
Looking for upload port...
Auto-detected: COM6
Forcing reset using 1200bps open/close on port COM6
Waiting for the new upload port...
Uploading .pio\build\mkr1000USB\firmware.bin
Atmel SMART device 0x10010005 found
Erase flash
done in 0.846 seconds

Write 6820 bytes to flash (107 pages)

[=================             ] 59% (64/107 pages)
[==============================] 100% (107/107 pages)
done in 0.063 seconds

Verify 6820 bytes of flash with checksum.
Verify successful
done in 0.006 seconds
CPU reset.
========================================================================== [SUCCESS] Took 10.85 seconds ==========================================================================

Terminal will be reused by tasks, press any key to close it.

automatic monitor mode:

> Executing task in folder mkr1000-client: C:\Users\Sinthoras\.platformio\penv\Scripts\pio.exe device monitor --environment mkr1000USB <

--- Available filters and text transformations: colorize, debug, default, direct, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at http://bit.ly/pio-monitor-filters

--- Available ports:
--- Enter port index or full name: 

while(!Serial){ ; } console logs
Upload:

> Executing task in folder mkr1000-client: C:\Users\Sinthoras\.platformio\penv\Scripts\pio.exe run --target upload --environment mkr1000USB <

Processing mkr1000USB (platform: atmelsam; board: mkr1000USB; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelsam/mkr1000USB.html
PLATFORM: Atmel SAM (5.0.2) > Arduino MKR1000
HARDWARE: SAMD21G18A 48MHz, 32KB RAM, 256KB Flash
DEBUG: Current (atmel-ice) External (atmel-ice, blackmagic, jlink)
PACKAGES:
 - framework-arduino-samd 1.8.9
 - framework-cmsis 1.40500.0 (4.5.0)
 - framework-cmsis-atmel 1.2.0
 - tool-bossac 1.10700.190624 (1.7.0)
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 12 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio\build\mkr1000USB\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   6.8% (used 2244 bytes from 32768 bytes)
Flash: [          ]   2.6% (used 6820 bytes from 262144 bytes)
Configuring upload protocol...
AVAILABLE: atmel-ice, blackmagic, jlink, sam-ba
CURRENT: upload_protocol = sam-ba
Looking for upload port...
Auto-detected: COM4
Forcing reset using 1200bps open/close on port COM4
Waiting for the new upload port...
Uploading .pio\build\mkr1000USB\firmware.bin
Atmel SMART device 0x10010005 found
Erase flash
done in 0.847 seconds

Write 6820 bytes to flash (107 pages)

[=================             ] 59% (64/107 pages)
[==============================] 100% (107/107 pages)
done in 0.063 seconds

Verify 6820 bytes of flash with checksum.
Verify successful
done in 0.007 seconds
CPU reset.
=========================================================================== [SUCCESS] Took 6.49 seconds ===========================================================================
Terminal will be reused by tasks, press any key to close it.

> Executing task in folder mkr1000-client: C:\Users\Sinthoras\.platformio\penv\Scripts\pio.exe run --target upload --environment mkr1000USB <

Processing mkr1000USB (platform: atmelsam; board: mkr1000USB; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelsam/mkr1000USB.html
PLATFORM: Atmel SAM (5.0.2) > Arduino MKR1000
HARDWARE: SAMD21G18A 48MHz, 32KB RAM, 256KB Flash
DEBUG: Current (atmel-ice) External (atmel-ice, blackmagic, jlink)
PACKAGES:
 - framework-arduino-samd 1.8.9 
 - framework-cmsis 1.40500.0 (4.5.0)
 - framework-cmsis-atmel 1.2.0
 - tool-bossac 1.10700.190624 (1.7.0)
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 12 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio\build\mkr1000USB\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   6.8% (used 2244 bytes from 32768 bytes)
Flash: [          ]   2.6% (used 6820 bytes from 262144 bytes)
Configuring upload protocol...
AVAILABLE: atmel-ice, blackmagic, jlink, sam-ba
CURRENT: upload_protocol = sam-ba
Looking for upload port...
Auto-detected: COM6
Forcing reset using 1200bps open/close on port COM6
Waiting for the new upload port...
Uploading .pio\build\mkr1000USB\firmware.bin
Atmel SMART device 0x10010005 found
Erase flash
done in 0.844 seconds

Write 6820 bytes to flash (107 pages)

[=================             ] 59% (64/107 pages)
[==============================] 100% (107/107 pages)
done in 0.062 seconds

Verify 6820 bytes of flash with checksum.
Verify successful
done in 0.007 seconds
CPU reset.
========================================================================== [SUCCESS] Took 10.72 seconds ==========================================================================

Terminal will be reused by tasks, press any key to close it.

> Executing task in folder mkr1000-client: C:\Users\Sinthoras\.platformio\penv\Scripts\pio.exe run --target upload --environment mkr1000USB <

Processing mkr1000USB (platform: atmelsam; board: mkr1000USB; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelsam/mkr1000USB.html
PLATFORM: Atmel SAM (5.0.2) > Arduino MKR1000
HARDWARE: SAMD21G18A 48MHz, 32KB RAM, 256KB Flash
DEBUG: Current (atmel-ice) External (atmel-ice, blackmagic, jlink)
PACKAGES:
 - framework-arduino-samd 1.8.9
 - framework-cmsis 1.40500.0 (4.5.0)
 - framework-cmsis-atmel 1.2.0
 - tool-bossac 1.10700.190624 (1.7.0)
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 12 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\mkr1000USB\src\main.cpp.o
Linking .pio\build\mkr1000USB\firmware.elf
Checking size .pio\build\mkr1000USB\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   6.8% (used 2244 bytes from 32768 bytes)
Flash: [          ]   2.6% (used 6820 bytes from 262144 bytes)
Configuring upload protocol...
AVAILABLE: atmel-ice, blackmagic, jlink, sam-ba
CURRENT: upload_protocol = sam-ba
Looking for upload port...
Error: Please specify `upload_port` for environment or use global `--upload-port` option.
For some development platforms it can be a USB flash drive (i.e. /media/<user>/<device name>)
*** [upload] Explicit exit, status 1
=========================================================================== [FAILED] Took 3.06 seconds ===========================================================================
The terminal process "C:\Users\Sinthoras\.platformio\penv\Scripts\pio.exe 'run', '--target', 'upload', '--environment', 'mkr1000USB'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

> Executing task in folder mkr1000-client: C:\Users\Sinthoras\.platformio\penv\Scripts\pio.exe run --target upload --environment mkr1000USB <

Processing mkr1000USB (platform: atmelsam; board: mkr1000USB; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelsam/mkr1000USB.html
PLATFORM: Atmel SAM (5.0.2) > Arduino MKR1000
HARDWARE: SAMD21G18A 48MHz, 32KB RAM, 256KB Flash
DEBUG: Current (atmel-ice) External (atmel-ice, blackmagic, jlink)
PACKAGES:
 - framework-arduino-samd 1.8.9
 - framework-cmsis 1.40500.0 (4.5.0) 
 - framework-cmsis-atmel 1.2.0
 - tool-bossac 1.10700.190624 (1.7.0)
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 12 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio\build\mkr1000USB\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   6.8% (used 2244 bytes from 32768 bytes)
Flash: [          ]   2.6% (used 6820 bytes from 262144 bytes)
Configuring upload protocol...
AVAILABLE: atmel-ice, blackmagic, jlink, sam-ba
CURRENT: upload_protocol = sam-ba
Looking for upload port...
Auto-detected: COM6
Forcing reset using 1200bps open/close on port COM6
Waiting for the new upload port...
Uploading .pio\build\mkr1000USB\firmware.bin
Atmel SMART device 0x10010005 found
Erase flash
done in 0.847 seconds

Write 6820 bytes to flash (107 pages)

[=================             ] 59% (64/107 pages)
[==============================] 100% (107/107 pages)
done in 0.057 seconds

Verify 6820 bytes of flash with checksum.
Verify successful
done in 0.006 seconds
CPU reset.
========================================================================== [SUCCESS] Took 10.75 seconds ==========================================================================

Terminal will be reused by tasks, press any key to close it.

Automatic followup of monitor:

> Executing task in folder mkr1000-client: C:\Users\Sinthoras\.platformio\penv\Scripts\pio.exe device monitor --environment mkr1000USB <

--- Available filters and text transformations: colorize, debug, default, direct, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at http://bit.ly/pio-monitor-filters

--- Available ports:
--- Enter port index or full name:

I removed monitor_speed = 115200 from the platformio.ini file and initialized Serial with a baudrate of 9600, but the upload command still transitions into the monitor mode immetiately and automatically. Logs are identical to those posted before. Would it make a difference to initialize the monitor mode manually or did you just ask for it because you prefer a separate log?

Cheers!

Please go into the PlatformIO extension settings and check that “Force Upload and Monitor” is off. Otherwise I can’t explain that behavior. You can also set the “Reopen Serial Monitor delay” to something like 1000 (=1 sec), maybe that has a positive effect.

I can confirm thast “Force Upload and Monitor” is already turned off. In installed a virgin windows and set up the project without any changes to platformio itself just before posting here. Setting a monitor delay also does not provide any difference. Even if i remove Serial completely i do not see any LEDs changing states. It is like the binary is faulty or the reset is malfunctioning.

This is indeed very weird. Can you please go into the Arduino IDE -> Tools -> Board Manager and then search for the board package that gives you the Arduino SAMD boards, and show what version of that package is installed? v1.8.9 or older?

I got 1.8.10 installed. Do you want me to try 1.8.9?

Okay then the Arduino IDE has a more recent package available to it than PlatformIO currently. Does the same no-boot behaviour happen in the Arduino IDE too with 1.8.9?

Also please double check that pressing the reset button has no or an effect on the firmware execution.

Arduino IDE is working with either versions, 1.8.9 and 1.8.10. If i press the reset button after i flashed with the Arduino IDE the scetch simply restarts. If i use PlatformIO i can only enable the bootloader while another press of the button disables it again, but nothing else happens.

Can you as a list thing please open a PlatformIO CLI and execute pio upgrade --dev, then restart VSCode, “Clean” the project and then “Upload” and then “Monitor” again?

If it’s still occuring with latest Core + Atmel SAM version something really weird is wrong and I’ll cross-check it with the Arduino IDE (at least the compiler paramters).

As a sidenote, did you flash this board at some point in some other way? Like burned another the bootloader on it or flashed it with another external adapter?

The board is stock from mouser and the only flashing i did was with the supplied sketch. PIO update in progress.

pio upgrade --dev did the trick. I can not upload without the serial monitor starting right afterwardes. Sadly, this does not solve the problem with the board.

Clean

> Executing task in folder mkr1000-client: C:\Users\Sinthoras\.platformio\penv\Scripts\pio.exe run --target clean --environment mkr1000USB <

Please wait while upgrading PlatformIO...
PlatformIO has been successfully upgraded to 5.0.4b1!

***********************************************************************************************************************************************************************************If you like PlatformIO, please:
- follow us on Twitter to stay up-to-date on the latest project news > https://twitter.com/PlatformIO_Org
- star it on GitHub > https://github.com/platformio/platformio
- try PlatformIO IDE for embedded development > https://platformio.org/platformio-ide
***********************************************************************************************************************************************************************************
Processing mkr1000USB (platform: atmelsam; board: mkr1000USB; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Done cleaning
=========================================================================== [SUCCESS] Took 0.77 seconds ===========================================================================
Terminal will be reused by tasks, press any key to close it.

Build

> Executing task in folder mkr1000-client: C:\Users\Sinthoras\.platformio\penv\Scripts\pio.exe run --environment mkr1000USB <

Processing mkr1000USB (platform: atmelsam; board: mkr1000USB; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelsam/mkr1000USB.html
PLATFORM: Atmel SAM (5.0.2) > Arduino MKR1000
HARDWARE: SAMD21G18A 48MHz, 32KB RAM, 256KB Flash
DEBUG: Current (atmel-ice) External (atmel-ice, blackmagic, jlink)
PACKAGES:
 - framework-arduino-samd 1.8.9
 - framework-cmsis 1.40500.0 (4.5.0)
 - framework-cmsis-atmel 1.2.0
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 12 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\mkr1000USB\src\main.cpp.o
Compiling .pio\build\mkr1000USB\FrameworkArduinoVariant\variant.cpp.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\IPAddress.cpp.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\Print.cpp.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\Reset.cpp.o
Archiving .pio\build\mkr1000USB\libFrameworkArduinoVariant.a
Compiling .pio\build\mkr1000USB\FrameworkArduino\SERCOM.cpp.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\Stream.cpp.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\Tone.cpp.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\USB\CDC.cpp.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\USB\PluggableUSB.cpp.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\USB\USBCore.cpp.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\USB\samd21_host.c.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\Uart.cpp.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\WInterrupts.c.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\WMath.cpp.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\WString.cpp.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\abi.cpp.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\avr\dtostrf.c.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\cortex_handlers.c.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\delay.c.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\hooks.c.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\itoa.c.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\main.cpp.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\new.cpp.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\pulse.c.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\pulse_asm.S.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\startup.c.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\wiring.c.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\wiring_analog.c.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\wiring_digital.c.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\wiring_private.c.o
Compiling .pio\build\mkr1000USB\FrameworkArduino\wiring_shift.c.o
Archiving .pio\build\mkr1000USB\libFrameworkArduino.a
Linking .pio\build\mkr1000USB\firmware.elf
Checking size .pio\build\mkr1000USB\firmware.elf
Building .pio\build\mkr1000USB\firmware.bin
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   6.8% (used 2244 bytes from 32768 bytes)
Flash: [          ]   2.6% (used 6820 bytes from 262144 bytes)
=========================================================================== [SUCCESS] Took 7.33 seconds ===========================================================================
Terminal will be reused by tasks, press any key to close it.

Upload

> Executing task in folder mkr1000-client: C:\Users\Sinthoras\.platformio\penv\Scripts\pio.exe run --target upload --environment mkr1000USB <

Processing mkr1000USB (platform: atmelsam; board: mkr1000USB; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelsam/mkr1000USB.html
PLATFORM: Atmel SAM (5.0.2) > Arduino MKR1000
HARDWARE: SAMD21G18A 48MHz, 32KB RAM, 256KB Flash
DEBUG: Current (atmel-ice) External (atmel-ice, blackmagic, jlink)
PACKAGES:
 - framework-arduino-samd 1.8.9
 - framework-cmsis 1.40500.0 (4.5.0)
 - framework-cmsis-atmel 1.2.0
 - tool-bossac 1.10700.190624 (1.7.0)
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 12 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio\build\mkr1000USB\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   6.8% (used 2244 bytes from 32768 bytes)
Flash: [          ]   2.6% (used 6820 bytes from 262144 bytes)
Configuring upload protocol...
AVAILABLE: atmel-ice, blackmagic, jlink, sam-ba
CURRENT: upload_protocol = sam-ba
Looking for upload port...
Auto-detected: COM6
Forcing reset using 1200bps open/close on port COM6
Waiting for the new upload port...
Uploading .pio\build\mkr1000USB\firmware.bin
Atmel SMART device 0x10010005 found
Erase flash
done in 0.847 seconds

Write 6820 bytes to flash (107 pages)

[=================             ] 59% (64/107 pages)
[==============================] 100% (107/107 pages)
done in 0.063 seconds

Verify 6820 bytes of flash with checksum.
Verify successful
done in 0.007 seconds
CPU reset.
========================================================================== [SUCCESS] Took 11.07 seconds ==========================================================================

Terminal will be reused by tasks, press any key to close it.

Finally, a separate call for the serial monitor

> Executing task in folder mkr1000-client: C:\Users\Sinthoras\.platformio\penv\Scripts\pio.exe device monitor --environment mkr1000USB <

--- Available filters and text transformations: colorize, debug, default, direct, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at http://bit.ly/pio-monitor-filters

--- Available ports:
--- Enter port index or full name:

But the serial monitor still has no port available.

Can you please add the line

extra_scripts = wait_after_upload.py

in the platformio.ini and then, in the same directory as that, add the file wait_after_upload.py with the content

Import("env")

def after_upload(source, target, env):
    print "Delay while uploading..."
    import time
    time.sleep(5)
    print("Done!")

env.AddPostAction("upload", after_upload)

and see if that enables the monitor to work? (The delay of 5 sec can also be adapted).

But I’m still not getting how there’s an automatic monitor after upload if the setting is turned off. The VSCode restart should apply these settings.

For completeness: Per posts above you should also upgrade to the latest core (pio upgrade --dev).

The script complained about missing () on the print statements, but otherwise worked like a charm (Could this Python 2 <-> Python 3 missmatch be the source of this problem?). Somehow, the upload task did trigger the serial monitor task again. I have no clue.

1 Like

My bad, yes this needs to Python3 style print statements with (). Copied it from SigFox MKR1200 Unit Testing - If you don't see any output for the first 10 secs, please reset board - #4 by isa56k.

This is still a mystery to me. When doing pio run -t upload in the PlatformIO CLI, does the serial monitor open too or does that behave correctly? Otherwise I’d recommend a re-install of the PlatformIO VSCode extension if that is bothersome o_O

The serial montor does not really bother me to be honest. I just need the board to get going^^

EDIT: Cannot create more replies on my first day so i will update this post as long as i can.

pio run -t upload works as expected.

Something is going terribly wrong in the process. I mean even if i press the reset button after flashing with PIO the board goes into the bootloader and not the sketch.

EDIT#2
It works now! Thank you so, so much for your time. Turns out i was record breakingly stupid. In my main.cpp file i commented everything out except a small line at the end:

int main() {}

The main() in the arduino framework might be a weak implementation. It was able to overwrite it without any warning. My bad.

Thanks again,
Johnny

1 Like

I’ve compared the invocaion flags for the compilation process and the bossac upload tool between latest Arduino IDE + package and PlatformIO.

Compile flags

PIO

arm-none-eabi-g++ -o .pio\build\mkr1000USB\src\main.cpp.o -c -fno-rtti -fno-exceptions -std=gnu++11 -fno-threadsafe-statics -Os -ffunction-sections -fdata-sections -Wall -mcpu=cortex-m0plus -mthumb -nostdlib --param max-inline-insns-single=500 -DPLATFORMIO=50004 -DARDUINO_SAMD_MKR1000 -D__SAMD21G18A__ -DUSE_ARDUINO_MKR_PIN_LAYOUT -DARDUINO=10805 -DF_CPU=48000000L -DUSBCON -DUSB_VID=0x2341 -DUSB_PID=0x804E “-DUSB_PRODUCT="Arduino MKR1000"” -DUSB_MANUFACTURER="Arduino" -DARDUINO_ARCH_SAMD -Iinclude -Isrc -IC:\Users\Max.platformio\packages\framework-cmsis@1.40500.0\CMSIS\Include -IC:\Users\Max.platformio\packages\framework-cmsis-atmel\CMSIS\Device\ATMEL -IC:\Users\Max.platformio\packages\framework-arduino-samd\cores\arduino -IC:\Users\Max.platformio\packages\framework-arduino-samd\variants\mkr1000 src\main.cpp

Arduino

arm-none-eabi-g++ -mcpu=cortex-m0plus -mthumb -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -DF_CPU=48000000L -DARDUINO=10813 -DARDUINO_SAMD_MKR1000 -DARDUINO_ARCH_SAMD -DUSE_ARDUINO_MKR_PIN_LAYOUT -D__SAMD21G18A__ -DUSB_VID=0x2341 -DUSB_PID=0x804e -DUSBCON “-DUSB_MANUFACTURER="Arduino LLC"” “-DUSB_PRODUCT="Arduino MKR1000"” “-IC:\Users\Max\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0/CMSIS/Include/” “-IC:\Users\Max\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/” “-IC:\Users\Max\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.10\cores\arduino/api/deprecated” “-IC:\Users\Max\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.10\cores\arduino” “-IC:\Users\Max\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.10\variants\mkr1000” “C:\Users\Max\AppData\Local\Temp\arduino_build_147867\sketch\Blink.ino.cpp” -o “C:\Users\Max\AppData\Local\Temp\arduino_build_147867\sketch\Blink.ino.cpp.o”

Upload cmd

PIO

bossac --info --debug --port “COM11” --write --verify --reset --erase -U true .pio\build\mkr1000USB\firmware.bin

Arduino

bossac.exe -i -d --port=COM1 -U true -i -e -w -v C:\Users\Max\AppData\Local\Temp\arduino_build_147867/Blink.ino.bin -R

So the only differences I could make out were -MMD and a higher ARDUINO macro value, both of which shouldn’t be critical. PlatformIO’s bossac invocation is missing the -R flag though for reset CPU after uploading.

Can you add

upload_flags = -R

to the platformio.ini and see if that changes the behavior?