Hello everyone,
I’m using VSC with PlatformIO extension installed running Ubuntu through WSL 2.
I’ve been following the Unit Testing Tutorial here:
I ran tests for the given circular_buffer with no issues on native platform, and am now trying to connect an embedded target.
In the tutorial, they use the SiFive HiFive-RevB board, but I only own an Arduino Uno and an Arduino Nano.
So instead of:
[env:hifive1-revb]
platform = sifive
framework = freedom-e-sdk
board = hifive1-revb
I’m using
[env:nanoatmega328]
platform = atmelavr
framework = arduino
board = nanoatmega328
[env:uno]
platform = atmelavr
framework = arduino
board = uno
I then connected both Arduinos to WSL with usbipd wsl attach --busid
When I run Test though, I get the following output:
Processing * in nanoatmega328 environment
Building & Uploading…
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file “.pio/build/nanoatmega328/firmware.hex”
avrdude: writing flash (2888 bytes):Writing | ################################################## | 100% 0.92s
avrdude: 2888 bytes of flash written
avrdude: verifying flash memory against .pio/build/nanoatmega328/firmware.hex:
avrdude: load data flash data from input file .pio/build/nanoatmega328/firmware.hex:
avrdude: input file .pio/build/nanoatmega328/firmware.hex contains 2888 bytes
avrdude: reading on-chip flash data:Reading | ################################################## | 100% 0.70s
avrdude: verifying …
avrdude: 2888 bytes of flash verifiedavrdude: safemode: Fuses OK (E:00, H:00, L:00)
avrdude done. Thank you.
Testing…
If you don’t see any output for the first 10 secs, please reset board (press reset button)
Which makes me think the code was correctly uploaded, but then I never see any output. The same output is there for both Arduinos and doesn’t change when running Verbose.
So far I’ve tried:
- Pressing the reset button on the Arduino and wait while stuck on Testing…
- Stopping the testing, clicking the reset button, and then starting it back up again
- Adding an extra script to wait 5 seconds as suggested by @maxgerhardt
- Adding a manual monitor speed as suggested in another post by @maxgerhardt
[env:nanoatmega328]
platform = atmelavr
framework = arduino
board = nanoatmega328
monitor_speed = 57600
extra_scripts = extra_script.py
and extra_script.py:
Import(“env”)
def after_upload(source, target, env):
print(“Delay while uploading…”)
import time
time.sleep(5)
print(“Done!”)env.AddPostAction(“upload”, after_upload)
I feel like I’m missing something real simple, but I’m really not sure what. Any help would really be great.
If I try Verbose Upload I do get an error, I don’t know if that’s expected or could be helpful:
Processing nanoatmega328 (platform: atmelavr; framework: arduino; board: nanoatmega328; monitor_speed: 57600; extra_scripts: extra_script.py)
CONFIGURATION: …/page/boards/atmelavr/nanoatmega328.html
PLATFORM: Atmel AVR (4.2.0) > Arduino Nano ATmega328
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 30KB Flash
DEBUG: Current (avr-stub) External (avr-stub, simavr)
PACKAGES:
- framework-arduino-avr @ 5.1.0
- tool-avrdude @ 1.60300.200527 (6.3.0)
- toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder ->…/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 7 compatible libraries
Scanning dependencies…
No dependencies
Building in release mode
avr-gcc -o .pio/build/nanoatmega328/firmware.elf -mmcu=atmega328p -Os -Wl,–gc-sections -flto -fuse-linker-plugin .pio/build/nanoatmega328/src/main.c.o -L.pio/build/nanoatmega328 -Wl,–start-group .pio/build/nanoatmega328/libFrameworkArduinoVariant.a .pio/build/nanoatmega328/libFrameworkArduino.a -lm -Wl,–end-group
MethodWrapper([“checkprogsize”], [“.pio/build/nanoatmega328/firmware.elf”])
Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [ ] 0.0% (used 0 bytes from 2048 bytes)
Flash: [ ] 0.4% (used 138 bytes from 30720 bytes)
.pio/build/nanoatmega328/firmware.elf :
section size addr
.data 0 8388864
.text 138 0
.comment 17 0
.note.gnu.avr.deviceinfo 64 0
.debug_aranges 32 0
.debug_info 1695 0
.debug_abbrev 1462 0
.debug_line 124 0
.debug_str 520 0
Total 4052
avr-objcopy -O ihex -R .eeprom .pio/build/nanoatmega328/firmware.elf .pio/build/nanoatmega328/firmware.hex
([“upload”], [“.pio/build/nanoatmega328/firmware.hex”])
AVAILABLE: arduino
CURRENT: upload_protocol = arduino
BeforeUpload([“upload”], [“.pio/build/nanoatmega328/firmware.hex”])
Auto-detected: /dev/ttyUSB0
avrdude -v -p atmega328p -C /home/abismuth/.platformio/packages/tool-avrdude/avrdude.conf -c arduino -b 57600 -D -P /dev/ttyUSB0 -U flash:w:.pio/build/nanoatmega328/firmware.hex:iavrdude: Version 6.3, compiled on Sep 12 2016 at 15:21:49
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg WunschSystem wide configuration file is "/home/abismuth/.platformio/packages/tool-avrdude/avrdude.conf" User configuration file is "/home/abismuth/.avrduderc" User configuration file does not exist or is not a regular file, skipping Using Port : /dev/ttyUSB0 Using Programmer : arduino Overriding Baud Rate : 57600 AVR Part : ATmega328P Chip Erase delay : 9000 us PAGEL : PD7 BS2 : PC2 RESET disposition : dedicated RETRY pulse : SCK serial program mode : yes parallel program mode : yes Timeout : 200 StabDelay : 100 CmdexeDelay : 25 SyncLoops : 32 ByteDelay : 0 PollIndex : 3 PollValue : 0x53 Memory Detail : Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00 signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00 Programmer Type : Arduino Description : Arduino
avrdude: stk500_recv(): programmer is not responding
Hardware Version: 2
Firmware Version: 1.16
Topcard : Unknown
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
Vtarget : 392000530.2 V
Varef : 1301558.4 V
Oscillator : Off
SCK period : 0.1 usavrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.avrdude: stk500_recv(): programmer is not responding
avrdude done. Thank you.
*** [upload] Error 1
=============================================================================== [FAILED] Took 51.69 seconds ===============================================================================Environment Status Duration
native IGNORED
nanoatmega328 FAILED 00:00:51.689
uno IGNORED
========================================================================== 1 failed, 0 succeeded in 00:00:51.689 ==========================================================================
- The terminal process “platformio ‘run’, ‘–verbose’, ‘–target’, ‘upload’, ‘–environment’, ‘nanoatmega328’” terminated with exit code: 1.