platformio / platform-atmelsam

Atmel SAM: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/atmelsam
Apache License 2.0
79 stars 105 forks source link

Arduino nano 33 iot - program don't start #113

Closed AndyF1995 closed 4 years ago

AndyF1995 commented 4 years ago

Operating system: Win10 x64

PlatformIO Version : 4.3.4 on VScode

Description of problem

When I upload a simple "blink" on Arduino nano 33 iot, after the last reset the program don't start its execution on microcontroller. Same program works on different architectures like AVR and STM32. For a new upload I need to put my nano on bootloader mode by pressing reset button twice.

I tried to:

I find a workaround:

  1. Create a new project
  2. Copy all sources files in it
  3. Build and upload
  4. BUT... When I connect a new board, sometimes I have same issue

Steps to Reproduce

The error is not systematic, but it seems to be happening with this procedure:

  1. Plug a new Arduino nano 33 iot on USB
  2. Load "blink"
  3. Change board with different architecture
  4. Load "blink"
  5. Plug a second new Arduino nano 33 iot on USB
  6. Load "blink"

The content of platformio.ini:

[platformio]
default_envs = nano_33_iot
[env:genericSTM32F401CC]
...
[env:nano_33_iot]
platform = atmelsam@4.1.0
board = nano_33_iot
framework = arduino
board_build.mcu = samd21g18a
build_flags = -D BUILD_ARCH_SAMD
lib_deps =
    U8g2    ;DISPLAY
    1       ;ONEWIRE
    https://github.com/arduino-libraries/SD.git         ;SD
    https://github.com/PaulStoffregen/Time.git          ;TimeLib
    https://github.com/PaulStoffregen/DS1307RTC.git     ;DS1307 RTC
    https://github.com/cyberp/AT24Cx.git                ;24C32 EEPROM
[env:megaatmega2560]
...

Source file to reproduce issue:

standard Arduino IDE blink sketch

Additional info

My upload log, with Arduino nano 33 iot in bootloader mode (press reset twice):

Click to open log ``` Building in release mode Checking size .pio\build\nano_33_iot\firmware.elf Advanced Memory Usage is available via "PlatformIO Home > Project Inspect" RAM: [== ] 20.8% (used 6816 bytes from 32768 bytes) Flash: [= ] 10.0% (used 26140 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: COM11 Forcing reset using 1200bps open/close on port COM11 Waiting for the new upload port... Uploading .pio\build\nano_33_iot\firmware.bin Atmel SMART device 0x10010005 found Erase flash done in 0.921 seconds Write 26140 bytes to flash (409 pages) [==== ] 15% (64/409 pages) [========= ] 31% (128/409 pages) [============== ] 46% (192/409 pages) [================== ] 62% (256/409 pages) [======================= ] 78% (320/409 pages) [============================ ] 93% (384/409 pages) [==============================] 100% (409/409 pages) done in 0.175 seconds Verify 26140 bytes of flash with checksum. Verify successful done in 0.021 seconds CPU reset. [SUCCESS] Took 16.19 seconds \```
AndyF1995 commented 4 years ago

Sorry, today I hardly debug it. Probably, there is an error in my custom linker script.