MYSBootloader support in PlatformIO

Unfortunately PlatformIO doesn't support the MYSBootloader by default, but it is quite easy to add this feature, adding a custom board.

The first step is to open a terminal and switch to Home Assistant user.

pi@d-diot:~ $ sudo -u homeassistant -H -s

Enter in the platformio boards directory:

homeassistant@d-diot:/home/pi $ cd /home/homeassistant/.platformio/platforms/atmelavr/boards

Create a custom board file for the ATMega328P 16 MHz - 5V devices:

homeassistant@d-diot:~/.platformio/platforms/atmelavr/boards $ nano MySpro16MHzatmega328.json

and insert the following lines:

MySpro16MHzatmega328.json
{
  "build": {
    "core": "arduino",
    "extra_flags": "-DARDUINO_AVR_PRO",
    "f_cpu": "16000000L",
    "mcu": "atmega328p",
    "variant": "eightanaloginputs"
  },
  "frameworks": [
    "arduino"
  ],
  "fuses": {
    "efuse": "0xFE",
    "hfuse": "0xDA",
    "lfuse": "0xFF"
  },
  "name": "MYSBootloader ATmega328P (5V, 16 MHz)",
  "upload": {
    "maximum_ram_size": 2048,
    "maximum_size": 30720,
    "protocol": "arduino",
    "require_upload_port": true,
    "speed": 57600
  },
  "url": "http://www.mysensors.org",
  "vendor": "MySensors"
}

Save and exit (Ctrl + x, Y).

Create a custom board file for the ATMega328P 8 MHz - 3.3V devices:

homeassistant@d-diot:~/.platformio/platforms/atmelavr/boards $ nano MySpro8MHzatmega328.json

and insert the following lines:

MySpro8MHzatmega328.json
{
  "build": {
    "core": "arduino",
    "extra_flags": "-DARDUINO_AVR_PRO",
    "f_cpu": "8000000L",
    "mcu": "atmega328p",
    "variant": "eightanaloginputs"
  },
  "frameworks": [
    "arduino"
  ],
  "fuses": {
    "efuse": "0xFE",
    "hfuse": "0xD2",
    "lfuse": "0xE2"
  },
  "name": "MYSBootloader ATmega328P (3.3V, 8 MHz)",
  "upload": {
    "maximum_ram_size": 2048,
    "maximum_size": 30720,
    "protocol": "arduino",
    "require_upload_port": true,
    "speed": 57600
  },
  "url": "http://www.mysensors.org",
  "vendor": "MySensors"
}

Save and exit (Ctrl + x, Y).

Create a custom board file for the ATMega328P 1 MHz devices (battery powered, BOD = 1.8V):

homeassistant@d-diot:~/.platformio/platforms/atmelavr/boards $ nano MySpro1MHzatmega328.json

and insert the following lines:

MySpro1MHzatmega328.json
{
  "build": {
    "core": "arduino",
    "extra_flags": "-DARDUINO_AVR_PRO",
    "f_cpu": "1000000L",
    "mcu": "atmega328p",
    "variant": "eightanaloginputs"
  },
  "frameworks": [
    "arduino"
  ],
  "fuses": {
    "efuse": "0xFE",
    "hfuse": "0xD2",
    "lfuse": "0x62"
  },
  "name": "MYSBootloader ATmega328P (1 MHz)",
  "upload": {
    "maximum_ram_size": 2048,
    "maximum_size": 30720,
    "protocol": "arduino",
    "require_upload_port": true,
    "speed": 9600
  },
  "url": "http://www.mysensors.org",
  "vendor": "MySensors"
}

Save and exit (Ctrl + x, Y).

Done!

Now if you want to support a MYSBootloader based device, simply add the following lines in the platformio.ini file of your project:

platformio.ini
[env:MySpro16MHzatmega328]
platform = atmelavr
board = MySpro16MHzatmega328
framework = arduino
 
[env:MySpro8MHzatmega328]
platform = atmelavr
board = MySpro8MHzatmega328
framework = arduino
 
[env:MySpro1MHzatmega328]
platform = atmelavr
board = MySpro1MHzatmega328
framework = arduino

  • how_to/mysensors/mysbootloader_platformio.txt
  • Last modified: 2019/11/11 21:40
  • by franzunix