Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flash using avrdude / pio + "arduino as ISP" #84

Open
corbolais opened this issue Jan 20, 2021 · 5 comments
Open

Flash using avrdude / pio + "arduino as ISP" #84

corbolais opened this issue Jan 20, 2021 · 5 comments
Labels
documentation Improvements or additions to documentation

Comments

@corbolais
Copy link

corbolais commented Jan 20, 2021

Hi,
Just flashed the ATTiny841 hex using pio and an "Arduino as ISP", here I used an UNO. For future reference in case anyone wants to quickly repeat this process I'm opening this issue. Maybe one could integrate it into the documentation?

Firstly, flash the bootloader (prefererably the "new" variant) to your *duino to be able to use it as ISP programmer. This can be done using the Arduino IDE (didn't get to flash it using pio run -t bootloader):

  1. Connect USB cable to the Arduino UNO and nothing else is connected at this point
  2. Tools->"Programmer: Arduino as ISP"
  3. Tools->"Flash bootloader" command.Sometimes this didn't work here, so an alternative is to select the "arduino ISP" example sketch compile and upload

Secondly, connect the Arduino ISP to your ATTiny board like this:

Arduino ISCP pin/
      header pin -> ATTiny board ICSP (pinout per schematic)
  ----------------------------
    1 MOSI / D11 -> 1 MOSI
    4 MISO / D12 -> 4 MISO
    3 SCK  / D13 -> 3 SCK
    2        VCC -> 2 VCC
    6        GND -> 6 GND
             D10 ->   /RST <== This is crucial
    5        RST -> 5 NC (!)

This may be done using the Arduino ISCP header or directly using the pins as shown in parenthesis. Arduino ICSP pinout.
Usually, you also need a 10uF cap across D10 (Arduino RST) and GND.
(For programming, in this case, CS (pin 6:PA7 or pin 11:PA2) on the ATTiny is not required to be pulled down.)

Thirdly, flash the firmware either using avrdude directly:
avrdude -C ~/./avrdude.conf -p attiny841 -P /dev/ttyUSB0 -b 19200 -c stk500v1 -U flash:w:.pio/build/attiny841_V400/module_firmware_attiny841_V400_400.hex:i
Just replace the hex filename with the one you need and the correct ttyUSB? device.

To flash using pio run -e attiny841_V400 -t upload --upload-port /dev/ttyUSB1 -vv one would need to modify platformio.ini:

upload_protocol = avrisp
; efuse = 1111 0100 = Enables SPM instruction
; hfuse = 1101 0110 = EESAVE & 1.8V BOD detection level
; lfuse = 1110 0010 = CKDIV8 & Calibrated Internal 8MHz Oscillator
board_fuses.lfuse = 0b11100010
board_fuses.hfuse = 0b11010110
board_fuses.efuse = 0b11110100
;-B16 option needed for my USBASP programmer to slow it down!
upload_speed = 19200
upload_flags =
    -C
    $PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf
    -p
    $BOARD_MCU
    -P
    $UPLOAD_PORT
    -b
    $UPLOAD_SPEED
    -c
    stk500v1
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

Then do:
pio run -e attiny841_V400 -t upload --upload-port /dev/ttyUSB0

HTH

@corbolais corbolais changed the title Flash using pio + "arduino as ISP" Flash using avrdude / pio + "arduino as ISP" Jan 20, 2021
@stuartpittaway stuartpittaway added the documentation Improvements or additions to documentation label Jan 20, 2021
@stuartpittaway
Copy link
Owner

Thank you

@LeighAS
Copy link

LeighAS commented Mar 6, 2023

I may have to try this, i have failed a few times trying with usbasp devices

EDIT my new usbasp device arrived. same problem as before observed. tried -F upload flag, tried -B16 upload flag. all to no avail. Any advices here Stuart. Last thing to try might be the tinyisp like Adam Welch does but honestly think that the slaves may be broken too.

I struggled last night to flash the 4.21 slaves
Uploading .pio\build\V421\module_fw_V421_attiny841_421_eF4_hD6_l62.hex

avrdude: error: program enable: target doesn’t answer. 1
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.

I have a usbasp device which is showing as good in device manager and is being recognised in platformio in vscode, I have triple checked the six wires that go from the icsp headers and when i attempt upload it give the message shown above. any advices would be appreciated. thanks. I get one green flash on the 4.21 slave board when the upload is attempted.

I have now put an order on amazon for the usbasp linked in the description of this video. hopefully there is just some difference in my old usbasp device that i cant see, but i am doubtful.

@stuartpittaway
Copy link
Owner

Are you using the older (small) controller PCB? The newer one includes a TINY841 programmer through the web interface.

@LeighAS
Copy link

LeighAS commented Mar 7, 2023 via email

@LeighAS
Copy link

LeighAS commented Mar 7, 2023

Here are 3 that i havent soldered the header to flash then yet
16781924817772524563565005864648

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants