Flash Bootloader via ISP to a Arduino Pro mini 8 Mhz

Hello,

this are my first steps in the PlatformIO. I have test in the past with Arduino, but now i will use PlatformIO.

With Arduino it is possible that i flash the Bootloader to my Arduino Pro mini 8 Mhz

Bootloader

With PlarformIO i have create a new project.

the SRC (main.ino):

{

  "build": {

    "core": "arduino",

    "extra_flags": "-DARDUINO_AVR_PRO",

    "f_cpu": "8000000L",

    "mcu": "atmega328p",

    "variant": "eightanaloginputs"

  },

  "bootloader": {

    "efuse": "0xFD",

    "file": "atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex",

    "hfuse": "0xDA",

    "lock_bits": "0x0F",

    "lfuse": "0xFF",

    "unlock_bits": "0x3F"

  },

  "debug": {

    "simavr_target": "atmega328p"

  },

  "frameworks": [

    "arduino"

  ],

  "name": "Arduino Pro or Pro Mini ATmega328 (3.3V, 8 MHz)",

  "upload": {

    "maximum_ram_size": 2048,

    "maximum_size": 30720,

    "protocol": "arduino",

    "require_upload_port": true,

    "speed": 57600

  },

  "url": "http://arduino.cc/en/Main/ArduinoBoardProMini",

  "vendor": "Arduino"

}

the platformio.ini is

[env:ATmega328]

platform = atmelavr

framework = arduino

board = ATmega328

board_build.f_cpu = 8000000L

board_fuses.hfuse = 0xDA

board_fuses.lfuse = 0xFF

board_fuses.efuse = 0xFD

upload_protocol = stk500v1

upload_flags =

    -P$UPLOAD_PORT

upload_port = COM4

But the lashing is not possible.

Have you me a tip?

Regards
Michael

So what error message are you getting?

this is the messages that i receive:

> Executing task in folder Pro Mini Bootlader: C:\Users\Michael\.platformio\penv\Scripts\platformio.exe run --target upload <

Processing ATmega328 (platform: atmelavr; framework: arduino; board: ATmega328)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/ATmega328.html
PLATFORM: Atmel AVR (2.2.0) > ATmega328
HARDWARE: ATMEGA328 8MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (simavr) On-board (simavr)       
PACKAGES:
 - framework-arduino-avr-minicore 2.0.5
 - tool-avrdude 1.60300.200527 (6.3.0)
 - toolchain-atmelavr 1.50400.190710 (5.4.0)    
Converting main.ino
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 8 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\ATmega328\src\main.ino.cpp.o
C:/Users/Michael/Documents/PlatformIO/Projects/Pro Mini Bootlader/src/main.ino:1:1: error: expected unqualified-id before '{' token
 {
 ^
*** [.pio\build\ATmega328\src\main.ino.cpp.o] Error 1
============================================================================================ [FAILED] Took 1.37 seconds ============================================================================================
The terminal process "C:\Users\Michael\.platformio\penv\Scripts\platformio.exe 'run', '--target', 'upload'" terminated with exit code: 1.

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

Wait, this is your main.ino? A JSON file describing the board? There has to be (C++) source code in there (or none at all for now if you just want to upload a bootloader).

Also it seems weird to me that you’re just duplicating the settings from the pro8MHzatmega328.json board but then explicitly override them with the same values in the platformio.ini.

Try the following:

  • rename main.ino to main.cpp with the content
#include <Arduino.h>

void setup() { }
void loop() { }
  • change your platformio.ini to
[env:ATmega328]
platform = atmelavr
framework = arduino
board = pro8MHzatmega328
upload_protocol = stk500v1
upload_flags =
    -P$UPLOAD_PORT
upload_port = COM4

(assuming that COM4 is still the correct port).

Also you have presed the “upload” button but if you want to burn the bootloader, that’s the wrong task. Execute

Do you mean only the following in the main.cpp or additional :

void setup() { }
void loop() { }

Only. As I said above, you are putting JSON data in there, which is uncompilable.

ok, with the changes main.cpp and in the platformio.ini i receive the following messages:

The terminal process "C:\Users\Michael\.platformio\penv\Scripts\platformio.exe 'run', '--target', 'bootloader', '--environment', 'ATmega328'" terminated with exit code: 1.

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

> Executing task in folder Pro Mini Bootlader: C:\Users\Michael\.platformio\penv\Scripts\platformio.exe run --target bootloader --environment ATmega328 <

Processing ATmega328 (platform: atmelavr; framework: arduino; board: pro8MHzatmega328)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/pro8MHzatmega328.html
PLATFORM: Atmel AVR (2.2.0) > Arduino Pro or Pro Mini ATmega328 (3.3V, 8 MHz)
HARDWARE: ATMEGA328P 8MHz, 2KB RAM, 30KB Flash
DEBUG: Current (simavr) On-board (simavr)
PACKAGES:
 - framework-arduino-avr 5.0.0
 - toolchain-atmelavr 1.50400.190710 (5.4.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Setting fuses
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x03

Well something responds somehow but not the expected thing. When I set my Arduino IDE to

grafik

and press “Burn Bootloader”, the following avrdude invocation is done

avrdude -CC:\Users\xxxx\Desktop\Programming_stuff\arduino-1.8.8\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cstk500 -PCOM1 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xFF:m 

And PIO does

avrdude -p atmega328p -e -C "C:\Users\Maxi\.platformio\packages\tool-avrdude\avrdude.conf" -c stk500v1 -PCOM4 -Ulock:w:0x3F:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xFF:m -Uefuse:w:0xFD:m

so the only difference here is stk500 vs stk500v1 from what I can see. Try and change the upload_protocol in the platformio.ini to

upload_protocol = stk500

And retry. If that still does not work, I would need to know which exact external programmer you have connected to your board and what the Arduino IDE log for burning a bootloader says.

now i have change it to “upload_protocol = stk500”

and it works !

Thanks
Michael