Hmm, PIO not uploading code to Arduino ProMini, yet works on Arduino IDE

I found a few of these posts…
… but from what I can tell, I did not make the mistakes listed in some.

I am testing LoRa modules on a ProMini; actually two, one sender and the other receiver… with the respective example code loaded on each.

The Arduino IDE uploads the programs without fail; not so on PIO.

My platformio.ini:

[env:pro8MHzatmega328]
platform = atmelavr
board = pro8MHzatmega328
framework = arduino

[env]
monitor_speed = 115200
lib_deps =
	sandeepmistry/LoRa@^0.8.0

The upload result:

pio run -v -t upload
Processing pro8MHzatmega328 (platform: atmelavr; board: pro8MHzatmega328; framework: arduino; lib_deps: sandeepmistry/LoRa@^0.8.0; monitor_speed: 115200)
----------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/pro8MHzatmega328.html
PLATFORM: Atmel AVR (5.0.0) > Arduino Pro or Pro Mini ATmega328 (3.3V, 8 MHz)
HARDWARE: ATMEGA328P 8MHz, 2KB RAM, 30KB Flash
DEBUG: Current (avr-stub) External (avr-stub, simavr)
PACKAGES: 
 - framework-arduino-avr @ 5.2.0 
 - tool-avrdude @ 1.60300.200527 (6.3.0) 
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 6 compatible libraries
Scanning dependencies...
Dependency Graph
|-- LoRa @ 0.8.0 (License: Unknown, Path: /home/maxg/Workspaces/PlatformIO/Projects/ProMini_328_8MHz_3V3/.pio/libdeps/pro8MHzatmega328/LoRa)
|   |-- SPI @ 1.0 (License: Unknown, Path: /home/maxg/.platformio/packages/framework-arduino-avr/libraries/SPI)
|-- SPI @ 1.0 (License: Unknown, Path: /home/maxg/.platformio/packages/framework-arduino-avr/libraries/SPI)
Building in release mode
MethodWrapper(["checkprogsize"], [".pio/build/pro8MHzatmega328/firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  16.8% (used 344 bytes from 2048 bytes)
Flash: [=         ]  12.4% (used 3810 bytes from 30720 bytes)
.pio/build/pro8MHzatmega328/firmware.elf  :
section                    size      addr
.data                       140   8388864
.text                      3670         0
.bss                        204   8389004
.comment                     17         0
.note.gnu.avr.deviceinfo     64         0
.debug_aranges              192         0
.debug_info                2550         0
.debug_abbrev              1562         0
.debug_line                 968         0
.debug_str                  520         0
Total                      9887
<lambda>(["upload"], [".pio/build/pro8MHzatmega328/firmware.hex"])
AVAILABLE: arduino
CURRENT: upload_protocol = arduino
BeforeUpload(["upload"], [".pio/build/pro8MHzatmega328/firmware.hex"])
Auto-detected: /dev/ttyUSB0
avrdude -v -p atmega328p -C /home/maxg/.platformio/packages/tool-avrdude/avrdude.conf -c arduino -b 57600 -D -P /dev/ttyUSB0 -U flash:w:.pio/build/pro8MHzatmega328/firmware.hex:i

avrdude: 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 Wunsch

         System wide configuration file is "/home/maxg/.platformio/packages/tool-avrdude/avrdude.conf"
         User configuration file is "/home/maxg/.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
         Hardware Version: 2
         Firmware Version: 1.16
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: reading input file ".pio/build/pro8MHzatmega328/firmware.hex"
avrdude: writing flash (3810 bytes):

Writing | ################################################## | 100% 1.92s

avrdude: 3810 bytes of flash written
avrdude: verifying flash memory against .pio/build/pro8MHzatmega328/firmware.hex:
avrdude: load data flash data from input file .pio/build/pro8MHzatmega328/firmware.hex:
avrdude: input file .pio/build/pro8MHzatmega328/firmware.hex contains 3810 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 1.62s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x019b
         0x9f != 0xbf
avrdude: verification error; content mismatch

avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done.  Thank you.

*** [upload] Error 1
============================== [FAILED] Took 5.75 seconds ==============================

Any hints appreciated.

Try and add

upload_flags = -e

to force an erase.

Added upload_flags = -e to platformio.ini.

Result (upload failed):

pio run -v -t upload
Processing pro8MHzatmega328 (platform: atmelavr; board: pro8MHzatmega328; framework: arduino; upload_port: /dev/ttyUSB0; upload_flags: -e; build_flags: -Wall, -Werror, -Wunused-variable; monitor_speed: 115200; lib_deps: sandeepmistry/LoRa@^0.8.0)
-----------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/pro8MHzatmega328.html
PLATFORM: Atmel AVR (5.0.0) > Arduino Pro or Pro Mini ATmega328 (3.3V, 8 MHz)
HARDWARE: ATMEGA328P 8MHz, 2KB RAM, 30KB Flash
DEBUG: Current (avr-stub) External (avr-stub, simavr)
PACKAGES: 
 - framework-arduino-avr @ 5.2.0 
 - tool-avrdude @ 1.60300.200527 (6.3.0) 
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 6 compatible libraries
Scanning dependencies...
Dependency Graph
|-- LoRa @ 0.8.0 (License: Unknown, Path: /home/maxg/Workspaces/PlatformIO/Projects/ProMini_328_8MHz_3V3/.pio/libdeps/pro8MHzatmega328/LoRa)
|   |-- SPI @ 1.0 (License: Unknown, Path: /home/maxg/.platformio/packages/framework-arduino-avr/libraries/SPI)
|-- SPI @ 1.0 (License: Unknown, Path: /home/maxg/.platformio/packages/framework-arduino-avr/libraries/SPI)
Building in release mode
avr-g++ -o .pio/build/pro8MHzatmega328/src/main.cpp.o -c -fno-exceptions -fno-threadsafe-statics -fpermissive -std=gnu++11 -Wall -Werror -Wunused-variable -mmcu=atmega328p -Os -Wall -ffunction-sections -fdata-sections -flto -DPLATFORMIO=60115 -DARDUINO_AVR_PRO -DF_CPU=8000000L -DARDUINO_ARCH_AVR -DARDUINO=10808 -Iinclude -Isrc -I.pio/libdeps/pro8MHzatmega328/LoRa/src -I/home/maxg/.platformio/packages/framework-arduino-avr/libraries/SPI/src -I/home/maxg/.platformio/packages/framework-arduino-avr/cores/arduino -I/home/maxg/.platformio/packages/framework-arduino-avr/variants/eightanaloginputs src/main.cpp
avr-g++ -o .pio/build/pro8MHzatmega328/firmware.elf -mmcu=atmega328p -Os -Wl,--gc-sections -flto -fuse-linker-plugin .pio/build/pro8MHzatmega328/src/main.cpp.o -L.pio/build/pro8MHzatmega328 -Wl,--start-group .pio/build/pro8MHzatmega328/libd92/libSPI.a .pio/build/pro8MHzatmega328/lib295/libLoRa.a .pio/build/pro8MHzatmega328/libFrameworkArduinoVariant.a .pio/build/pro8MHzatmega328/libFrameworkArduino.a -lm -Wl,--end-group
MethodWrapper(["checkprogsize"], [".pio/build/pro8MHzatmega328/firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  15.4% (used 316 bytes from 2048 bytes)
Flash: [=         ]  13.2% (used 4066 bytes from 30720 bytes)
.pio/build/pro8MHzatmega328/firmware.elf  :
section                     size      addr
.data                        114   8388864
.text                       3952         0
.bss                         202   8388978
.comment                      17         0
.note.gnu.avr.deviceinfo      64         0
.debug_aranges               192         0
.debug_info                 2550         0
.debug_abbrev               1562         0
.debug_line                  968         0
.debug_str                   520         0
Total                      10141
avr-objcopy -O ihex -R .eeprom .pio/build/pro8MHzatmega328/firmware.elf .pio/build/pro8MHzatmega328/firmware.hex
<lambda>(["upload"], [".pio/build/pro8MHzatmega328/firmware.hex"])
AVAILABLE: arduino
CURRENT: upload_protocol = arduino
BeforeUpload(["upload"], [".pio/build/pro8MHzatmega328/firmware.hex"])
Using manually specified: /dev/ttyUSB0
avrdude -e -v -p atmega328p -C /home/maxg/.platformio/packages/tool-avrdude/avrdude.conf -c arduino -b 57600 -D -P /dev/ttyUSB0 -U flash:w:.pio/build/pro8MHzatmega328/firmware.hex:i

avrdude: 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 Wunsch

         System wide configuration file is "/home/maxg/.platformio/packages/tool-avrdude/avrdude.conf"
         User configuration file is "/home/maxg/.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
         Hardware Version: 2
         Firmware Version: 1.16

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xe2

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x81
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us


avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xe4

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x84
avrdude: stk500_initialize(): (a) protocol error, expect=0x14, resp=0xe5
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: stk500_disable(): protocol error, expect=0x14, resp=0xe7

avrdude done.  Thank you.

*** [upload] Error 1
=========================== [FAILED] Took 3.11 seconds ===========================