Flashing with mySmartUSB MK2 to ATmega328P-PU target

Hi, I have got this board here and would like to flash a firmware with the “mySmartUSB MK2” programmer. (shop website)

The board itself is called “myAVR Board MK2 V2.20”.
The programmer is already installed on the board.(left side where the USB port is)

I tried different ATmega targets and get each time the error shown below, as the programmer seems not to be supported.

platformio.ini
[common]
default_src_filter = 
  +<*> 
  -<.git/> 
  -<.svn/> 
  -<example/> 
  -<examples/> 
  -<test/> 
  -<tests/> 
  -<target/>


[env:lpc1768]
platform = nxplpc
board = lpc1768

src_filter = 
  ${common.default_src_filter} 
  +<traget/LPC1768/>

build_flags = 
  -Wl,-T"scripts/target/LPC1768/LPC1768.ld"
  -D LPC1768 
  -D DEBUG

extra_scripts = scripts/target/LPC1768/extra_script.py

;J-Link Probe
upload_protocol = jlink-jtag
debug_tool = jlink

[env:atmega328p]
platform = atmelavr
board = atmega328p

src_filter = 
  ${common.default_src_filter} 
  +<traget/ATMEGA328P/>

; build and debugging flags
build_flags = 
  -D ATMEGA328P
  -D DEBUG

; upload port.
upload_port = /dev/cu.SLAB_USBtoUART

small detail that might help, the device is found under /dev/cu.SLAB_USBtoUART

Error:

Compiling .pio/build/atmega328p/src/main.o
Linking .pio/build/atmega328p/firmware.elf
Checking size .pio/build/atmega328p/firmware.elf
Building .pio/build/atmega328p/firmware.hex
Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [          ]   0.0% (used 0 bytes from 2048 bytes)
PROGRAM: [          ]   0.6% (used 202 bytes from 32256 bytes)
Configuring upload protocol...
AVAILABLE: arduino
CURRENT: upload_protocol = arduino
Looking for upload port...
Use manually specified: /dev/cu.SLAB_USBtoUART
Uploading .pio/build/atmega328p/firmware.hex
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
^C*** [upload] Build interrupted.
Error: Aborted by user

Based on the technical data sheet (page 3) and the avrdude reference sheet the protocol AVR911 should be used, which avrdude does when you give it the -c avr911 switch. Currently it’s invoked with the -c stk500 flag for standard arduino programming.

You should try

upload_protocol = avr911
upload_port = /dev/cu.SLAB_USBtoUART

And do a verbose upload. For me this results in the call

avrdude -v -p atmega328p -C C:\Users\Maxi\.platformio\packages\tool-avrdude\avrdude.conf -c avr911 -b 115200 -D -P "/dev/cu.SLAB_USBtoUART" -U flash:w:.pio\build\uno3\firmware.hex:i

… Which is OK except for the -P option… this should use only the USB interface and not a COM port. But lets see what happens first.

Maybe then a -Pusb might help? (Atmel AVR — PlatformIO latest documentation)

Same error with both verbose and not verbose.

>>> avrdude -v -p atmega328p -C ~/.platformio/packages/tool-avrdude/avrdude.conf -c avr911 -b 115200 -D -P "/dev/cu.SLAB_USBtoUART" -U flash:w:.pio/build/myAVRBoard_atmega328p/firmware.hex:i


avrdude: Version 6.3, compiled on Sep 21 2018 at 19:15:33
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/Users/john/.platformio/packages/tool-avrdude/avrdude.conf"
         User configuration file is "/Users/john/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/cu.SLAB_USBtoUART
         Using Programmer              : avr911
         Overriding Baud Rate          : 115200
         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 : butterfly
         Description     : Atmel AppNote AVR911 AVROSP

Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding

avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
Found programmer: Id = ""; type = 
    Software Version = .; Hardware Version = (.
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: error: buffered memory access not supported. Maybe it isn't
a butterfly/AVR109 but a AVR910 device?
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: butterfly_recv(): programmer is not responding
avrdude: error: programmer did not respond to command: leave prog mode
avrdude: butterfly_recv(): programmer is not responding
avrdude: error: programmer did not respond to command: exit bootloader

avrdude done.  Thank you.

>>> avrdude -v -p atmega328p -C ~/.platformio/packages/tool-avrdude/avrdude.conf -c avr910 -b 115200 -D -P "/dev/cu.SLAB_USBtoUART" -U flash:w:.pio/build/myAVRBoard_atmega328p/firmware.hex:i


avrdude: Version 6.3, compiled on Sep 21 2018 at 19:15:33
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/Users/john/.platformio/packages/tool-avrdude/avrdude.conf"
         User configuration file is "/Users/john/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/cu.SLAB_USBtoUART
         Using Programmer              : avr910
         avr910_devcode (avrdude.conf) : none
         Overriding Baud Rate          : 115200
         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 : avr910
         Description     : Atmel Low Cost Serial Programmer

avrdude: avr910_recv(): programmer is not responding
avrdude: avr910_recv(): programmer is not responding
avrdude: avr910_recv(): programmer is not responding
avrdude: avr910_recv(): programmer is not responding
Found programmer: Id = ""; type = 0
    Software Version =  .; Hardware Version = .
avrdude: avr910_recv(): programmer is not responding
avrdude: avr910_recv(): programmer is not responding

Programmer supports the following devices:
avrdude: avr910_recv(): programmer is not responding

avrdude: error: selected device is not supported by programmer: m328p
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: avr910_recv(): programmer is not responding
avrdude: error: programmer did not respond to command: leave prog mode

avrdude done.  Thank you.
[env:myAVRBoard_atmega328p]
platform = atmelavr
board = uno

src_filter = 
  ${common.default_src_filter} 
  +<traget/ATMEGA328P/>

; build and debugging flags
build_flags = 
  -D ATMEGA328P
  -D DEBUG

; upload port.
upload_port = /dev/cu.SLAB_USBtoUART
upload_protocol = avr911
upload_flags =
    -Pusb

leads to the same error.

Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding

avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
Found programmer: Id = ""; type = 
    Software Version = .; Hardware Version = .
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: error: buffered memory access not supported. Maybe it isn't
a butterfly/AVR109 but a AVR910 device?
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: butterfly_recv(): programmer is not responding
avrdude: error: programmer did not respond to command: leave prog mode
avrdude: butterfly_recv(): programmer is not responding
avrdude: error: programmer did not respond to command: exit bootloader

avrdude done.  Thank you.

*** [upload] Error 1

Okay they actually show the avrdude invocation example on the last few pages

So upload_protocol should definitely be avr910 after all. Now there could still be a wrong baud rate. According to the next page, 19200 seems to be used? So could ydou try

upload_port = /dev/cu.SLAB_USBtoUART
upload_protocol = avr910
upload_speed = 19200

and check the resulting avrdude invocation?

Looks like progress.

Error message(click me)
Compiling .pio/build/myAVRBoard_atmega328p/src/main.o
Linking .pio/build/myAVRBoard_atmega328p/firmware.elf
Building .pio/build/myAVRBoard_atmega328p/firmware.hex
Checking size .pio/build/myAVRBoard_atmega328p/firmware.elf
Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [          ]   0.0% (used 0 bytes from 2048 bytes)
PROGRAM: [          ]   0.5% (used 164 bytes from 32256 bytes)
Configuring upload protocol...
AVAILABLE: avr910
CURRENT: upload_protocol = avr910
Looking for upload port...
Use manually specified: /dev/cu.SLAB_USBtoUART
Uploading .pio/build/myAVRBoard_atmega328p/firmware.hex

Found programmer: Id = "AVR ISP"; type = S
    Software Version = 2.5; Hardware Version = 2.0
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize = 512 bytes.

Programmer supports the following devices:
    Device code: 0x01 = (unknown)
    Device code: 0x02 = (unknown)
    Device code: 0x03 = (unknown)
    Device code: 0x04 = (unknown)
    Device code: 0x05 = (unknown)
    Device code: 0x06 = (unknown)
    Device code: 0x07 = (unknown)
    Device code: 0x08 = (unknown)
    Device code: 0x09 = (unknown)
    Device code: 0x0a = (unknown)
    Device code: 0x0b = (unknown)
    Device code: 0x0c = (unknown)
    Device code: 0x0d = (unknown)
    Device code: 0x0e = (unknown)
    Device code: 0x0f = (unknown)
    Device code: 0x10 = (unknown)
    Device code: 0x11 = (unknown)
    Device code: 0x12 = (unknown)
    Device code: 0x13 = AT90S1200
    Device code: 0x14 = (unknown)
    Device code: 0x15 = (unknown)
    Device code: 0x16 = (unknown)
    Device code: 0x17 = (unknown)
    Device code: 0x18 = (unknown)
    Device code: 0x19 = (unknown)
    Device code: 0x1a = (unknown)
    Device code: 0x1b = (unknown)
    Device code: 0x1c = (unknown)
    Device code: 0x1d = (unknown)
    Device code: 0x1e = (unknown)
    Device code: 0x1f = (unknown)
    Device code: 0x20 = ATtiny167
    Device code: 0x21 = (unknown)
    Device code: 0x22 = (unknown)
    Device code: 0x23 = (unknown)
    Device code: 0x24 = (unknown)
    Device code: 0x25 = (unknown)
    Device code: 0x26 = (unknown)
    Device code: 0x27 = (unknown)
    Device code: 0x28 = AT90S4414
    Device code: 0x29 = (unknown)
    Device code: 0x2a = (unknown)
    Device code: 0x2b = (unknown)
    Device code: 0x2c = (unknown)
    Device code: 0x2d = (unknown)
    Device code: 0x2e = (unknown)
    Device code: 0x2f = (unknown)
    Device code: 0x30 = AT90S4433
    Device code: 0x31 = (unknown)
    Device code: 0x32 = (unknown)
    Device code: 0x33 = (unknown)
    Device code: 0x34 = AT90S2333
    Device code: 0x35 = (unknown)
    Device code: 0x36 = (unknown)
    Device code: 0x37 = (unknown)
    Device code: 0x38 = AT90S8515
    Device code: 0x39 = (unknown)
    Device code: 0x3a = ATmega8515
    Device code: 0x3b = (unknown)
    Device code: 0x3c = (unknown)
    Device code: 0x3d = (unknown)
    Device code: 0x3e = (unknown)
    Device code: 0x3f = (unknown)
    Device code: 0x40 = (unknown)
    Device code: 0x41 = ATmega103
    Device code: 0x42 = (unknown)
    Device code: 0x43 = ATmega128
    Device code: 0x44 = (unknown)
    Device code: 0x45 = ATmega64
    Device code: 0x46 = (unknown)
    Device code: 0x47 = (unknown)
    Device code: 0x48 = (unknown)
    Device code: 0x49 = (unknown)
    Device code: 0x4a = (unknown)
    Device code: 0x4b = (unknown)
    Device code: 0x4c = AT90S2343
    Device code: 0x4d = (unknown)
    Device code: 0x4e = (unknown)
    Device code: 0x4f = (unknown)
    Device code: 0x50 = (unknown)
    Device code: 0x51 = (unknown)
    Device code: 0x52 = (unknown)
    Device code: 0x53 = (unknown)
    Device code: 0x54 = (unknown)
    Device code: 0x55 = ATtiny12
    Device code: 0x56 = ATtiny15
    Device code: 0x57 = (unknown)
    Device code: 0x58 = (unknown)
    Device code: 0x59 = (unknown)
    Device code: 0x5a = (unknown)
    Device code: 0x5b = (unknown)
    Device code: 0x5c = ATtiny28
    Device code: 0x5d = (unknown)
    Device code: 0x5e = ATtiny4313
    Device code: 0x5f = (unknown)
    Device code: 0x60 = ATmega161
    Device code: 0x61 = (unknown)
    Device code: 0x62 = (unknown)
    Device code: 0x63 = ATmega162
    Device code: 0x64 = ATmega163
    Device code: 0x65 = (unknown)
    Device code: 0x66 = (unknown)
    Device code: 0x67 = (unknown)
    Device code: 0x68 = AT90S8535
    Device code: 0x69 = ATmega8535
    Device code: 0x6a = (unknown)
    Device code: 0x6b = (unknown)
    Device code: 0x6c = AT90S4434
    Device code: 0x6d = (unknown)
    Device code: 0x6e = (unknown)
    Device code: 0x6f = (unknown)
    Device code: 0x70 = (unknown)
    Device code: 0x71 = (unknown)
    Device code: 0x72 = ATmega32
    Device code: 0x73 = (unknown)
    Device code: 0x74 = ATmega644PA
    Device code: 0x75 = ATmega6490
    Device code: 0x76 = ATmega8
    Device code: 0x77 = (unknown)
    Device code: 0x78 = ATmega169
    Device code: 0x79 = (unknown)
    Device code: 0x7a = (unknown)
    Device code: 0x7b = (unknown)
    Device code: 0x7c = (unknown)
    Device code: 0x7d = (unknown)
    Device code: 0x7e = (unknown)
    Device code: 0x7f = (unknown)

avrdude: error: selected device is not supported by programmer: m328p
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: avr910_recv(): programmer is not responding
avrdude: error: programmer did not respond to command: leave prog mode

avrdude done.  Thank you.

*** [upload] Error 1

Edit: Guess the device must be set to Atmega8
Edit2: Guess the ATmega8 was just an example of using the myAVR USB Programmer…, thus my idea to try that is void.

For fun, is the result also the same when using upload_protocol = avr911?

I’ve found topic mysmartusb, atmega168 und avrdude - Mikrocontroller.net but it doesn’t really help much. Maybe try to use -F by adding upload_flags = -F?

Changing the board to ATmega328 or ATmega328P seems to yield different results.

[env:myAVRBoard_atmega328p]
platform = atmelavr
board = ATmega328P

src_filter = 
  ${common.default_src_filter} 
  +<traget/ATMEGA328P/>

; build and debugging flags
build_flags = 
  -D ATMEGA328P
  -D DEBUG

; upload port.
upload_port = /dev/cu.SLAB_USBtoUART
upload_protocol = avr911
upload_speed = 19200

Result:

mory Usage -> http://bit.ly/pio-memory-usage
DATA:    [          ]   0.0% (used 0 bytes from 2048 bytes)
PROGRAM: [          ]   0.5% (used 164 bytes from 32256 bytes)
Configuring upload protocol...
AVAILABLE: avr911
CURRENT: upload_protocol = avr911
Looking for upload port...
Use manually specified: /dev/cu.SLAB_USBtoUART
Uploading .pio/build/myAVRBoard_atmega328p/firmware.hex

Connecting to programmer: .
Found programmer: Id = "AVR ISP"; type = S
    Software Version = 2.5; Hardware Version = 2.0
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=512 bytes.

Programmer supports the following devices:
    Device code: 0x01
    Device code: 0x02
    Device code: 0x03
    Device code: 0x04
    Device code: 0x05
    Device code: 0x06
    Device code: 0x07
    Device code: 0x08
    Device code: 0x09
    Device code: 0x0a
    Device code: 0x0b
    Device code: 0x0c
    Device code: 0x0d
    Device code: 0x0e
    Device code: 0x0f
    Device code: 0x10
    Device code: 0x11
    Device code: 0x12
    Device code: 0x13
    Device code: 0x14
    Device code: 0x15
    Device code: 0x16
    Device code: 0x17
    Device code: 0x18
    Device code: 0x19
    Device code: 0x1a
    Device code: 0x1b
    Device code: 0x1c
    Device code: 0x1d
    Device code: 0x1e
    Device code: 0x1f
    Device code: 0x20
    Device code: 0x21
    Device code: 0x22
    Device code: 0x23
    Device code: 0x24
    Device code: 0x25
    Device code: 0x26
    Device code: 0x27
    Device code: 0x28
    Device code: 0x29
    Device code: 0x2a
    Device code: 0x2b
    Device code: 0x2c
    Device code: 0x2d
    Device code: 0x2e
    Device code: 0x2f
    Device code: 0x30
    Device code: 0x31
    Device code: 0x32
    Device code: 0x33
    Device code: 0x34
    Device code: 0x35
    Device code: 0x36
    Device code: 0x37
    Device code: 0x38
    Device code: 0x39
    Device code: 0x3a
    Device code: 0x3b
    Device code: 0x3c
    Device code: 0x3d
    Device code: 0x3e
    Device code: 0x3f
    Device code: 0x40
    Device code: 0x41
    Device code: 0x42
    Device code: 0x43
    Device code: 0x44
    Device code: 0x45
    Device code: 0x46
    Device code: 0x47
    Device code: 0x48
    Device code: 0x49
    Device code: 0x4a
    Device code: 0x4b
    Device code: 0x4c
    Device code: 0x4d
    Device code: 0x4e
    Device code: 0x4f
    Device code: 0x50
    Device code: 0x51
    Device code: 0x52
    Device code: 0x53
    Device code: 0x54
    Device code: 0x55
    Device code: 0x56
    Device code: 0x57
    Device code: 0x58
    Device code: 0x59
    Device code: 0x5a
    Device code: 0x5b
    Device code: 0x5c
    Device code: 0x5d
    Device code: 0x5e
    Device code: 0x5f
    Device code: 0x60
    Device code: 0x61
    Device code: 0x62
    Device code: 0x63
    Device code: 0x64
    Device code: 0x65
    Device code: 0x66
    Device code: 0x67
    Device code: 0x68
    Device code: 0x69
    Device code: 0x6a
    Device code: 0x6b
    Device code: 0x6c
    Device code: 0x6d
    Device code: 0x6e
    Device code: 0x6f
    Device code: 0x70
    Device code: 0x71
    Device code: 0x72
    Device code: 0x73
    Device code: 0x74
    Device code: 0x75
    Device code: 0x76
    Device code: 0x77
    Device code: 0x78
    Device code: 0x79
    Device code: 0x7a
    Device code: 0x7b
    Device code: 0x7c
    Device code: 0x7d
    Device code: 0x7e
    Device code: 0x7f

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.05s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file ".pio/build/myAVRBoard_atmega328p/firmware.hex"
avrdude: writing flash (164 bytes):

Writing | ################################################## | 100% 0.25s

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

Reading | ################################################## | 100% 0.15s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0006
         0x1e != 0x3e
avrdude: verification error; content mismatch

avrdude: safemode: Fuses OK (E:FF, H:D9, L:FF)

avrdude done.  Thank you.

But this is the closest that comes to actually writing the firmware.

This result is independent of whether avr911 or avr910 used when setting the board to ATmega328 or ATmega328P?

This is the avr911 result with ATmega328P

And avr910 plus board = ATmega328 or board = ATmega328P?

[env:myAVRBoard_atmega328p]
platform = atmelavr
board = ATmega328

src_filter = 
  ${common.default_src_filter} 
  +<traget/ATMEGA328P/>

; build and debugging flags
build_flags = 
  -D ATMEGA328P
  -D DEBUG

; upload port.
upload_port = /dev/cu.SLAB_USBtoUART
upload_protocol = avr910
upload_speed = 19200

Results in:

PROGRAM: [          ]   0.5% (used 164 bytes from 32256 bytes)
Configuring upload protocol...
AVAILABLE: avr910
CURRENT: upload_protocol = avr910
Looking for upload port...
Use manually specified: /dev/cu.SLAB_USBtoUART
Uploading .pio/build/myAVRBoard_atmega328p/firmware.hex

Found programmer: Id = "AVR ISP"; type = S
    Software Version = 2.5; Hardware Version = 2.0
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize = 512 bytes.

Programmer supports the following devices:
    Device code: 0x01 = (unknown)
    Device code: 0x02 = (unknown)
    Device code: 0x03 = (unknown)
    Device code: 0x04 = (unknown)
    Device code: 0x05 = (unknown)
    Device code: 0x06 = (unknown)
    Device code: 0x07 = (unknown)
    Device code: 0x08 = (unknown)
    Device code: 0x09 = (unknown)
    Device code: 0x0a = (unknown)
    Device code: 0x0b = (unknown)
    Device code: 0x0c = (unknown)
    Device code: 0x0d = (unknown)
    Device code: 0x0e = (unknown)
    Device code: 0x0f = (unknown)
    Device code: 0x10 = (unknown)
    Device code: 0x11 = (unknown)
    Device code: 0x12 = (unknown)
    Device code: 0x13 = AT90S1200
    Device code: 0x14 = (unknown)
    Device code: 0x15 = (unknown)
    Device code: 0x16 = (unknown)
    Device code: 0x17 = (unknown)
    Device code: 0x18 = (unknown)
    Device code: 0x19 = (unknown)
    Device code: 0x1a = (unknown)
    Device code: 0x1b = (unknown)
    Device code: 0x1c = (unknown)
    Device code: 0x1d = (unknown)
    Device code: 0x1e = (unknown)
    Device code: 0x1f = (unknown)
    Device code: 0x20 = ATtiny167
    Device code: 0x21 = (unknown)
    Device code: 0x22 = (unknown)
    Device code: 0x23 = (unknown)
    Device code: 0x24 = (unknown)
    Device code: 0x25 = (unknown)
    Device code: 0x26 = (unknown)
    Device code: 0x27 = (unknown)
    Device code: 0x28 = AT90S4414
    Device code: 0x29 = (unknown)
    Device code: 0x2a = (unknown)
    Device code: 0x2b = (unknown)
    Device code: 0x2c = (unknown)
    Device code: 0x2d = (unknown)
    Device code: 0x2e = (unknown)
    Device code: 0x2f = (unknown)
    Device code: 0x30 = AT90S4433
    Device code: 0x31 = (unknown)
    Device code: 0x32 = (unknown)
    Device code: 0x33 = (unknown)
    Device code: 0x34 = AT90S2333
    Device code: 0x35 = (unknown)
    Device code: 0x36 = (unknown)
    Device code: 0x37 = (unknown)
    Device code: 0x38 = AT90S8515
    Device code: 0x39 = (unknown)
    Device code: 0x3a = ATmega8515
    Device code: 0x3b = (unknown)
    Device code: 0x3c = (unknown)
    Device code: 0x3d = (unknown)
    Device code: 0x3e = (unknown)
    Device code: 0x3f = (unknown)
    Device code: 0x40 = (unknown)
    Device code: 0x41 = ATmega103
    Device code: 0x42 = (unknown)
    Device code: 0x43 = ATmega128
    Device code: 0x44 = (unknown)
    Device code: 0x45 = ATmega64
    Device code: 0x46 = (unknown)
    Device code: 0x47 = (unknown)
    Device code: 0x48 = (unknown)
    Device code: 0x49 = (unknown)
    Device code: 0x4a = (unknown)
    Device code: 0x4b = (unknown)
    Device code: 0x4c = AT90S2343
    Device code: 0x4d = (unknown)
    Device code: 0x4e = (unknown)
    Device code: 0x4f = (unknown)
    Device code: 0x50 = (unknown)
    Device code: 0x51 = (unknown)
    Device code: 0x52 = (unknown)
    Device code: 0x53 = (unknown)
    Device code: 0x54 = (unknown)
    Device code: 0x55 = ATtiny12
    Device code: 0x56 = ATtiny15
    Device code: 0x57 = (unknown)
    Device code: 0x58 = (unknown)
    Device code: 0x59 = (unknown)
    Device code: 0x5a = (unknown)
    Device code: 0x5b = (unknown)
    Device code: 0x5c = ATtiny28
    Device code: 0x5d = (unknown)
    Device code: 0x5e = ATtiny4313
    Device code: 0x5f = (unknown)
    Device code: 0x60 = ATmega161
    Device code: 0x61 = (unknown)
    Device code: 0x62 = (unknown)
    Device code: 0x63 = ATmega162
    Device code: 0x64 = ATmega163
    Device code: 0x65 = (unknown)
    Device code: 0x66 = (unknown)
    Device code: 0x67 = (unknown)
    Device code: 0x68 = AT90S8535
    Device code: 0x69 = ATmega8535
    Device code: 0x6a = (unknown)
    Device code: 0x6b = (unknown)
    Device code: 0x6c = AT90S4434
    Device code: 0x6d = (unknown)
    Device code: 0x6e = (unknown)
    Device code: 0x6f = (unknown)
    Device code: 0x70 = (unknown)
    Device code: 0x71 = (unknown)
    Device code: 0x72 = ATmega32
    Device code: 0x73 = (unknown)
    Device code: 0x74 = ATmega644PA
    Device code: 0x75 = ATmega6490
    Device code: 0x76 = ATmega8
    Device code: 0x77 = (unknown)
    Device code: 0x78 = ATmega169
    Device code: 0x79 = (unknown)
    Device code: 0x7a = (unknown)
    Device code: 0x7b = (unknown)
    Device code: 0x7c = (unknown)
    Device code: 0x7d = (unknown)
    Device code: 0x7e = (unknown)
    Device code: 0x7f = (unknown)

avrdude: error: selected device is not supported by programmer: m328
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.

*** [upload] Error 1

And ATmega328P results in the same error message.

So the closest method is indeed

upload_port = /dev/cu.SLAB_USBtoUART
upload_protocol = avr911
upload_speed = 19200

right now.

Maybe the erase flag is missing? I mean yeah it would destroy a bootloader flashed unto the target ATMega328P I guess it isn’t even programmed yet with one…

When you do a verbose upload (pio run -t upload) you get e.g. the line

avrdude -v -p atmega328p -C C:\Users\Maxi\.platformio\packages\tool-avrdude\avrdude.conf -c avr911 -b 19200 -D -P "COM3" -U flash:w:.pio\build\uno3\firmware.hex:i

Can you just check what line that is for you, then open a shell, cd into the path of your project (so that the path to the firmware is correct), replace avrdude with the full path to the avrdude program (located in the user’s home directory, then .platformio/packages/tool-avrdude/avrdude), get rid of the -D flag and add a -e flag? Sadly you can’t easily unsetupload flags from the platformio.ini.

pio run -t upload -v 

Results in:

avrdude -v -p atmega328p -C /Users/john/.platformio/packages/tool-avrdude/avrdude.conf -c avr911 -b 19200 -D -P "/dev/cu.SLAB_USBtoUART" -U flash:w:.pio/build/myAVRBoard_atmega328p/firmware.hex:i

So what does

/Users/john/.platformio/packages/tool-avrdude/avrdude -v -p atmega328p -C /Users/john/.platformio/packages/tool-avrdude/avrdude.conf -c avr911 -b 19200 -e -P "/dev/cu.SLAB_USBtoUART" -U flash:w:.pio/build/myAVRBoard_atmega328p/firmware.hex:i

Do when executed in a shell within your project?

1 Like

Fixed command:

~/.platformio/packages/tool-avrdude/bin/avrdude -v -p atmega328p -C ~/.platformio/packages/tool-avrdude/avrdude.conf -c avr911 -b 19200 -e -P "/dev/cu.SLAB_USBtoUART" -U flash:w:.pio/build/myAVRBoard_atmega328p/firmware.hex:i 

Looks like it works :o

~/.platformio/packages/tool-avrdude/bin/avrdude -v -p atmega328p -C ~/.platformio/packages/tool-avrdude/avrdude.conf -c avr911 -b 19200 -e -P "/dev/cu.SLAB_USBtoUART" -U flash:w:.pio/build/myAVRBoard_atmega328p/firmware.hex:i 


avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/Users/john/.platformio/packages/tool-avrdude/avrdude.conf"
         User configuration file is "/Users/john/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/cu.SLAB_USBtoUART
         Using Programmer              : avr911
         Overriding Baud Rate          : 19200
         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 : butterfly
         Description     : Atmel AppNote AVR911 AVROSP

Connecting to programmer: .
Found programmer: Id = "AVR ISP"; type = S
    Software Version = 2.5; Hardware Version = 2.0
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=512 bytes.

Programmer supports the following devices:
    Device code: 0x01
    Device code: 0x02
    Device code: 0x03
    Device code: 0x04
    Device code: 0x05
    Device code: 0x06
    Device code: 0x07
    Device code: 0x08
    Device code: 0x09
    Device code: 0x0a
    Device code: 0x0b
    Device code: 0x0c
    Device code: 0x0d
    Device code: 0x0e
    Device code: 0x0f
    Device code: 0x10
    Device code: 0x11
    Device code: 0x12
    Device code: 0x13
    Device code: 0x14
    Device code: 0x15
    Device code: 0x16
    Device code: 0x17
    Device code: 0x18
    Device code: 0x19
    Device code: 0x1a
    Device code: 0x1b
    Device code: 0x1c
    Device code: 0x1d
    Device code: 0x1e
    Device code: 0x1f
    Device code: 0x20
    Device code: 0x21
    Device code: 0x22
    Device code: 0x23
    Device code: 0x24
    Device code: 0x25
    Device code: 0x26
    Device code: 0x27
    Device code: 0x28
    Device code: 0x29
    Device code: 0x2a
    Device code: 0x2b
    Device code: 0x2c
    Device code: 0x2d
    Device code: 0x2e
    Device code: 0x2f
    Device code: 0x30
    Device code: 0x31
    Device code: 0x32
    Device code: 0x33
    Device code: 0x34
    Device code: 0x35
    Device code: 0x36
    Device code: 0x37
    Device code: 0x38
    Device code: 0x39
    Device code: 0x3a
    Device code: 0x3b
    Device code: 0x3c
    Device code: 0x3d
    Device code: 0x3e
    Device code: 0x3f
    Device code: 0x40
    Device code: 0x41
    Device code: 0x42
    Device code: 0x43
    Device code: 0x44
    Device code: 0x45
    Device code: 0x46
    Device code: 0x47
    Device code: 0x48
    Device code: 0x49
    Device code: 0x4a
    Device code: 0x4b
    Device code: 0x4c
    Device code: 0x4d
    Device code: 0x4e
    Device code: 0x4f
    Device code: 0x50
    Device code: 0x51
    Device code: 0x52
    Device code: 0x53
    Device code: 0x54
    Device code: 0x55
    Device code: 0x56
    Device code: 0x57
    Device code: 0x58
    Device code: 0x59
    Device code: 0x5a
    Device code: 0x5b
    Device code: 0x5c
    Device code: 0x5d
    Device code: 0x5e
    Device code: 0x5f
    Device code: 0x60
    Device code: 0x61
    Device code: 0x62
    Device code: 0x63
    Device code: 0x64
    Device code: 0x65
    Device code: 0x66
    Device code: 0x67
    Device code: 0x68
    Device code: 0x69
    Device code: 0x6a
    Device code: 0x6b
    Device code: 0x6c
    Device code: 0x6d
    Device code: 0x6e
    Device code: 0x6f
    Device code: 0x70
    Device code: 0x71
    Device code: 0x72
    Device code: 0x73
    Device code: 0x74
    Device code: 0x75
    Device code: 0x76
    Device code: 0x77
    Device code: 0x78
    Device code: 0x79
    Device code: 0x7a
    Device code: 0x7b
    Device code: 0x7c
    Device code: 0x7d
    Device code: 0x7e
    Device code: 0x7f

avrdude: devcode selected: 0x01
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.05s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D9
avrdude: safemode: efuse reads as FF
avrdude: erasing chip
avrdude: reading input file ".pio/build/myAVRBoard_atmega328p/firmware.hex"
avrdude: writing flash (164 bytes):

Writing | ################################################## | 100% 0.25s

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

Reading | ################################################## | 100% 0.15s

avrdude: verifying ...
avrdude: 164 bytes of flash verified

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D9
avrdude: safemode: efuse reads as FF
avrdude: safemode: Fuses OK (E:FF, H:D9, L:FF)

avrdude done.  Thank you.

This firmware seems to extremely small, almost non-existing. What does it do? Can you try a blinky on an LED to verify?

So basically this setup works here:

[env:myAVRBoard_atmega328p]
platform = atmelavr
board = ATmega328P

src_filter = 
  ${common.default_src_filter} 
  +<traget/ATMEGA328P/>

; build and debugging flags
build_flags = 
  -D ATMEGA328P
  -D DEBUG

; upload port.
upload_port = /dev/cu.SLAB_USBtoUART
upload_protocol = avr911
upload_speed = 19200
upload_flags = -e

I’m going to try, but I’m completely new to this :smiley: might take another 3 weeks.

Especially the -e upload flag there.

Wat I’m trying to upload:

Mainly a Blinky example that worked on the Arduino Uno.

Connecting Port-B Pin 5 to the LED Pin (Pin2-1) actually worked and it blinks.

Interesting that this works, so it will get the default -D but also the -e but the -e is stronger o_O?

Why that? I think the ATMega328P board you’re using is that here: http://sisy.name/mymcu_download/produkte/myavr_board_light/techb_myavr-board-light_de_en.pdf

You can just e.g. take the upper right pin (PC5 aka A5) and connect it to one of the LEDs.

grafik

See https://www.arduino.cc/en/Hacking/PinMapping168

E.g. with the simple code

#include <Arduino.h>

#define LED_PIN A5

void setup() {
	pinMode(LED_PIN, OUTPUT);
}

void loop() {
	digitalWrite(LED_PIN, HIGH);
	delay(500);
	digitalWrite(LED_PIN, LOW);
	delay(500);
}

1 Like