I was playing with megaTinyCore and it works well with Arduino IDE.
I was also looking into the guide they have for PlatformIO.
Note: megaTinyCore is not published in platformio’s platforms by the core developer (He’s is super busy with many things. So don’t to bug him).
Human.readable fuse settings in Arduino IDE setup:
So let’s say I have a target ATTINY-1607
In Arduino IDE, I can customise these attributes (which translate into then necessary fuse settings):
clock = 5internal bodvoltage = 1v8 # BOD voltage level bodmode = disabled eesave = enable # Enable saving in EEPROM resetpin = UPDI millis=enabled startuptime=0 wiremode=mors printf=minimal attach=allenabled
I found (MAy. be I do not have all the information) I can only customise these few of these settings and they are as marked in [x] below and these would be:
[env:set_fuses] ; Fuse setting ; [x] clock=5internal ; [x] bodvoltage=1v8 ; no need as bodmode is disabled? ; [x] bodmode=disabled ; [x] eesave=enable ; [x] resetpin=UPDI ; millis=enabled ; startuptime=0 ; wiremode=mors ; printf=minimal ; attach=allenabled board_hardware.oscillator = internal ; Oscillator type (internal or external) board_build.f_cpu = 5000000L ; 5 MHz internal board_hardware.bod = disabled ; 1.8V, 2.6V, 4.8V, disabled board_hardware.eesave = yes board_hardware.rstpin = updi
Note: I guess the
printf is set in the platformio.ini in build flags as:
build_flags = -lprintf_flt
The question, is now, how can we set the other params missing? Or do we have to manually adjust the fuses?
Some of the fuse settings I can see, when I see the Arduino IDE verbose, which uses the command:
/Users/<USER>/Library/Arduino15/packages/megaTinyCore/tools/python3/3.7.2-post1/python3 -u /Users/<USER>/Library/Arduino15/packages/megaTinyCore/hardware/megaavr/2.5.11/tools/prog.py -t uart -u /dev/tty.usbserial-14220 -b 921600 -d attiny1607 --fuses 2:0x02 6:0x00 8:0x00 -f $SOURCE -a write
Here’s my ini file (and the questions and dilemmas are in there in the comments):
[env:ATtiny1607] platform = atmelmegaavr framework = arduino board = ATtiny1607 ; chip is ATTINY-1607 ; monitor_speed = 115200 ; monitor_port = "" ; ---------- BUILD PARAMS ---------- ; ; Fuse setting: board_hardware.oscillator = internal ; Oscillator type (internal or external) board_build.f_cpu = 5000000L ; 5 MHz internal board_hardware.bod = disabled ; 1.8v, 2.6v (default), 4.8v, disabled. ; In the above step, guessing if it is disabled, we do not need to mention the bod voltage level? board_hardware.eesave = yes board_hardware.rstpin = updi ; The question is now, how can we set the other params missing? ; Do we have to manually adjust the fuses responsible for the other parameters? ; What are the fuses for these or how can they be setup? (I was looking in boards.txt for the megaTinyCore used in Arduino IDE) ; millis=enabled ; startuptime=0 ; wiremode=mors ;i2c related ; printf=minimal ; attach=allenabled ; [fuse2 / OSCCFG = 0x02] (specifying 5MHz internal oscillator, but I guess we don't need to write this manually as we have already specified it) ; For [fuse6 / SYSCFG1 = 0x00], guessing ti stands for "startup time" and if I wanted a 0 ms, it would be: ; board_fuses.SYSCFG1 = 0x00 ; fuse:6 -> startup time, 0ms ? ; [fuse8 / BOOTEND = 0x00] ; The fuse settings (`--fuses 2:0x02 6:0x00 8:0x00`) in the `upload_comamnd` were derived here after I looked into the Arduino IDE verbose output. ; To enable interrupts on all pins: ; board_fuses.attachmode=-DCORE_ATTACH_ALL ? ; I saw in HELP, e.g of how to write: to write fuse byte 1 to 0xE0 on a kit, the. command would be: pymcuprog write -m fuses -o 1 -l 0xE0 ; ---------- UPLOAD PARAMS ---------- ; ; Serial UPDI based programming setup upload_protocol = custom ; to use serialUPDI upload_speed = 115200 ; less aggressive baud than 921600 upload_port = "/dev/tty.usbserial-14220" upload_flags = -t uart -u $UPLOAD_PORT -c $UPLOAD_SPEED -d attiny1607 -v info ; ---- INSTALL GOOD PYMCUPROG for pio bfeore proceeding ----- ; ; execute: 'pio system info' ; get python path from 'Python Executable' ; install pymcuprog by: <python executable> -m pip install -i https://test.pypi.org/simple/ pymcuprog==220.127.116.11 upload_command = pymcuprog write $UPLOAD_FLAGS -f $SOURCE