2021-12-08
1. avrdude and programming
Last time was a tour of the AVR/ATtiny85 fuses and their function.
Today is a tour of how avrdude
and ArduinoIDE relate to each other.
First the code.
-
Dated items Gfolder: https://drive.google.com/drive/folders/1KESSc0lTkqCQv7l6YTCy2890BLr_D317?usp=sharing
-
direct link
day35_blink-avrdude.ino
/*
* Blink
* using native register operations on the ATtiny85
*
* ECE 322 day35
*/
#include <stdint.h>
#define LED_PIN 3
/*
* xdelay
*
* Busy loop delay.
*
* input:
* uint16_t count -- loop count
*
* output:
* none
*/
void xdelay(uint16_t count)
{
volatile uint8_t temp;
for (uint16_t i=0; i<count; i++) {
temp++;
}
}
void setup() {
// set DDRBn to 1, making the pin attached to the board LED an output
DDRB |= (1 << LED_PIN);
}
void loop() {
PORTB |= (1 << LED_PIN);
xdelay(UINT16_MAX);
PORTB &= ~(1 << LED_PIN);
xdelay(UINT16_MAX);
}
Compile and load this code to your ATtiny85.
We are using the github: ATTinyCore board definitions.
-
http://drazzy.com/package_drazzy.com_index.json
Change your ArduinoIDE preferences:

-
Verbose output for both compilation and upload
-
All compiler warnings
Tool/board settings:

First do Tools -> Burn Bootloader to set the appropriate fuse bits that correspond to these settings (specifically the clocking configuration).
After that action, take a look at the message window.
Under the hood, ArduinoIDE ran avrdude
with the following huge command line:
`/home/dan/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino18/bin/avrdude -C/home/dan/.arduino15/packages/ATTinyCore/hardware/avr/1.5.2/avrdude.conf -v -pattiny85 -cstk500v1 -P/dev/ttyUSB1 -b19200 -e -Uefuse:w:0xFF:m -Uhfuse:w:0b11010111:m -Ulfuse:w:0x62:m -Uflash:w:/home/dan/.arduino15/packages/ATTinyCore/hardware/avr/1.5.2/bootloaders/empty/empty_all.hex:i `
-
Full path to the avrdude executable
/home/dan/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino18/bin/avrdude
-
Configuration file
-C/home/dan/.arduino15/packages/ATTinyCore/hardware/avr/1.5.2/avrdude.conf
-
Verbose output
-v
-
Chip model
-pattiny85
-
Programmer protocol ` -cstk500v1`
-
Serial port
-P/dev/ttyUSB1
-
Serial baud rate ` -b19200`
-
Erase chip
-e
-
Program the Extended Fuse
-Uefuse:w:0xFF:m
-
Program the High Fuse
-Uhfuse:w:0b11010111:m
-
Program the Low Fuse
-Ulfuse:w:0x62:m
-
Flash contents
-Uflash:w:/home/dan/.arduino15/packages/ATTinyCore/hardware/avr/1.5.2/bootloaders/empty/empty_all.hex:i
-
-Uflash:w:/path-to/empty_all.hex:i
-
Look up the meaning of these fuse settings!
Now upload the sketch. Remember, the previous command ERASED the flash also. (How can you avoid this side-effect?)
Not the blink rate.
Set the clock to 8 MHz (internal).
Tools -> Burn Bootloader again.
Compare the command line arguments. Only a single Low Fuse bit should have changed.
Upload the same sketch.
Notice how the blinking is now 8x faster.
Export compiled Binary.

You now have two new files in your sketch folder:
-
day35_blink-avrdude.ino.hex
-
day35_blink-avrdude.ino.lst
Inspect these!
-
Intel HEX format
-
assembly listing