1
0
Fork 0

arduino-0022

This commit is contained in:
Eve Entropia 2011-02-23 21:47:18 +01:00
parent 4f99742f03
commit a9ad0e80a0
803 changed files with 69785 additions and 33024 deletions

22
arduino-0022-linux-x64/arduino Executable file
View file

@ -0,0 +1,22 @@
#!/bin/sh
APPDIR="$(dirname -- $(readlink -f -- "${0}") )"
cd $APPDIR
for LIB in \
java/lib/rt.jar \
java/lib/tools.jar \
lib/*.jar \
;
do
CLASSPATH="${CLASSPATH}:${LIB}"
done
export CLASSPATH
LD_LIBRARY_PATH=`pwd`/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
export LD_LIBRARY_PATH
export PATH="${APPDIR}/java/bin:${PATH}"
java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel processing.app.Base

View file

@ -0,0 +1,15 @@
/*
AnalogReadSerial
Reads an analog input on pin 0, prints the result to the serial monitor
This example code is in the public domain.
*/
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(A0);
Serial.println(sensorValue, DEC);
}

View file

@ -0,0 +1,9 @@
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}

View file

@ -0,0 +1,19 @@
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(13, LOW); // set the LED off
delay(1000); // wait for a second
}

View file

@ -0,0 +1,19 @@
/*
DigitalReadSerial
Reads a digital input on pin 2, prints the result to the serial monitor
This example code is in the public domain.
*/
void setup() {
Serial.begin(9600);
pinMode(2, INPUT);
}
void loop() {
int sensorValue = digitalRead(2);
Serial.println(sensorValue, DEC);
}

View file

@ -0,0 +1,31 @@
/*
Fade
This example shows how to fade an LED on pin 9
using the analogWrite() function.
This example code is in the public domain.
*/
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by
void setup() {
// declare pin 9 to be an output:
pinMode(9, OUTPUT);
}
void loop() {
// set the brightness of pin 9:
analogWrite(9, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}

View file

@ -0,0 +1,65 @@
/* Blink without Delay
Turns on and off a light emitting diode(LED) connected to a digital
pin, without using the delay() function. This means that other code
can run at the same time without being interrupted by the LED code.
The circuit:
* LED attached from pin 13 to ground.
* Note: on most Arduinos, there is already an LED on the board
that's attached to pin 13, so no hardware is needed for this example.
created 2005
by David A. Mellis
modified 8 Feb 2010
by Paul Stoffregen
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
*/
// constants won't change. Used here to
// set pin numbers:
const int ledPin = 13; // the number of the LED pin
// Variables will change:
int ledState = LOW; // ledState used to set the LED
long previousMillis = 0; // will store last time LED was updated
// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval = 1000; // interval at which to blink (milliseconds)
void setup() {
// set the digital pin as output:
pinMode(ledPin, OUTPUT);
}
void loop()
{
// here is where you'd put code that needs to be running all the time.
// check to see if it's time to blink the LED; that is, if the
// difference between the current time and last time you blinked
// the LED is bigger than the interval at which you want to
// blink the LED.
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW)
ledState = HIGH;
else
ledState = LOW;
// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
}
}

View file

@ -0,0 +1,56 @@
/*
Button
Turns on and off a light emitting diode(LED) connected to digital
pin 13, when pressing a pushbutton attached to pin 2.
The circuit:
* LED attached from pin 13 to ground
* pushbutton attached to pin 2 from +5V
* 10K resistor attached to pin 2 from ground
* Note: on most Arduinos there is already an LED on the board
attached to pin 13.
created 2005
by DojoDave <http://www.0j0.org>
modified 28 Oct 2010
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Button
*/
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}

View file

@ -0,0 +1,75 @@
/*
Debounce
Each time the input pin goes from LOW to HIGH (e.g. because of a push-button
press), the output pin is toggled from LOW to HIGH or HIGH to LOW. There's
a minimum delay between toggles to debounce the circuit (i.e. to ignore
noise).
The circuit:
* LED attached from pin 13 to ground
* pushbutton attached from pin 2 to +5V
* 10K resistor attached from pin 2 to ground
* Note: On most Arduino boards, there is already an LED on the board
connected to pin 13, so you don't need any extra components for this example.
created 21 November 2006
by David A. Mellis
modified 3 Jul 2009
by Limor Fried
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Debounce
*/
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
// Variables will change:
int ledState = HIGH; // the current state of the output pin
int buttonState; // the current reading from the input pin
int lastButtonState = LOW; // the previous reading from the input pin
// the following variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long lastDebounceTime = 0; // the last time the output pin was toggled
long debounceDelay = 50; // the debounce time; increase if the output flickers
void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the state of the switch into a local variable:
int reading = digitalRead(buttonPin);
// check to see if you just pressed the button
// (i.e. the input went from LOW to HIGH), and you've waited
// long enough since the last press to ignore any noise:
// If the switch changed, due to noise or pressing:
if (reading != lastButtonState) {
// reset the debouncing timer
lastDebounceTime = millis();
}
if ((millis() - lastDebounceTime) > debounceDelay) {
// whatever the reading is at, it's been there for longer
// than the debounce delay, so take it as the actual current state:
buttonState = reading;
}
// set the LED using the state of the button:
digitalWrite(ledPin, buttonState);
// save the reading. Next time through the loop,
// it'll be the lastButtonState:
lastButtonState = reading;
}

View file

@ -0,0 +1,92 @@
/*
State change detection (edge detection)
Often, you don't need to know the state of a digital input all the time,
but you just need to know when the input changes from one state to another.
For example, you want to know when a button goes from OFF to ON. This is called
state change detection, or edge detection.
This example shows how to detect when a button or button changes from off to on
and on to off.
The circuit:
* pushbutton attached to pin 2 from +5V
* 10K resistor attached to pin 2 from ground
* LED attached from pin 13 to ground (or use the built-in LED on
most Arduino boards)
created 27 Sep 2005
modified 14 Oct 2010
by Tom Igoe
This example code is in the public domain.
http://arduino.cc/en/Tutorial/ButtonStateChange
*/
// this constant won't change:
const int buttonPin = 2; // the pin that the pushbutton is attached to
const int ledPin = 13; // the pin that the LED is attached to
// Variables will change:
int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button
void setup() {
// initialize the button pin as a input:
pinMode(buttonPin, INPUT);
// initialize the LED as an output:
pinMode(ledPin, OUTPUT);
// initialize serial communication:
Serial.begin(9600);
}
void loop() {
// read the pushbutton input pin:
buttonState = digitalRead(buttonPin);
// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == HIGH) {
// if the current state is HIGH then the button
// wend from off to on:
buttonPushCounter++;
Serial.println("on");
Serial.print("number of button pushes: ");
Serial.println(buttonPushCounter, DEC);
}
else {
// if the current state is LOW then the button
// wend from on to off:
Serial.println("off");
}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState;
// turns on the LED every four button pushes by
// checking the modulo of the button push counter.
// the modulo function gives you the remainder of
// the division of two numbers:
if (buttonPushCounter % 4 == 0) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
}

View file

@ -0,0 +1,95 @@
/*************************************************
* Public Constants
*************************************************/
#define NOTE_B0 31
#define NOTE_C1 33
#define NOTE_CS1 35
#define NOTE_D1 37
#define NOTE_DS1 39
#define NOTE_E1 41
#define NOTE_F1 44
#define NOTE_FS1 46
#define NOTE_G1 49
#define NOTE_GS1 52
#define NOTE_A1 55
#define NOTE_AS1 58
#define NOTE_B1 62
#define NOTE_C2 65
#define NOTE_CS2 69
#define NOTE_D2 73
#define NOTE_DS2 78
#define NOTE_E2 82
#define NOTE_F2 87
#define NOTE_FS2 93
#define NOTE_G2 98
#define NOTE_GS2 104
#define NOTE_A2 110
#define NOTE_AS2 117
#define NOTE_B2 123
#define NOTE_C3 131
#define NOTE_CS3 139
#define NOTE_D3 147
#define NOTE_DS3 156
#define NOTE_E3 165
#define NOTE_F3 175
#define NOTE_FS3 185
#define NOTE_G3 196
#define NOTE_GS3 208
#define NOTE_A3 220
#define NOTE_AS3 233
#define NOTE_B3 247
#define NOTE_C4 262
#define NOTE_CS4 277
#define NOTE_D4 294
#define NOTE_DS4 311
#define NOTE_E4 330
#define NOTE_F4 349
#define NOTE_FS4 370
#define NOTE_G4 392
#define NOTE_GS4 415
#define NOTE_A4 440
#define NOTE_AS4 466
#define NOTE_B4 494
#define NOTE_C5 523
#define NOTE_CS5 554
#define NOTE_D5 587
#define NOTE_DS5 622
#define NOTE_E5 659
#define NOTE_F5 698
#define NOTE_FS5 740
#define NOTE_G5 784
#define NOTE_GS5 831
#define NOTE_A5 880
#define NOTE_AS5 932
#define NOTE_B5 988
#define NOTE_C6 1047
#define NOTE_CS6 1109
#define NOTE_D6 1175
#define NOTE_DS6 1245
#define NOTE_E6 1319
#define NOTE_F6 1397
#define NOTE_FS6 1480
#define NOTE_G6 1568
#define NOTE_GS6 1661
#define NOTE_A6 1760
#define NOTE_AS6 1865
#define NOTE_B6 1976
#define NOTE_C7 2093
#define NOTE_CS7 2217
#define NOTE_D7 2349
#define NOTE_DS7 2489
#define NOTE_E7 2637
#define NOTE_F7 2794
#define NOTE_FS7 2960
#define NOTE_G7 3136
#define NOTE_GS7 3322
#define NOTE_A7 3520
#define NOTE_AS7 3729
#define NOTE_B7 3951
#define NOTE_C8 4186
#define NOTE_CS8 4435
#define NOTE_D8 4699
#define NOTE_DS8 4978

View file

@ -0,0 +1,45 @@
/*
keyboard
Plays a pitch that changes based on a changing analog input
circuit:
* 3 force-sensing resistors from +5V to analog in 0 through 5
* 3 10K resistors from analog in 0 through 5 to ground
* 8-ohm speaker on digital pin 8
created 21 Jan 2010
Modified 4 Sep 2010
by Tom Igoe
This example code is in the public domain.
http://arduino.cc/en/Tutorial/Tone3
*/
#include "pitches.h"
const int threshold = 10; // minimum reading of the sensors that generates a note
// notes to play, corresponding to the 3 sensors:
int notes[] = {
NOTE_A4, NOTE_B4,NOTE_C3 };
void setup() {
}
void loop() {
for (int thisSensor = 0; thisSensor < 3; thisSensor++) {
// get a sensor reading:
int sensorReading = analogRead(thisSensor);
// if the sensor is pressed hard enough:
if (sensorReading > threshold) {
// play the note corresponding to this sensor:
tone(8, notes[thisSensor], 20);
}
}
Serial.println();
}

View file

@ -0,0 +1,95 @@
/*************************************************
* Public Constants
*************************************************/
#define NOTE_B0 31
#define NOTE_C1 33
#define NOTE_CS1 35
#define NOTE_D1 37
#define NOTE_DS1 39
#define NOTE_E1 41
#define NOTE_F1 44
#define NOTE_FS1 46
#define NOTE_G1 49
#define NOTE_GS1 52
#define NOTE_A1 55
#define NOTE_AS1 58
#define NOTE_B1 62
#define NOTE_C2 65
#define NOTE_CS2 69
#define NOTE_D2 73
#define NOTE_DS2 78
#define NOTE_E2 82
#define NOTE_F2 87
#define NOTE_FS2 93
#define NOTE_G2 98
#define NOTE_GS2 104
#define NOTE_A2 110
#define NOTE_AS2 117
#define NOTE_B2 123
#define NOTE_C3 131
#define NOTE_CS3 139
#define NOTE_D3 147
#define NOTE_DS3 156
#define NOTE_E3 165
#define NOTE_F3 175
#define NOTE_FS3 185
#define NOTE_G3 196
#define NOTE_GS3 208
#define NOTE_A3 220
#define NOTE_AS3 233
#define NOTE_B3 247
#define NOTE_C4 262
#define NOTE_CS4 277
#define NOTE_D4 294
#define NOTE_DS4 311
#define NOTE_E4 330
#define NOTE_F4 349
#define NOTE_FS4 370
#define NOTE_G4 392
#define NOTE_GS4 415
#define NOTE_A4 440
#define NOTE_AS4 466
#define NOTE_B4 494
#define NOTE_C5 523
#define NOTE_CS5 554
#define NOTE_D5 587
#define NOTE_DS5 622
#define NOTE_E5 659
#define NOTE_F5 698
#define NOTE_FS5 740
#define NOTE_G5 784
#define NOTE_GS5 831
#define NOTE_A5 880
#define NOTE_AS5 932
#define NOTE_B5 988
#define NOTE_C6 1047
#define NOTE_CS6 1109
#define NOTE_D6 1175
#define NOTE_DS6 1245
#define NOTE_E6 1319
#define NOTE_F6 1397
#define NOTE_FS6 1480
#define NOTE_G6 1568
#define NOTE_GS6 1661
#define NOTE_A6 1760
#define NOTE_AS6 1865
#define NOTE_B6 1976
#define NOTE_C7 2093
#define NOTE_CS7 2217
#define NOTE_D7 2349
#define NOTE_DS7 2489
#define NOTE_E7 2637
#define NOTE_F7 2794
#define NOTE_FS7 2960
#define NOTE_G7 3136
#define NOTE_GS7 3322
#define NOTE_A7 3520
#define NOTE_AS7 3729
#define NOTE_B7 3951
#define NOTE_C8 4186
#define NOTE_CS8 4435
#define NOTE_D8 4699
#define NOTE_DS8 4978

View file

@ -0,0 +1,49 @@
/*
Melody
Plays a melody
circuit:
* 8-ohm speaker on digital pin 8
created 21 Jan 2010
modified 14 Oct 2010
by Tom Igoe
This example code is in the public domain.
http://arduino.cc/en/Tutorial/Tone
*/
#include "pitches.h"
// notes in the melody:
int melody[] = {
NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4};
// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
4, 8, 8, 4,4,4,4,4 };
void setup() {
// iterate over the notes of the melody:
for (int thisNote = 0; thisNote < 8; thisNote++) {
// to calculate the note duration, take one second
// divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1000/noteDurations[thisNote];
tone(8, melody[thisNote],noteDuration);
// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
// stop the tone playing:
noTone(8);
}
}
void loop() {
// no need to repeat the melody.
}

View file

@ -0,0 +1,95 @@
/*************************************************
* Public Constants
*************************************************/
#define NOTE_B0 31
#define NOTE_C1 33
#define NOTE_CS1 35
#define NOTE_D1 37
#define NOTE_DS1 39
#define NOTE_E1 41
#define NOTE_F1 44
#define NOTE_FS1 46
#define NOTE_G1 49
#define NOTE_GS1 52
#define NOTE_A1 55
#define NOTE_AS1 58
#define NOTE_B1 62
#define NOTE_C2 65
#define NOTE_CS2 69
#define NOTE_D2 73
#define NOTE_DS2 78
#define NOTE_E2 82
#define NOTE_F2 87
#define NOTE_FS2 93
#define NOTE_G2 98
#define NOTE_GS2 104
#define NOTE_A2 110
#define NOTE_AS2 117
#define NOTE_B2 123
#define NOTE_C3 131
#define NOTE_CS3 139
#define NOTE_D3 147
#define NOTE_DS3 156
#define NOTE_E3 165
#define NOTE_F3 175
#define NOTE_FS3 185
#define NOTE_G3 196
#define NOTE_GS3 208
#define NOTE_A3 220
#define NOTE_AS3 233
#define NOTE_B3 247
#define NOTE_C4 262
#define NOTE_CS4 277
#define NOTE_D4 294
#define NOTE_DS4 311
#define NOTE_E4 330
#define NOTE_F4 349
#define NOTE_FS4 370
#define NOTE_G4 392
#define NOTE_GS4 415
#define NOTE_A4 440
#define NOTE_AS4 466
#define NOTE_B4 494
#define NOTE_C5 523
#define NOTE_CS5 554
#define NOTE_D5 587
#define NOTE_DS5 622
#define NOTE_E5 659
#define NOTE_F5 698
#define NOTE_FS5 740
#define NOTE_G5 784
#define NOTE_GS5 831
#define NOTE_A5 880
#define NOTE_AS5 932
#define NOTE_B5 988
#define NOTE_C6 1047
#define NOTE_CS6 1109
#define NOTE_D6 1175
#define NOTE_DS6 1245
#define NOTE_E6 1319
#define NOTE_F6 1397
#define NOTE_FS6 1480
#define NOTE_G6 1568
#define NOTE_GS6 1661
#define NOTE_A6 1760
#define NOTE_AS6 1865
#define NOTE_B6 1976
#define NOTE_C7 2093
#define NOTE_CS7 2217
#define NOTE_D7 2349
#define NOTE_DS7 2489
#define NOTE_E7 2637
#define NOTE_F7 2794
#define NOTE_FS7 2960
#define NOTE_G7 3136
#define NOTE_GS7 3322
#define NOTE_A7 3520
#define NOTE_AS7 3729
#define NOTE_B7 3951
#define NOTE_C8 4186
#define NOTE_CS8 4435
#define NOTE_D8 4699
#define NOTE_DS8 4978

View file

@ -0,0 +1,42 @@
/*
Multiple tone player
Plays multiple tones on multiple pins in sequence
circuit:
* 3 8-ohm speaker on digital pins 6, 7, and 11
created 8 March 2010
by Tom Igoe
based on a snippet from Greg Borenstein
This example code is in the public domain.
http://arduino.cc/en/Tutorial/Tone4
*/
void setup() {
}
void loop() {
// turn off tone function for pin 11:
noTone(11);
// play a note on pin 6 for 200 ms:
tone(6, 440, 200);
delay(200);
// turn off tone function for pin 6:
noTone(6);
// play a note on pin 7 for 500 ms:
tone(7, 494, 500);
delay(500);
// turn off tone function for pin 7:
noTone(7);
// play a note on pin 11 for 500 ms:
tone(11, 523, 300);
delay(300);
}

View file

@ -0,0 +1,46 @@
/*
Pitch follower
Plays a pitch that changes based on a changing analog input
circuit:
* 8-ohm speaker on digital pin 8
* photoresistor on analog 0 to 5V
* 4.7K resistor on analog 0 to ground
created 21 Jan 2010
Modified 4 Sep 2010
by Tom Igoe
This example code is in the public domain.
http://arduino.cc/en/Tutorial/Tone2
*/
void setup() {
// initialize serial communications (for debugging only):
Serial.begin(9600);
}
void loop() {
// read the sensor:
int sensorReading = analogRead(A0);
// print the sensor reading so you know its range
Serial.println(sensorReading);
// map the pitch to the range of the analog input.
// change the minimum and maximum input numbers below
// depending on the range your sensor's giving:
int thisPitch = map(sensorReading, 400, 1000, 100, 1000);
// play the pitch:
tone(8, thisPitch, 10);
}

View file

@ -0,0 +1,53 @@
/*
Analog input, analog output, serial output
Reads an analog input pin, maps the result to a range from 0 to 255
and uses the result to set the pulsewidth modulation (PWM) of an output pin.
Also prints the results to the serial monitor.
The circuit:
* potentiometer connected to analog pin 0.
Center pin of the potentiometer goes to the analog pin.
side pins of the potentiometer go to +5V and ground
* LED connected from digital pin 9 to ground
created 29 Dec. 2008
Modified 4 Sep 2010
by Tom Igoe
This example code is in the public domain.
*/
// These constants won't change. They're used to give names
// to the pins used:
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// change the analog out value:
analogWrite(analogOutPin, outputValue);
// print the results to the serial monitor:
Serial.print("sensor = " );
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);
// wait 10 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(10);
}

View file

@ -0,0 +1,50 @@
/*
Analog Input
Demonstrates analog input by reading an analog sensor on analog pin 0 and
turning on and off a light emitting diode(LED) connected to digital pin 13.
The amount of time the LED will be on and off depends on
the value obtained by analogRead().
The circuit:
* Potentiometer attached to analog input 0
* center pin of the potentiometer to the analog pin
* one side pin (either one) to ground
* the other side pin to +5V
* LED anode (long leg) attached to digital output 13
* LED cathode (short leg) attached to ground
* Note: because most Arduinos have a built-in LED attached
to pin 13 on the board, the LED is optional.
Created by David Cuartielles
Modified 4 Sep 2010
By Tom Igoe
This example code is in the public domain.
http://arduino.cc/en/Tutorial/AnalogInput
*/
int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
// turn the ledPin on
digitalWrite(ledPin, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(ledPin, LOW);
// stop the program for for <sensorValue> milliseconds:
delay(sensorValue);
}

View file

@ -0,0 +1,45 @@
/*
Mega analogWrite() test
This sketch fades LEDs up and down one at a time on digital pins 2 through 13.
This sketch was written for the Arduino Mega, and will not work on previous boards.
The circuit:
* LEDs attached from pins 2 through 13 to ground.
created 8 Feb 2009
by Tom Igoe
This example code is in the public domain.
*/
// These constants won't change. They're used to give names
// to the pins used:
const int lowestPin = 2;
const int highestPin = 13;
void setup() {
// set pins 2 through 13 as outputs:
for (int thisPin =lowestPin; thisPin <= highestPin; thisPin++) {
pinMode(thisPin, OUTPUT);
}
}
void loop() {
// iterate over the pins:
for (int thisPin =lowestPin; thisPin <= highestPin; thisPin++) {
// fade the LED on thisPin from off to brightest:
for (int brightness = 0; brightness < 255; brightness++) {
analogWrite(thisPin, brightness);
delay(2);
}
// fade the LED on thisPin from brithstest to off:
for (int brightness = 255; brightness >= 0; brightness--) {
analogWrite(thisPin, brightness);
delay(2);
}
// pause between LEDs:
delay(100);
}
}

View file

@ -0,0 +1,75 @@
/*
Calibration
Demonstrates one technique for calibrating sensor input. The
sensor readings during the first five seconds of the sketch
execution define the minimum and maximum of expected values
attached to the sensor pin.
The sensor minimum and maximum initial values may seem backwards.
Initially, you set the minimum high and listen for anything
lower, saving it as the new minimum. Likewise, you set the
maximum low and listen for anything higher as the new maximum.
The circuit:
* Analog sensor (potentiometer will do) attached to analog input 0
* LED attached from digital pin 9 to ground
created 29 Oct 2008
By David A Mellis
Modified 4 Sep 2010
By Tom Igoe
http://arduino.cc/en/Tutorial/Calibration
This example code is in the public domain.
*/
// These constants won't change:
const int sensorPin = A0; // pin that the sensor is attached to
const int ledPin = 9; // pin that the LED is attached to
// variables:
int sensorValue = 0; // the sensor value
int sensorMin = 1023; // minimum sensor value
int sensorMax = 0; // maximum sensor value
void setup() {
// turn on LED to signal the start of the calibration period:
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
// calibrate during the first five seconds
while (millis() < 5000) {
sensorValue = analogRead(sensorPin);
// record the maximum sensor value
if (sensorValue > sensorMax) {
sensorMax = sensorValue;
}
// record the minimum sensor value
if (sensorValue < sensorMin) {
sensorMin = sensorValue;
}
}
// signal the end of the calibration period
digitalWrite(13, LOW);
}
void loop() {
// read the sensor:
sensorValue = analogRead(sensorPin);
// apply the calibration to the sensor reading
sensorValue = map(sensorValue, sensorMin, sensorMax, 0, 255);
// in case the sensor value is outside the range seen during calibration
sensorValue = constrain(sensorValue, 0, 255);
// fade the LED using the calibrated value:
analogWrite(ledPin, sensorValue);
}

View file

@ -0,0 +1,45 @@
/*
Fading
This example shows how to fade an LED using the analogWrite() function.
The circuit:
* LED attached from digital pin 9 to ground.
Created 1 Nov 2008
By David A. Mellis
Modified 17 June 2009
By Tom Igoe
http://arduino.cc/en/Tutorial/Fading
This example code is in the public domain.
*/
int ledPin = 9; // LED connected to digital pin 9
void setup() {
// nothing happens in setup
}
void loop() {
// fade in from min to max in increments of 5 points:
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
// fade out from max to min in increments of 5 points:
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
}

View file

@ -0,0 +1,66 @@
/*
Smoothing
Reads repeatedly from an analog input, calculating a running average
and printing it to the computer. Keeps ten readings in an array and
continually averages them.
The circuit:
* Analog sensor (potentiometer will do) attached to analog input 0
Created 22 April 2007
By David A. Mellis <dam@mellis.org>
http://www.arduino.cc/en/Tutorial/Smoothing
This example code is in the public domain.
*/
// Define the number of samples to keep track of. The higher the number,
// the more the readings will be smoothed, but the slower the output will
// respond to the input. Using a constant rather than a normal variable lets
// use this value to determine the size of the readings array.
const int numReadings = 10;
int readings[numReadings]; // the readings from the analog input
int index = 0; // the index of the current reading
int total = 0; // the running total
int average = 0; // the average
int inputPin = A0;
void setup()
{
// initialize serial communication with computer:
Serial.begin(9600);
// initialize all the readings to 0:
for (int thisReading = 0; thisReading < numReadings; thisReading++)
readings[thisReading] = 0;
}
void loop() {
// subtract the last reading:
total= total - readings[index];
// read from the sensor:
readings[index] = analogRead(inputPin);
// add the reading to the total:
total= total + readings[index];
// advance to the next position in the array:
index = index + 1;
// if we're at the end of the array...
if (index >= numReadings)
// ...wrap around to the beginning:
index = 0;
// calculate the average:
average = total / numReadings;
// send it to the computer (as ASCII digits)
Serial.println(average, DEC);
}

View file

@ -0,0 +1,76 @@
/*
ASCII table
Prints out byte values in all possible formats:
* as raw binary values
* as ASCII-encoded decimal, hex, octal, and binary values
For more on ASCII, see http://www.asciitable.com and http://en.wikipedia.org/wiki/ASCII
The circuit: No external hardware needed.
created 2006
by Nicholas Zambetti
modified 18 Jan 2009
by Tom Igoe
This example code is in the public domain.
<http://www.zambetti.com>
*/
void setup()
{
Serial.begin(9600);
// prints title with ending line break
Serial.println("ASCII Table ~ Character Map");
}
// first visible ASCIIcharacter '!' is number 33:
int thisByte = 33;
// you can also write ASCII characters in single quotes.
// for example. '!' is the same as 33, so you could also use this:
//int thisByte = '!';
void loop()
{
// prints value unaltered, i.e. the raw binary version of the
// byte. The serial monitor interprets all bytes as
// ASCII, so 33, the first number, will show up as '!'
Serial.print(thisByte, BYTE);
Serial.print(", dec: ");
// prints value as string as an ASCII-encoded decimal (base 10).
// Decimal is the default format for Serial.print() and Serial.println(),
// so no modifier is needed:
Serial.print(thisByte);
// But you can declare the modifier for decimal if you want to.
//this also works if you uncomment it:
// Serial.print(thisByte, DEC);
Serial.print(", hex: ");
// prints value as string in hexadecimal (base 16):
Serial.print(thisByte, HEX);
Serial.print(", oct: ");
// prints value as string in octal (base 8);
Serial.print(thisByte, OCT);
Serial.print(", bin: ");
// prints value as string in binary (base 2)
// also prints ending line break:
Serial.println(thisByte, BIN);
// if printed last visible character '~' or 126, stop:
if(thisByte == 126) { // you could also use if (thisByte == '~') {
// This loop loops forever and does nothing
while(true) {
continue;
}
}
// go on to the next character
thisByte++;
}

View file

@ -0,0 +1,364 @@
/*
Dimmer
Demonstrates the sending data from the computer to the Arduino board,
in this case to control the brightness of an LED. The data is sent
in individual bytes, each of which ranges from 0 to 255. Arduino
reads these bytes and uses them to set the brightness of the LED.
The circuit:
LED attached from digital pin 9 to ground.
Serial connection to Processing, Max/MSP, or another serial application
created 2006
by David A. Mellis
modified 14 Apr 2009
by Tom Igoe and Scott Fitzgerald
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Dimmer
*/
const int ledPin = 9; // the pin that the LED is attached to
void setup()
{
// initialize the serial communication:
Serial.begin(9600);
// initialize the ledPin as an output:
pinMode(ledPin, OUTPUT);
}
void loop() {
byte brightness;
// check if data has been sent from the computer:
if (Serial.available()) {
// read the most recent byte (which will be from 0 to 255):
brightness = Serial.read();
// set the brightness of the LED:
analogWrite(ledPin, brightness);
}
}
/* Processing code for this example
// Dimmer - sends bytes over a serial port
// by David A. Mellis
//This example code is in the public domain.
import processing.serial.*;
Serial port;
void setup() {
size(256, 150);
println("Available serial ports:");
println(Serial.list());
// Uses the first port in this list (number 0). Change this to
// select the port corresponding to your Arduino board. The last
// parameter (e.g. 9600) is the speed of the communication. It
// has to correspond to the value passed to Serial.begin() in your
// Arduino sketch.
port = new Serial(this, Serial.list()[0], 9600);
// If you know the name of the port used by the Arduino board, you
// can specify it directly like this.
//port = new Serial(this, "COM1", 9600);
}
void draw() {
// draw a gradient from black to white
for (int i = 0; i < 256; i++) {
stroke(i);
line(i, 0, i, 150);
}
// write the current X-position of the mouse to the serial port as
// a single byte
port.write(mouseX);
}
*/
/* Max/MSP v5 patch for this example
{
"boxes" : [ {
"box" : {
"maxclass" : "comment",
"text" : "Dimmer\n\nThis patch sends a binary number from 0 to 255 out the serial port to an Arduino connected to the port. It dims an LED attached to the Arduino.\n\ncreated 2006\nby David A. Mellis\nmodified 14 Apr 2009\nby Scott Fitzgerald and Tom Igoe",
"linecount" : 10,
"patching_rect" : [ 209.0, 55.0, 344.0, 144.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-32",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "change the slider to alter the brightness of the LED",
"linecount" : 3,
"patching_rect" : [ 90.0, 235.0, 117.0, 48.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-7",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "number",
"patching_rect" : [ 215.0, 385.0, 50.0, 19.0 ],
"numoutlets" : 2,
"fontsize" : 10.0,
"outlettype" : [ "int", "bang" ],
"id" : "obj-6",
"fontname" : "Verdana",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "slider",
"patching_rect" : [ 215.0, 235.0, 20.0, 140.0 ],
"numoutlets" : 1,
"outlettype" : [ "" ],
"bgcolor" : [ 0.94902, 0.94902, 0.94902, 0.0 ],
"id" : "obj-1",
"size" : 256.0,
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "select 0 1",
"patching_rect" : [ 342.0, 305.0, 62.0, 20.0 ],
"numoutlets" : 3,
"fontsize" : 12.0,
"outlettype" : [ "bang", "bang", "" ],
"id" : "obj-30",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "click here to close the serial port",
"patching_rect" : [ 390.0, 396.0, 206.0, 20.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-26",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "click here to open the serial port",
"patching_rect" : [ 415.0, 370.0, 206.0, 20.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-27",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "close",
"patching_rect" : [ 342.0, 396.0, 39.0, 18.0 ],
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "" ],
"id" : "obj-21",
"fontname" : "Arial",
"numinlets" : 2
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "port a",
"patching_rect" : [ 364.0, 370.0, 41.0, 18.0 ],
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "" ],
"id" : "obj-19",
"fontname" : "Arial",
"numinlets" : 2
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "Click here to get a list of serial ports",
"patching_rect" : [ 435.0, 344.0, 207.0, 20.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-2",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "toggle",
"patching_rect" : [ 342.0, 268.0, 15.0, 15.0 ],
"numoutlets" : 1,
"outlettype" : [ "int" ],
"id" : "obj-11",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "print",
"patching_rect" : [ 384.0, 344.0, 36.0, 18.0 ],
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "" ],
"id" : "obj-13",
"fontname" : "Arial",
"numinlets" : 2
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "serial a 9600",
"patching_rect" : [ 259.0, 420.0, 84.0, 20.0 ],
"numoutlets" : 2,
"fontsize" : 12.0,
"outlettype" : [ "int", "" ],
"id" : "obj-14",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "Click to start",
"patching_rect" : [ 369.0, 268.0, 117.0, 20.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-17",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "panel",
"patching_rect" : [ 215.0, 235.0, 21.0, 139.0 ],
"numoutlets" : 0,
"mode" : 1,
"grad1" : [ 1.0, 1.0, 1.0, 1.0 ],
"id" : "obj-8",
"grad2" : [ 0.509804, 0.509804, 0.509804, 1.0 ],
"numinlets" : 1,
"angle" : 270.0
}
}
],
"lines" : [ {
"patchline" : {
"source" : [ "obj-11", 0 ],
"destination" : [ "obj-30", 0 ],
"hidden" : 0,
"midpoints" : [ 351.0, 296.0, 351.5, 296.0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-30", 1 ],
"destination" : [ "obj-19", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-30", 0 ],
"destination" : [ "obj-21", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-21", 0 ],
"destination" : [ "obj-14", 0 ],
"hidden" : 0,
"midpoints" : [ 351.5, 416.5, 268.5, 416.5 ]
}
}
, {
"patchline" : {
"source" : [ "obj-19", 0 ],
"destination" : [ "obj-14", 0 ],
"hidden" : 0,
"midpoints" : [ 373.5, 393.5, 268.5, 393.5 ]
}
}
, {
"patchline" : {
"source" : [ "obj-13", 0 ],
"destination" : [ "obj-14", 0 ],
"hidden" : 0,
"midpoints" : [ 393.5, 365.5, 268.5, 365.5 ]
}
}
, {
"patchline" : {
"source" : [ "obj-1", 0 ],
"destination" : [ "obj-6", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-6", 0 ],
"destination" : [ "obj-14", 0 ],
"hidden" : 0,
"midpoints" : [ 224.5, 411.5, 268.5, 411.5 ]
}
}
]
}
*/

View file

@ -0,0 +1,579 @@
/*
Graph
A simple example of communication from the Arduino board to the computer:
the value of analog input 0 is sent out the serial port. We call this "serial"
communication because the connection appears to both the Arduino and the
computer as a serial port, even though it may actually use
a USB cable. Bytes are sent one after another (serially) from the Arduino
to the computer.
You can use the Arduino serial monitor to view the sent data, or it can
be read by Processing, PD, Max/MSP, or any other program capable of reading
data from a serial port. The Processing code below graphs the data received
so you can see the value of the analog input changing over time.
The circuit:
Any analog input sensor is attached to analog in pin 0.
created 2006
by David A. Mellis
modified 14 Apr 2009
by Tom Igoe and Scott Fitzgerald
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Graph
*/
void setup() {
// initialize the serial communication:
Serial.begin(9600);
}
void loop() {
// send the value of analog input 0:
Serial.println(analogRead(A0));
// wait a bit for the analog-to-digital converter
// to stabilize after the last reading:
delay(10);
}
/* Processing code for this example
// Graphing sketch
// This program takes ASCII-encoded strings
// from the serial port at 9600 baud and graphs them. It expects values in the
// range 0 to 1023, followed by a newline, or newline and carriage return
// Created 20 Apr 2005
// Updated 18 Jan 2008
// by Tom Igoe
// This example code is in the public domain.
import processing.serial.*;
Serial myPort; // The serial port
int xPos = 1; // horizontal position of the graph
void setup () {
// set the window size:
size(400, 300);
// List all the available serial ports
println(Serial.list());
// I know that the first port in the serial list on my mac
// is always my Arduino, so I open Serial.list()[0].
// Open whatever port is the one you're using.
myPort = new Serial(this, Serial.list()[0], 9600);
// don't generate a serialEvent() unless you get a newline character:
myPort.bufferUntil('\n');
// set inital background:
background(0);
}
void draw () {
// everything happens in the serialEvent()
}
void serialEvent (Serial myPort) {
// get the ASCII string:
String inString = myPort.readStringUntil('\n');
if (inString != null) {
// trim off any whitespace:
inString = trim(inString);
// convert to an int and map to the screen height:
float inByte = float(inString);
inByte = map(inByte, 0, 1023, 0, height);
// draw the line:
stroke(127,34,255);
line(xPos, height, xPos, height - inByte);
// at the edge of the screen, go back to the beginning:
if (xPos >= width) {
xPos = 0;
background(0);
}
else {
// increment the horizontal position:
xPos++;
}
}
}
*/
/* Max/MSP v5 patch for this example
{
"boxes" : [ {
"box" : {
"maxclass" : "comment",
"text" : "Graph\n\nThis patch takes a string, containing ASCII formatted number from 0 to 1023, with a carriage return and linefeed at the end. It converts the string to an integer and graphs it.\n\ncreated 2006\nby David A. Mellis\nmodified 14 Apr 2009\nby Scott Fitzgerald and Tom Igoe",
"linecount" : 10,
"patching_rect" : [ 479.0, 6.0, 344.0, 144.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-32",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "select 0 1",
"patching_rect" : [ 327.0, 80.0, 62.0, 20.0 ],
"numoutlets" : 3,
"fontsize" : 12.0,
"outlettype" : [ "bang", "bang", "" ],
"id" : "obj-30",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "click here to close the serial port",
"patching_rect" : [ 412.0, 231.0, 206.0, 20.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-26",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "click here to open the serial port",
"patching_rect" : [ 412.0, 205.0, 206.0, 20.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-27",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "close",
"patching_rect" : [ 327.0, 231.0, 39.0, 18.0 ],
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "" ],
"id" : "obj-21",
"fontname" : "Arial",
"numinlets" : 2
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "port a",
"patching_rect" : [ 349.0, 205.0, 41.0, 18.0 ],
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "" ],
"id" : "obj-19",
"fontname" : "Arial",
"numinlets" : 2
}
}
, {
"box" : {
"maxclass" : "multislider",
"candicane7" : [ 0.878431, 0.243137, 0.145098, 1.0 ],
"patching_rect" : [ 302.0, 450.0, 246.0, 167.0 ],
"contdata" : 1,
"numoutlets" : 2,
"peakcolor" : [ 0.498039, 0.498039, 0.498039, 1.0 ],
"slidercolor" : [ 0.066667, 0.058824, 0.776471, 1.0 ],
"candicane8" : [ 0.027451, 0.447059, 0.501961, 1.0 ],
"outlettype" : [ "", "" ],
"setminmax" : [ 0.0, 1023.0 ],
"settype" : 0,
"candicane6" : [ 0.733333, 0.035294, 0.788235, 1.0 ],
"setstyle" : 3,
"bgcolor" : [ 0.231373, 0.713726, 1.0, 1.0 ],
"id" : "obj-1",
"candicane4" : [ 0.439216, 0.619608, 0.070588, 1.0 ],
"candicane5" : [ 0.584314, 0.827451, 0.431373, 1.0 ],
"candicane2" : [ 0.145098, 0.203922, 0.356863, 1.0 ],
"candicane3" : [ 0.290196, 0.411765, 0.713726, 1.0 ],
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "Click here to get a list of serial ports",
"patching_rect" : [ 412.0, 179.0, 207.0, 20.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-2",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "Here's the number from Arduino's analog input",
"linecount" : 2,
"patching_rect" : [ 153.0, 409.0, 138.0, 34.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-3",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "Convert ASCII to symbol",
"patching_rect" : [ 379.0, 378.0, 147.0, 20.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-4",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "Convert integer to ASCII",
"patching_rect" : [ 379.0, 355.0, 147.0, 20.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-5",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "number",
"patching_rect" : [ 302.0, 414.0, 37.0, 20.0 ],
"numoutlets" : 2,
"fontsize" : 12.0,
"outlettype" : [ "int", "bang" ],
"bgcolor" : [ 0.866667, 0.866667, 0.866667, 1.0 ],
"id" : "obj-6",
"triscale" : 0.9,
"fontname" : "Arial",
"htextcolor" : [ 0.870588, 0.870588, 0.870588, 1.0 ],
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "fromsymbol",
"patching_rect" : [ 302.0, 378.0, 74.0, 20.0 ],
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "" ],
"id" : "obj-7",
"fontname" : "Arial",
"color" : [ 1.0, 0.890196, 0.090196, 1.0 ],
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "itoa",
"patching_rect" : [ 302.0, 355.0, 46.0, 20.0 ],
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "int" ],
"id" : "obj-8",
"fontname" : "Arial",
"color" : [ 1.0, 0.890196, 0.090196, 1.0 ],
"numinlets" : 3
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "zl group 4",
"patching_rect" : [ 302.0, 332.0, 64.0, 20.0 ],
"numoutlets" : 2,
"fontsize" : 12.0,
"outlettype" : [ "", "" ],
"id" : "obj-9",
"fontname" : "Arial",
"numinlets" : 2
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "select 10 13",
"patching_rect" : [ 244.0, 281.0, 77.0, 20.0 ],
"numoutlets" : 3,
"fontsize" : 12.0,
"outlettype" : [ "bang", "bang", "" ],
"id" : "obj-10",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "toggle",
"patching_rect" : [ 244.0, 43.0, 15.0, 15.0 ],
"numoutlets" : 1,
"outlettype" : [ "int" ],
"id" : "obj-11",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "qmetro 10",
"patching_rect" : [ 244.0, 80.0, 65.0, 20.0 ],
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "bang" ],
"id" : "obj-12",
"fontname" : "Arial",
"numinlets" : 2
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "print",
"patching_rect" : [ 369.0, 179.0, 36.0, 18.0 ],
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "" ],
"id" : "obj-13",
"fontname" : "Arial",
"numinlets" : 2
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "serial a 9600",
"patching_rect" : [ 244.0, 255.0, 84.0, 20.0 ],
"numoutlets" : 2,
"fontsize" : 12.0,
"outlettype" : [ "int", "" ],
"id" : "obj-14",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "Read serial input buffer every 10 milliseconds",
"linecount" : 2,
"patching_rect" : [ 53.0, 72.0, 185.0, 34.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-15",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "If you get newline (ASCII 10), send the list. If you get return (ASCII 13) do nothing. Any other value, add to the list",
"linecount" : 3,
"patching_rect" : [ 332.0, 269.0, 320.0, 48.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-16",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "Click to open/close serial port and start/stop patch",
"linecount" : 2,
"patching_rect" : [ 271.0, 32.0, 199.0, 34.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-17",
"fontname" : "Arial",
"numinlets" : 1
}
}
],
"lines" : [ {
"patchline" : {
"source" : [ "obj-6", 0 ],
"destination" : [ "obj-1", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-7", 0 ],
"destination" : [ "obj-6", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-8", 0 ],
"destination" : [ "obj-7", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-9", 0 ],
"destination" : [ "obj-8", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-10", 0 ],
"destination" : [ "obj-9", 0 ],
"hidden" : 0,
"midpoints" : [ 253.5, 308.0, 311.5, 308.0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-10", 2 ],
"destination" : [ "obj-9", 0 ],
"hidden" : 0,
"midpoints" : [ 311.5, 320.0, 311.5, 320.0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-14", 0 ],
"destination" : [ "obj-10", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-12", 0 ],
"destination" : [ "obj-14", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-11", 0 ],
"destination" : [ "obj-12", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-13", 0 ],
"destination" : [ "obj-14", 0 ],
"hidden" : 0,
"midpoints" : [ 378.5, 200.5, 253.5, 200.5 ]
}
}
, {
"patchline" : {
"source" : [ "obj-19", 0 ],
"destination" : [ "obj-14", 0 ],
"hidden" : 0,
"midpoints" : [ 358.5, 228.5, 253.5, 228.5 ]
}
}
, {
"patchline" : {
"source" : [ "obj-21", 0 ],
"destination" : [ "obj-14", 0 ],
"hidden" : 0,
"midpoints" : [ 336.5, 251.5, 253.5, 251.5 ]
}
}
, {
"patchline" : {
"source" : [ "obj-30", 0 ],
"destination" : [ "obj-21", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-30", 1 ],
"destination" : [ "obj-19", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-11", 0 ],
"destination" : [ "obj-30", 0 ],
"hidden" : 0,
"midpoints" : [ 253.0, 71.0, 336.5, 71.0 ]
}
}
]
}
*/

View file

@ -0,0 +1,49 @@
/*
MIDI note player
This sketch shows how to use the serial transmit pin (pin 1) to send MIDI note data.
If this circuit is connected to a MIDI synth, it will play
the notes F#-0 (0x1E) to F#-5 (0x5A) in sequence.
The circuit:
* digital in 1 connected to MIDI jack pin 5
* MIDI jack pin 2 connected to ground
* MIDI jack pin 4 connected to +5V through 220-ohm resistor
Attach a MIDI cable to the jack, then to a MIDI synth, and play music.
created 13 Jun 2006
modified 2 Jul 2009
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/MIDI
*/
void setup() {
// Set MIDI baud rate:
Serial.begin(31250);
}
void loop() {
// play notes from F#-0 (0x1E) to F#-5 (0x5A):
for (intnote = 0x1E; note < 0x5A; note ++) {
//Note on channel 1 (0x90), some note value (note), middle velocity (0x45):
noteOn(0x90, note, 0x45);
delay(100);
//Note on channel 1 (0x90), some note value (note), silent velocity (0x00):
noteOn(0x90, note, 0x00);
delay(100);
}
}
// plays a MIDI note. Doesn't check to see that
// cmd is greater than 127, or that data values are less than 127:
void noteOn(int cmd, int pitch, int velocity) {
Serial.print(cmd, BYTE);
Serial.print(pitch, BYTE);
Serial.print(velocity, BYTE);
}

View file

@ -0,0 +1,33 @@
/*
Mega multple serial test
Receives from the main serial port, sends to the others.
Receives from serial port 1, sends to the main serial (Serial 0).
This example works only on the Arduino Mega
The circuit:
* Any serial device attached to Serial port 1
* Serial monitor open on Serial port 0:
created 30 Dec. 2008
by Tom Igoe
This example code is in the public domain.
*/
void setup() {
// initialize both serial ports:
Serial.begin(9600);
Serial1.begin(9600);
}
void loop() {
// read from port 1, send to port 0:
if (Serial1.available()) {
int inByte = Serial1.read();
Serial.print(inByte, BYTE);
}
}

View file

@ -0,0 +1,711 @@
/*
Physical Pixel
An example of using the Arduino board to receive data from the
computer. In this case, the Arduino boards turns on an LED when
it receives the character 'H', and turns off the LED when it
receives the character 'L'.
The data can be sent from the Arduino serial monitor, or another
program like Processing (see code below), Flash (via a serial-net
proxy), PD, or Max/MSP.
The circuit:
* LED connected from digital pin 13 to ground
created 2006
by David A. Mellis
modified 14 Apr 2009
by Tom Igoe and Scott Fitzgerald
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/PhysicalPixel
*/
const int ledPin = 13; // the pin that the LED is attached to
int incomingByte; // a variable to read incoming serial data into
void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
}
void loop() {
// see if there's incoming serial data:
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
incomingByte = Serial.read();
// if it's a capital H (ASCII 72), turn on the LED:
if (incomingByte == 'H') {
digitalWrite(ledPin, HIGH);
}
// if it's an L (ASCII 76) turn off the LED:
if (incomingByte == 'L') {
digitalWrite(ledPin, LOW);
}
}
}
/* Processing code for this example
// mouseover serial
// Demonstrates how to send data to the Arduino I/O board, in order to
// turn ON a light if the mouse is over a square and turn it off
// if the mouse is not.
// created 2003-4
// based on examples by Casey Reas and Hernando Barragan
// modified 18 Jan 2009
// by Tom Igoe
// This example code is in the public domain.
import processing.serial.*;
float boxX;
float boxY;
int boxSize = 20;
boolean mouseOverBox = false;
Serial port;
void setup() {
size(200, 200);
boxX = width/2.0;
boxY = height/2.0;
rectMode(RADIUS);
// List all the available serial ports in the output pane.
// You will need to choose the port that the Arduino board is
// connected to from this list. The first port in the list is
// port #0 and the third port in the list is port #2.
println(Serial.list());
// Open the port that the Arduino board is connected to (in this case #0)
// Make sure to open the port at the same speed Arduino is using (9600bps)
port = new Serial(this, Serial.list()[0], 9600);
}
void draw()
{
background(0);
// Test if the cursor is over the box
if (mouseX > boxX-boxSize && mouseX < boxX+boxSize &&
mouseY > boxY-boxSize && mouseY < boxY+boxSize) {
mouseOverBox = true;
// draw a line around the box and change its color:
stroke(255);
fill(153);
// send an 'H' to indicate mouse is over square:
port.write('H');
}
else {
// return the box to it's inactive state:
stroke(153);
fill(153);
// send an 'L' to turn the LED off:
port.write('L');
mouseOverBox = false;
}
// Draw the box
rect(boxX, boxY, boxSize, boxSize);
}
*/
/*
{
"boxes" : [ {
"box" : {
"maxclass" : "comment",
"text" : "Physical Pixel\n\nThis patch sends an ASCII H or an ASCII L out the serial port to turn on an LED attached to an Arduino board. It can also send alternating H and L characters once every second to make the LED blink.\n\ncreated 2006\nby David A. Mellis\nmodified 14 Apr 2009\nby Scott Fitzgerald and Tom Igoe",
"linecount" : 11,
"patching_rect" : [ 14.0, 35.0, 354.0, 158.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-1",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "Click to blink every second",
"patching_rect" : [ 99.0, 251.0, 161.0, 20.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-38",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "toggle",
"patching_rect" : [ 74.0, 251.0, 21.0, 21.0 ],
"numoutlets" : 1,
"outlettype" : [ "int" ],
"id" : "obj-39",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "p blink",
"patching_rect" : [ 74.0, 286.0, 45.0, 20.0 ],
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "int" ],
"id" : "obj-37",
"fontname" : "Arial",
"numinlets" : 2,
"patcher" : {
"fileversion" : 1,
"rect" : [ 54.0, 94.0, 640.0, 480.0 ],
"bglocked" : 0,
"defrect" : [ 54.0, 94.0, 640.0, 480.0 ],
"openrect" : [ 0.0, 0.0, 0.0, 0.0 ],
"openinpresentation" : 0,
"default_fontsize" : 10.0,
"default_fontface" : 0,
"default_fontname" : "Verdana",
"gridonopen" : 0,
"gridsize" : [ 25.0, 25.0 ],
"gridsnaponopen" : 0,
"toolbarvisible" : 1,
"boxanimatetime" : 200,
"imprint" : 0,
"boxes" : [ {
"box" : {
"maxclass" : "newobj",
"text" : "* 1000",
"patching_rect" : [ 200.0, 150.0, 46.0, 19.0 ],
"numoutlets" : 1,
"fontsize" : 10.0,
"outlettype" : [ "int" ],
"id" : "obj-12",
"fontname" : "Verdana",
"numinlets" : 2
}
}
, {
"box" : {
"maxclass" : "inlet",
"patching_rect" : [ 200.0, 75.0, 25.0, 25.0 ],
"numoutlets" : 1,
"outlettype" : [ "" ],
"id" : "obj-11",
"numinlets" : 0,
"comment" : ""
}
}
, {
"box" : {
"maxclass" : "toggle",
"patching_rect" : [ 125.0, 250.0, 20.0, 20.0 ],
"numoutlets" : 1,
"outlettype" : [ "int" ],
"id" : "obj-10",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "metro 1000",
"patching_rect" : [ 115.0, 190.0, 69.0, 19.0 ],
"numoutlets" : 1,
"fontsize" : 10.0,
"outlettype" : [ "bang" ],
"id" : "obj-3",
"fontname" : "Verdana",
"numinlets" : 2
}
}
, {
"box" : {
"maxclass" : "outlet",
"patching_rect" : [ 125.0, 400.0, 25.0, 25.0 ],
"numoutlets" : 0,
"id" : "obj-2",
"numinlets" : 1,
"comment" : ""
}
}
, {
"box" : {
"maxclass" : "inlet",
"patching_rect" : [ 100.0, 25.0, 25.0, 25.0 ],
"numoutlets" : 1,
"outlettype" : [ "int" ],
"id" : "obj-1",
"numinlets" : 0,
"comment" : ""
}
}
],
"lines" : [ {
"patchline" : {
"source" : [ "obj-12", 0 ],
"destination" : [ "obj-3", 1 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-11", 0 ],
"destination" : [ "obj-12", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-1", 0 ],
"destination" : [ "obj-3", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-10", 0 ],
"destination" : [ "obj-2", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-3", 0 ],
"destination" : [ "obj-10", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
]
}
,
"saved_object_attributes" : {
"fontface" : 0,
"fontsize" : 10.0,
"default_fontface" : 0,
"default_fontname" : "Verdana",
"default_fontsize" : 10.0,
"fontname" : "Verdana",
"globalpatchername" : ""
}
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "convert to int",
"patching_rect" : [ 154.0, 386.0, 104.0, 20.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-36",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "send L if 0, H if 1",
"patching_rect" : [ 154.0, 361.0, 104.0, 20.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-35",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "is it on or off?",
"patching_rect" : [ 179.0, 336.0, 95.0, 20.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-34",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "atoi",
"patching_rect" : [ 279.0, 386.0, 46.0, 20.0 ],
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "list" ],
"id" : "obj-33",
"fontname" : "Arial",
"numinlets" : 3
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "H",
"patching_rect" : [ 329.0, 361.0, 32.5, 17.0 ],
"numoutlets" : 1,
"fontsize" : 10.0,
"outlettype" : [ "" ],
"id" : "obj-32",
"fontname" : "Verdana",
"numinlets" : 2
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "L",
"patching_rect" : [ 279.0, 361.0, 32.5, 17.0 ],
"numoutlets" : 1,
"fontsize" : 10.0,
"outlettype" : [ "" ],
"id" : "obj-31",
"fontname" : "Verdana",
"numinlets" : 2
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "select 0 1",
"patching_rect" : [ 279.0, 336.0, 62.0, 20.0 ],
"numoutlets" : 3,
"fontsize" : 12.0,
"outlettype" : [ "bang", "bang", "" ],
"id" : "obj-25",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "Click to turn the LED on and off",
"linecount" : 2,
"patching_rect" : [ 130.0, 205.0, 143.0, 34.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-24",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "toggle",
"patching_rect" : [ 279.0, 211.0, 24.0, 24.0 ],
"numoutlets" : 1,
"outlettype" : [ "int" ],
"id" : "obj-23",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "select 0 1",
"patching_rect" : [ 381.0, 331.0, 62.0, 20.0 ],
"numoutlets" : 3,
"fontsize" : 12.0,
"outlettype" : [ "bang", "bang", "" ],
"id" : "obj-30",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "click here to close the serial port",
"patching_rect" : [ 429.0, 422.0, 206.0, 20.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-26",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "click here to open the serial port",
"patching_rect" : [ 454.0, 396.0, 206.0, 20.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-27",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "close",
"patching_rect" : [ 381.0, 422.0, 39.0, 18.0 ],
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "" ],
"id" : "obj-21",
"fontname" : "Arial",
"numinlets" : 2
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "port a",
"patching_rect" : [ 403.0, 396.0, 41.0, 18.0 ],
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "" ],
"id" : "obj-19",
"fontname" : "Arial",
"numinlets" : 2
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "Click here to get a list of serial ports",
"patching_rect" : [ 474.0, 370.0, 207.0, 20.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-2",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "toggle",
"patching_rect" : [ 381.0, 181.0, 21.0, 21.0 ],
"numoutlets" : 1,
"outlettype" : [ "int" ],
"id" : "obj-11",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "print",
"patching_rect" : [ 423.0, 370.0, 36.0, 18.0 ],
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "" ],
"id" : "obj-13",
"fontname" : "Arial",
"numinlets" : 2
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "serial a 9600",
"patching_rect" : [ 279.0, 461.0, 84.0, 20.0 ],
"numoutlets" : 2,
"fontsize" : 12.0,
"outlettype" : [ "int", "" ],
"id" : "obj-14",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "Click to start",
"patching_rect" : [ 408.0, 181.0, 117.0, 20.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-17",
"fontname" : "Arial",
"numinlets" : 1
}
}
],
"lines" : [ {
"patchline" : {
"source" : [ "obj-39", 0 ],
"destination" : [ "obj-37", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-37", 0 ],
"destination" : [ "obj-25", 0 ],
"hidden" : 0,
"midpoints" : [ 83.5, 320.5, 288.5, 320.5 ]
}
}
, {
"patchline" : {
"source" : [ "obj-33", 0 ],
"destination" : [ "obj-14", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-32", 0 ],
"destination" : [ "obj-33", 0 ],
"hidden" : 0,
"midpoints" : [ 338.5, 381.5, 288.5, 381.5 ]
}
}
, {
"patchline" : {
"source" : [ "obj-31", 0 ],
"destination" : [ "obj-33", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-25", 0 ],
"destination" : [ "obj-31", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-25", 1 ],
"destination" : [ "obj-32", 0 ],
"hidden" : 0,
"midpoints" : [ 310.0, 358.0, 338.5, 358.0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-23", 0 ],
"destination" : [ "obj-25", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-13", 0 ],
"destination" : [ "obj-14", 0 ],
"hidden" : 0,
"midpoints" : [ 432.5, 389.0, 367.0, 389.0, 367.0, 411.0, 288.5, 411.0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-19", 0 ],
"destination" : [ "obj-14", 0 ],
"hidden" : 0,
"midpoints" : [ 412.5, 417.0, 288.5, 417.0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-21", 0 ],
"destination" : [ "obj-14", 0 ],
"hidden" : 0,
"midpoints" : [ 390.5, 450.0, 288.5, 450.0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-30", 0 ],
"destination" : [ "obj-21", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-30", 1 ],
"destination" : [ "obj-19", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-11", 0 ],
"destination" : [ "obj-30", 0 ],
"hidden" : 0,
"midpoints" : [ 390.5, 322.0, 390.5, 322.0 ]
}
}
]
}
*/

View file

@ -0,0 +1,699 @@
/*
This example reads three analog sensors (potentiometers are easiest)
and sends their values serially. The Processing and Max/MSP programs at the bottom
take those three values and use them to change the background color of the screen.
The circuit:
* potentiometers attached to analog inputs 0, 1, and 2
http://www.arduino.cc/en/Tutorial/VirtualColorMixer
created 2 Dec 2006
by David A. Mellis
modified 4 Sep 2010
by Tom Igoe and Scott Fitzgerald
This example code is in the public domain.
*/
const int redPin = A0; // sensor to control red color
const int greenPin = A1; // sensor to control green color
const int bluePin = A2; // sensor to control blue color
void setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.print(analogRead(redPin));
Serial.print(",");
Serial.print(analogRead(greenPin));
Serial.print(",");
Serial.println(analogRead(bluePin));
}
/* Processing code for this example
// This example code is in the public domain.
import processing.serial.*;
float redValue = 0; // red value
float greenValue = 0; // green value
float blueValue = 0; // blue value
Serial myPort;
void setup() {
size(200, 200);
// List all the available serial ports
println(Serial.list());
// I know that the first port in the serial list on my mac
// is always my Arduino, so I open Serial.list()[0].
// Open whatever port is the one you're using.
myPort = new Serial(this, Serial.list()[0], 9600);
// don't generate a serialEvent() unless you get a newline character:
myPort.bufferUntil('\n');
}
void draw() {
// set the background color with the color values:
background(redValue, greenValue, blueValue);
}
void serialEvent(Serial myPort) {
// get the ASCII string:
String inString = myPort.readStringUntil('\n');
if (inString != null) {
// trim off any whitespace:
inString = trim(inString);
// split the string on the commas and convert the
// resulting substrings into an integer array:
float[] colors = float(split(inString, ","));
// if the array has at least three elements, you know
// you got the whole thing. Put the numbers in the
// color variables:
if (colors.length >=3) {
// map them to the range 0-255:
redValue = map(colors[0], 0, 1023, 0, 255);
greenValue = map(colors[1], 0, 1023, 0, 255);
blueValue = map(colors[2], 0, 1023, 0, 255);
}
}
}
*/
/* Max/MSP patch for this example
{
"boxes" : [ {
"box" : {
"maxclass" : "newobj",
"text" : "/ 4",
"patching_rect" : [ 448.0, 502.0, 32.5, 20.0 ],
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "int" ],
"id" : "obj-25",
"fontname" : "Arial",
"numinlets" : 2
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "/ 4",
"patching_rect" : [ 398.0, 502.0, 32.5, 20.0 ],
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "int" ],
"id" : "obj-24",
"fontname" : "Arial",
"numinlets" : 2
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "/ 4",
"patching_rect" : [ 348.0, 502.0, 32.5, 20.0 ],
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "int" ],
"id" : "obj-23",
"fontname" : "Arial",
"numinlets" : 2
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "Virtual color mixer\n\nThis patch takes a string, containing three comma-separated ASCII formatted numbers from 0 to 1023, with a carriage return and linefeed at the end. It converts the string to three integers and uses them to set the background color.\n\n created 2 Dec 2006\n by David A. Mellis\nmodified 14 Apr 2009\nby Scott Fitzgerald and Tom Igoe",
"linecount" : 11,
"patching_rect" : [ 524.0, 51.0, 398.0, 158.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-32",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "select 0 1",
"patching_rect" : [ 372.0, 125.0, 62.0, 20.0 ],
"numoutlets" : 3,
"fontsize" : 12.0,
"outlettype" : [ "bang", "bang", "" ],
"id" : "obj-30",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "click here to close the serial port",
"patching_rect" : [ 457.0, 276.0, 206.0, 20.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-26",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "click here to open the serial port",
"patching_rect" : [ 457.0, 250.0, 206.0, 20.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-27",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "close",
"patching_rect" : [ 372.0, 276.0, 39.0, 18.0 ],
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "" ],
"id" : "obj-21",
"fontname" : "Arial",
"numinlets" : 2
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "port a",
"patching_rect" : [ 394.0, 250.0, 41.0, 18.0 ],
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "" ],
"id" : "obj-19",
"fontname" : "Arial",
"numinlets" : 2
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "Click here to get a list of serial ports",
"patching_rect" : [ 457.0, 224.0, 207.0, 20.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-2",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "Convert ASCII to symbol",
"patching_rect" : [ 424.0, 423.0, 147.0, 20.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-4",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "Convert integer to ASCII",
"patching_rect" : [ 424.0, 400.0, 147.0, 20.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-5",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "fromsymbol",
"patching_rect" : [ 347.0, 423.0, 74.0, 20.0 ],
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "" ],
"id" : "obj-7",
"fontname" : "Arial",
"color" : [ 1.0, 0.890196, 0.090196, 1.0 ],
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "itoa",
"patching_rect" : [ 347.0, 400.0, 46.0, 20.0 ],
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "int" ],
"id" : "obj-8",
"fontname" : "Arial",
"color" : [ 1.0, 0.890196, 0.090196, 1.0 ],
"numinlets" : 3
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "zl group",
"patching_rect" : [ 347.0, 377.0, 53.0, 20.0 ],
"numoutlets" : 2,
"fontsize" : 12.0,
"outlettype" : [ "", "" ],
"id" : "obj-9",
"fontname" : "Arial",
"numinlets" : 2
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "select 10 13",
"patching_rect" : [ 289.0, 326.0, 77.0, 20.0 ],
"numoutlets" : 3,
"fontsize" : 12.0,
"outlettype" : [ "bang", "bang", "" ],
"id" : "obj-10",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "toggle",
"patching_rect" : [ 289.0, 88.0, 15.0, 15.0 ],
"numoutlets" : 1,
"outlettype" : [ "int" ],
"id" : "obj-11",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "qmetro 10",
"patching_rect" : [ 289.0, 125.0, 65.0, 20.0 ],
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "bang" ],
"id" : "obj-12",
"fontname" : "Arial",
"numinlets" : 2
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "print",
"patching_rect" : [ 414.0, 224.0, 36.0, 18.0 ],
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "" ],
"id" : "obj-13",
"fontname" : "Arial",
"numinlets" : 2
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "serial a 9600",
"patching_rect" : [ 289.0, 300.0, 84.0, 20.0 ],
"numoutlets" : 2,
"fontsize" : 12.0,
"outlettype" : [ "int", "" ],
"id" : "obj-14",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "Read serial input buffer every 10 milliseconds",
"linecount" : 2,
"patching_rect" : [ 98.0, 117.0, 185.0, 34.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-15",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "If you get newline (ASCII 10), send the list. If you get return (ASCII 13) do nothing. Any other value, add to the list",
"linecount" : 3,
"patching_rect" : [ 377.0, 314.0, 320.0, 48.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-16",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "Click to open/close serial port and start/stop patch",
"linecount" : 2,
"patching_rect" : [ 316.0, 77.0, 199.0, 34.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-17",
"fontname" : "Arial",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "bgcolor 0 0 0",
"patching_rect" : [ 348.0, 585.0, 169.0, 19.0 ],
"numoutlets" : 0,
"fontsize" : 10.0,
"id" : "obj-6",
"fontname" : "Verdana",
"numinlets" : 4
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "unpack 0 0 0 0 0",
"patching_rect" : [ 347.0, 470.0, 119.0, 19.0 ],
"numoutlets" : 5,
"fontsize" : 10.0,
"outlettype" : [ "int", "int", "int", "int", "int" ],
"id" : "obj-20",
"fontname" : "Verdana",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "number",
"patching_rect" : [ 448.0, 535.0, 50.0, 19.0 ],
"numoutlets" : 2,
"fontsize" : 10.0,
"outlettype" : [ "int", "bang" ],
"id" : "obj-18",
"fontname" : "Verdana",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "number",
"patching_rect" : [ 398.0, 535.0, 50.0, 19.0 ],
"numoutlets" : 2,
"fontsize" : 10.0,
"outlettype" : [ "int", "bang" ],
"id" : "obj-1",
"fontname" : "Verdana",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "number",
"patching_rect" : [ 348.0, 535.0, 50.0, 19.0 ],
"numoutlets" : 2,
"fontsize" : 10.0,
"outlettype" : [ "int", "bang" ],
"id" : "obj-22",
"fontname" : "Verdana",
"numinlets" : 1
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "Here's the numbers from Arduino's analog input",
"linecount" : 3,
"patching_rect" : [ 198.0, 484.0, 138.0, 48.0 ],
"numoutlets" : 0,
"fontsize" : 12.0,
"id" : "obj-3",
"fontname" : "Arial",
"numinlets" : 1
}
}
],
"lines" : [ {
"patchline" : {
"source" : [ "obj-18", 0 ],
"destination" : [ "obj-6", 2 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-1", 0 ],
"destination" : [ "obj-6", 1 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-22", 0 ],
"destination" : [ "obj-6", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-25", 0 ],
"destination" : [ "obj-18", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-20", 4 ],
"destination" : [ "obj-25", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-20", 2 ],
"destination" : [ "obj-24", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-24", 0 ],
"destination" : [ "obj-1", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-23", 0 ],
"destination" : [ "obj-22", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-20", 0 ],
"destination" : [ "obj-23", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-8", 0 ],
"destination" : [ "obj-7", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-14", 0 ],
"destination" : [ "obj-10", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-12", 0 ],
"destination" : [ "obj-14", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-11", 0 ],
"destination" : [ "obj-12", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-13", 0 ],
"destination" : [ "obj-14", 0 ],
"hidden" : 0,
"midpoints" : [ 423.5, 245.5, 298.5, 245.5 ]
}
}
, {
"patchline" : {
"source" : [ "obj-19", 0 ],
"destination" : [ "obj-14", 0 ],
"hidden" : 0,
"midpoints" : [ 403.5, 273.5, 298.5, 273.5 ]
}
}
, {
"patchline" : {
"source" : [ "obj-21", 0 ],
"destination" : [ "obj-14", 0 ],
"hidden" : 0,
"midpoints" : [ 381.5, 296.5, 298.5, 296.5 ]
}
}
, {
"patchline" : {
"source" : [ "obj-30", 0 ],
"destination" : [ "obj-21", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-30", 1 ],
"destination" : [ "obj-19", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-11", 0 ],
"destination" : [ "obj-30", 0 ],
"hidden" : 0,
"midpoints" : [ 298.0, 116.0, 381.5, 116.0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-7", 0 ],
"destination" : [ "obj-20", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-9", 0 ],
"destination" : [ "obj-8", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-10", 0 ],
"destination" : [ "obj-9", 0 ],
"hidden" : 0,
"midpoints" : [ 298.5, 353.0, 356.5, 353.0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-10", 2 ],
"destination" : [ "obj-9", 0 ],
"hidden" : 0,
"midpoints" : [ 356.5, 365.0, 356.5, 365.0 ]
}
}
]
}
*/

View file

@ -0,0 +1,57 @@
/*
Arrays
Demonstrates the use of an array to hold pin numbers
in order to iterate over the pins in a sequence.
Lights multiple LEDs in sequence, then in reverse.
Unlike the For Loop tutorial, where the pins have to be
contiguous, here the pins can be in any random order.
The circuit:
* LEDs from pins 2 through 7 to ground
created 2006
by David A. Mellis
modified 5 Jul 2009
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Array
*/
int timer = 100; // The higher the number, the slower the timing.
int ledPins[] = {
2, 7, 4, 6, 5, 3 }; // an array of pin numbers to which LEDs are attached
int pinCount = 6; // the number of pins (i.e. the length of the array)
void setup() {
int thisPin;
// the array elements are numbered from 0 to (pinCount - 1).
// use a for loop to initialize each pin as an output:
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
pinMode(ledPins[thisPin], OUTPUT);
}
}
void loop() {
// loop from the lowest pin to the highest:
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
// turn the pin on:
digitalWrite(ledPins[thisPin], HIGH);
delay(timer);
// turn the pin off:
digitalWrite(ledPins[thisPin], LOW);
}
// loop from the highest pin to the lowest:
for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) {
// turn the pin on:
digitalWrite(ledPins[thisPin], HIGH);
delay(timer);
// turn the pin off:
digitalWrite(ledPins[thisPin], LOW);
}
}

View file

@ -0,0 +1,47 @@
/*
For Loop Iteration
Demonstrates the use of a for() loop.
Lights multiple LEDs in sequence, then in reverse.
The circuit:
* LEDs from pins 2 through 7 to ground
created 2006
by David A. Mellis
modified 5 Jul 2009
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/ForLoop
*/
int timer = 100; // The higher the number, the slower the timing.
void setup() {
// use a for loop to initialize each pin as an output:
for (int thisPin = 2; thisPin < 8; thisPin++) {
pinMode(thisPin, OUTPUT);
}
}
void loop() {
// loop from the lowest pin to the highest:
for (int thisPin = 2; thisPin < 8; thisPin++) {
// turn the pin on:
digitalWrite(thisPin, HIGH);
delay(timer);
// turn the pin off:
digitalWrite(thisPin, LOW);
}
// loop from the highest pin to the lowest:
for (int thisPin = 7; thisPin >= 2; thisPin--) {
// turn the pin on:
digitalWrite(thisPin, HIGH);
delay(timer);
// turn the pin off:
digitalWrite(thisPin, LOW);
}
}

View file

@ -0,0 +1,56 @@
/*
Conditionals - If statement
This example demonstrates the use of if() statements.
It reads the state of a potentiometer (an analog input) and turns on an LED
only if the LED goes above a certain threshold level. It prints the analog value
regardless of the level.
The circuit:
* potentiometer connected to analog pin 0.
Center pin of the potentiometer goes to the analog pin.
side pins of the potentiometer go to +5V and ground
* LED connected from digital pin 13 to ground
* Note: On most Arduino boards, there is already an LED on the board
connected to pin 13, so you don't need any extra components for this example.
created 17 Jan 2009
modified 4 Sep 2010
by Tom Igoe
This example code is in the public domain.
http://arduino.cc/en/Tutorial/IfStatement
*/
// These constants won't change:
const int analogPin = A0; // pin that the sensor is attached to
const int ledPin = 13; // pin that the LED is attached to
const int threshold = 400; // an arbitrary threshold level that's in the range of the analog input
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize serial communications:
Serial.begin(9600);
}
void loop() {
// read the value of the potentiometer:
int analogValue = analogRead(analogPin);
// if the analog value is high enough, turn on the LED:
if (analogValue > threshold) {
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin,LOW);
}
// print the analog value:
Serial.println(analogValue, DEC);
}

View file

@ -0,0 +1,88 @@
/*
Conditionals - while statement
This example demonstrates the use of while() statements.
While the pushbutton is pressed, the sketch runs the calibration routine.
The sensor readings during the while loop define the minimum and maximum
of expected values from the photo resistor.
This is a variation on the calibrate example.
The circuit:
* photo resistor connected from +5V to analog in pin 0
* 10K resistor connected from ground to analog in pin 0
* LED connected from digital pin 9 to ground through 220 ohm resistor
* pushbutton attached from pin 2 to +5V
* 10K resistor attached from pin 2 to ground
created 17 Jan 2009
modified 4 Sep 2010
by Tom Igoe
This example code is in the public domain.
http://arduino.cc/en/Tutorial/WhileLoop
*/
// These constants won't change:
const int sensorPin = A2; // pin that the sensor is attached to
const int ledPin = 9; // pin that the LED is attached to
const int indicatorLedPin = 13; // pin that the built-in LED is attached to
const int buttonPin = 2; // pin that the button is attached to
// These variables will change:
int sensorMin = 1023; // minimum sensor value
int sensorMax = 0; // maximum sensor value
int sensorValue = 0; // the sensor value
void setup() {
// set the LED pins as outputs and the switch pin as input:
pinMode(indicatorLedPin, OUTPUT);
pinMode (ledPin, OUTPUT);
pinMode (buttonPin, INPUT);
}
void loop() {
// while the button is pressed, take calibration readings:
while (digitalRead(buttonPin) == HIGH) {
calibrate();
}
// signal the end of the calibration period
digitalWrite(indicatorLedPin, LOW);
// read the sensor:
sensorValue = analogRead(sensorPin);
// apply the calibration to the sensor reading
sensorValue = map(sensorValue, sensorMin, sensorMax, 0, 255);
// in case the sensor value is outside the range seen during calibration
sensorValue = constrain(sensorValue, 0, 255);
// fade the LED using the calibrated value:
analogWrite(ledPin, sensorValue);
}
void calibrate() {
// turn on the indicator LED to indicate that calibration is happening:
digitalWrite(indicatorLedPin, HIGH);
// read the sensor:
sensorValue = analogRead(sensorPin);
// record the maximum sensor value
if (sensorValue > sensorMax) {
sensorMax = sensorValue;
}
// record the minimum sensor value
if (sensorValue < sensorMin) {
sensorMin = sensorValue;
}
}

View file

@ -0,0 +1,62 @@
/*
Switch statement
Demonstrates the use of a switch statement. The switch
statement allows you to choose from among a set of discrete values
of a variable. It's like a series of if statements.
To see this sketch in action, but the board and sensor in a well-lit
room, open the serial monitor, and and move your hand gradually
down over the sensor.
The circuit:
* photoresistor from analog in 0 to +5V
* 10K resistor from analog in 0 to ground
created 1 Jul 2009
modified 4 Sep 2010
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/SwitchCase
*/
// these constants won't change:
const int sensorMin = 0; // sensor minimum, discovered through experiment
const int sensorMax = 600; // sensor maximum, discovered through experiment
void setup() {
// initialize serial communication:
Serial.begin(9600);
}
void loop() {
// read the sensor:
int sensorReading = analogRead(A0);
// map the sensor range to a range of four options:
int range = map(sensorReading, sensorMin, sensorMax, 0, 3);
// do something different depending on the
// range value:
switch (range) {
case 0: // your hand is on the sensor
Serial.println("dark");
break;
case 1: // your hand is close to the sensor
Serial.println("dim");
break;
case 2: // your hand is a few inches from the sensor
Serial.println("medium");
break;
case 3: // your hand is nowhere near the sensor
Serial.println("bright");
break;
}
}

View file

@ -0,0 +1,66 @@
/*
Switch statement with serial input
Demonstrates the use of a switch statement. The switch
statement allows you to choose from among a set of discrete values
of a variable. It's like a series of if statements.
To see this sketch in action, open the Serial monitor and send any character.
The characters a, b, c, d, and e, will turn on LEDs. Any other character will turn
the LEDs off.
The circuit:
* 5 LEDs attached to digital pins 2 through 6 through 220-ohm resistors
created 1 Jul 2009
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/SwitchCase2
*/
void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pins:
for (int thisPin = 2; thisPin < 7; thisPin++) {
pinMode(thisPin, OUTPUT);
}
}
void loop() {
// read the sensor:
if (Serial.available() > 0) {
int inByte = Serial.read();
// do something different depending on the character received.
// The switch statement expects single number values for each case;
// in this exmaple, though, you're using single quotes to tell
// the controller to get the ASCII value for the character. For
// example 'a' = 97, 'b' = 98, and so forth:
switch (inByte) {
case 'a':
digitalWrite(2, HIGH);
break;
case 'b':
digitalWrite(3, HIGH);
break;
case 'c':
digitalWrite(4, HIGH);
break;
case 'd':
digitalWrite(5, HIGH);
break;
case 'e':
digitalWrite(6, HIGH);
break;
default:
// turn all the LEDs off:
for (int thisPin = 2; thisPin < 7; thisPin++) {
digitalWrite(thisPin, LOW);
}
}
}
}

View file

@ -0,0 +1,64 @@
/*
ADXL3xx
Reads an Analog Devices ADXL3xx accelerometer and communicates the
acceleration to the computer. The pins used are designed to be easily
compatible with the breakout boards from Sparkfun, available from:
http://www.sparkfun.com/commerce/categories.php?c=80
http://www.arduino.cc/en/Tutorial/ADXL3xx
The circuit:
analog 0: accelerometer self test
analog 1: z-axis
analog 2: y-axis
analog 3: x-axis
analog 4: ground
analog 5: vcc
created 2 Jul 2008
by David A. Mellis
modified 4 Sep 2010
by Tom Igoe
This example code is in the public domain.
*/
// these constants describe the pins. They won't change:
const int groundpin = 18; // analog input pin 4 -- ground
const int powerpin = 19; // analog input pin 5 -- voltage
const int xpin = A3; // x-axis of the accelerometer
const int ypin = A2; // y-axis
const int zpin = A1; // z-axis (only on 3-axis models)
void setup()
{
// initialize the serial communications:
Serial.begin(9600);
// Provide ground and power by using the analog inputs as normal
// digital pins. This makes it possible to directly connect the
// breakout board to the Arduino. If you use the normal 5V and
// GND pins on the Arduino, you can remove these lines.
pinMode(groundpin, OUTPUT);
pinMode(powerpin, OUTPUT);
digitalWrite(groundpin, LOW);
digitalWrite(powerpin, HIGH);
}
void loop()
{
// print the sensor values:
Serial.print(analogRead(xpin));
// print a tab between values:
Serial.print("\t");
Serial.print(analogRead(ypin));
// print a tab between values:
Serial.print("\t");
Serial.print(analogRead(zpin));
Serial.println();
// delay before next reading:
delay(100);
}

View file

@ -0,0 +1,55 @@
/* Knock Sensor
This sketch reads a piezo element to detect a knocking sound.
It reads an analog pin and compares the result to a set threshold.
If the result is greater than the threshold, it writes
"knock" to the serial port, and toggles the LED on pin 13.
The circuit:
* + connection of the piezo attached to analog in 0
* - connection of the piezo attached to ground
* 1-megohm resistor attached from analog in 0 to ground
http://www.arduino.cc/en/Tutorial/Knock
created 25 Mar 2007
by David Cuartielles <http://www.0j0.org>
modified 4 Sep 2010
by Tom Igoe
This example code is in the public domain.
*/
// these constants won't change:
const int ledPin = 13; // led connected to digital pin 13
const int knockSensor = A0; // the piezo is connected to analog pin 0
const int threshold = 100; // threshold value to decide when the detected sound is a knock or not
// these variables will change:
int sensorReading = 0; // variable to store the value read from the sensor pin
int ledState = LOW; // variable used to store the last LED status, to toggle the light
void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as as OUTPUT
Serial.begin(9600); // use the serial port
}
void loop() {
// read the sensor and store it in the variable sensorReading:
sensorReading = analogRead(knockSensor);
// if the sensor reading is greater than the threshold:
if (sensorReading >= threshold) {
// toggle the status of the ledPin:
ledState = !ledState;
// update the LED pin itself:
digitalWrite(ledPin, ledState);
// send the string "Knock!" back to the computer, followed by newline
Serial.println("Knock!");
}
delay(100); // delay to avoid overloading the serial port buffer
}

View file

@ -0,0 +1,63 @@
/*
Memsic2125
Read the Memsic 2125 two-axis accelerometer. Converts the
pulses output by the 2125 into milli-g's (1/1000 of earth's
gravity) and prints them over the serial connection to the
computer.
The circuit:
* X output of accelerometer to digital pin 2
* Y output of accelerometer to digital pin 3
* +V of accelerometer to +5V
* GND of accelerometer to ground
http://www.arduino.cc/en/Tutorial/Memsic2125
created 6 Nov 2008
by David A. Mellis
modified 30 Jun 2009
by Tom Igoe
This example code is in the public domain.
*/
// these constants won't change:
const int xPin = 2; // X output of the accelerometer
const int yPin = 3; // Y output of the accelerometer
void setup() {
// initialize serial communications:
Serial.begin(9600);
// initialize the pins connected to the accelerometer
// as inputs:
pinMode(xPin, INPUT);
pinMode(yPin, INPUT);
}
void loop() {
// variables to read the pulse widths:
int pulseX, pulseY;
// variables to contain the resulting accelerations
int accelerationX, accelerationY;
// read pulse from x- and y-axes:
pulseX = pulseIn(xPin,HIGH);
pulseY = pulseIn(yPin,HIGH);
// convert the pulse width into acceleration
// accelerationX and accelerationY are in milli-g's:
// earth's gravity is 1000 milli-g's, or 1g.
accelerationX = ((pulseX / 10) - 500) * 8;
accelerationY = ((pulseY / 10) - 500) * 8;
// print the acceleration
Serial.print(accelerationX);
// print a tab character:
Serial.print("\t");
Serial.print(accelerationY);
Serial.println();
delay(100);
}

View file

@ -0,0 +1,84 @@
/* Ping))) Sensor
This sketch reads a PING))) ultrasonic rangefinder and returns the
distance to the closest object in range. To do this, it sends a pulse
to the sensor to initiate a reading, then listens for a pulse
to return. The length of the returning pulse is proportional to
the distance of the object from the sensor.
The circuit:
* +V connection of the PING))) attached to +5V
* GND connection of the PING))) attached to ground
* SIG connection of the PING))) attached to digital pin 7
http://www.arduino.cc/en/Tutorial/Ping
created 3 Nov 2008
by David A. Mellis
modified 30 Jun 2009
by Tom Igoe
This example code is in the public domain.
*/
// this constant won't change. It's the pin number
// of the sensor's output:
const int pingPin = 7;
void setup() {
// initialize serial communication:
Serial.begin(9600);
}
void loop()
{
// establish variables for duration of the ping,
// and the distance result in inches and centimeters:
long duration, inches, cm;
// The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);
// The same pin is used to read the signal from the PING))): a HIGH
// pulse whose duration is the time (in microseconds) from the sending
// of the ping to the reception of its echo off of an object.
pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);
// convert the time into a distance
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(100);
}
long microsecondsToInches(long microseconds)
{
// According to Parallax's datasheet for the PING))), there are
// 73.746 microseconds per inch (i.e. sound travels at 1130 feet per
// second). This gives the distance travelled by the ping, outbound
// and return, so we divide by 2 to get the distance of the obstacle.
// See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf
return microseconds / 74 / 2;
}
long microsecondsToCentimeters(long microseconds)
{
// The speed of sound is 340 m/s or 29 microseconds per centimeter.
// The ping travels out and back, so to find the distance of the
// object we take half of the distance travelled.
return microseconds / 29 / 2;
}

View file

@ -0,0 +1,114 @@
/*
Row-Column Scanning an 8x8 LED matrix with X-Y input
This example controls an 8x8 LED matrix using two analog inputs
created 27 May 2009
modified 4 Sep 2010
by Tom Igoe
This example works for the Lumex LDM-24488NI Matrix. See
http://sigma.octopart.com/140413/datasheet/Lumex-LDM-24488NI.pdf
for the pin connections
For other LED cathode column matrixes, you should only need to change
the pin numbers in the row[] and column[] arrays
rows are the anodes
cols are the cathodes
---------
Pin numbers:
Matrix:
* Digital pins 2 through 13,
* analog pins 2 through 5 used as digital 16 through 19
Potentiometers:
* center pins are attached to analog pins 0 and 1, respectively
* side pins attached to +5V and ground, respectively.
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/RowColumnScanning
see also http://www.tigoe.net/pcomp/code/category/arduinowiring/514 for more
*/
// 2-dimensional array of row pin numbers:
const int row[8] = {
2,7,19,5,13,18,12,16 };
// 2-dimensional array of column pin numbers:
const int col[8] = {
6,11,10,3,17,4,8,9 };
// 2-dimensional array of pixels:
int pixels[8][8];
// cursor position:
int x = 5;
int y = 5;
void setup() {
Serial.begin(9600);
// initialize the I/O pins as outputs:
// iterate over the pins:
for (int thisPin = 0; thisPin < 8; thisPin++) {
// initialize the output pins:
pinMode(col[thisPin], OUTPUT);
pinMode(row[thisPin], OUTPUT);
// take the col pins (i.e. the cathodes) high to ensure that
// the LEDS are off:
digitalWrite(col[thisPin], HIGH);
}
// initialize the pixel matrix:
for (int x = 0; x < 8; x++) {
for (int y = 0; y < 8; y++) {
pixels[x][y] = HIGH;
}
}
}
void loop() {
// read input:
readSensors();
// draw the screen:
refreshScreen();
}
void readSensors() {
// turn off the last position:
pixels[x][y] = HIGH;
// read the sensors for X and Y values:
x = 7 - map(analogRead(A0), 0, 1023, 0, 7);
y = map(analogRead(A1), 0, 1023, 0, 7);
// set the new pixel position low so that the LED will turn on
// in the next screen refresh:
pixels[x][y] = LOW;
}
void refreshScreen() {
// iterate over the rows (anodes):
for (int thisRow = 0; thisRow < 8; thisRow++) {
// take the row pin (anode) high:
digitalWrite(row[thisRow], HIGH);
// iterate over the cols (cathodes):
for (int thisCol = 0; thisCol < 8; thisCol++) {
// get the state of the current pixel;
int thisPixel = pixels[thisRow][thisCol];
// when the row is HIGH and the col is LOW,
// the LED where they meet turns on:
digitalWrite(col[thisCol], thisPixel);
// turn the pixel off:
if (thisPixel == LOW) {
digitalWrite(col[thisCol], HIGH);
}
}
// take the row pin low to turn off the whole row:
digitalWrite(row[thisRow], LOW);
}
}

View file

@ -0,0 +1,60 @@
/*
LED bar graph
Turns on a series of LEDs based on the value of an analog sensor.
This is a simple way to make a bar graph display. Though this graph
uses 10 LEDs, you can use any number by changing the LED count
and the pins in the array.
This method can be used to control any series of digital outputs that
depends on an analog input.
The circuit:
* LEDs from pins 2 through 11 to ground
created 4 Sep 2010
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/BarGraph
*/
// these constants won't change:
const int analogPin = A0; // the pin that the potentiometer is attached to
const int ledCount = 10; // the number of LEDs in the bar graph
int ledPins[] = {
2, 3, 4, 5, 6, 7,8,9,10,11 }; // an array of pin numbers to which LEDs are attached
void setup() {
// loop over the pin array and set them all to output:
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
pinMode(ledPins[thisLed], OUTPUT);
}
}
void loop() {
// read the potentiometer:
int sensorReading = analogRead(analogPin);
// map the result to a range from 0 to the number of LEDs:
int ledLevel = map(sensorReading, 0, 1023, 0, ledCount);
// loop over the LED array:
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
// if the array element's index is less than ledLevel,
// turn the pin for this element on:
if (thisLed < ledLevel) {
digitalWrite(ledPins[thisLed], HIGH);
}
// turn off all pins higher than the ledLevel:
else {
digitalWrite(ledPins[thisLed], LOW);
}
}
}

View file

@ -0,0 +1,85 @@
/*
Character analysis operators
Examples using the character analysis operators.
Send any byte and the sketch will tell you about it.
created 29 Nov 2010
by Tom Igoe
This example code is in the public domain.
*/
void setup() {
// Open serial communications:
Serial.begin(9600);
// send an intro:
Serial.println("send any byte and I'll tell you everything I can about it");
Serial.println();
}
void loop() {
// get any incoming bytes:
if (Serial.available() > 0) {
int thisChar = Serial.read();
// say what was sent:
Serial.print("You sent me: \'");
Serial.write(thisChar);
Serial.print("\' ASCII Value: ");
Serial.println(thisChar);
// analyze what was sent:
if(isAlphaNumeric(thisChar)) {
Serial.println("it's alphanumeric");
}
if(isAlpha(thisChar)) {
Serial.println("it's alphabetic");
}
if(isAscii(thisChar)) {
Serial.println("it's ASCII");
}
if(isWhitespace(thisChar)) {
Serial.println("it's whitespace");
}
if(isControl(thisChar)) {
Serial.println("it's a control character");
}
if(isDigit(thisChar)) {
Serial.println("it's a numeric digit");
}
if(isGraph(thisChar)) {
Serial.println("it's a printable character that's not whitespace");
}
if(isLowerCase(thisChar)) {
Serial.println("it's lower case");
}
if(isPrintable(thisChar)) {
Serial.println("it's printable");
}
if(isPunct(thisChar)) {
Serial.println("it's punctuation");
}
if(isSpace(thisChar)) {
Serial.println("it's a space character");
}
if(isUpperCase(thisChar)) {
Serial.println("it's upper case");
}
if (isHexadecimalDigit(thisChar)) {
Serial.println("it's a valid hexadecimaldigit (i.e. 0 - 9, a - F, or A - F)");
}
// add some space and ask for another byte:
Serial.println();
Serial.println("Give me another byte:");
Serial.println();
}
}

View file

@ -0,0 +1,61 @@
/*
Adding Strings together
Examples of how to add strings together
You can also add several different data types to string, as shown here:
created 27 July 2010
modified 4 Sep 2010
by Tom Igoe
http://arduino.cc/en/Tutorial/StringAdditionOperator
This example code is in the public domain.
*/
// declare three strings:
String stringOne, stringTwo, stringThree;
void setup() {
Serial.begin(9600);
stringOne = String("stringThree = ");
stringTwo = String("this string");
stringThree = String ();
Serial.println("\n\nAdding strings together (concatenation):");
}
void loop() {
// adding a constant integer to a string:
stringThree = stringOne + 123;
Serial.println(stringThree); // prints "stringThree = 123"
// adding a constant long interger to a string:
stringThree = stringOne + 123456789;
Serial.println(stringThree); // prints " You added 123456789"
// adding a constant character to a string:
stringThree = stringOne + 'A';
Serial.println(stringThree); // prints "You added A"
// adding a constant string to a string:
stringThree = stringOne + "abc";
Serial.println(stringThree); // prints "You added abc"
stringThree = stringOne + stringTwo;
Serial.println(stringThree); // prints "You added this string"
// adding a variable integer to a string:
int sensorValue = analogRead(A0);
stringOne = "Sensor value: ";
stringThree = stringOne + sensorValue;
Serial.println(stringThree); // prints "Sensor Value: 401" or whatever value analogRead(A0) has
// adding a variable long integer to a string:
long currentTime = millis();
stringOne="millis() value: ";
stringThree = stringOne + millis();
Serial.println(stringThree); // prints "The millis: 345345" or whatever value currentTime has
// do nothing while true:
while(true);
}

View file

@ -0,0 +1,64 @@
/*
Appending to Strings using the += operator and concat()
Examples of how to append different data types to strings
created 27 July 2010
modified 4 Sep 2010
by Tom Igoe
http://arduino.cc/en/Tutorial/StringAppendOperator
This example code is in the public domain.
*/
String stringOne, stringTwo;
void setup() {
Serial.begin(9600);
stringOne = String("Sensor ");
stringTwo = String("value");
Serial.println("\n\nAppending to a string:");
}
void loop() {
Serial.println(stringOne); // prints "Sensor "
// adding a string to a string:
stringOne += stringTwo;
Serial.println(stringOne); // prints "Sensor value"
// adding a constant string to a string:
stringOne += " for input ";
Serial.println(stringOne); // prints "Sensor value for input"
// adding a constant character to a string:
stringOne += 'A';
Serial.println(stringOne); // prints "Sensor value for input A"
// adding a constant integer to a string:
stringOne += 0;
Serial.println(stringOne); // prints "Sensor value for input A0"
// adding a constant string to a string:
stringOne += ": ";
Serial.println(stringOne); // prints "Sensor value for input"
// adding a variable integer to a string:
stringOne += analogRead(A0);
Serial.println(stringOne); // prints "Sensor value for input A0: 456" or whatever analogRead(A0) is
Serial.println("\n\nchanging the Strings' values");
stringOne = "A long integer: ";
stringTwo = "The millis(): ";
// adding a constant long integer to a string:
stringOne += 123456789;
Serial.println(stringOne); // prints "A long integer: 123456789"
// using concat() to add a long variable to a string:
stringTwo.concat(millis());
Serial.println(stringTwo); // prints "The millis(): 43534" or whatever the value of the millis() is
// do nothing while true:
while(true);
}

View file

@ -0,0 +1,35 @@
/*
String Case changes
Examples of how to change the case of a string
created 27 July 2010
by Tom Igoe
http://arduino.cc/en/Tutorial/StringCaseChanges
This example code is in the public domain.
*/
void setup() {
Serial.begin(9600);
Serial.println("\n\nString case changes:");
}
void loop() {
// toUpperCase() changes all letters to upper case:
String stringOne = "<html><head><body>";
Serial.println(stringOne);
stringOne = (stringOne.toUpperCase());
Serial.println(stringOne);
// toLowerCase() changes all letters to lower case:
String stringTwo = "</BODY></HTML>";
Serial.println(stringTwo);
stringTwo = stringTwo.toLowerCase();
Serial.println(stringTwo);
// do nothing while true:
while(true);
}

View file

@ -0,0 +1,37 @@
/*
String charAt() and setCharAt()
Examples of how to get and set characters of a String
created 27 July 2010
by Tom Igoe
http://arduino.cc/en/Tutorial/StringCharacters
This example code is in the public domain.
*/
void setup() {
Serial.begin(9600);
Serial.println("\n\nString charAt() and setCharAt():");
}
void loop() {
// make a string to report a sensor reading:
String reportString = "SensorReading: 456";
Serial.println(reportString);
// the reading's most significant digit is at position 15 in the reportString:
String mostSignificantDigit = reportString.charAt(15);
Serial.println("Most significant digit of the sensor reading is: " + mostSignificantDigit);
// add blank space:
Serial.println();
// you can alo set the character of a string. Change the : to a = character
reportString.setCharAt(13, '=');
Serial.println(reportString);
// do nothing while true:
while(true);
}

View file

@ -0,0 +1,124 @@
/*
Comparing Strings
Examples of how to compare strings using the comparison operators
created 27 July 2010
modified 4 Sep 2010
by Tom Igoe
http://arduino.cc/en/Tutorial/StringComparisonOperators
This example code is in the public domain.
*/
String stringOne, stringTwo;
void setup() {
Serial.begin(9600);
stringOne = String("this");
stringTwo = String("that");
Serial.println("\n\nComparing Strings:");
}
void loop() {
// two strings equal:
if (stringOne == "this") {
Serial.println("StringOne == \"this\"");
}
// two strings not equal:
if (stringOne != stringTwo) {
Serial.println(stringOne + " =! " + stringTwo);
}
// two strings not equal (case sensitivity matters):
stringOne = "This";
stringTwo = "this";
if (stringOne != stringTwo) {
Serial.println(stringOne + " =! " + stringTwo);
}
// you can also use equals() to see if two strings are the same:
if (stringOne.equals(stringTwo)) {
Serial.println(stringOne + " equals " + stringTwo);
}
else {
Serial.println(stringOne + " does not equal " + stringTwo);
}
// or perhaps you want to ignore case:
if (stringOne.equalsIgnoreCase(stringTwo)) {
Serial.println(stringOne + " equals (ignoring case) " + stringTwo);
}
else {
Serial.println(stringOne + " does not equal (ignoring case) " + stringTwo);
}
// a numeric string compared to the number it represents:
stringOne = "1";
int numberOne = 1;
if (stringOne == numberOne) {
Serial.println(stringOne + " = " + numberOne);
}
// two numeric strings compared:
stringOne = "2";
stringTwo = "1";
if (stringOne >= stringTwo) {
Serial.println(stringOne + " >= " + stringTwo);
}
// comparison operators can be used to compare strings for alphabetic sorting too:
stringOne = String("Brown");
if (stringOne < "Charles") {
Serial.println(stringOne + " < Charles");
}
if (stringOne > "Adams") {
Serial.println(stringOne + " > Adams");
}
if (stringOne <= "Browne") {
Serial.println(stringOne + " <= Browne");
}
if (stringOne >= "Brow") {
Serial.println(stringOne + " >= Brow");
}
// the compareTo() operator also allows you to compare strings
// it evaluates on the first character that's different.
// if the first character of the string you're comparing to
// comes first in alphanumeric order, then compareTo() is greater than 0:
stringOne = "Cucumber";
stringTwo = "Cucuracha";
if (stringOne.compareTo(stringTwo) < 0 ) {
Serial.println(stringOne + " comes before " + stringTwo);
}
else {
Serial.println(stringOne + " comes after " + stringTwo);
}
delay(10000); // because the next part is a loop:
// compareTo() is handy when you've got strings with numbers in them too:
while (true) {
stringOne = "Sensor: ";
stringTwo= "Sensor: ";
stringOne += analogRead(A0);
stringTwo += analogRead(A5);
if (stringOne.compareTo(stringTwo) < 0 ) {
Serial.println(stringOne + " comes before " + stringTwo);
}
else {
Serial.println(stringOne + " comes after " + stringTwo);
}
}
}

View file

@ -0,0 +1,64 @@
/*
String constructors
Examples of how to create strings from other data types
created 27 July 2010
modified 4 Sep 2010
by Tom Igoe
http://arduino.cc/en/Tutorial/StringConstructors
This example code is in the public domain.
*/
void setup() {
Serial.begin(9600);
}
void loop() {
// using a constant String:
String stringOne = "Hello String";
Serial.println(stringOne); // prints "Hello String"
// converting a constant char into a String:
stringOne = String('a');
Serial.println(stringOne); // prints "a"
// converting a constant string into a String object:
String stringTwo = String("This is a string");
Serial.println(stringTwo); // prints "This is a string"
// concatenating two strings:
stringOne = String(stringTwo + " with more");
// prints "This is a string with more":
Serial.println(stringOne);
// using a constant integer:
stringOne = String(13);
Serial.println(stringOne); // prints "13"
// using an int and a base:
stringOne = String(analogRead(A0), DEC);
// prints "453" or whatever the value of analogRead(A0) is
Serial.println(stringOne);
// using an int and a base (hexadecimal):
stringOne = String(45, HEX);
// prints "2d", which is the hexadecimal version of decimal 45:
Serial.println(stringOne);
// using an int and a base (binary)
stringOne = String(255, BIN);
// prints "11111111" which is the binary value of 255
Serial.println(stringOne);
// using a long and a base:
stringOne = String(millis(), DEC);
// prints "123456" or whatever the value of millis() is:
Serial.println(stringOne);
// do nothing while true:
while(true);
}

View file

@ -0,0 +1,58 @@
/*
String indexOf() and lastIndexOf() functions
Examples of how to evaluate, look for, and replace characters in a String
created 27 July 2010
by Tom Igoe
http://arduino.cc/en/Tutorial/StringIndexOf
This example code is in the public domain.
*/
void setup() {
Serial.begin(9600);
Serial.println("\n\nString indexOf() and lastIndexOf() functions:");
}
void loop() {
// indexOf() returns the position (i.e. index) of a particular character
// in a string. For example, if you were parsing HTML tags, you could use it:
String stringOne = "<HTML><HEAD><BODY>";
int firstClosingBracket = stringOne.indexOf('>');
Serial.println("The index of > in the string " + stringOne + " is " + firstClosingBracket);
stringOne = "<HTML><HEAD><BODY>";
int secondOpeningBracket = firstClosingBracket + 1;
int secondClosingBracket = stringOne.indexOf('>', secondOpeningBracket );
Serial.println("The index of the second > in the string " + stringOne + " is " + secondClosingBracket);
// you can also use indexOf() to search for Strings:
stringOne = "<HTML><HEAD><BODY>";
int bodyTag = stringOne.indexOf("<BODY>");
Serial.println("The index of the body tag in the string " + stringOne + " is " + bodyTag);
stringOne = "<UL><LI>item<LI>item<LI>item</UL>";
int firstListItem = stringOne.indexOf("<LI>");
int secondListItem = stringOne.indexOf("item", firstListItem + 1 );
Serial.println("The index of the second list item in the string " + stringOne + " is " + secondClosingBracket);
// lastIndexOf() gives you the last occurrence of a character or string:
int lastOpeningBracket = stringOne.lastIndexOf('<');
Serial.println("The index of the last < in the string " + stringOne + " is " + lastOpeningBracket);
int lastListItem = stringOne.lastIndexOf("<LI>");
Serial.println("The index of the last list item in the string " + stringOne + " is " + lastListItem);
// lastIndexOf() can also search for a string:
stringOne = "<p>Lorem ipsum dolor sit amet</p><p>Ipsem</p><p>Quod</p>";
int lastParagraph = stringOne.lastIndexOf("<p");
int secondLastGraf = stringOne.lastIndexOf("<p", lastParagraph - 1);
Serial.println("The index of the second last paragraph tag " + stringOne + " is " + secondLastGraf);
// do nothing while true:
while(true);
}

View file

@ -0,0 +1,43 @@
/*
String length()
Examples of how to use length() in a String.
Open the Serial Monitor and start sending characters to see the results.
created 1 Aug 2010
by Tom Igoe
http://arduino.cc/en/Tutorial/StringLengthTrim
This example code is in the public domain.
*/
String txtMsg = ""; // a string for incoming text
int lastStringLength = txtMsg.length(); // previous length of the String
void setup() {
// open the serial port:
Serial.begin(9600);
}
void loop() {
// add any incoming characters to the String:
while (Serial.available() > 0) {
char inChar = Serial.read();
txtMsg += inChar;
}
// print the message and a notice if it's changed:
if (txtMsg.length() != lastStringLength) {
Serial.println(txtMsg);
Serial.println(txtMsg.length());
// if the String's longer than 140 characters, complain:
if (txtMsg.length() < 140) {
Serial.println("That's a perfectly acceptable text message");
}
else {
Serial.println("That's too long for a text message.");
}
// note the length for next time through the loop:
lastStringLength = txtMsg.length();
}
}

View file

@ -0,0 +1,34 @@
/*
String length() and trim()
Examples of how to use length() and trim() in a String
created 27 July 2010
by Tom Igoe
http://arduino.cc/en/Tutorial/StringLengthTrim
This example code is in the public domain.
*/
void setup() {
Serial.begin(9600);
Serial.println("\n\nString length() and trim():");
}
void loop() {
// here's a String with empty spaces at the end (called white space):
String stringOne = "Hello! ";
Serial.print(stringOne);
Serial.print("<--- end of string. Length: ");
Serial.println(stringOne.length());
// trim the white space off the string:
stringOne = stringOne.trim();
Serial.print(stringOne);
Serial.print("<--- end of trimmed string. Length: ");
Serial.println(stringOne.length());
// do nothing while true:
while(true);
}

View file

@ -0,0 +1,35 @@
/*
String replace()
Examples of how to replace characters or substrings of a string
created 27 July 2010
by Tom Igoe
http://arduino.cc/en/Tutorial/StringReplace
This example code is in the public domain.
*/
void setup() {
Serial.begin(9600);
Serial.println("\n\nString replace:");
}
void loop() {
String stringOne = "<html><head><body>";
Serial.println(stringOne);
// replace() changes all instances of one substring with another:
String stringTwo = stringOne.replace("<", "</");
Serial.println(stringTwo);
// you can also use replace() on single characters:
String normalString = "bookkeeper";
Serial.println("normal: " + normalString);
String leetString = normalString.replace('o', '0');
leetString = leetString.replace('e', '3');
Serial.println("l33tspeak: " + leetString);
// do nothing while true:
while(true);
}

View file

@ -0,0 +1,49 @@
/*
String startWith() and endsWith()
Examples of how to use startsWith() and endsWith() in a String
created 27 July 2010
modified 4 Sep 2010
by Tom Igoe
http://arduino.cc/en/Tutorial/StringStartsWithEndsWith
This example code is in the public domain.
*/
void setup() {
Serial.begin(9600);
Serial.println("\n\nString startsWith() and endsWith():");
}
void loop() {
// startsWith() checks to see if a String starts with a particular substring:
String stringOne = "HTTP/1.1 200 OK";
Serial.println(stringOne);
if (stringOne.startsWith("HTTP/1.1")) {
Serial.println("Server's using http version 1.1");
}
// you can also look for startsWith() at an offset position in the string:
stringOne = "HTTP/1.1 200 OK";
if (stringOne.startsWith("200 OK", 9)) {
Serial.println("Got an OK from the server");
}
// endsWith() checks to see if a String ends with a particular character:
String sensorReading = "sensor = ";
sensorReading += analogRead(A0);
Serial.print (sensorReading);
if (sensorReading.endsWith(0)) {
Serial.println(". This reading is divisible by ten");
}
else {
Serial.println(". This reading is not divisible by ten");
}
// do nothing while true:
while(true);
}

View file

@ -0,0 +1,35 @@
/*
String substring()
Examples of how to use substring in a String
created 27 July 2010
by Tom Igoe
http://arduino.cc/en/Tutorial/StringSubstring
This example code is in the public domain.
*/
void setup() {
Serial.begin(9600);
Serial.println("\n\nString substring():");
}
void loop() {
// Set up a String:
String stringOne = "Content-Type: text/html";
Serial.println(stringOne);
// substring(index) looks for the substring from the index position to the end:
if (stringOne.substring(19) == "html") {
Serial.println("It's an html file");
}
// you can also look for a substring in the middle of a string:
if (stringOne.substring(14,18) == "text") {
Serial.println("It's a text-based file");
}
// do nothing while true:
while(true);
}

View file

@ -0,0 +1,47 @@
/*
String to Integer conversion
Reads a serial input string until it sees a newline, then converts
the string to a number if the characters are digits.
The circuit:
No external components needed.
created 29 Nov 2010
by Tom Igoe
This example code is in the public domain.
*/
String inString = ""; // string to hold input
void setup() {
// Initialize serial communications:
Serial.begin(9600);
}
void loop() {
// Read serial input:
while (Serial.available() > 0) {
int inChar = Serial.read();
if (isDigit(inChar)) {
// convert the incoming byte to a char
// and add it to the string:
inString += (char)inChar;
}
// if you get a newline, print the string,
// then the string's value:
if (inChar == '\n') {
Serial.print("Value:");
Serial.println(inString.toInt());
Serial.print("String: ");
Serial.println(inString);
// clear the string for new input:
inString = "";
}
}
}

View file

@ -0,0 +1,230 @@
/*
Serial RGB controller
Reads a serial input string looking for three comma-separated
integers with a newline at the end. Values should be between
0 and 255. The sketch uses those values to set the color
of an RGB LED attached to pins 9 - 11.
The circuit:
* Common-anode RGB LED cathodes attached to pins 9 - 11
* LED anode connected to pin 13
To turn on any given channel, set the pin LOW.
To turn off, set the pin HIGH. The higher the analogWrite level,
the lower the brightness.
created 29 Nov 2010
by Tom Igoe
This example code is in the public domain.
*/
String inString = ""; // string to hold input
int currentColor = 0;
int red, green, blue = 0;
void setup() {
// Initialize serial communications:
Serial.begin(9600);
// set LED cathode pins as outputs:
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
// turn on pin 13 to power the LEDs:
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
void loop() {
int inChar;
// Read serial input:
if (Serial.available() > 0) {
inChar = Serial.read();
}
if (isDigit(inChar)) {
// convert the incoming byte to a char
// and add it to the string:
inString += (char)inChar;
}
// if you get a comma, convert to a number,
// set the appropriate color, and increment
// the color counter:
if (inChar == ',') {
// do something different for each value of currentColor:
switch (currentColor) {
case 0: // 0 = red
red = inString.toInt();
// clear the string for new input:
inString = "";
break;
case 1: // 1 = green:
green = inString.toInt();
// clear the string for new input:
inString = "";
break;
}
currentColor++;
}
// if you get a newline, you know you've got
// the last color, i.e. blue:
if (inChar == '\n') {
blue = inString.toInt();
// set the levels of the LED.
// subtract value from 255 because a higher
// analogWrite level means a dimmer LED, since
// you're raising the level on the anode:
analogWrite(11, 255 - red);
analogWrite(9, 255 - green);
analogWrite(10, 255 - blue);
// print the colors:
Serial.print("Red: ");
Serial.print(red);
Serial.print(", Green: ");
Serial.print(green);
Serial.print(", Blue: ");
Serial.println(blue);
// clear the string for new input:
inString = "";
// reset the color counter:
currentColor = 0;
}
}
/*
Here's a Processing sketch that will draw a color wheel and send a serial
string with the color you click on:
// Subtractive Color Wheel with Serial
// Based on a Processing example by Ira Greenberg.
// Serial output added by Tom Igoe
//
// The primaries are red, yellow, and blue. The secondaries are green,
// purple, and orange. The tertiaries are yellow-orange, red-orange,
// red-purple, blue-purple, blue-green, and yellow-green.
//
// Create a shade or tint of the subtractive color wheel using
// SHADE or TINT parameters.
// Updated 29 November 2010.
import processing.serial.*;
int segs = 12;
int steps = 6;
float rotAdjust = TWO_PI / segs / 2;
float radius;
float segWidth;
float interval = TWO_PI / segs;
Serial myPort;
void setup() {
size(200, 200);
background(127);
smooth();
ellipseMode(RADIUS);
noStroke();
// make the diameter 90% of the sketch area
radius = min(width, height) * 0.45;
segWidth = radius / steps;
// swap which line is commented out to draw the other version
// drawTintWheel();
drawShadeWheel();
// open the first serial port in your computer's list
myPort = new Serial(this, Serial.list()[0], 9600);
}
void drawShadeWheel() {
for (int j = 0; j < steps; j++) {
color[] cols = {
color(255-(255/steps)*j, 255-(255/steps)*j, 0),
color(255-(255/steps)*j, (255/1.5)-((255/1.5)/steps)*j, 0),
color(255-(255/steps)*j, (255/2)-((255/2)/steps)*j, 0),
color(255-(255/steps)*j, (255/2.5)-((255/2.5)/steps)*j, 0),
color(255-(255/steps)*j, 0, 0),
color(255-(255/steps)*j, 0, (255/2)-((255/2)/steps)*j),
color(255-(255/steps)*j, 0, 255-(255/steps)*j),
color((255/2)-((255/2)/steps)*j, 0, 255-(255/steps)*j),
color(0, 0, 255-(255/steps)*j),
color(0, 255-(255/steps)*j, (255/2.5)-((255/2.5)/steps)*j),
color(0, 255-(255/steps)*j, 0),
color((255/2)-((255/2)/steps)*j, 255-(255/steps)*j, 0)
};
for (int i = 0; i < segs; i++) {
fill(cols[i]);
arc(width/2, height/2, radius, radius,
interval*i+rotAdjust, interval*(i+1)+rotAdjust);
}
radius -= segWidth;
}
}
void drawTintWheel() {
for (int j = 0; j < steps; j++) {
color[] cols = {
color((255/steps)*j, (255/steps)*j, 0),
color((255/steps)*j, ((255/1.5)/steps)*j, 0),
color((255/steps)*j, ((255/2)/steps)*j, 0),
color((255/steps)*j, ((255/2.5)/steps)*j, 0),
color((255/steps)*j, 0, 0),
color((255/steps)*j, 0, ((255/2)/steps)*j),
color((255/steps)*j, 0, (255/steps)*j),
color(((255/2)/steps)*j, 0, (255/steps)*j),
color(0, 0, (255/steps)*j),
color(0, (255/steps)*j, ((255/2.5)/steps)*j),
color(0, (255/steps)*j, 0),
color(((255/2)/steps)*j, (255/steps)*j, 0)
};
for (int i = 0; i < segs; i++) {
fill(cols[i]);
arc(width/2, height/2, radius, radius,
interval*i+rotAdjust, interval*(i+1)+rotAdjust);
}
radius -= segWidth;
}
}
void draw() {
// nothing happens here
}
void mouseReleased() {
// get the color of the mouse position's pixel:
color targetColor = get(mouseX, mouseY);
// get the component values:
int r = int(red(targetColor));
int g = int(green(targetColor));
int b = int(blue(targetColor));
// make a comma-separated string:
String colorString = r + "," + g + "," + b + "\n";
// send it out the serial port:
myPort.write(colorString );
}
*/

View file

@ -0,0 +1,478 @@
// this sketch turns the Arduino into a AVRISP
// using the following pins:
// 10: slave reset
// 11: MOSI
// 12: MISO
// 13: SCK
// Put an LED (with resistor) on the following pins:
// 9: Heartbeat - shows the programmer is running
// 8: Error - Lights up if something goes wrong (use red if that makes sense)
// 7: Programming - In communication with the slave
//
// October 2009 by David A. Mellis
// - Added support for the read signature command
//
// February 2009 by Randall Bohn
// - Added support for writing to EEPROM (what took so long?)
// Windows users should consider WinAVR's avrdude instead of the
// avrdude included with Arduino software.
//
// January 2008 by Randall Bohn
// - Thanks to Amplificar for helping me with the STK500 protocol
// - The AVRISP/STK500 (mk I) protocol is used in the arduino bootloader
// - The SPI functions herein were developed for the AVR910_ARD programmer
// - More information at http://code.google.com/p/mega-isp
#include "pins_arduino.h" // defines SS,MOSI,MISO,SCK
#define RESET SS
#define LED_HB 9
#define LED_ERR 8
#define LED_PMODE 7
#define HWVER 2
#define SWMAJ 1
#define SWMIN 18
// STK Definitions
#define STK_OK 0x10
#define STK_FAILED 0x11
#define STK_UNKNOWN 0x12
#define STK_INSYNC 0x14
#define STK_NOSYNC 0x15
#define CRC_EOP 0x20 //ok it is a space...
void pulse(int pin, int times);
void setup() {
Serial.begin(19200);
pinMode(7, OUTPUT);
pulse(7, 2);
pinMode(8, OUTPUT);
pulse(8, 2);
pinMode(9, OUTPUT);
pulse(9, 2);
}
int error=0;
int pmode=0;
// address for reading and writing, set by 'U' command
int here;
uint8_t buff[256]; // global block storage
#define beget16(addr) (*addr * 256 + *(addr+1) )
typedef struct param {
uint8_t devicecode;
uint8_t revision;
uint8_t progtype;
uint8_t parmode;
uint8_t polling;
uint8_t selftimed;
uint8_t lockbytes;
uint8_t fusebytes;
int flashpoll;
int eeprompoll;
int pagesize;
int eepromsize;
int flashsize;
}
parameter;
parameter param;
// this provides a heartbeat on pin 9, so you can tell the software is running.
uint8_t hbval=128;
int8_t hbdelta=8;
void heartbeat() {
if (hbval > 192) hbdelta = -hbdelta;
if (hbval < 32) hbdelta = -hbdelta;
hbval += hbdelta;
analogWrite(LED_HB, hbval);
delay(40);
}
void loop(void) {
// is pmode active?
if (pmode) digitalWrite(LED_PMODE, HIGH);
else digitalWrite(LED_PMODE, LOW);
// is there an error?
if (error) digitalWrite(LED_ERR, HIGH);
else digitalWrite(LED_ERR, LOW);
// light the heartbeat LED
heartbeat();
if (Serial.available()) {
avrisp();
}
}
uint8_t getch() {
while(!Serial.available());
return Serial.read();
}
void readbytes(int n) {
for (int x = 0; x < n; x++) {
buff[x] = Serial.read();
}
}
#define PTIME 30
void pulse(int pin, int times) {
do {
digitalWrite(pin, HIGH);
delay(PTIME);
digitalWrite(pin, LOW);
delay(PTIME);
}
while (times--);
}
void spi_init() {
uint8_t x;
SPCR = 0x53;
x=SPSR;
x=SPDR;
}
void spi_wait() {
do {
}
while (!(SPSR & (1 << SPIF)));
}
uint8_t spi_send(uint8_t b) {
uint8_t reply;
SPDR=b;
spi_wait();
reply = SPDR;
return reply;
}
uint8_t spi_transaction(uint8_t a, uint8_t b, uint8_t c, uint8_t d) {
uint8_t n;
spi_send(a);
n=spi_send(b);
//if (n != a) error = -1;
n=spi_send(c);
return spi_send(d);
}
void empty_reply() {
if (CRC_EOP == getch()) {
Serial.print((char)STK_INSYNC);
Serial.print((char)STK_OK);
}
else {
Serial.print((char)STK_NOSYNC);
}
}
void breply(uint8_t b) {
if (CRC_EOP == getch()) {
Serial.print((char)STK_INSYNC);
Serial.print((char)b);
Serial.print((char)STK_OK);
}
else {
Serial.print((char)STK_NOSYNC);
}
}
void get_version(uint8_t c) {
switch(c) {
case 0x80:
breply(HWVER);
break;
case 0x81:
breply(SWMAJ);
break;
case 0x82:
breply(SWMIN);
break;
case 0x93:
breply('S'); // serial programmer
break;
default:
breply(0);
}
}
void set_parameters() {
// call this after reading paramter packet into buff[]
param.devicecode = buff[0];
param.revision = buff[1];
param.progtype = buff[2];
param.parmode = buff[3];
param.polling = buff[4];
param.selftimed = buff[5];
param.lockbytes = buff[6];
param.fusebytes = buff[7];
param.flashpoll = buff[8];
// ignore buff[9] (= buff[8])
//getch(); // discard second value
// WARNING: not sure about the byte order of the following
// following are 16 bits (big endian)
param.eeprompoll = beget16(&buff[10]);
param.pagesize = beget16(&buff[12]);
param.eepromsize = beget16(&buff[14]);
// 32 bits flashsize (big endian)
param.flashsize = buff[16] * 0x01000000
+ buff[17] * 0x00010000
+ buff[18] * 0x00000100
+ buff[19];
}
void start_pmode() {
spi_init();
// following delays may not work on all targets...
pinMode(RESET, OUTPUT);
digitalWrite(RESET, HIGH);
pinMode(SCK, OUTPUT);
digitalWrite(SCK, LOW);
delay(50);
digitalWrite(RESET, LOW);
delay(50);
pinMode(MISO, INPUT);
pinMode(MOSI, OUTPUT);
spi_transaction(0xAC, 0x53, 0x00, 0x00);
pmode = 1;
}
void end_pmode() {
pinMode(MISO, INPUT);
pinMode(MOSI, INPUT);
pinMode(SCK, INPUT);
pinMode(RESET, INPUT);
pmode = 0;
}
void universal() {
int w;
uint8_t ch;
for (w = 0; w < 4; w++) {
buff[w] = getch();
}
ch = spi_transaction(buff[0], buff[1], buff[2], buff[3]);
breply(ch);
}
void flash(uint8_t hilo, int addr, uint8_t data) {
spi_transaction(0x40+8*hilo,
addr>>8 & 0xFF,
addr & 0xFF,
data);
}
void commit(int addr) {
spi_transaction(0x4C, (addr >> 8) & 0xFF, addr & 0xFF, 0);
}
//#define _current_page(x) (here & 0xFFFFE0)
int current_page(int addr) {
if (param.pagesize == 32) return here & 0xFFFFFFF0;
if (param.pagesize == 64) return here & 0xFFFFFFE0;
if (param.pagesize == 128) return here & 0xFFFFFFC0;
if (param.pagesize == 256) return here & 0xFFFFFF80;
return here;
}
uint8_t write_flash(int length) {
if (param.pagesize < 1) return STK_FAILED;
//if (param.pagesize != 64) return STK_FAILED;
int page = current_page(here);
int x = 0;
while (x < length) {
if (page != current_page(here)) {
commit(page);
page = current_page(here);
}
flash(LOW, here, buff[x++]);
flash(HIGH, here, buff[x++]);
here++;
}
commit(page);
return STK_OK;
}
uint8_t write_eeprom(int length) {
// here is a word address, so we use here*2
// this writes byte-by-byte,
// page writing may be faster (4 bytes at a time)
for (int x = 0; x < length; x++) {
spi_transaction(0xC0, 0x00, here*2+x, buff[x]);
delay(45);
}
return STK_OK;
}
void program_page() {
char result = (char) STK_FAILED;
int length = 256 * getch() + getch();
if (length > 256) {
Serial.print((char) STK_FAILED);
return;
}
char memtype = getch();
for (int x = 0; x < length; x++) {
buff[x] = getch();
}
if (CRC_EOP == getch()) {
Serial.print((char) STK_INSYNC);
if (memtype == 'F') result = (char)write_flash(length);
if (memtype == 'E') result = (char)write_eeprom(length);
Serial.print(result);
}
else {
Serial.print((char) STK_NOSYNC);
}
}
uint8_t flash_read(uint8_t hilo, int addr) {
return spi_transaction(0x20 + hilo * 8,
(addr >> 8) & 0xFF,
addr & 0xFF,
0);
}
char flash_read_page(int length) {
for (int x = 0; x < length; x+=2) {
uint8_t low = flash_read(LOW, here);
Serial.print((char) low);
uint8_t high = flash_read(HIGH, here);
Serial.print((char) high);
here++;
}
return STK_OK;
}
char eeprom_read_page(int length) {
// here again we have a word address
for (int x = 0; x < length; x++) {
uint8_t ee = spi_transaction(0xA0, 0x00, here*2+x, 0xFF);
Serial.print((char) ee);
}
return STK_OK;
}
void read_page() {
char result = (char)STK_FAILED;
int length = 256 * getch() + getch();
char memtype = getch();
if (CRC_EOP != getch()) {
Serial.print((char) STK_NOSYNC);
return;
}
Serial.print((char) STK_INSYNC);
if (memtype == 'F') result = flash_read_page(length);
if (memtype == 'E') result = eeprom_read_page(length);
Serial.print(result);
return;
}
void read_signature() {
if (CRC_EOP != getch()) {
Serial.print((char) STK_NOSYNC);
return;
}
Serial.print((char) STK_INSYNC);
uint8_t high = spi_transaction(0x30, 0x00, 0x00, 0x00);
Serial.print((char) high);
uint8_t middle = spi_transaction(0x30, 0x00, 0x01, 0x00);
Serial.print((char) middle);
uint8_t low = spi_transaction(0x30, 0x00, 0x02, 0x00);
Serial.print((char) low);
Serial.print((char) STK_OK);
}
//////////////////////////////////////////
//////////////////////////////////////////
////////////////////////////////////
////////////////////////////////////
int avrisp() {
uint8_t data, low, high;
uint8_t ch = getch();
switch (ch) {
case '0': // signon
empty_reply();
break;
case '1':
if (getch() == CRC_EOP) {
Serial.print((char) STK_INSYNC);
Serial.print("AVR ISP");
Serial.print((char) STK_OK);
}
break;
case 'A':
get_version(getch());
break;
case 'B':
readbytes(20);
set_parameters();
empty_reply();
break;
case 'E': // extended parameters - ignore for now
readbytes(5);
empty_reply();
break;
case 'P':
start_pmode();
empty_reply();
break;
case 'U':
here = getch() + 256 * getch();
empty_reply();
break;
case 0x60: //STK_PROG_FLASH
low = getch();
high = getch();
empty_reply();
break;
case 0x61: //STK_PROG_DATA
data = getch();
empty_reply();
break;
case 0x64: //STK_PROG_PAGE
program_page();
break;
case 0x74: //STK_READ_PAGE
read_page();
break;
case 'V':
universal();
break;
case 'Q':
error=0;
end_pmode();
empty_reply();
break;
case 0x75: //STK_READ_SIGN
read_signature();
break;
// expecting a command, not CRC_EOP
// this is how we can get back in sync
case CRC_EOP:
Serial.print((char) STK_NOSYNC);
break;
// anything else we will return STK_UNKNOWN
default:
if (CRC_EOP == getch())
Serial.print((char)STK_UNKNOWN);
else
Serial.print((char)STK_NOSYNC);
}
}

View file

@ -0,0 +1,338 @@
##############################################################
uno.name=Arduino Uno
uno.upload.protocol=stk500
uno.upload.maximum_size=32256
uno.upload.speed=115200
uno.bootloader.low_fuses=0xff
uno.bootloader.high_fuses=0xde
uno.bootloader.extended_fuses=0x05
uno.bootloader.path=optiboot
uno.bootloader.file=optiboot_atmega328.hex
uno.bootloader.unlock_bits=0x3F
uno.bootloader.lock_bits=0x0F
uno.build.mcu=atmega328p
uno.build.f_cpu=16000000L
uno.build.core=arduino
##############################################################
atmega328.name=Arduino Duemilanove or Nano w/ ATmega328
atmega328.upload.protocol=stk500
atmega328.upload.maximum_size=30720
atmega328.upload.speed=57600
atmega328.bootloader.low_fuses=0xFF
atmega328.bootloader.high_fuses=0xDA
atmega328.bootloader.extended_fuses=0x05
atmega328.bootloader.path=atmega
atmega328.bootloader.file=ATmegaBOOT_168_atmega328.hex
atmega328.bootloader.unlock_bits=0x3F
atmega328.bootloader.lock_bits=0x0F
atmega328.build.mcu=atmega328p
atmega328.build.f_cpu=16000000L
atmega328.build.core=arduino
##############################################################
diecimila.name=Arduino Diecimila, Duemilanove, or Nano w/ ATmega168
diecimila.upload.protocol=stk500
diecimila.upload.maximum_size=14336
diecimila.upload.speed=19200
diecimila.bootloader.low_fuses=0xff
diecimila.bootloader.high_fuses=0xdd
diecimila.bootloader.extended_fuses=0x00
diecimila.bootloader.path=atmega
diecimila.bootloader.file=ATmegaBOOT_168_diecimila.hex
diecimila.bootloader.unlock_bits=0x3F
diecimila.bootloader.lock_bits=0x0F
diecimila.build.mcu=atmega168
diecimila.build.f_cpu=16000000L
diecimila.build.core=arduino
##############################################################
mega2560.name=Arduino Mega 2560
mega2560.upload.protocol=stk500v2
mega2560.upload.maximum_size=258048
mega2560.upload.speed=115200
mega2560.bootloader.low_fuses=0xFF
mega2560.bootloader.high_fuses=0xD8
mega2560.bootloader.extended_fuses=0xFD
mega2560.bootloader.path=stk500v2
mega2560.bootloader.file=stk500boot_v2_mega2560.hex
mega2560.bootloader.unlock_bits=0x3F
mega2560.bootloader.lock_bits=0x0F
mega2560.build.mcu=atmega2560
mega2560.build.f_cpu=16000000L
mega2560.build.core=arduino
##############################################################
mega.name=Arduino Mega (ATmega1280)
mega.upload.protocol=stk500
mega.upload.maximum_size=126976
mega.upload.speed=57600
mega.bootloader.low_fuses=0xFF
mega.bootloader.high_fuses=0xDA
mega.bootloader.extended_fuses=0xF5
mega.bootloader.path=atmega
mega.bootloader.file=ATmegaBOOT_168_atmega1280.hex
mega.bootloader.unlock_bits=0x3F
mega.bootloader.lock_bits=0x0F
mega.build.mcu=atmega1280
mega.build.f_cpu=16000000L
mega.build.core=arduino
##############################################################
mini.name=Arduino Mini
mini.upload.protocol=stk500
mini.upload.maximum_size=14336
mini.upload.speed=19200
mini.bootloader.low_fuses=0xff
mini.bootloader.high_fuses=0xdd
mini.bootloader.extended_fuses=0x00
mini.bootloader.path=atmega
mini.bootloader.file=ATmegaBOOT_168_ng.hex
mini.bootloader.unlock_bits=0x3F
mini.bootloader.lock_bits=0x0F
mini.build.mcu=atmega168
mini.build.f_cpu=16000000L
mini.build.core=arduino
##############################################################
fio.name=Arduino Fio
fio.upload.protocol=stk500
fio.upload.maximum_size=30720
fio.upload.speed=57600
fio.bootloader.low_fuses=0xFF
fio.bootloader.high_fuses=0xDA
fio.bootloader.extended_fuses=0x05
fio.bootloader.path=arduino:atmega
fio.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
fio.bootloader.unlock_bits=0x3F
fio.bootloader.lock_bits=0x0F
fio.build.mcu=atmega328p
fio.build.f_cpu=8000000L
fio.build.core=arduino:arduino
##############################################################
bt328.name=Arduino BT w/ ATmega328
bt328.upload.protocol=stk500
bt328.upload.maximum_size=28672
bt328.upload.speed=19200
bt328.upload.disable_flushing=true
bt328.bootloader.low_fuses=0xff
bt328.bootloader.high_fuses=0xd8
bt328.bootloader.extended_fuses=0x05
bt328.bootloader.path=bt
bt328.bootloader.file=ATmegaBOOT_168_atmega328_bt.hex
bt328.bootloader.unlock_bits=0x3F
bt328.bootloader.lock_bits=0x0F
bt328.build.mcu=atmega328p
bt328.build.f_cpu=16000000L
bt328.build.core=arduino
##############################################################
bt.name=Arduino BT w/ ATmega168
bt.upload.protocol=stk500
bt.upload.maximum_size=14336
bt.upload.speed=19200
bt.upload.disable_flushing=true
bt.bootloader.low_fuses=0xff
bt.bootloader.high_fuses=0xdd
bt.bootloader.extended_fuses=0x00
bt.bootloader.path=bt
bt.bootloader.file=ATmegaBOOT_168.hex
bt.bootloader.unlock_bits=0x3F
bt.bootloader.lock_bits=0x0F
bt.build.mcu=atmega168
bt.build.f_cpu=16000000L
bt.build.core=arduino
##############################################################
lilypad328.name=LilyPad Arduino w/ ATmega328
lilypad328.upload.protocol=stk500
lilypad328.upload.maximum_size=30720
lilypad328.upload.speed=57600
lilypad328.bootloader.low_fuses=0xFF
lilypad328.bootloader.high_fuses=0xDA
lilypad328.bootloader.extended_fuses=0x05
lilypad328.bootloader.path=atmega
lilypad328.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
lilypad328.bootloader.unlock_bits=0x3F
lilypad328.bootloader.lock_bits=0x0F
lilypad328.build.mcu=atmega328p
lilypad328.build.f_cpu=8000000L
lilypad328.build.core=arduino
##############################################################
lilypad.name=LilyPad Arduino w/ ATmega168
lilypad.upload.protocol=stk500
lilypad.upload.maximum_size=14336
lilypad.upload.speed=19200
lilypad.bootloader.low_fuses=0xe2
lilypad.bootloader.high_fuses=0xdd
lilypad.bootloader.extended_fuses=0x00
lilypad.bootloader.path=lilypad
lilypad.bootloader.file=LilyPadBOOT_168.hex
lilypad.bootloader.unlock_bits=0x3F
lilypad.bootloader.lock_bits=0x0F
lilypad.build.mcu=atmega168
lilypad.build.f_cpu=8000000L
lilypad.build.core=arduino
##############################################################
pro5v328.name=Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega328
pro5v328.upload.protocol=stk500
pro5v328.upload.maximum_size=30720
pro5v328.upload.speed=57600
pro5v328.bootloader.low_fuses=0xFF
pro5v328.bootloader.high_fuses=0xDA
pro5v328.bootloader.extended_fuses=0x05
pro5v328.bootloader.path=atmega
pro5v328.bootloader.file=ATmegaBOOT_168_atmega328.hex
pro5v328.bootloader.unlock_bits=0x3F
pro5v328.bootloader.lock_bits=0x0F
pro5v328.build.mcu=atmega328p
pro5v328.build.f_cpu=16000000L
pro5v328.build.core=arduino
##############################################################
pro5v.name=Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega168
pro5v.upload.protocol=stk500
pro5v.upload.maximum_size=14336
pro5v.upload.speed=19200
pro5v.bootloader.low_fuses=0xff
pro5v.bootloader.high_fuses=0xdd
pro5v.bootloader.extended_fuses=0x00
pro5v.bootloader.path=atmega
pro5v.bootloader.file=ATmegaBOOT_168_diecimila.hex
pro5v.bootloader.unlock_bits=0x3F
pro5v.bootloader.lock_bits=0x0F
pro5v.build.mcu=atmega168
pro5v.build.f_cpu=16000000L
pro5v.build.core=arduino
##############################################################
pro328.name=Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328
pro328.upload.protocol=stk500
pro328.upload.maximum_size=30720
pro328.upload.speed=57600
pro328.bootloader.low_fuses=0xFF
pro328.bootloader.high_fuses=0xDA
pro328.bootloader.extended_fuses=0x05
pro328.bootloader.path=atmega
pro328.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
pro328.bootloader.unlock_bits=0x3F
pro328.bootloader.lock_bits=0x0F
pro328.build.mcu=atmega328p
pro328.build.f_cpu=8000000L
pro328.build.core=arduino
##############################################################
pro.name=Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega168
pro.upload.protocol=stk500
pro.upload.maximum_size=14336
pro.upload.speed=19200
pro.bootloader.low_fuses=0xc6
pro.bootloader.high_fuses=0xdd
pro.bootloader.extended_fuses=0x00
pro.bootloader.path=atmega
pro.bootloader.file=ATmegaBOOT_168_pro_8MHz.hex
pro.bootloader.unlock_bits=0x3F
pro.bootloader.lock_bits=0x0F
pro.build.mcu=atmega168
pro.build.f_cpu=8000000L
pro.build.core=arduino
##############################################################
atmega168.name=Arduino NG or older w/ ATmega168
atmega168.upload.protocol=stk500
atmega168.upload.maximum_size=14336
atmega168.upload.speed=19200
atmega168.bootloader.low_fuses=0xff
atmega168.bootloader.high_fuses=0xdd
atmega168.bootloader.extended_fuses=0x00
atmega168.bootloader.path=atmega
atmega168.bootloader.file=ATmegaBOOT_168_ng.hex
atmega168.bootloader.unlock_bits=0x3F
atmega168.bootloader.lock_bits=0x0F
atmega168.build.mcu=atmega168
atmega168.build.f_cpu=16000000L
atmega168.build.core=arduino
##############################################################
atmega8.name=Arduino NG or older w/ ATmega8
atmega8.upload.protocol=stk500
atmega8.upload.maximum_size=7168
atmega8.upload.speed=19200
atmega8.bootloader.low_fuses=0xdf
atmega8.bootloader.high_fuses=0xca
atmega8.bootloader.path=atmega8
atmega8.bootloader.file=ATmegaBOOT.hex
atmega8.bootloader.unlock_bits=0x3F
atmega8.bootloader.lock_bits=0x0F
atmega8.build.mcu=atmega8
atmega8.build.f_cpu=16000000L
atmega8.build.core=arduino

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,245 @@
:020000021000EC
:10F000000C9472F80C9492F80C9492F80C9492F878
:10F010000C9492F80C9492F80C9492F80C9492F848
:10F020000C9492F80C9492F80C9492F80C9492F838
:10F030000C9492F80C9492F80C9492F80C9492F828
:10F040000C9492F80C9492F80C9492F80C9492F818
:10F050000C9492F80C9492F80C9492F80C9492F808
:10F060000C9492F80C9492F80C9492F80C9492F8F8
:10F070000C9492F80C9492F80C9492F80C9492F8E8
:10F080000C9492F80C9492F80C9492F80C9492F8D8
:10F090000C9492F80C9492F80C9492F80C9492F8C8
:10F0A0000C9492F80C9492F80C9492F80C9492F8B8
:10F0B0000C9492F80C9492F80C9492F80C9492F8A8
:10F0C0000C9492F80C9492F80C9492F80C9492F898
:10F0D0000C9492F80C9492F80C9492F80C9492F888
:10F0E0000C9492F811241FBECFEFD1E2DEBFCDBF4A
:10F0F00012E0A0E0B2E0EEEDFEEF01E00BBF02C0D7
:10F1000007900D92A833B107D9F71BBE13E0A8E30F
:10F11000B2E001C01D92A334B107E1F70E9412FAD8
:10F120000C946DFF0C9400F8982F959595959595F6
:10F130009595905D8F708A301CF1282F295A809107
:10F140003802813019F0823071F008958091C0004A
:10F1500085FFFCCF9093C6008091C00085FFFCCF57
:10F160002093C60008958091C80085FFFCCF90933E
:10F17000CE008091C80085FFFCCF2093CE0008957B
:10F18000282F205DDCCF982F80913802813019F034
:10F19000823041F008958091C00085FFFCCF9093AC
:10F1A000C60008958091C80085FFFCCF9093CE00E3
:10F1B0000895EF92FF920F931F9380913802813050
:10F1C00069F1823031F080E01F910F91FF90EF9054
:10F1D0000895EE24FF2487018091C80087FD17C0A1
:10F1E0000894E11CF11C011D111D81E4E81682E464
:10F1F000F8068FE0080780E0180770F3E0913A0204
:10F20000F0913B0209958091C80087FFE9CF80917A
:10F21000CE001F910F91FF90EF900895EE24FF24F0
:10F2200087018091C00087FD17C00894E11CF11C84
:10F23000011D111D81E4E81682E4F8068FE008073D
:10F2400080E0180770F3E0913A02F0913B020995D3
:10F250008091C00087FFE9CF8091C6001F910F9178
:10F26000FF90EF9008950E94D9F8982F809138026E
:10F27000813049F0823091F091366CF490330CF08B
:10F280009053892F08958091C00085FFFCCF909303
:10F29000C60091369CF39755892F08958091C80038
:10F2A00085FFFCCF9093CE00E7CF1F930E9433F9E8
:10F2B000182F0E9433F91295107F810F1F91089526
:10F2C000982F20913802992339F0213031F02230E3
:10F2D00061F091509923C9F708958091C00087FF8C
:10F2E000FCCF8091C6009150F5CF8091C80087FF78
:10F2F000FCCF8091CE009150EDCF1F93182F0E942C
:10F30000D9F8803249F0809139028F5F80933902B9
:10F31000853091F11F910895809138028130B9F0C4
:10F320008230C1F78091C80085FFFCCF84E18093D3
:10F33000CE008091C80085FFFCCF1093CE00809155
:10F34000C80085FFFCCF80E18093CE00E3CF8091A1
:10F35000C00085FFFCCF84E18093C6008091C0008F
:10F3600085FFFCCF1093C6008091C00085FFFCCFC5
:10F3700080E18093C600CECFE0913A02F0913B024B
:10F3800009951F9108950E94D9F8803241F080912B
:10F3900039028F5F80933902853029F10895809179
:10F3A0003802813089F08230C9F78091C80085FF2A
:10F3B000FCCF84E18093CE008091C80085FFFCCF14
:10F3C00080E18093CE0008958091C00085FFFCCF3E
:10F3D00084E18093C6008091C00085FFFCCF80E16E
:10F3E0008093C6000895E0913A02F0913B0209959E
:10F3F000089540E951E08823A1F02F9A28EE33E0E8
:10F40000FA013197F1F721503040D1F72F9828EECB
:10F4100033E0FA013197F1F721503040D1F78150B4
:10F4200061F708952F923F924F925F926F927F9271
:10F430008F929F92AF92BF92CF92DF92EF92FF9204
:10F440000F931F93CF93DF93000081E080933802E6
:10F4500080E18093C4001092C5001092C00086E045
:10F460008093C20088E18093C1006898709A279ABF
:10F4700081E00E94F9F9E4E1EE2E7EE1D72E67E902
:10F48000C62E53E0B52E40E1A42E9924939431E486
:10F49000832E26E5722E92E5692E80E2582E09E42D
:10F4A000402E13E5312EB0E52B2E0E94D9F8803383
:10F4B000C9F1813309F452C0803409F4C8C08134E1
:10F4C00009F4EAC0823489F1853409F4CAC0803570
:10F4D00049F1823539F1813529F1853509F4ECC0DE
:10F4E000863509F409C1843609F428C1843709F442
:10F4F000ABC1853709F473C2863709F4D9C08132AC
:10F5000009F4B7C2809139028F5F80933902853048
:10F5100061F6E0913A02F0913B0209950E94D9F818
:10F52000803339F60E94C3F9C0CF2091380293E1AD
:10F5300005C0223061F09923A9F391502130C9F719
:10F540008091C00087FFFCCF8091C600F4CF8091EE
:10F55000C80087FFFCCF8091CE00EDCF0E94D9F884
:10F56000803281F6809138028130D1F1823009F009
:10F570009CCF8091C80085FFFCCFE092CE008091A7
:10F58000C80085FFFCCF8092CE008091C80085FF27
:10F59000FCCF7092CE008091C80085FFFCCF6092B6
:10F5A000CE008091C80085FFFCCF5092CE008091A4
:10F5B000C80085FFFCCF4092CE008091C80085FF37
:10F5C000FCCF3092CE008091C80085FFFCCF209206
:10F5D000CE008091C80085FFFCCFA092CE0065CF01
:10F5E0008091C00085FFFCCFE092C6008091C000F2
:10F5F00085FFFCCF8092C6008091C00085FFFCCFC4
:10F600007092C6008091C00085FFFCCF6092C6005A
:10F610008091C00085FFFCCF5092C6008091C00051
:10F6200085FFFCCF4092C6008091C00085FFFCCFD3
:10F630003092C6008091C00085FFFCCF2092C600AA
:10F640008091C00085FFFCCFA092C6002ECF0E9403
:10F65000D9F8863808F466CF0E94D9F80E94C3F919
:10F6600024CF2091380294E0213041F0223069F01B
:10F67000992309F457CF91502130C1F78091C000F0
:10F6800087FFFCCF8091C600F3CF8091C80087FF31
:10F69000FCCF8091CE00ECCF0E94D9F8803841F1A8
:10F6A000813809F447C0823809F4CAC08839E1F0CA
:10F6B00080E00E947DF9F9CE0E94D9F880933C0247
:10F6C0000E94D9F880933D020E94C3F9EECE0E94B9
:10F6D000D9F80E94D9F8182F0E94D9F8112309F4FB
:10F6E0007EC2113009F40AC283E00E947DF9DDCEAA
:10F6F00082E00E947DF9D9CE0E94D9F8803339F397
:10F700002091380292E0213039F0223061F09923C3
:10F7100079F291502130C9F78091C00087FFFCCF6A
:10F720008091C600F4CF8091C80087FFFCCF809104
:10F73000CE00EDCF81E00E947DF9B7CE0E94D9F8CE
:10F7400080933F030E94D9F880933E038091420347
:10F750008E7F809342030E94D9F8853409F4B3C1A7
:10F7600080913E0390913F03892B89F000E010E0E7
:10F770000E94D9F8F801E25CFD4F80830F5F1F4FB4
:10F7800080913E0390913F030817190788F30E9468
:10F79000D9F8803209F0B6CE8091420380FFB2C121
:10F7A00040913C0250913D02440F551F50933D0241
:10F7B00040933C0260913E0370913F0361157105D7
:10F7C000F1F080E090E09A01280F391FFC01E25C23
:10F7D000FD4FE081F999FECF1FBA32BD21BDE0BDDA
:10F7E0000FB6F894FA9AF99A0FBE01968617970702
:10F7F00050F3460F571F50933D0240933C028091B7
:10F800003802813081F0823009F04FCE8091C800FB
:10F8100085FFFCCFE092CE008091C80085FFFCCF31
:10F82000A092CE0042CE8091C00085FFFCCFE09236
:10F83000C6008091C00085FFFCCFA092C60035CEE7
:10F8400080E10E947DF931CE0E94D9F880933F0378
:10F850000E94D9F880933E0320913C0230913D02F2
:10F8600037FD46C1809142038D7F80934203220F72
:10F87000331F30933D0220933C020E94D9F8853417
:10F8800009F430C1809142038E7F809342030E942D
:10F89000D9F8803209F009CE60913802613009F45C
:10F8A0006FC0623009F473C000913E0310913F03B2
:10F8B0000115110509F440C080914203782F717041
:10F8C000F82EF69481E0F82240913C0250913D02DE
:10F8D00020E030E013C0FF2009F060C0FA019491ED
:10F8E000613009F43BC0623009F441C0CA0101969D
:10F8F0002F5F3F4FAC0120173107D0F4772359F326
:10F90000F999FECF52BD41BDF89A90B56130F9F03A
:10F91000623061F78091C80085FFFCCF9093CE00E4
:10F92000CA0101962F5F3F4FAC012017310730F31A
:10F9300090933D0280933C02613009F4CAC062306A
:10F9400009F0B3CD8091C80085FFFCCF46CE8091F1
:10F95000C00085FFFCCF9093C600C8CF8091C00047
:10F9600085FDF9CF8091C00085FFF8CFF4CF80915D
:10F97000C80085FDD3CF8091C80085FFF8CFCECFDA
:10F980008091C00085FFFCCFE092C6008DCF8091B2
:10F99000C80085FFFCCFE092CE0086CFCA01A0E070
:10F9A000B0E080509040AF4FBF4FABBFFC0197918C
:10F9B000613061F0623009F099CF8091C80085FD17
:10F9C000ADCF8091C80085FFF8CFA8CF8091C0004F
:10F9D00085FDC1CF8091C00085FFF8CFBCCF0E94CC
:10F9E000D9F8803209F08ECD80913802813011F142
:10F9F000823009F05ACD8091C80085FFFCCFE0929B
:10FA0000CE008091C80085FFFCCFD092CE008091BF
:10FA1000C80085FFFCCFC092CE008091C80085FF52
:10FA2000FCCFB092CE008091C80085FFFCCFA092A1
:10FA3000CE003BCD8091C00085FFFCCFE092C60098
:10FA40008091C00085FFFCCFD092C6008091C0009D
:10FA500085FFFCCFC092C6008091C00085FFFCCF1F
:10FA6000B092C6008091C00085FFFCCFA092C60076
:10FA70001CCD0E94D9F8813209F017CD0E94D9F827
:10FA8000813209F012CD279A2F98109240032091CD
:10FA90003802E1E491E00EC0223009F4A4C0909352
:10FAA0004003E92FF0E0E050FE4FE0819F5FEE233E
:10FAB00009F4A0C0213081F78091C00085FFFCCF00
:10FAC000E093C600ECCF80914203816080934203B3
:10FAD00047CE8091C00085FDB7CD8091C00085FFE5
:10FAE000F8CFB2CD80914203816080934203CFCEA4
:10FAF00080914203826080934203B9CE87E90E94DD
:10FB00007DF9D3CC80913D028823880F880B892111
:10FB1000809341038BBF80913C0290913D02880FFE
:10FB2000991F90933D0280933C0280913E0380FF99
:10FB300009C080913E0390913F03019690933F034B
:10FB400080933E03F894F999FECF1127E0913C028F
:10FB5000F0913D02CEE3D2E080913E0390913F03CD
:10FB6000103091F40091570001700130D9F303E097
:10FB700000935700E8950091570001700130D9F3C8
:10FB800001E100935700E895099019900091570002
:10FB900001700130D9F301E000935700E895139507
:10FBA000103898F011270091570001700130D9F3F7
:10FBB00005E000935700E89500915700017001306F
:10FBC000D9F301E100935700E8953296029709F0C6
:10FBD000C7CF103011F00296E5CF112410CE8EE180
:10FBE0000E947DF962CC8091C80085FFFCCFE09334
:10FBF000CE0055CF7AE0B72E6DE0A62E5AE3952EB3
:10FC000040E2842E3DE3732E90E3692E81E3582E6B
:10FC1000213009F442C0223009F45FC00E94D9F8B3
:10FC2000982F20913802213089F1223009F44EC0FA
:10FC3000943709F46BC0923709F405C1973709F47A
:10FC40007BC0953799F0923609F4BDC09A3601F71A
:10FC5000E0913A02F0913B02099520913802D8CF09
:10FC60008091C00085FFFCCF9093C6000E94D9F818
:10FC7000982F80913802813099F38230B9F78091C2
:10FC8000C80085FFFCCF9093CE00F0CF8091C000DC
:10FC900085FFFCCF9093C600CBCF8091C00085FF3D
:10FCA000FCCFB092C6008091C00085FFFCCFA0922F
:10FCB000C6008091C00085FFFCCF9092C600809165
:10FCC000C00085FFFCCF8092C600A8CF8091C800FD
:10FCD00085FFFCCF9093CE00ABCF8091C80085FF0D
:10FCE000FCCFB092CE008091C80085FFFCCFA092DF
:10FCF000CE008091C80085FFFCCF9092CE0080910D
:10FD0000C80085FFFCCF8092CE0088CF1F9947C0E6
:10FD10002F9A213051F0223009F07ACF8091C8001B
:10FD200085FFFCCF6092CE0073CF8091C00085FF2D
:10FD3000FCCF6092C6006CCF0E94D9F8982F8091BA
:10FD400038028130F1F0823009F4ABC00E9455F9DD
:10FD5000082F0E9455F9182F0E94D9F8982F8091EA
:10FD600038028130A9F0823009F4A2C00E9455F90E
:10FD7000D02ECC24F601E10FF11D808320913802B2
:10FD800047CF8091C00085FFFCCF9093C600DECFA7
:10FD90008091C00085FFFCCF9093C600E7CF2F98DD
:10FDA000213051F0223009F033CF8091C80085FF17
:10FDB000FCCF5092CE002CCF8091C00085FFFCCFAD
:10FDC0005092C60025CF213041F1223081F080E8E9
:10FDD00085BF109274001092750080E091E1FC01E3
:10FDE000819180E091E13097D1F3CF01F8CF8091FC
:10FDF000C80085FFFCCF82E68093CE008091C800CA
:10FE000085FFFCCF85E78093CE008091C80085FFF9
:10FE1000FCCF83E78093CE00DACF8091C00085FFCE
:10FE2000FCCF82E68093C6008091C00085FFFCCFA6
:10FE300085E78093C6008091C00085FFFCCF83E7F3
:10FE40008093C600C4CF0E94D9F8982F80913802C1
:10FE50008130C9F08230D1F10E9455F9182F0E94EB
:10FE600055F9982F809138028130A1F0823039F114
:10FE7000F12EEE24F701E90FF11D80810E9494F824
:10FE800020913802C5CE8091C00085FFFCCF9093B1
:10FE9000C600E2CF8091C00085FFFCCF7092C60003
:10FEA000E7CF8091C80085FFFCCF9093CE004ECF66
:10FEB0008091C80085FFFCCF9093CE0057CF8091F2
:10FEC000C80085FFFCCF7092CE00D2CF8091C800D1
:0EFED00085FFFCCF9093CE00BFCFF894FFCFFC
:10FEDE0041546D656761424F4F54202F204172642B
:10FEEE0075696E6F204D656761202D20284329208E
:10FEFE0041726475696E6F204C4C43202D20303951
:08FF0E00303933300A0D008088
:040000031000F000F9
:00000001FF

View file

@ -0,0 +1,125 @@
:107800000C94343C0C94513C0C94513C0C94513CE1
:107810000C94513C0C94513C0C94513C0C94513CB4
:107820000C94513C0C94513C0C94513C0C94513CA4
:107830000C94513C0C94513C0C94513C0C94513C94
:107840000C94513C0C94513C0C94513C0C94513C84
:107850000C94513C0C94513C0C94513C0C94513C74
:107860000C94513C0C94513C11241FBECFEFD8E036
:10787000DEBFCDBF11E0A0E0B1E0ECE9FFE702C060
:1078800005900D92A230B107D9F712E0A2E0B1E065
:1078900001C01D92AD30B107E1F70E942D3D0C945F
:1078A000CC3F0C94003C982F959595959595959582
:1078B000905D8F708A307CF0282F295A8091C0000B
:1078C00085FFFCCF9093C6008091C00085FFFCCF60
:1078D0002093C6000895282F205DF0CF982F809127
:1078E000C00085FFFCCF9093C6000895EF92FF92F1
:1078F0000F931F93EE24FF2487018091C00087FD22
:1079000017C00894E11CF11C011D111D81E4E8164B
:1079100082E4F8068FE0080780E0180770F3E09132
:107920000401F091050109958091C00087FFE9CF1E
:107930008091C6001F910F91FF90EF9008950E94D3
:10794000763C982F8091C00085FFFCCF9093C600B5
:1079500091362CF490330CF09053892F089597555D
:10796000892F08951F930E949F3C182F0E949F3CCF
:107970001295107F810F1F9108951F93182F882350
:1079800021F00E94763C1150E1F71F9108951F935A
:10799000182F0E94763C803249F0809103018F5F5E
:1079A000809303018530C1F01F9108958091C0003C
:1079B00085FFFCCF84E18093C6008091C00085FFE5
:1079C000FCCF1093C6008091C00085FFFCCF80E102
:1079D0008093C6001F910895E0910401F091050184
:1079E00009951F9108950E94763C803241F0809164
:1079F00003018F5F80930301853081F008958091AA
:107A0000C00085FFFCCF84E18093C6008091C00058
:107A100085FFFCCF80E18093C6000895E0910401CA
:107A2000F09105010995089540E951E08823A1F0FE
:107A30002D9A28EE33E0FA013197F1F721503040CA
:107A4000D1F72D9828EE33E0FA013197F1F7215064
:107A50003040D1F7815061F708953F924F925F9285
:107A60006F927F928F929F92AF92BF92CF92DF924E
:107A7000EF92FF920F931F93CF93DF93000080E16B
:107A80008093C4001092C50088E18093C10086E015
:107A90008093C2005098589A259A81E00E94143D24
:107AA00024E1F22E9EE1E92E85E9D82E0FE0C02ECA
:107AB00010E1B12EAA24A394B1E49B2EA6E58A2E50
:107AC000F2E57F2EE0E26E2E79E4572E63E5462E36
:107AD00050E5352E0E94763C8033B1F18133B9F107
:107AE000803409F46FC0813409F476C0823409F41B
:107AF00085C0853409F488C0803531F1823521F1A3
:107B0000813511F1853509F485C0863509F48DC0BC
:107B1000843609F496C0843709F403C1853709F423
:107B200072C1863709F466C0809103018F5F80932C
:107B30000301853079F6E0910401F0910501099582
:107B40000E94763C803351F60E94F33CC3CF0E94E2
:107B5000763C803249F78091C00085FFFCCFF092DF
:107B6000C6008091C00085FFFCCF9092C600809136
:107B7000C00085FFFCCF8092C6008091C00085FFC9
:107B8000FCCF7092C6008091C00085FFFCCF609250
:107B9000C6008091C00085FFFCCF5092C600809146
:107BA000C00085FFFCCF4092C6008091C00085FFD9
:107BB000FCCF3092C6008091C00085FFFCCFB09210
:107BC000C60088CF0E94763C863808F4BDCF0E945C
:107BD000763C0E94F33C7ECF0E94763C803809F4CC
:107BE0009CC0813809F40BC1823809F43CC1883942
:107BF00009F48FC080E00E94C73C6CCF84E10E94F2
:107C0000BD3C0E94F33C66CF85E00E94BD3C0E94D3
:107C1000F33C60CF0E94763C809306010E94763C44
:107C2000809307010E94F33C55CF0E94763C80333D
:107C300009F41DC183E00E94BD3C80E00E94C73C66
:107C400049CF0E94763C809309020E94763C809343
:107C5000080280910C028E7F80930C020E94763C79
:107C6000853409F415C18091080290910902892B8D
:107C700089F000E010E00E94763CF801E85FFE4FDA
:107C800080830F5F1F4F80910802909109020817AF
:107C9000190788F30E94763C803209F045CF809125
:107CA0000C0280FF01C16091060170910701660F0F
:107CB000771F7093070160930601A0910802B091AD
:107CC00009021097C9F0E8E0F1E09B01AD014E0F09
:107CD0005F1FF999FECF32BD21BD819180BDFA9A17
:107CE000F99A2F5F3F4FE417F50799F76A0F7B1F4B
:107CF00070930701609306018091C00085FFFCCF5F
:107D0000F092C6008091C00085FFFCCFB092C60003
:107D1000E1CE83E00E94C73CDDCE82E00E94C73CFA
:107D2000D9CE0E94763C809309020E94763C8093D3
:107D300008028091060190910701880F991F909386
:107D40000701809306010E94763C853409F4A6C0A1
:107D500080910C028E7F80930C020E94763C8032D0
:107D600009F0B8CE8091C00085FFFCCFF092C6002C
:107D7000609108027091090261157105B9F140E046
:107D800050E080910C02A82FA170B82FB27011C0E2
:107D9000BB2309F45CC0E0910601F0910701319624
:107DA000F0930701E09306014F5F5F4F46175707B7
:107DB000E8F4AA2369F3F999FECF209106013091E6
:107DC000070132BD21BDF89A90B58091C00085FFB2
:107DD000FCCF9093C6002F5F3F4F30930701209355
:107DE00006014F5F5F4F4617570718F38091C00099
:107DF00085FDE5CE8091C00085FFF8CFE0CE81E023
:107E00000E94C73C67CE0E94763C803209F08CCE3F
:107E10008091C00085FFFCCFF092C6008091C00029
:107E200085FFFCCFE092C6008091C00085FFFCCFAB
:107E3000D092C6008091C00085FFFCCFC092C600E2
:107E40008091C00085FFFCCFB092C60043CEE09188
:107E50000601F091070194918091C00085FFFCCF4D
:107E60009093C6009CCF80E10E94C73C33CE0E9415
:107E7000763C0E94763C182F0E94763C112309F430
:107E800083C0113009F484C08FE00E94C73C22CE29
:107E900080910C02816080930C02E5CE80910C02EF
:107EA000816080930C0259CF809107018823880F4D
:107EB000880B8A2180930B02809106019091070123
:107EC000880F991F90930701809306018091080203
:107ED00080FF09C080910802909109020196909359
:107EE000090280930802F894F999FECF1127E091D6
:107EF0000601F0910701C8E0D1E08091080290915D
:107F00000902103091F40091570001700130D9F34B
:107F100003E000935700E89500915700017001308D
:107F2000D9F301E100935700E89509901990009169
:107F3000570001700130D9F301E000935700E89534
:107F40001395103498F011270091570001700130FB
:107F5000D9F305E000935700E895009157000170B0
:107F60000130D9F301E100935700E895329602976A
:107F700009F0C7CF103011F00296E5CF112480919F
:107F8000C00085FFB9CEBCCE8EE10E94C73CA2CD19
:0C7F900085E90E94C73C9ECDF894FFCF0D
:027F9C00800063
:040000030000780081
:00000001FF

View file

@ -0,0 +1,124 @@
:107800000C94343C0C94513C0C94513C0C94513CE1
:107810000C94513C0C94513C0C94513C0C94513CB4
:107820000C94513C0C94513C0C94513C0C94513CA4
:107830000C94513C0C94513C0C94513C0C94513C94
:107840000C94513C0C94513C0C94513C0C94513C84
:107850000C94513C0C94513C0C94513C0C94513C74
:107860000C94513C0C94513C11241FBECFEFD8E036
:10787000DEBFCDBF11E0A0E0B1E0EAE8FFE702C063
:1078800005900D92A230B107D9F712E0A2E0B1E065
:1078900001C01D92AD30B107E1F70E942D3D0C945F
:1078A000C33F0C94003C982F95959595959595958B
:1078B000905D8F708A307CF0282F295A8091C0000B
:1078C00085FFFCCF9093C6008091C00085FFFCCF60
:1078D0002093C6000895282F205DF0CF982F809127
:1078E000C00085FFFCCF9093C6000895EF92FF92F1
:1078F0000F931F93EE24FF2487018091C00087FD22
:1079000017C00894E11CF11C011D111D81E2E8164D
:1079100081EAF80687E0080780E0180770F3E09135
:107920000401F091050109958091C00087FFE9CF1E
:107930008091C6001F910F91FF90EF9008950E94D3
:10794000763C982F8091C00085FFFCCF9093C600B5
:1079500091362CF490330CF09053892F089597555D
:10796000892F08951F930E949F3C182F0E949F3CCF
:107970001295107F810F1F9108951F93182F882350
:1079800021F00E94763C1150E1F71F9108951F935A
:10799000182F0E94763C803249F0809103018F5F5E
:1079A000809303018530C1F01F9108958091C0003C
:1079B00085FFFCCF84E18093C6008091C00085FFE5
:1079C000FCCF1093C6008091C00085FFFCCF80E102
:1079D0008093C6001F910895E0910401F091050184
:1079E00009951F9108950E94763C803241F0809164
:1079F00003018F5F80930301853081F008958091AA
:107A0000C00085FFFCCF84E18093C6008091C00058
:107A100085FFFCCF80E18093C6000895E0910401CA
:107A2000F09105010995089548EC50E08823A1F0F4
:107A30002D9A28EE33E0FA013197F1F721503040CA
:107A4000D1F72D9828EE33E0FA013197F1F7215064
:107A50003040D1F7815061F708953F924F925F9285
:107A60006F927F928F929F92AF92BF92CF92DF924E
:107A7000EF92FF920F931F93CF93DF93000082E06A
:107A80008093C00080E18093C4001092C50088E11B
:107A90008093C10086E08093C2005098589A259A3E
:107AA00081E00E94143D24E1F22E9EE1E92E85E959
:107AB000D82E0FE0C02E10E1B12EAA24A394B1E479
:107AC0009B2EA6E58A2EF2E57F2EE0E26E2E79E46B
:107AD000572E63E5462E50E5352E0E94763C8033C6
:107AE000B1F18133B9F1803409F46FC0813409F404
:107AF00076C0823409F485C0853409F488C08035A5
:107B000031F1823521F1813511F1853509F485C0D6
:107B1000863509F48DC0843609F496C0843709F49B
:107B200003C1853709F472C1863709F466C08091B4
:107B300003018F5F80930301853079F6E0910401A2
:107B4000F091050109950E94763C803351F60E9420
:107B5000F33CC3CF0E94763C803249F78091C0004D
:107B600085FFFCCFF092C6008091C00085FFFCCF5E
:107B70009092C6008091C00085FFFCCF8092C60025
:107B80008091C00085FFFCCF7092C6008091C0003C
:107B900085FFFCCF6092C6008091C00085FFFCCFBE
:107BA0005092C6008091C00085FFFCCF4092C60075
:107BB0008091C00085FFFCCF3092C6008091C0004C
:107BC00085FFFCCFB092C60088CF0E94763C8638F5
:107BD00008F4BDCF0E94763C0E94F33C7ECF0E9409
:107BE000763C803809F49CC0813809F40BC1823896
:107BF00009F430C1883909F48FC080E00E94C73C85
:107C00006CCF84E10E94BD3C0E94F33C66CF85E0CE
:107C10000E94BD3C0E94F33C60CF0E94763C809362
:107C200006010E94763C809307010E94F33C55CFE9
:107C30000E94763C803309F411C183E00E94BD3C70
:107C400080E00E94C73C49CF0E94763C80930902A5
:107C50000E94763C8093080280910C028E7F809374
:107C60000C020E94763C853409F409C18091080217
:107C700090910902892B89F000E010E00E94763C87
:107C8000F801E85FFE4F80830F5F1F4F809108026D
:107C9000909109020817190788F30E94763C8032F8
:107CA00009F045CF80910C0280FFF5C0609106017C
:107CB00070910701660F771F7093070160930601AB
:107CC000A0910802B09109021097C9F0E8E0F1E034
:107CD0009B01AD014E0F5F1FF999FECF32BD21BD53
:107CE000819180BDFA9AF99A2F5F3F4FE417F5070B
:107CF00099F76A0F7B1F70930701609306018091CB
:107D0000C00085FFFCCFF092C6008091C00085FFC7
:107D1000FCCFB092C600E1CE83E00E94C73CDDCE2E
:107D200082E00E94C73CD9CE0E94763C8093090233
:107D30000E94763C80930802809106019091070191
:107D4000880F991F90930701809306010E94763C4B
:107D5000853409F49AC080910C028E7F80930C02C6
:107D60000E94763C803209F0B8CE8091C00085FF39
:107D7000FCCFF092C600A0910802B09109021097C2
:107D8000C1F180910C02082F0170182F1695117007
:107D9000E0910601F0910701AF014F5F5F4FBA011B
:107DA00020E030E00023B1F4112339F49491809164
:107DB000C00085FFFCCF9093C6002F5F3F4FCB01E3
:107DC0000196FA012A173B0780F4BC014F5F5F4F11
:107DD000002351F3F999FECFF2BDE1BDF89A90B5B9
:107DE0008091C00085FFFCCFE6CF709307016093C0
:107DF00006018091C00085FDE5CE8091C00085FF21
:107E0000F8CFE0CE81E00E94C73C67CE0E94763C6E
:107E1000803209F08CCE8091C00085FFFCCFF092BB
:107E2000C6008091C00085FFFCCFE092C600809123
:107E3000C00085FFFCCFD092C6008091C00085FFB6
:107E4000FCCFC092C6008091C00085FFFCCFB092ED
:107E5000C60043CE80E10E94C73C3FCE0E94763CE4
:107E60000E94763C182F0E94763C112309F483C0AF
:107E7000113009F484C08FE00E94C73C2ECE80915F
:107E80000C02816080930C02F1CE80910C02816023
:107E900080930C0265CF809107018823880F880B9F
:107EA0008A2180930B028091060190910701880F2F
:107EB000991F90930701809306018091080280FF2B
:107EC00009C08091080290910902019690930902DD
:107ED00080930802F894F999FECF1127E0910601EA
:107EE000F0910701C8E0D1E0809108029091090269
:107EF000103091F40091570001700130D9F303E084
:107F000000935700E8950091570001700130D9F3B4
:107F100001E100935700E8950990199000915700EE
:107F200001700130D9F301E000935700E8951395F3
:107F3000103498F011270091570001700130D9F3E7
:107F400005E000935700E89500915700017001305B
:107F5000D9F301E100935700E8953296029709F0B2
:107F6000C7CF103011F00296E5CF11248091C000E8
:107F700085FFC5CEC8CE8EE10E94C73CAECD85E957
:0A7F80000E94C73CAACDF894FFCF81
:027F8A00800075
:040000030000780081
:00000001FF

View file

@ -0,0 +1,126 @@
:103800000C94341C0C94511C0C94511C0C94511CA1
:103810000C94511C0C94511C0C94511C0C94511C74
:103820000C94511C0C94511C0C94511C0C94511C64
:103830000C94511C0C94511C0C94511C0C94511C54
:103840000C94511C0C94511C0C94511C0C94511C44
:103850000C94511C0C94511C0C94511C0C94511C34
:103860000C94511C0C94511C11241FBECFEFD4E0BA
:10387000DEBFCDBF11E0A0E0B1E0E4EAFFE302C0AB
:1038800005900D92A230B107D9F712E0A2E0B1E0A5
:1038900001C01D92AD30B107E1F70E94361D0C94B6
:1038A000D01F0C94001C982F9595959595959595FE
:1038B000905D8F708A307CF0282F295A8091C0004B
:1038C00085FFFCCF9093C6008091C00085FFFCCFA0
:1038D0002093C6000895282F205DF0CF982F809167
:1038E000C00085FFFCCF9093C6000895EF92FF9231
:1038F0000F931F93EE24FF2487018091C00087FD62
:1039000017C00894E11CF11C011D111D81E4E8168B
:1039100082E4F8068FE0080780E0180770F3E09172
:103920000401F091050109958091C00087FFE9CF5E
:103930008091C6001F910F91FF90EF9008950E9413
:10394000761C982F8091C00085FFFCCF9093C60015
:1039500091362CF490330CF09053892F089597559D
:10396000892F08951F930E949F1C182F0E949F1C4F
:103970001295107F810F1F910895882351F0982F81
:1039800091508091C00087FFFCCF8091C6009923A1
:10399000B9F708951F93182F0E94761C803249F0C2
:1039A000809103018F5F809303018530C1F01F91E7
:1039B00008958091C00085FFFCCF84E18093C6000C
:1039C0008091C00085FFFCCF1093C6008091C0009D
:1039D00085FFFCCF80E18093C6001F910895E091A0
:1039E0000401F091050109951F9108950E94761C2C
:1039F000803241F0809103018F5F80930301853015
:103A000081F008958091C00085FFFCCF84E1809310
:103A1000C6008091C00085FFFCCF80E18093C60086
:103A20000895E0910401F09105010995089510921F
:103A30000A028823D1F090E040E951E02D9A28EE67
:103A400033E0FA013197F1F721503040D1F72D984A
:103A500028EE33E0FA013197F1F721503040D1F7E9
:103A60009F5F981758F380930A0208953F924F92F0
:103A70005F926F927F928F929F92AF92BF92CF92FE
:103A8000DF92EF92FF920F931F93CF93DF9300008B
:103A900083E38093C4001092C50088E18093C10045
:103AA00086E08093C2005098589A259A81E00E943F
:103AB000171D44E1F42E3EE1E32E24E9D22E96E0D8
:103AC000C92E80E1B82EAA24A39401E4902E16E515
:103AD000812EB2E57B2EA0E26A2EF9E45F2EE3E5AB
:103AE0004E2E70E5372E0E94761C8033B1F1813363
:103AF00009F441C0803409F479C0813409F48CC0E0
:103B0000823471F1853409F47BC0803531F182351E
:103B100021F1813511F1853509F48DC0863509F41F
:103B20009DC0843609F4AEC0843709F41BC18537C3
:103B300009F485C1863709F47AC0809103018F5F4B
:103B400080930301853079F6E0910401F09105013D
:103B500009950E94761C803351F60E94F61CC3CF53
:103B600093E18091C00087FFFCCF8091C60099232C
:103B7000A1F39150F6CF0E94761C8032F1F680912D
:103B8000C00085FFFCCFF092C6008091C00085FF89
:103B9000FCCF9092C6008091C00085FFFCCF809240
:103BA000C6008091C00085FFFCCF7092C600809156
:103BB000C00085FFFCCF6092C6008091C00085FFE9
:103BC000FCCF5092C6008091C00085FFFCCF409290
:103BD000C6008091C00085FFFCCF3092C600809166
:103BE000C00085FFFCCFB092C6007DCF0E94761C3E
:103BF000863808F4B2CF0E94761C0E94F61C73CF60
:103C000094E08091C00087FFFCCF8091C60099238B
:103C100009F4A3CF9150F5CF0E94761C8038D1F0E3
:103C2000813861F1823809F499C0883979F080E0EF
:103C30000E94CA1C58CF0E94761C809306010E94E5
:103C4000761C809307010E94F61C4DCF83E00E94F2
:103C5000CA1C49CF82E00E94CA1C45CF0E94761C34
:103C6000803309F486C192E08091C00087FFFCCFC9
:103C70008091C6009923D9F29150F6CF81E00E943D
:103C8000CA1C31CF0E94761C809309020E94761CC8
:103C90008093080280910C028E7F80930C020E9418
:103CA000761C853429F480910C02816080930C028B
:103CB0008091080290910902892B89F000E010E0C0
:103CC0000E94761CF801E85FFE4F80830F5F1F4F54
:103CD00080910802909109020817190788F30E9441
:103CE000761C803209F029CF80910C0280FFD1C070
:103CF0004091060150910701440F551F5093070151
:103D000040930601A0910802B09109021097C9F0F2
:103D1000E8E0F1E09A01BD016E0F7F1FF999FECF37
:103D200032BD21BD819180BDFA9AF99A2F5F3F4F34
:103D3000E617F70799F74A0F5B1F50930701409367
:103D400006018091C00085FFFCCFF092C6008091F3
:103D5000C00085FFFCCFB092C600C5CE80E10E94B6
:103D6000CA1CC1CE0E94761C809309020E94761C58
:103D7000809308028091060190910701880F991F96
:103D800090930701809306010E94761C853409F404
:103D90007AC080910C028E7F80930C020E94761C68
:103DA000803209F0A0CE8091C00085FFFCCFF09258
:103DB000C600A0910802B09109021097B9F1809154
:103DC0000C02182F1170082F0270E0910601F0917B
:103DD00007019F012F5F3F4FB90140E050E01123E1
:103DE000B1F4002339F494918091C00085FFFCCF99
:103DF0009093C6004F5F5F4FCB010196F9014A17C0
:103E00005B0780F4BC012F5F3F4F112351F3F999F9
:103E1000FECFF2BDE1BDF89A90B58091C00085FF5C
:103E2000FCCFE6CF70930701609306018091C0003C
:103E300085FDD9CE8091C00085FFF8CFD4CE0E94F9
:103E4000761C803209F079CE8091C00085FFFCCFCE
:103E5000F092C6008091C00085FFFCCFE092C600C2
:103E60008091C00085FFFCCFD092C6008091C00039
:103E700085FFFCCFC092C6008091C00085FFFCCFBB
:103E8000B092C60030CE80910C02816080930C020B
:103E900085CF809107018823880F880B8A21809322
:103EA0000B028091060190910701880F991F909352
:103EB0000701809306018091080280FF09C080916C
:103EC00008029091090201969093090280930802DA
:103ED000F894F999FECF1127E0910601F0910701BE
:103EE000C8E0D1E08091080290910902103091F46D
:103EF0000091570001700130D9F303E0009357009F
:103F0000E8950091570001700130D9F301E1009369
:103F10005700E89509901990009157000170013001
:103F2000D9F301E000935700E8951395103498F009
:103F300011270091570001700130D9F305E000937B
:103F40005700E8950091570001700130D9F301E165
:103F500000935700E8953296029709F0C7CF1030CA
:103F600011F00296E5CF11248091C00085FFE9CEC3
:103F7000ECCE0E94761C0E94761C182F0E94761CA4
:103F8000112351F0113021F086E00E94CA1CABCD04
:103F900084E90E94CA1CA7CD8EE10E94CA1CA3CD51
:043FA000F894FFCFC3
:023FA40080009B
:0400000300003800C1
:00000001FF

View file

@ -0,0 +1,110 @@
:103800000C94341C0C94511C0C94511C0C94511CA1
:103810000C94511C0C94511C0C94511C0C94511C74
:103820000C94511C0C94511C0C94511C0C94511C64
:103830000C94511C0C94511C0C94511C0C94511C54
:103840000C94511C0C94511C0C94511C0C94511C44
:103850000C94511C0C94511C0C94511C0C94511C34
:103860000C94511C0C94511C11241FBECFEFD4E0BA
:10387000DEBFCDBF11E0A0E0B1E0E4EAFEE302C0AC
:1038800005900D92A230B107D9F712E0A2E0B1E0A5
:1038900001C01D92AD30B107E1F70E94ED1C0C9400
:1038A000511F0C94001C482F10920A0280E08417CC
:1038B000E0F4582F2D9A28EE33E080E991E001974B
:1038C000F1F721503040C9F72D9828EE33E080E918
:1038D00091E00197F1F721503040C9F7852F8F5FB4
:1038E000582F841738F380930A020895EF92FF92BD
:1038F0000F931F93EE24FF2487018091C00087FD62
:1039000017C00894E11CF11C011D111D81E0E8168F
:1039100082E1F8068AE7080780E0180770F3E09173
:103920000201F091030109958091C00087FFE9CF62
:103930008091C600992787FD90951F910F91FF9068
:10394000EF900895982F8091C00085FFFCCF909351
:10395000C60008950E94761C803271F080910401A7
:103960008F5F80930401853009F00895E091020192
:10397000F09103010995089584E10E94A21C80E161
:103980000E94A21C0895CF93C82F0E94761C8032FB
:1039900041F0809104018F5F80930401853081F4B0
:1039A0000AC084E10E94A21C8C2F0E94A21C80E10C
:1039B0000E94A21C05C0E0910201F091030109954B
:1039C000CF910895CF93C82FC150CF3F21F00E94CF
:1039D000761CC150E0F7CF910895CFEFD4E0DEBF61
:1039E000CDBF000083E38093C4001092C50088E13E
:1039F0008093C10086E08093C2005098589A259A1F
:103A000083E00E94531C0E94761C8033B1F1813305
:103A1000B9F1803409F455C0813409F45BC08234B3
:103A200009F46DC0853409F470C0803531F18235F8
:103A300021F1813511F1853509F46BC0863509F422
:103A400073C0843609F47AC0843709F4CEC0853750
:103A500009F429C1863709F44AC0809104018F5FB7
:103A600080930401853079F6E0910201F091030121
:103A700009950E94761C803351F60E94AA1CC3CF80
:103A80000E94761CC82F803241F784E10E94A21C5C
:103A900081E40E94A21C86E50E94A21C82E50E948D
:103AA000A21C8C2F0E94A21C89E40E94A21C83E508
:103AB0000E94A21C80E50E94A21C80E10E94A21C20
:103AC000A2CF0E94761C8638C0F20E94761C0E940B
:103AD000AA1C99CF0E94761C803809F486C18138CF
:103AE00009F487C1823809F488C1883921F080E05F
:103AF0000E94C31C88CF83E00E94C31C84CF84E152
:103B00000E94E21C0E94AA1C7ECF85E00E94E21C5B
:103B1000F9CF0E94761C809306010E94761C809348
:103B200007010E94AA1C6FCF0E94761C803309F403
:103B3000CAC083E00E94E21C80E0DACF0E94761CBB
:103B4000809309020E94761C8093080280910C02E7
:103B50008E7F80930C020E94761C853409F4C4C0C9
:103B600000E010E0809108029091090218161906F1
:103B700070F4C8E0D1E00E94761C89930F5F1F4F5C
:103B8000809108029091090208171907A0F30E947A
:103B9000761C803209F061CF80910C0280FFAEC0AC
:103BA000E0910601F0910701EE0FFF1F00E010E029
:103BB00020910802309109021216130680F4A8E041
:103BC000B1E0F999FECFF2BDE1BD8D9180BDFA9AC9
:103BD000F99A31960F5F1F4F0217130790F3F09376
:103BE0000701E093060184E166CF0E94761C809372
:103BF00009020E94761C8093080280910601909130
:103C00000701880F991F90930701809306010E9476
:103C1000761C853409F46EC080910C028E7F8093EF
:103C20000C020E94761C803209F0EDCE84E10E94E5
:103C3000A21C00E010E02091080230910902121647
:103C4000130608F03ACFE0910601F0910701809148
:103C50000C0280FF1FC0F999FECFF2BDE1BDF89ABA
:103C600080B50E94A21CE0910601F09107013196F7
:103C7000F0930701E09306012091080230910902B8
:103C80000F5F1F4F0217130708F017CF80910C0228
:103C900080FDE1CF869580FFB4C03196F093070197
:103CA000E0930601EDCF0E94761C803209F0D5CE5C
:103CB00084E10E94A21C8EE10E94A21C84E90E9461
:103CC000A21C86E0F8CE0E94761C0E94761CC82FAB
:103CD0000E94761CCC2309F47CC0C13009F47DC05D
:103CE00086E00E94C31C8FCE80910C02816080937D
:103CF0000C0236CF80910C02816091CF8091070138
:103D000087FD6FC010920B02809106019091070110
:103D1000880F991F909307018093060180910802F4
:103D200080FF09C08091080290910902019690934A
:103D3000090280930802F894F999FECF1127E091C7
:103D40000601F0910701C8E0D1E08091080290914E
:103D50000902103091F40091570001700130D9F33D
:103D600003E000935700E89500915700017001307F
:103D7000D9F301E100935700E8950990199000915B
:103D8000570001700130D9F301E000935700E89526
:103D90001395103498F011270091570001700130ED
:103DA000D9F305E000935700E895009157000170A2
:103DB0000130D9F301E100935700E895329602975C
:103DC00009F0C7CF103011F00296E5CF112484E13D
:103DD00072CE8EE10E94C31C16CE84E90E94C31CE1
:103DE00012CE81E080930B028FCF82E00E94C31C31
:103DF0000ACE81E00E94C31C06CE80E10E94C31C53
:103E000002CE84910E94A21C2091080230910902E6
:103E1000E0910601F091070140CFCF930E94761CFC
:103E2000C82F0E94A21CC13614F0C75503C0C0336E
:103E30000CF0C0538C2F992787FD9095CF91089552
:103E40000F931F930E940D1F082F112707FD109538
:103E500002951295107F1027007F10270E940D1FDA
:103E6000800F992787FD90951F910F910895CF930B
:103E7000C82F85958595859585958A3034F0895A22
:103E8000CF70CA3034F0C95A05C0805DCF70CA30D7
:103E9000D4F7C05D0E94A21C8C2F0E94A21CCF915F
:043EA0000895FFCFB3
:023EA40080009C
:0400000300003800C1
:00000001FF

View file

@ -0,0 +1,126 @@
:103800000C94341C0C94511C0C94511C0C94511CA1
:103810000C94511C0C94511C0C94511C0C94511C74
:103820000C94511C0C94511C0C94511C0C94511C64
:103830000C94511C0C94511C0C94511C0C94511C54
:103840000C94511C0C94511C0C94511C0C94511C44
:103850000C94511C0C94511C0C94511C0C94511C34
:103860000C94511C0C94511C11241FBECFEFD4E0BA
:10387000DEBFCDBF11E0A0E0B1E0EEEAFFE302C0A1
:1038800005900D92A230B107D9F712E0A2E0B1E0A5
:1038900001C01D92AD30B107E1F70E94331D0C94B9
:1038A000D51F0C94001C982F9595959595959595F9
:1038B000905D8F708A307CF0282F295A8091C0004B
:1038C00085FFFCCF9093C6008091C00085FFFCCFA0
:1038D0002093C6000895282F205DF0CF982F809167
:1038E000C00085FFFCCF9093C6000895EF92FF9231
:1038F0000F931F93EE24FF2487018091C00087FD62
:1039000017C00894E11CF11C011D111D81E2E8168D
:1039100081EAF80687E0080780E0180770F3E09175
:103920000401F091050109958091C00087FFE9CF5E
:103930008091C6001F910F91FF90EF9008950E9413
:10394000761C982F8091C00085FFFCCF9093C60015
:1039500091362CF490330CF09053892F089597559D
:10396000892F08951F930E949F1C182F0E949F1C4F
:103970001295107F810F1F9108951F93182F882390
:1039800021F00E94761C1150E1F71F9108951F93BA
:10399000182F0E94761C803249F0809103018F5FBE
:1039A000809303018530C1F01F9108958091C0007C
:1039B00085FFFCCF84E18093C6008091C00085FF25
:1039C000FCCF1093C6008091C00085FFFCCF80E142
:1039D0008093C6001F910895E0910401F0910501C4
:1039E00009951F9108950E94761C803241F08091C4
:1039F00003018F5F80930301853081F008958091EA
:103A0000C00085FFFCCF84E18093C6008091C00098
:103A100085FFFCCF80E18093C6000895E09104010A
:103A2000F09105010995089510920A028823D1F0BA
:103A300090E048EC50E02D9A28EE33E0FA013197FF
:103A4000F1F721503040D1F72D9828EE33E0FA01FC
:103A50003197F1F721503040D1F79F5F981758F315
:103A600080930A0208953F924F925F926F927F92E5
:103A70008F929F92AF92BF92CF92DF92EF92FF927E
:103A80000F931F93CF93DF9394B714BE8091600080
:103A90008861809360001092600091FF0CC289E100
:103AA0008093C4001092C50088E18093C10086E035
:103AB0008093C2005098589A259A81E00E94141D64
:103AC00044E1F42E3EE1E32E24E9D22E96E0C92E05
:103AD00080E1B82EAA24A39401E4902E16E5812E4D
:103AE000B2E57B2EA0E26A2EF9E45F2EE3E54E2ECE
:103AF00070E5372E0E94761C8033B9F18133C1F115
:103B0000803409F470C0813409F477C0823409F438
:103B100086C0853409F489C0803539F1823529F1B0
:103B2000813509F4AFC1853509F485C0863509F4BE
:103B30008DC0843609F435C1843709F4C1C0853796
:103B400009F490C0863709F466C0809103018F5F45
:103B500080930301853071F6E0910401F091050135
:103B600009950E94761C803349F60E94F31CC2CF4F
:103B70000E94761C803249F78091C00085FFFCCFFF
:103B8000F092C6008091C00085FFFCCF9092C600E5
:103B90008091C00085FFFCCF8092C6008091C0005C
:103BA00085FFFCCF7092C6008091C00085FFFCCFDE
:103BB0006092C6008091C00085FFFCCF5092C60085
:103BC0008091C00085FFFCCF4092C6008091C0006C
:103BD00085FFFCCF3092C6008091C00085FFFCCFEE
:103BE000B092C60087CF0E94761C863808F4BDCFFD
:103BF0000E94761C0E94F31C7DCF0E94761C8038A8
:103C000009F45AC0813809F453C0823809F440C11C
:103C1000883909F449C080E00E94C71C6BCF84E159
:103C20000E94BD1C0E94F31C65CF85E00E94BD1C54
:103C30000E94F31C5FCF0E94761C809306010E94B5
:103C4000761C809307010E94F31C54CF0E94761CBF
:103C5000803309F421C183E00E94BD1C80E00E94F2
:103C6000C71C48CF0E94761C803209F06ECF80912D
:103C7000C00085FFFCCFF092C6008091C00085FF98
:103C8000FCCFE092C6008091C00085FFFCCFD092AF
:103C9000C6008091C00085FFFCCFC092C600809115
:103CA000C00085FFFCCF9CCF83E00E94C71C22CFC1
:103CB00081E00E94C71C1ECF82E00E94C71C1ACF61
:103CC0000E94761C809309020E94761C8093080251
:103CD0008091060190910701880F991F9093070129
:103CE000809306010E94761C853409F4C5C080913A
:103CF0000C028E7F80930C020E94761C803209F0A9
:103D0000F9CE8091C00085FFFCCFF092C600609193
:103D10000802709109026115710591F140E050E0CF
:103D200080910C02A82FA170B82FB27010C0BB23D5
:103D300061F1E0910601F09107013196F0930701DE
:103D4000E09306014F5F5F4F46175707C8F4AA2359
:103D500071F3F999FECF209106013091070132BD30
:103D600021BDF89A90B58091C00085FFFCCF90935B
:103D7000C6002F5F3F4F3093070120930601E2CF2B
:103D80008091C00085FFFCCF2BCFE0910601F09120
:103D9000070194918091C00085FFFCCF9093C600ED
:103DA000CCCF0E94761C809309020E94761C8093DF
:103DB000080280910C028E7F80930C020E94761C78
:103DC000853429F480910C02816080930C028091EB
:103DD000080290910902892B89F000E010E00E940E
:103DE000761CF801E85FFE4F80830F5F1F4F8091C4
:103DF0000802909109020817190788F30E94761C9F
:103E0000803209F0A2CE80910C0280FF62C0409106
:103E1000060150910701440F551F5093070140932D
:103E20000601609108027091090261157105C9F0DF
:103E3000E8E0F1E09A01DB01AE0FBF1FF999FECF78
:103E400032BD21BD819180BDFA9AF99A2F5F3F4F13
:103E5000EA17FB0799F7460F571F50930701409346
:103E600006018091C00085FFFCCFF092C6008091D2
:103E7000C00085FFFCCFB4CE80910C02816080939E
:103E80000C023ACF0E94F31C88E080936000FFCFC1
:103E900080E10E94C71C2ECE0E94761C0E94761CD8
:103EA000182F0E94761C112381F0113051F086E00A
:103EB0000E94C71C1FCEE0910401F09105010995F5
:103EC000EECD84E90E94C71C15CE8EE10E94C71C6E
:103ED00011CE809107018823880F880B8A21809357
:103EE0000B028091060190910701880F991F909312
:103EF0000701809306018091080280FF09C080912C
:103F00000802909109020196909309028093080299
:103F1000F894F999FECF1127E0910601F09107017D
:103F2000C8E0D1E08091080290910902103091F42C
:103F30000091570001700130D9F303E0009357005E
:103F4000E8950091570001700130D9F301E1009329
:103F50005700E895099019900091570001700130C1
:103F6000D9F301E000935700E8951395103498F0C9
:103F700011270091570001700130D9F305E000933B
:103F80005700E8950091570001700130D9F301E125
:103F900000935700E8953296029709F0C7CF10308A
:0E3FA00011F00296E5CF11245CCFF894FFCF0C
:023FAE00800091
:0400000300003800C1
:00000001FF

View file

@ -0,0 +1,224 @@
# Makefile for ATmegaBOOT
# E.Lins, 18.7.2005
# $Id$
#
# Instructions
#
# To make bootloader .hex file:
# make diecimila
# make lilypad
# make ng
# etc...
#
# To burn bootloader .hex file:
# make diecimila_isp
# make lilypad_isp
# make ng_isp
# etc...
# program name should not be changed...
PROGRAM = ATmegaBOOT_168
# enter the parameters for the avrdude isp tool
ISPTOOL = stk500v2
ISPPORT = usb
ISPSPEED = -b 115200
MCU_TARGET = atmega168
LDSECTION = --section-start=.text=0x3800
# the efuse should really be 0xf8; since, however, only the lower
# three bits of that byte are used on the atmega168, avrdude gets
# confused if you specify 1's for the higher bits, see:
# http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/
#
# similarly, the lock bits should be 0xff instead of 0x3f (to
# unlock the bootloader section) and 0xcf instead of 0x0f (to
# lock it), but since the high two bits of the lock byte are
# unused, avrdude would get confused.
ISPFUSES = avrdude -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
-e -u -U lock:w:0x3f:m -U efuse:w:0x$(EFUSE):m -U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m
ISPFLASH = avrdude -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
-U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x0f:m
STK500 = "C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe"
STK500-1 = $(STK500) -e -d$(MCU_TARGET) -pf -vf -if$(PROGRAM)_$(TARGET).hex \
-lFF -LFF -f$(HFUSE)$(LFUSE) -EF8 -ms -q -cUSB -I200kHz -s -wt
STK500-2 = $(STK500) -d$(MCU_TARGET) -ms -q -lCF -LCF -cUSB -I200kHz -s -wt
OBJ = $(PROGRAM).o
OPTIMIZE = -O2
DEFS =
LIBS =
CC = avr-gcc
# Override is only needed by avr-lib build system.
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
override LDFLAGS = -Wl,$(LDSECTION)
#override LDFLAGS = -Wl,-Map,$(PROGRAM).map,$(LDSECTION)
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
all:
lilypad: TARGET = lilypad
lilypad: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>1' '-DNUM_LED_FLASHES=3'
lilypad: AVR_FREQ = 8000000L
lilypad: $(PROGRAM)_lilypad.hex
lilypad_isp: lilypad
lilypad_isp: TARGET = lilypad
lilypad_isp: HFUSE = DD
lilypad_isp: LFUSE = E2
lilypad_isp: EFUSE = 00
lilypad_isp: isp
lilypad_resonator: TARGET = lilypad_resonator
lilypad_resonator: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=3'
lilypad_resonator: AVR_FREQ = 8000000L
lilypad_resonator: $(PROGRAM)_lilypad_resonator.hex
lilypad_resonator_isp: lilypad_resonator
lilypad_resonator_isp: TARGET = lilypad_resonator
lilypad_resonator_isp: HFUSE = DD
lilypad_resonator_isp: LFUSE = C6
lilypad_resonator_isp: EFUSE = 00
lilypad_resonator_isp: isp
pro8: TARGET = pro_8MHz
pro8: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' '-DWATCHDOG_MODS'
pro8: AVR_FREQ = 8000000L
pro8: $(PROGRAM)_pro_8MHz.hex
pro8_isp: pro8
pro8_isp: TARGET = pro_8MHz
pro8_isp: HFUSE = DD
pro8_isp: LFUSE = C6
pro8_isp: EFUSE = 00
pro8_isp: isp
pro16: TARGET = pro_16MHz
pro16: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' '-DWATCHDOG_MODS'
pro16: AVR_FREQ = 16000000L
pro16: $(PROGRAM)_pro_16MHz.hex
pro16_isp: pro16
pro16_isp: TARGET = pro_16MHz
pro16_isp: HFUSE = DD
pro16_isp: LFUSE = C6
pro16_isp: EFUSE = 00
pro16_isp: isp
pro20: TARGET = pro_20mhz
pro20: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' '-DWATCHDOG_MODS'
pro20: AVR_FREQ = 20000000L
pro20: $(PROGRAM)_pro_20mhz.hex
pro20_isp: pro20
pro20_isp: TARGET = pro_20mhz
pro20_isp: HFUSE = DD
pro20_isp: LFUSE = C6
pro20_isp: EFUSE = 00
pro20_isp: isp
diecimila: TARGET = diecimila
diecimila: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1'
diecimila: AVR_FREQ = 16000000L
diecimila: $(PROGRAM)_diecimila.hex
diecimila_isp: diecimila
diecimila_isp: TARGET = diecimila
diecimila_isp: HFUSE = DD
diecimila_isp: LFUSE = FF
diecimila_isp: EFUSE = 00
diecimila_isp: isp
ng: TARGET = ng
ng: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>1' '-DNUM_LED_FLASHES=3'
ng: AVR_FREQ = 16000000L
ng: $(PROGRAM)_ng.hex
ng_isp: ng
ng_isp: TARGET = ng
ng_isp: HFUSE = DD
ng_isp: LFUSE = FF
ng_isp: EFUSE = 00
ng_isp: isp
atmega328: TARGET = atmega328
atmega328: MCU_TARGET = atmega328p
atmega328: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' -DBAUD_RATE=57600
atmega328: AVR_FREQ = 16000000L
atmega328: LDSECTION = --section-start=.text=0x7800
atmega328: $(PROGRAM)_atmega328.hex
atmega328_isp: atmega328
atmega328_isp: TARGET = atmega328
atmega328_isp: MCU_TARGET = atmega328p
atmega328_isp: HFUSE = DA
atmega328_isp: LFUSE = FF
atmega328_isp: EFUSE = 05
atmega328_isp: isp
atmega328_pro8: TARGET = atmega328_pro_8MHz
atmega328_pro8: MCU_TARGET = atmega328p
atmega328_pro8: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' -DBAUD_RATE=57600 -DDOUBLE_SPEED
atmega328_pro8: AVR_FREQ = 8000000L
atmega328_pro8: LDSECTION = --section-start=.text=0x7800
atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.hex
atmega328_pro8_isp: atmega328_pro8
atmega328_pro8_isp: TARGET = atmega328_pro_8MHz
atmega328_pro8_isp: MCU_TARGET = atmega328p
atmega328_pro8_isp: HFUSE = DA
atmega328_pro8_isp: LFUSE = FF
atmega328_pro8_isp: EFUSE = 05
atmega328_pro8_isp: isp
mega: TARGET = atmega1280
mega: MCU_TARGET = atmega1280
mega: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=0' -DBAUD_RATE=57600
mega: AVR_FREQ = 16000000L
mega: LDSECTION = --section-start=.text=0x1F000
mega: $(PROGRAM)_atmega1280.hex
mega_isp: mega
mega_isp: TARGET = atmega1280
mega_isp: MCU_TARGET = atmega1280
mega_isp: HFUSE = DA
mega_isp: LFUSE = FF
mega_isp: EFUSE = F5
mega_isp: isp
isp: $(TARGET)
$(ISPFUSES)
$(ISPFLASH)
isp-stk500: $(PROGRAM)_$(TARGET).hex
$(STK500-1)
$(STK500-2)
%.elf: $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
clean:
rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex
%.lst: %.elf
$(OBJDUMP) -h -S $< > $@
%.hex: %.elf
$(OBJCOPY) -j .text -j .data -O ihex $< $@
%.srec: %.elf
$(OBJCOPY) -j .text -j .data -O srec $< $@
%.bin: %.elf
$(OBJCOPY) -j .text -j .data -O binary $< $@

View file

@ -0,0 +1,507 @@
/**********************************************************/
/* Serial Bootloader for Atmel mega8 AVR Controller */
/* */
/* ATmegaBOOT.c */
/* */
/* Copyright (c) 2003, Jason P. Kyle */
/* */
/* Hacked by DojoCorp - ZGZ - MMX - IVR */
/* Hacked by David A. Mellis */
/* */
/* This program is free software; you can redistribute it */
/* and/or modify it under the terms of the GNU General */
/* Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or */
/* (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will */
/* be useful, but WITHOUT ANY WARRANTY; without even the */
/* implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public */
/* License for more details. */
/* */
/* You should have received a copy of the GNU General */
/* Public License along with this program; if not, write */
/* to the Free Software Foundation, Inc., */
/* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* */
/* Licence can be viewed at */
/* http://www.fsf.org/licenses/gpl.txt */
/* */
/* Target = Atmel AVR m8 */
/**********************************************************/
#include <inttypes.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/eeprom.h>
#include <avr/interrupt.h>
#include <avr/delay.h>
//#define F_CPU 16000000
/* We, Malmoitians, like slow interaction
* therefore the slow baud rate ;-)
*/
//#define BAUD_RATE 9600
/* 6.000.000 is more or less 8 seconds at the
* speed configured here
*/
//#define MAX_TIME_COUNT 6000000
#define MAX_TIME_COUNT (F_CPU>>1)
///#define MAX_TIME_COUNT_MORATORY 1600000
/* SW_MAJOR and MINOR needs to be updated from time to time to avoid warning message from AVR Studio */
#define HW_VER 0x02
#define SW_MAJOR 0x01
#define SW_MINOR 0x12
// AVR-GCC compiler compatibility
// avr-gcc compiler v3.1.x and older doesn't support outb() and inb()
// if necessary, convert outb and inb to outp and inp
#ifndef outb
#define outb(sfr,val) (_SFR_BYTE(sfr) = (val))
#endif
#ifndef inb
#define inb(sfr) _SFR_BYTE(sfr)
#endif
/* defines for future compatibility */
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
/* Adjust to suit whatever pin your hardware uses to enter the bootloader */
#define eeprom_rb(addr) eeprom_read_byte ((uint8_t *)(addr))
#define eeprom_rw(addr) eeprom_read_word ((uint16_t *)(addr))
#define eeprom_wb(addr, val) eeprom_write_byte ((uint8_t *)(addr), (uint8_t)(val))
/* Onboard LED is connected to pin PB5 */
#define LED_DDR DDRB
#define LED_PORT PORTB
#define LED_PIN PINB
#define LED PINB5
#define SIG1 0x1E // Yep, Atmel is the only manufacturer of AVR micros. Single source :(
#define SIG2 0x93
#define SIG3 0x07
#define PAGE_SIZE 0x20U //32 words
void putch(char);
char getch(void);
void getNch(uint8_t);
void byte_response(uint8_t);
void nothing_response(void);
union address_union {
uint16_t word;
uint8_t byte[2];
} address;
union length_union {
uint16_t word;
uint8_t byte[2];
} length;
struct flags_struct {
unsigned eeprom : 1;
unsigned rampz : 1;
} flags;
uint8_t buff[256];
//uint8_t address_high;
uint8_t pagesz=0x80;
uint8_t i;
//uint8_t bootuart0=0,bootuart1=0;
void (*app_start)(void) = 0x0000;
int main(void)
{
uint8_t ch,ch2;
uint16_t w;
//cbi(BL_DDR,BL);
//sbi(BL_PORT,BL);
asm volatile("nop\n\t");
/* check if flash is programmed already, if not start bootloader anyway */
//if(pgm_read_byte_near(0x0000) != 0xFF) {
/* check if bootloader pin is set low */
//if(bit_is_set(BL_PIN,BL)) app_start();
//}
/* initialize UART(s) depending on CPU defined */
/* m8 */
UBRRH = (((F_CPU/BAUD_RATE)/16)-1)>>8; // set baud rate
UBRRL = (((F_CPU/BAUD_RATE)/16)-1);
UCSRB = (1<<RXEN)|(1<<TXEN); // enable Rx & Tx
UCSRC = (1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0); // config USART; 8N1
//UBRRL = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1);
//UBRRH = (F_CPU/(BAUD_RATE*16L)-1) >> 8;
//UCSRA = 0x00;
//UCSRC = 0x86;
//UCSRB = _BV(TXEN)|_BV(RXEN);
/* this was giving uisp problems, so I removed it; without it, the boot
works on with uisp and avrdude on the mac (at least). */
//putch('\0');
//uint32_t l;
//uint32_t time_count;
//time_count=0;
/* set LED pin as output */
sbi(LED_DDR,LED);
for (i = 0; i < 16; i++) {
outb(LED_PORT, inb(LED_PORT) ^ _BV(LED));
_delay_loop_2(0);
}
//for (l=0; l<40000000; l++)
//outb(LED_PORT, inb(LED_PORT) ^= _BV(LED));
/* flash onboard LED three times to signal entering of bootloader */
//for(i=0; i<3; ++i) {
//for(l=0; l<40000000; ++l);
//sbi(LED_PORT,LED);
//for(l=0; l<40000000; ++l);
//cbi(LED_PORT,LED);
//}
/* see comment at previous call to putch() */
//putch('\0'); // this line is needed for the synchronization of the programmer
/* forever */
for (;;) {
//if((inb(UCSRA) & _BV(RXC))){
/* get character from UART */
ch = getch();
/* A bunch of if...else if... gives smaller code than switch...case ! */
/* Hello is anyone home ? */
if(ch=='0') {
nothing_response();
}
/* Request programmer ID */
/* Not using PROGMEM string due to boot block in m128 being beyond 64kB boundry */
/* Would need to selectively manipulate RAMPZ, and it's only 9 characters anyway so who cares. */
else if(ch=='1') {
if (getch() == ' ') {
putch(0x14);
putch('A');
putch('V');
putch('R');
putch(' ');
putch('I');
putch('S');
putch('P');
putch(0x10);
}
}
/* AVR ISP/STK500 board commands DON'T CARE so default nothing_response */
else if(ch=='@') {
ch2 = getch();
if (ch2>0x85) getch();
nothing_response();
}
/* AVR ISP/STK500 board requests */
else if(ch=='A') {
ch2 = getch();
if(ch2==0x80) byte_response(HW_VER); // Hardware version
else if(ch2==0x81) byte_response(SW_MAJOR); // Software major version
else if(ch2==0x82) byte_response(SW_MINOR); // Software minor version
//else if(ch2==0x98) byte_response(0x03); // Unknown but seems to be required by avr studio 3.56
else byte_response(0x00); // Covers various unnecessary responses we don't care about
}
/* Device Parameters DON'T CARE, DEVICE IS FIXED */
else if(ch=='B') {
getNch(20);
nothing_response();
}
/* Parallel programming stuff DON'T CARE */
else if(ch=='E') {
getNch(5);
nothing_response();
}
/* Enter programming mode */
else if(ch=='P') {
nothing_response();
// FIXME: modified only here by DojoCorp, Mumbai, India, 20050626
//time_count=0; // exted the delay once entered prog.mode
}
/* Leave programming mode */
else if(ch=='Q') {
nothing_response();
//time_count=MAX_TIME_COUNT_MORATORY; // once the programming is done,
// we should start the application
// but uisp has problems with this,
// therefore we just change the times
// and give the programmer 1 sec to react
}
/* Erase device, don't care as we will erase one page at a time anyway. */
else if(ch=='R') {
nothing_response();
}
/* Set address, little endian. EEPROM in bytes, FLASH in words */
/* Perhaps extra address bytes may be added in future to support > 128kB FLASH. */
/* This might explain why little endian was used here, big endian used everywhere else. */
else if(ch=='U') {
address.byte[0] = getch();
address.byte[1] = getch();
nothing_response();
}
/* Universal SPI programming command, disabled. Would be used for fuses and lock bits. */
else if(ch=='V') {
getNch(4);
byte_response(0x00);
}
/* Write memory, length is big endian and is in bytes */
else if(ch=='d') {
length.byte[1] = getch();
length.byte[0] = getch();
flags.eeprom = 0;
if (getch() == 'E') flags.eeprom = 1;
for (w=0;w<length.word;w++) {
buff[w] = getch(); // Store data in buffer, can't keep up with serial data stream whilst programming pages
}
if (getch() == ' ') {
if (flags.eeprom) { //Write to EEPROM one byte at a time
for(w=0;w<length.word;w++) {
eeprom_wb(address.word,buff[w]);
address.word++;
}
} else { //Write to FLASH one page at a time
//if (address.byte[1]>127) address_high = 0x01; //Only possible with m128, m256 will need 3rd address byte. FIXME
//else address_high = 0x00;
//address.word = address.word << 1; //address * 2 -> byte location
//if ((length.byte[0] & 0x01)) length.word++; //Even up an odd number of bytes
cli(); //Disable interrupts, just to be sure
while(bit_is_set(EECR,EEWE)); //Wait for previous EEPROM writes to complete
asm volatile(
"clr r17 \n\t" //page_word_count
"lds r30,address \n\t" //Address of FLASH location (in words)
"lds r31,address+1 \n\t"
"lsl r30 \n\t" //address * 2 -> byte location
"rol r31 \n\t"
"ldi r28,lo8(buff) \n\t" //Start of buffer array in RAM
"ldi r29,hi8(buff) \n\t"
"lds r24,length \n\t" //Length of data to be written (in bytes)
"lds r25,length+1 \n\t"
"sbrs r24,0 \n\t" //Even up an odd number of bytes
"rjmp length_loop \n\t"
"adiw r24,1 \n\t"
"length_loop: \n\t" //Main loop, repeat for number of words in block
"cpi r17,0x00 \n\t" //If page_word_count=0 then erase page
"brne no_page_erase \n\t"
"rcall wait_spm \n\t"
// "wait_spm1: \n\t"
// "lds r16,%0 \n\t" //Wait for previous spm to complete
// "andi r16,1 \n\t"
// "cpi r16,1 \n\t"
// "breq wait_spm1 \n\t"
"ldi r16,0x03 \n\t" //Erase page pointed to by Z
"sts %0,r16 \n\t"
"spm \n\t"
"rcall wait_spm \n\t"
// "wait_spm2: \n\t"
// "lds r16,%0 \n\t" //Wait for previous spm to complete
// "andi r16,1 \n\t"
// "cpi r16,1 \n\t"
// "breq wait_spm2 \n\t"
"ldi r16,0x11 \n\t" //Re-enable RWW section
"sts %0,r16 \n\t"
"spm \n\t"
"no_page_erase: \n\t"
"ld r0,Y+ \n\t" //Write 2 bytes into page buffer
"ld r1,Y+ \n\t"
"rcall wait_spm \n\t"
// "wait_spm3: \n\t"
// "lds r16,%0 \n\t" //Wait for previous spm to complete
// "andi r16,1 \n\t"
// "cpi r16,1 \n\t"
// "breq wait_spm3 \n\t"
"ldi r16,0x01 \n\t" //Load r0,r1 into FLASH page buffer
"sts %0,r16 \n\t"
"spm \n\t"
"inc r17 \n\t" //page_word_count++
"cpi r17,%1 \n\t"
"brlo same_page \n\t" //Still same page in FLASH
"write_page: \n\t"
"clr r17 \n\t" //New page, write current one first
"rcall wait_spm \n\t"
// "wait_spm4: \n\t"
// "lds r16,%0 \n\t" //Wait for previous spm to complete
// "andi r16,1 \n\t"
// "cpi r16,1 \n\t"
// "breq wait_spm4 \n\t"
"ldi r16,0x05 \n\t" //Write page pointed to by Z
"sts %0,r16 \n\t"
"spm \n\t"
"rcall wait_spm \n\t"
// "wait_spm5: \n\t"
// "lds r16,%0 \n\t" //Wait for previous spm to complete
// "andi r16,1 \n\t"
// "cpi r16,1 \n\t"
// "breq wait_spm5 \n\t"
"ldi r16,0x11 \n\t" //Re-enable RWW section
"sts %0,r16 \n\t"
"spm \n\t"
"same_page: \n\t"
"adiw r30,2 \n\t" //Next word in FLASH
"sbiw r24,2 \n\t" //length-2
"breq final_write \n\t" //Finished
"rjmp length_loop \n\t"
"wait_spm: \n\t"
"lds r16,%0 \n\t" //Wait for previous spm to complete
"andi r16,1 \n\t"
"cpi r16,1 \n\t"
"breq wait_spm \n\t"
"ret \n\t"
"final_write: \n\t"
"cpi r17,0 \n\t"
"breq block_done \n\t"
"adiw r24,2 \n\t" //length+2, fool above check on length after short page write
"rjmp write_page \n\t"
"block_done: \n\t"
"clr __zero_reg__ \n\t" //restore zero register
: "=m" (SPMCR) : "M" (PAGE_SIZE) : "r0","r16","r17","r24","r25","r28","r29","r30","r31");
/* Should really add a wait for RWW section to be enabled, don't actually need it since we never */
/* exit the bootloader without a power cycle anyhow */
}
putch(0x14);
putch(0x10);
}
}
/* Read memory block mode, length is big endian. */
else if(ch=='t') {
length.byte[1] = getch();
length.byte[0] = getch();
if (getch() == 'E') flags.eeprom = 1;
else {
flags.eeprom = 0;
address.word = address.word << 1; // address * 2 -> byte location
}
if (getch() == ' ') { // Command terminator
putch(0x14);
for (w=0;w < length.word;w++) { // Can handle odd and even lengths okay
if (flags.eeprom) { // Byte access EEPROM read
putch(eeprom_rb(address.word));
address.word++;
} else {
if (!flags.rampz) putch(pgm_read_byte_near(address.word));
address.word++;
}
}
putch(0x10);
}
}
/* Get device signature bytes */
else if(ch=='u') {
if (getch() == ' ') {
putch(0x14);
putch(SIG1);
putch(SIG2);
putch(SIG3);
putch(0x10);
}
}
/* Read oscillator calibration byte */
else if(ch=='v') {
byte_response(0x00);
}
// } else {
// time_count++;
// if (time_count>=MAX_TIME_COUNT) {
// app_start();
// }
// }
} /* end of forever loop */
}
void putch(char ch)
{
/* m8 */
while (!(inb(UCSRA) & _BV(UDRE)));
outb(UDR,ch);
}
char getch(void)
{
/* m8 */
uint32_t count = 0;
while(!(inb(UCSRA) & _BV(RXC))) {
/* HACKME:: here is a good place to count times*/
count++;
if (count > MAX_TIME_COUNT)
app_start();
}
return (inb(UDR));
}
void getNch(uint8_t count)
{
uint8_t i;
for(i=0;i<count;i++) {
/* m8 */
//while(!(inb(UCSRA) & _BV(RXC)));
//inb(UDR);
getch(); // need to handle time out
}
}
void byte_response(uint8_t val)
{
if (getch() == ' ') {
putch(0x14);
putch(val);
putch(0x10);
}
}
void nothing_response(void)
{
if (getch() == ' ') {
putch(0x14);
putch(0x10);
}
}
/* end of file ATmegaBOOT.c */

View file

@ -0,0 +1,66 @@
:101C000012C02BC02AC029C028C027C026C025C0AA
:101C100024C023C022C021C020C01FC01EC01DC0C0
:101C20001CC01BC01AC011241FBECFE5D4E0DEBF0C
:101C3000CDBF10E0A0E6B0E0E8EEFFE102C0059005
:101C40000D92A236B107D9F711E0A2E6B0E001C0CB
:101C50001D92AA36B107E1F74FC0D2CFEF92FF92A3
:101C60000F931F93EE24FF24870113C00894E11CF7
:101C7000F11C011D111D81E0E81682E1F8068AE7DA
:101C8000080780E0180728F0E0916200F0916300F7
:101C900009955F9BEBCF8CB1992787FD90951F919C
:101CA0000F91FF90EF9008955D9BFECF8CB9089542
:101CB000D5DF803221F484E1F7DF80E1F5DF08959C
:101CC0001F93182FCBDF803231F484E1EDDF812FB9
:101CD000EBDF80E1E9DF1F9108951F93CF93DF933E
:101CE000182FC0E0D0E002C0B9DF2196C117E0F3A1
:101CF000DF91CF911F910895CFE5D4E0DEBFCDBF36
:101D0000000010BC83E389B988E18AB986E880BD08
:101D1000BD9A1092680130E2E0E0F0E02FE088B375
:101D2000832788BBCF010197F1F7215027FFF7CF19
:101D300020E12093680192DF803381F1813399F4AF
:101D40008DDF8032C1F784E1AFDF81E4ADDF86E56E
:101D5000ABDF82E5A9DF80E2A7DF89E4A5DF83E5C9
:101D6000A3DF80E5C7C0803429F478DF8638B0F07F
:101D700075DF14C0813471F471DF803811F482E0B2
:101D80001DC1813811F481E019C1823809F015C1F3
:101D900082E114C1823421F484E19FDF89DFCBCF5B
:101DA000853411F485E0F9CF8035C1F38135B1F385
:101DB0008235A1F3853539F451DF809364004EDF1D
:101DC00080936500EBCF863519F484E086DFF5C09B
:101DD000843609F093C042DF809367013FDF809330
:101DE0006601809169018E7F8093690137DF8534B8
:101DF00029F480916901816080936901C0E0D0E09D
:101E000006E610E005C02ADFF80181938F012196D4
:101E10008091660190916701C817D907A0F31EDF72
:101E2000803209F088CF8091690180FF1FC020E0D7
:101E300030E0E6E6F0E012C0A0916400B0916500E9
:101E40008191082EC5D08091640090916500019623
:101E500090936500809364002F5F3F4F80916601EF
:101E6000909167012817390738F343C0F894E19936
:101E7000FECF1127E0916400F0916500EE0FFF1F87
:101E8000C6E6D0E0809166019091670180FF01C0B5
:101E90000196103051F422D003E000935700E895EA
:101EA0001DD001E100935700E8950990199016D0D4
:101EB00001E000935700E8951395103258F0112770
:101EC0000DD005E000935700E89508D001E100939C
:101ED0005700E8953296029739F0DBCF0091570012
:101EE00001700130D9F30895103011F00296E7CF58
:101EF000112484E1D9DE80E1D7DE1DCF843709F0DB
:101F00004BC0ACDE80936701A9DE80936601A6DE3C
:101F100090916901853421F49160909369010DC01D
:101F20009E7F909369018091640090916500880F75
:101F3000991F909365008093640090DE803209F0D1
:101F4000FACE84E1B1DEC0E0D0E01EC0809169012C
:101F500080FF07C0A0916400B091650031D0802D52
:101F600008C081FD07C0E0916400F0916500E49134
:101F70008E2F9ADE80916400909165000196909377
:101F800065008093640021968091660190916701BD
:101F9000C817D907D8F2AFCF853761F45FDE80323A
:101FA00009F0C9CE84E180DE8EE17EDE83E97CDE4D
:101FB00087E0A0CF863709F0BECE80E081DEBBCEC1
:101FC000E199FECFBFBBAEBBE09A11960DB208956A
:101FD000E199FECFBFBBAEBB0DBA11960FB6F89418
:081FE000E29AE19A0FBE089598
:021FE800800077
:0400000300001C00DD
:00000001FF

View file

@ -0,0 +1,88 @@
# Makefile for ATmegaBOOT
# E.Lins, 2004-10-14
# program name should not be changed...
PROGRAM = ATmegaBOOT
PRODUCT=atmega8
# enter the parameters for the UISP isp tool
ISPPARAMS = -dprog=stk500 -dserial=$(SERIAL) -dspeed=115200
#DIRAVR = /usr/local/avr
DIRAVRBIN = $(DIRAVR)/bin
DIRAVRUTILS = $(DIRAVR)/utils/bin
DIRINC = $(DIRAVR)/include
DIRLIB = $(DIRAVR)/avr/lib
MCU_TARGET = atmega8
LDSECTION = --section-start=.text=0x1c00
FUSE_L = 0xdf
FUSE_H = 0xca
ISPFUSES = $(DIRAVRBIN)/uisp -dpart=ATmega8 $(ISPPARAMS) --wr_fuse_l=$(FUSE_L) --wr_fuse_h=$(FUSE_H)
ISPFLASH = $(DIRAVRBIN)/uisp -dpart=ATmega8 $(ISPPARAMS) --erase --upload if=$(PROGRAM).hex -v
OBJ = $(PROGRAM).o
OPTIMIZE = -Os
DEFS = -DF_CPU=16000000 -DBAUD_RATE=19200
LIBS =
CC = $(DIRAVRBIN)/avr-gcc
# Override is only needed by avr-lib build system.
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -D$(PRODUCT) $(DEFS) -I$(DIRINC)
override LDFLAGS = -Wl,-Map,$(PROGRAM).map,$(LDSECTION)
OBJCOPY = $(DIRAVRBIN)/avr-objcopy
OBJDUMP = $(DIRAVRBIN)/avr-objdump
SIZE = $(DIRAVRBIN)/avr-size
all: $(PROGRAM).elf lst text asm size
isp: $(PROGRAM).hex
$(ISPFUSES)
$(ISPFLASH)
$(PROGRAM).elf: $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
clean:
rm -rf *.s
rm -rf *.o *.elf
rm -rf *.lst *.map
asm: $(PROGRAM).s
%.s: %.c
$(CC) -S $(CFLAGS) -g1 $^
lst: $(PROGRAM).lst
%.lst: %.elf
$(OBJDUMP) -h -S $< > $@
size: $(PROGRAM).hex
$(SIZE) $^
# Rules for building the .text rom images
text: hex bin srec
hex: $(PROGRAM).hex
bin: $(PROGRAM).bin
srec: $(PROGRAM).srec
%.hex: %.elf
$(OBJCOPY) -j .text -j .data -O ihex $< $@
%.srec: %.elf
$(OBJCOPY) -j .text -j .data -O srec $< $@
%.bin: %.elf
$(OBJCOPY) -j .text -j .data -O binary $< $@

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,121 @@
:103800000C94341C0C944F1C0C944F1C0C944F1CA7
:103810000C944F1C0C944F1C0C944F1C0C944F1C7C
:103820000C944F1C0C944F1C0C944F1C0C944F1C6C
:103830000C944F1C0C944F1C0C944F1C0C944F1C5C
:103840000C944F1C0C944F1C0C944F1C0C944F1C4C
:103850000C944F1C0C944F1C0C944F1C0C944F1C3C
:103860000C944F1C0C944F1C11241FBECFEFD4E0BE
:10387000DEBFCDBF11E0A0E0B1E0E0E6FFE302C0B3
:1038800005900D92A230B107D9F712E0A2E0B1E0A5
:1038900001C01D92AC30B107E1F70C94D61C0C941A
:1038A000001C882309F483E01092090290E0981725
:1038B000F0F4692F2D9A2FEF37E448EE51E02253B0
:1038C00030404040504057FFFACF2D982FEF33ED56
:1038D00040E350E0225330404040504057FFFACF81
:1038E000962F9F5F692F981728F3909309020895E8
:1038F000982F8091C00085FFFCCF9093C60008955B
:10390000EF92FF920F931F93EE24FF248701809183
:10391000C00087FD17C00894E11CF11C011D111D9A
:1039200081E0E81682E1F8068AE7080780E01807D8
:1039300070F3E0910201F091030109958091C000BC
:1039400087FFE9CF8091C600992787FD90951F9149
:103950000F91FF90EF9008950E94801C803209F033
:10396000089584E10E94781C80E10E94781C0895EB
:10397000CF93C82F0E94801C803249F484E10E94BA
:10398000781C8C2F0E94781C80E10E94781CCF91BB
:103990000895282F90E007C08091C0008823E4F7A5
:1039A0008091C6009F5F9217B8F30895CFEFD4E0DF
:1039B000DEBFCDBF000056985E9A1092C50088E029
:1039C0008093C40088E18093C10086E08093C200A8
:1039D000259A579A5F9A109209022FE080E090E0B2
:1039E0000197F1F7215027FFF9CF20E12093090239
:1039F0005F9883E00E94511C83E50E94781C85E457
:103A00000E94781C84E50E94781C80E20E94781C49
:103A100082E40E94781C84E50E94781C80E20E9467
:103A2000781C80E50E94781C81E40E94781C87E461
:103A30000E94781C85E40E94781C8DE40E94781C0A
:103A40008FE40E94781C84E40E94781C85E40E9424
:103A5000781C80E20E94781C83E30E94781C80E23C
:103A60000E94781C82E30E94781C80E30E94781CEC
:103A700080E30E94781C80E30E94781C80E20E9410
:103A8000781C81E30E94781C8DE00E94781C83E5FD
:103A90000E94781C85E40E94781C84E50E94781CB2
:103AA00080E20E94781C82E40E94781C84E50E94D7
:103AB000781C80E20E94781C82E50E94781C8FE4CA
:103AC0000E94781C8CE40E94781C85E40E94781C7B
:103AD00080E20E94781C80E30E94781C80E20E94B1
:103AE000781C86E60E94781C80E20E94781C87E39E
:103AF0000E94781C84E60E94781C80E30E94781C57
:103B000080E30E94781C8DE00E94781C0E94801C3B
:103B1000803361F1813369F1803409F449C0813423
:103B200009F44FC0823409F45DC0853409F460C0E3
:103B30008035E1F08135D1F08235C1F0853509F469
:103B40005BC0863509F463C0843609F465C08437E8
:103B500009F4B9C0853709F414C18637B9F680E095
:103B60000E94B81C0E94801C8033A1F60E94AC1CED
:103B7000CDCF0E94801CC82F803241F684E10E9484
:103B8000781C81E40E94781C86E50E94781C82E5FE
:103B90000E94781C8C2F0E94781C89E40E94781C5B
:103BA00083E50E94781C80E50E94781C80E1ACCF00
:103BB0000E94801C8638D0F20E94801C0E94AC1C9F
:103BC000A5CF0E94801C803809F4EDC0813809F42B
:103BD000EEC0823809F4EFC0883909F683E00E940C
:103BE000B81CC0CF84E10E94C91C0E94AC1C8ECFBF
:103BF00085E00E94C91CF9CF0E94801C80930501BA
:103C00000E94801C809306010E94AC1C7FCF84E040
:103C10000E94C91C80E0A4CF0E94801C80930802EF
:103C20000E94801C8093070280910B028E7F8093FC
:103C30000B020E94801C853409F4C1C000E010E032
:103C400080910702909108021816190670F4C7E0D7
:103C5000D1E00E94801C89930F5F1F4F8091070263
:103C60009091080208171907A0F30E94801C803267
:103C700009F04CCF80910B0280FFADC000E010E056
:103C8000209107023091080212161306C0F4E09149
:103C90000501F0910601A7E0B1E0F999FECFF2BD70
:103CA000E1BD8D9180BDFA9AF99A31960F5F1F4F51
:103CB0000217130790F3F0930601E093050184E1E6
:103CC0000E94781C73CF0E94801C809308020E947F
:103CD000801C809307020E94801C853409F475C003
:103CE00080910B028E7F80930B0280910501909151
:103CF0000601880F991F90930601809305010E9489
:103D0000801C803209F002CF84E10E94781C00E020
:103D100010E020910702309108021216130608F0F5
:103D200045CFE0910501F091060180910B0280FFE3
:103D30001FC0F999FECFF2BDE1BDF89A80B50E948F
:103D4000781CE0910501F09106013196F09306018F
:103D5000E093050120910702309108020F5F1F4F89
:103D60000217130708F022CF80910B0280FDE1CFEC
:103D7000869580FF9BC03196F0930601E093050184
:103D8000EDCF0E94801C803209F0C0CE84E10E94F9
:103D9000781C8EE10E94781C84E90E94781C86E0E1
:103DA0000E94781C03CF82E00E94B81CDBCE81E029
:103DB0000E94B81CD7CE8FE00E94B81CD3CE809151
:103DC0000B02816080930B0239CF80910B028160DE
:103DD00080930B0294CF8091060187FD73C01092EF
:103DE0000A028091050190910601880F991F909316
:103DF0000601809305018091070280FF09C0809130
:103E0000070290910802019690930802809307029E
:103E1000F894F999FECF1127E0910501F091060180
:103E2000C7E0D1E08091070290910802103091F430
:103E30000091570001700130D9F303E0009357005F
:103E4000E8950091570001700130D9F301E100932A
:103E50005700E895099019900091570001700130C2
:103E6000D9F301E000935700E8951395103498F0CA
:103E700011270091570001700130D9F305E000933C
:103E80005700E8950091570001700130D9F301E126
:103E900000935700E8953296029709F0C7CF10308B
:103EA00011F00296E5CF112484E10ACF84910E949B
:103EB000781C2091070230910802E0910501F091F1
:103EC000060159CF81E080930A028BCF1F93CF93D5
:103ED0000E94801CC82F0E94781C0E94801C182FF2
:103EE0000E94781CC1362CF0C75511363CF017558E
:103EF00008C0C033D4F3C0531136CCF710330CF0E4
:103F00001053C295C07FC10F8C2F992787FD9095C4
:103F1000CF911F910895CF93282F992787FD9095D2
:103F2000807F9070959587959595879595958795C0
:103F3000959587958A303CF0895AC22FCF70CA3048
:103F40003CF0C95A06C0805DC22FCF70CA30CCF792
:103F5000C05D0E94781C8C2F0E94781CCF91089520
:023F60008000DF
:0400000300003800C1
:00000001FF

View file

@ -0,0 +1,162 @@
:107000000C9434380C9451380C9451380C945138F9
:107010000C9451380C9451380C9451380C945138CC
:107020000C9451380C9451380C9451380C945138BC
:107030000C9451380C9451380C9451380C945138AC
:107040000C9451380C9451380C9451380C9451389C
:107050000C9451380C9451380C9451380C9451388C
:107060000C9451380C94513811241FBECFEFD8E046
:10707000DEBFCDBF11E0A0E0B1E0E4EEF9E702C071
:1070800005900D92A230B107D9F712E0A2E0B1E06D
:1070900001C01D92AC30B107E1F70E942D390C946C
:1070A000F03C0C940038282F992787FD9095807F1D
:1070B00090709595879595958795959587959595D4
:1070C00087958A30C4F0382F395A822F8F708A30D2
:1070D0007CF0982F995A8091C00085FFFCCF3093A7
:1070E000C6008091C00085FFFCCF9093C600089534
:1070F000982F905DF0CF382F305DE7CF982F80919B
:10710000C00085FFFCCF9093C6000895EF92FF92D8
:107110000F931F93EE24FF2487018091C00087FD09
:1071200017C00894E11CF11C011D111D81E0E81637
:1071300082E1F8068AE7080780E0180770F3E0911B
:107140000301F091040109958091C00087FFE9CF08
:107150008091C6001F910F91FF90EF9008951F93AB
:107160000E948638182F8091C00085FFFCCF1093B5
:10717000C6000E948638982F8091C00085FFFCCF02
:107180009093C600113664F01755913674F490331D
:107190000CF090531295107F892F810F1F91089545
:1071A00010339CF31053913694F397551295107F3A
:1071B000892F810F1F910895282F882351F090E087
:1071C0008091C00087FFFCCF8091C6009F5F92171F
:1071D000B8F308951F93182F0E948638803211F05B
:1071E0001F9108958091C00085FFFCCF84E18093BA
:1071F000C6008091C00085FFFCCF1093C60080912F
:10720000C00085FFFCCF80E18093C6001F910895E8
:107210000E948638803209F008958091C00085FF71
:10722000FCCF84E18093C6008091C00085FFFCCF35
:1072300080E18093C6000895882359F010920902D6
:1072400090E02D9A2D989F5F9817D8F3909309029C
:1072500008951092090283E0F3CF3F924F925F921C
:107260006F927F928F929F92AF92BF92CF92DF9256
:10727000EF92FF920F931F93CF93DF9300005698E6
:107280005E9A1092C50088E08093C40088E18093E4
:10729000C10086E08093C200259A579A5F9A21E048
:1072A00040E050E0CA010197F1F72F5F2131D1F79B
:1072B00080E1809309025F9883E00E941C398091ED
:1072C000C00085FFFCCF83E58093C6008091C0009D
:1072D00085FFFCCF85E48093C6008091C00085FFC8
:1072E000FCCF84E58093C6008091C00085FFFCCF71
:1072F00080E28093C6008091C00085FFFCCF82E4CD
:107300008093C6008091C00085FFFCCF84E5809308
:10731000C6008091C00085FFFCCF80E28093C6004C
:107320008091C00085FFFCCF80E58093C6008091EE
:10733000C00085FFFCCF81E48093C6008091C0002F
:1073400085FFFCCF87E48093C6008091C00085FF55
:10735000FCCF85E48093C6008091C00085FFFCCF00
:107360008DE48093C6008091C00085FFFCCF8FE440
:107370008093C6008091C00085FFFCCF84E4809399
:10738000C6008091C00085FFFCCF85E48093C600D5
:107390008091C00085FFFCCF80E28093C600809181
:1073A000C00085FFFCCF83E38093C6008091C000BE
:1073B00085FFFCCF80E28093C6008091C00085FFEE
:1073C000FCCF82E38093C6008091C00085FFFCCF94
:1073D00080E38093C6008091C00085FFFCCF80E3EE
:1073E0008093C6008091C00085FFFCCF80E380932E
:1073F000C6008091C00085FFFCCF80E28093C6006C
:107400008091C00085FFFCCF81E38093C60080910E
:10741000C00085FFFCCF8DE08093C6008091C00046
:1074200085FFFCCF83E58093C6008091C00085FF77
:10743000FCCF85E48093C6008091C00085FFFCCF1F
:1074400084E58093C6008091C00085FFFCCF80E278
:107450008093C6008091C00085FFFCCF82E48093BA
:10746000C6008091C00085FFFCCF84E58093C600F4
:107470008091C00085FFFCCF80E28093C6008091A0
:10748000C00085FFFCCF82E58093C6008091C000DC
:1074900085FFFCCF8FE48093C6008091C00085FFFC
:1074A000FCCF8CE48093C6008091C00085FFFCCFA8
:1074B00085E48093C6008091C00085FFFCCF80E208
:1074C0008093C6008091C00085FFFCCF80E380934D
:1074D000C6008091C00085FFFCCF80E28093C6008B
:1074E0008091C00085FFFCCF86E68093C600809126
:1074F000C00085FFFCCF80E28093C6008091C00071
:1075000085FFFCCF87E38093C6008091C00085FF94
:10751000FCCF84E68093C6008091C00085FFFCCF3D
:1075200080E38093C6008091C00085FFFCCF80E39C
:107530008093C6008091C00085FFFCCF8DE08093D2
:10754000C60034E1F32E2EE1E22E95E9D92E8FE02C
:10755000C82E00E1B02EAA24A39411E4912EB6E522
:107560008B2EA2E57A2EF0E26F2EE9E45E2E73E513
:10757000472E60E5362E0E948638803359F18133DC
:10758000C9F1803409F472C0813409F486C08234B0
:1075900021F1853409F474C08035E1F08135D1F0F2
:1075A0008235C1F0853509F497C0863509F486C067
:1075B000843609F4A0C0843709F40BC1853709F477
:1075C00075C18637C1F680E00E94EA380E9486388D
:1075D0008033A9F60E940839CECF90E08091C00098
:1075E00087FFFCCF8091C6009F5F9431B9F70E945E
:1075F0000839C1CF0E948638803209F0BCCF809113
:10760000C00085FFFCCFF092C6008091C00085FFCE
:10761000FCCF9092C6008091C00085FFFCCF809285
:10762000C6008091C00085FFFCCF7092C60080919B
:10763000C00085FFFCCF6092C6008091C00085FF2E
:10764000FCCF5092C6008091C00085FFFCCF4092D5
:10765000C6008091C00085FFFCCF3092C6008091AB
:10766000C00085FFFCCFB092C60085CF0E9486384F
:10767000863808F4AFCF0E9486380E9408397BCF45
:1076800090E08091C00087FFFCCF8091C6009F5F93
:107690009530B9F70E9408396ECF0E94863880383D
:1076A00031F1813809F48DC0823809F48EC08839EF
:1076B00009F089CF83E00E94EA385DCF90E08091A5
:1076C000C00087FFFCCF8091C6009F5F9430B9F760
:1076D00080E00E94EA387ACF0E94863880930501C4
:1076E0000E948638809306010E94083944CF82E0C8
:1076F0000E94EA3840CF0E948638809308020E9498
:1077000086388093070280910B028E7F80930B0254
:107710000E948638853429F480910B028160809321
:107720000B028091070290910802892B89F000E0FA
:1077300010E00E948638F801E95FFE4F80830F5FFA
:107740001F4F80910702909108020817190788F3CC
:107750000E948638803209F00ECF80910B0280FFA4
:10776000CFC0A0910702B09108021097E9F0609194
:10777000050170910601E7E0F1E09B01AD014E0FBC
:107780005F1FF999FECF32BD21BD819180BDFA9A6C
:10779000F99A2F5F3F4FE417F50799F76A0F7B1FA0
:1077A00070930601609305018091C00085FFFCCFB6
:1077B000F092C6008091C00085FFFCCFB092C60059
:1077C000DACE81E00E94EA38D6CE8FE00E94EA3815
:1077D000D2CE0E948638809308020E948638809319
:1077E00007020E948638853409F484C080910B0218
:1077F0008E7F80930B028091050190910601880F86
:10780000991F90930601809305010E94863880326B
:1078100009F0B1CE8091C00085FFFCCFF092C60088
:10782000A0910702B09108021097B9F180910B0264
:10783000182F1170082F0270E0910501F0910601D8
:107840009F012F5F3F4FB90140E050E01123B1F499
:10785000002339F494918091C00085FFFCCF909370
:10786000C6004F5F5F4FCB010196F9014A175B07D6
:1078700080F4BC012F5F3F4F112351F3F999FECFE4
:10788000F2BDE1BDF89A90B58091C00085FFFCCFB4
:10789000E6CF70930601609305018091C00085FDDD
:1078A000E2CE8091C00085FFF8CFDDCE0E94863801
:1078B000803209F060CE8091C00085FFFCCFF0924D
:1078C000C6008091C00085FFFCCFE092C600809189
:1078D000C00085FFFCCFD092C6008091C00085FF1C
:1078E000FCCFC092C6008091C00085FFFCCFB09253
:1078F000C60041CE80910B02816080930B0285CF40
:10790000809106018823880F880B8A2180930A02C0
:107910008091050190910601880F991F90930601AF
:10792000809305018091070280FF09C080910702C2
:107930009091080201969093080280930702F894B0
:10794000F999FECF1127E0910501F0910601C7E0FA
:10795000D1E08091070290910802103091F40091DB
:10796000570001700130D9F303E000935700E89508
:107970000091570001700130D9F301E100935700E5
:10798000E895099019900091570001700130D9F3E2
:1079900001E000935700E8951395103498F01127F3
:1079A0000091570001700130D9F305E000935700B2
:1079B000E8950091570001700130D9F301E100937F
:1079C0005700E8953296029709F0C7CF103011F0B2
:1079D0000296E5CF11248091C00085FFE5CEE8CE68
:0479E000F894FFCF49
:0279E400800021
:040000030000700089
:00000001FF

View file

@ -0,0 +1,109 @@
# Makefile for ATmegaBOOT
# E.Lins, 18.7.2005
# $Id$
#
# Instructions
#
# To make bootloader .hex file:
# make diecimila
# make lilypad
# make ng
# etc...
#
# To burn bootloader .hex file:
# make diecimila_isp
# make lilypad_isp
# make ng_isp
# etc...
# program name should not be changed...
PROGRAM = ATmegaBOOT_168
# enter the parameters for the avrdude isp tool
ISPTOOL = stk500v2
ISPPORT = usb
ISPSPEED = -b 115200
MCU_TARGET = atmega168
LDSECTION = --section-start=.text=0x3800
# the efuse should really be 0xf8; since, however, only the lower
# three bits of that byte are used on the atmega168, avrdude gets
# confused if you specify 1's for the higher bits, see:
# http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/
#
# similarly, the lock bits should be 0xff instead of 0x3f (to
# unlock the bootloader section) and 0xcf instead of 0x0f (to
# lock it), but since the high two bits of the lock byte are
# unused, avrdude would get confused.
ISPFUSES = avrdude -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
-e -u -U lock:w:0x3f:m -U efuse:w:0x$(EFUSE):m -U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m
ISPFLASH = avrdude -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
-U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x0f:m
STK500 = "C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe"
STK500-1 = $(STK500) -e -d$(MCU_TARGET) -pf -vf -if$(PROGRAM)_$(TARGET).hex \
-lFF -LFF -f$(HFUSE)$(LFUSE) -EF8 -ms -q -cUSB -I200kHz -s -wt
STK500-2 = $(STK500) -d$(MCU_TARGET) -ms -q -lCF -LCF -cUSB -I200kHz -s -wt
OBJ = $(PROGRAM).o
OPTIMIZE = -O2
DEFS =
LIBS =
CC = avr-gcc
# Override is only needed by avr-lib build system.
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
override LDFLAGS = -Wl,$(LDSECTION)
#override LDFLAGS = -Wl,-Map,$(PROGRAM).map,$(LDSECTION)
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
all:
atmega328_bt: TARGET = atmega328_bt
atmega328_bt: MCU_TARGET = atmega328p
atmega328_bt: AVR_FREQ = 16000000L
atmega328_bt: LDSECTION = --section-start=.text=0x7000
atmega328_bt: $(PROGRAM)_atmega328_bt.hex
atmega328_bt_isp: atmega328_bt
atmega328_bt_isp: TARGET = atmega328_bt
atmega328_bt_isp: MCU_TARGET = atmega328p
atmega328_bt_isp: HFUSE = D8
atmega328_bt_isp: LFUSE = FF
atmega328_bt_isp: EFUSE = 05
atmega328_bt_isp: isp
isp: $(TARGET)
$(ISPFUSES)
$(ISPFLASH)
isp-stk500: $(PROGRAM)_$(TARGET).hex
$(STK500-1)
$(STK500-2)
%.elf: $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
clean:
rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex
%.lst: %.elf
$(OBJDUMP) -h -S $< > $@
%.hex: %.elf
$(OBJCOPY) -j .text -j .data -O ihex $< $@
%.srec: %.elf
$(OBJCOPY) -j .text -j .data -O srec $< $@
%.bin: %.elf
$(OBJCOPY) -j .text -j .data -O binary $< $@

View file

@ -0,0 +1,117 @@
:103800000C94341C0C944F1C0C944F1C0C944F1CA7
:103810000C944F1C0C944F1C0C944F1C0C944F1C7C
:103820000C944F1C0C944F1C0C944F1C0C944F1C6C
:103830000C944F1C0C944F1C0C944F1C0C944F1C5C
:103840000C944F1C0C944F1C0C944F1C0C944F1C4C
:103850000C944F1C0C944F1C0C944F1C0C944F1C3C
:103860000C944F1C0C944F1C11241FBECFEFD4E0BE
:10387000DEBFCDBF11E0A0E0B1E0E8E1FFE302C0B0
:1038800005900D92A230B107D9F712E0A2E0B1E0A5
:1038900001C01D92AD30B107E1F70C94311D0C94BD
:1038A000001CCF93DF93CDB7DEB724970FB6F89403
:1038B000DEBF0FBECDBF382F882309F433E010924E
:1038C0000A02332309F44BC020E02D9A19821A8290
:1038D0001B821C8289819A81AB81BC8180549F416B
:1038E000A040B040A0F489819A81AB81BC8101964F
:1038F000A11DB11D89839A83AB83BC8389819A8181
:10390000AB81BC8180549F41A040B04060F32D98B2
:1039100019821A821B821C8289819A81AB81BC81A7
:1039200080549F41A040B040A0F489819A81AB812E
:10393000BC810196A11DB11D89839A83AB83BC8391
:1039400089819A81AB81BC8180549F41A040B04065
:1039500060F32F5F231708F4B8CF20930A02249650
:103960000FB6F894DEBF0FBECDBFDF91CF910895A3
:10397000EF92FF920F931F93EE24FF248701809113
:10398000C00087FD17C00894E11CF11C011D111D2A
:1039900081E0E81689E0F8068DE3080780E0180763
:1039A00070F3E0910201F091030109958091C0004C
:1039B00087FFE9CF8091C600992787FD90951F91D9
:1039C0000F91FF90EF900895982F8091C00085FF90
:1039D000FCCF9093C60008950E94B81C803271F00D
:1039E000809104018F5F80930401853009F0089570
:1039F000E0910201F09103010995089584E10E948C
:103A0000E41C80E10E94E41C08951F93182F0E947B
:103A1000B81C803269F0809104018F5F80930401AB
:103A2000853079F4E0910201F0910301099509C014
:103A300084E10E94E41C812F0E94E41C80E10E942A
:103A4000E41C1F910895282F882351F090E0809165
:103A5000C00087FFFCCF8091C6009F5F2917B9F790
:103A60000895CFEFD4E0DEBFCDBF000089E18093A1
:103A7000C4001092C50088E18093C10086E0809365
:103A8000C2005098589A259A83E00E94511C0E94C7
:103A9000B81C8033B1F18133B9F1803409F454C0DA
:103AA000813409F45AC0823409F469C0853409F4B8
:103AB0006CC0803531F1813521F1823511F18535C8
:103AC00009F4B2C0863509F4BAC0843609F463C07B
:103AD000843709F4BBC0853709F40EC1863709F471
:103AE0004AC0809104018F5F80930401853079F68C
:103AF000E0910201F091030109950E94B81C803306
:103B000051F60E94EC1CC3CF0E94B81C803249F7CA
:103B100084E10E94E41C81E40E94E41C86E50E948A
:103B2000E41C82E50E94E41C80E20E94E41C89E41B
:103B30000E94E41C83E50E94E41C80E50E94E41CD2
:103B400080E10E94E41CA3CF0E94B81C8638C8F212
:103B50000E94B81C0E94EC1C9ACF0E94B81C8038AE
:103B600009F4F7C0813809F4F8C0823809F4F9C0C3
:103B7000883909F4BDC080E00E94051D88CF84E12A
:103B80000E94231D0E94EC1C82CF85E00E94231D11
:103B90000E94EC1C7CCF0E94B81C809309020E94FA
:103BA000B81C8093080280910C028E7F80930C02D7
:103BB0000E94B81C853409F4C6C080910802909117
:103BC0000902892B09F0ADC00E94B81C803209F0AF
:103BD00088CF80910C0280FFC8C08091080290912C
:103BE00009020097D1F02091060130910701E8E029
:103BF000F1E0AC014E0F5F1FF999FECF32BD21BD40
:103C0000819180BDFA9AF99A2F5F3F4F4E175F0757
:103C100099F7309307012093060184E10E94E41C88
:103C200080E10E94E41C33CF0E94B81C80930601FF
:103C30000E94B81C809307010E94EC1C28CF84E0EE
:103C40000E94231D80E00E94051D21CF0E94B81C08
:103C5000809309020E94B81C809308020E94B81C3D
:103C6000853409F4F4C080910C028E7F80930C029D
:103C70008091060190910701880F991F9093070189
:103C8000809306010E94B81C803209F000CF84E1C5
:103C90000E94E41C2091080230910902211531058F
:103CA00019F1C0E0D0E0E0910601F09107018091A8
:103CB0000C0280FFC4C0F999FECFF2BDE1BDF89AB5
:103CC00080B50E94E41CE0910601F0910701319655
:103CD000F0930701E0930601209108023091090258
:103CE0002196C217D30718F380E10E94E41CCFCEBF
:103CF00083E00E94051DCBCE0E94B81C803209F0E3
:103D0000F0CE84E10E94E41C8EE10E94E41C84E970
:103D10000E94E41C86E00E94E41C80E10E94E41CF6
:103D2000B6CEC0E0D0E008E011E00E94B81CF80177
:103D300081938F0121968091080290910902C81702
:103D4000D90798F341CF80910C02816080930C02D7
:103D500034CF82E00E94051D9ACE81E00E94051DAD
:103D600096CE80E10E94051D92CE8091070187FDCD
:103D700080C010920B028091060190910701880F7C
:103D8000991F90930701809306018091080280FF9C
:103D900009C080910802909109020196909309024E
:103DA00080930802F894F999FECF1127E09106015B
:103DB000F0910701C8E0D1E08091080290910902DA
:103DC000103091F40091570001700130D9F303E0F5
:103DD00000935700E8950091570001700130D9F326
:103DE00001E100935700E895099019900091570060
:103DF00001700130D9F301E000935700E895139565
:103E0000103498F011270091570001700130D9F358
:103E100005E000935700E8950091570001700130CC
:103E2000D9F301E100935700E8953296029709F023
:103E3000C7CF103011F00296E5CF1124EECE81FFEE
:103E40000CC03196F0930701E093060149CF8091B1
:103E50000C02816080930C0215CF84910E94E41CB7
:103E60002091080230910902E0910601F0910701CA
:103E7000E8CF81E080930B027ECF0F931F930E94C7
:103E8000B81C182F0E94E41C0E94B81C082F0E9426
:103E9000E41C11362CF0175501363CF0075508C0CC
:103EA0001033D4F310530136CCF700330CF0005329
:103EB0001295107F100F812F992787FD90951F91E4
:103EC0000F9108951F93282F992787FD9095807F44
:103ED00090709595879595958795959587959595E6
:103EE00087958A304CF0982F995A822F8F708A309C
:103EF0004CF0182F195A08C0982F905D822F8F70A0
:103F00008A30BCF7182F105D892F0E94E41C812F86
:083F10000E94E41C1F910895BA
:023F1800800027
:0400000300003800C1
:00000001FF

View file

@ -0,0 +1,979 @@
/**********************************************************/
/* Serial Bootloader for Atmel megaAVR Controllers */
/* */
/* tested with ATmega8, ATmega128 and ATmega168 */
/* should work with other mega's, see code for details */
/* */
/* ATmegaBOOT.c */
/* */
/* 20070626: hacked for Arduino Diecimila (which auto- */
/* resets when a USB connection is made to it) */
/* by D. Mellis */
/* 20060802: hacked for Arduino by D. Cuartielles */
/* based on a previous hack by D. Mellis */
/* and D. Cuartielles */
/* */
/* Monitor and debug functions were added to the original */
/* code by Dr. Erik Lins, chip45.com. (See below) */
/* */
/* Thanks to Karl Pitrich for fixing a bootloader pin */
/* problem and more informative LED blinking! */
/* */
/* For the latest version see: */
/* http://www.chip45.com/ */
/* */
/* ------------------------------------------------------ */
/* */
/* based on stk500boot.c */
/* Copyright (c) 2003, Jason P. Kyle */
/* All rights reserved. */
/* see avr1.org for original file and information */
/* */
/* This program is free software; you can redistribute it */
/* and/or modify it under the terms of the GNU General */
/* Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or */
/* (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will */
/* be useful, but WITHOUT ANY WARRANTY; without even the */
/* implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public */
/* License for more details. */
/* */
/* You should have received a copy of the GNU General */
/* Public License along with this program; if not, write */
/* to the Free Software Foundation, Inc., */
/* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* */
/* Licence can be viewed at */
/* http://www.fsf.org/licenses/gpl.txt */
/* */
/* Target = Atmel AVR m128,m64,m32,m16,m8,m162,m163,m169, */
/* m8515,m8535. ATmega161 has a very small boot block so */
/* isn't supported. */
/* */
/* Tested with m168 */
/**********************************************************/
/* $Id$ */
/* some includes */
#include <inttypes.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#include <avr/wdt.h>
/* the current avr-libc eeprom functions do not support the ATmega168 */
/* own eeprom write/read functions are used instead */
#ifndef __AVR_ATmega168__
#include <avr/eeprom.h>
#endif
/* Use the F_CPU defined in Makefile */
/* 20060803: hacked by DojoCorp */
/* 20070626: hacked by David A. Mellis to decrease waiting time for auto-reset */
/* set the waiting time for the bootloader */
/* get this from the Makefile instead */
/* #define MAX_TIME_COUNT (F_CPU>>4) */
/* 20070707: hacked by David A. Mellis - after this many errors give up and launch application */
#define MAX_ERROR_COUNT 5
/* set the UART baud rate */
/* 20060803: hacked by DojoCorp */
//#define BAUD_RATE 115200
#define BAUD_RATE 19200
/* SW_MAJOR and MINOR needs to be updated from time to time to avoid warning message from AVR Studio */
/* never allow AVR Studio to do an update !!!! */
#define HW_VER 0x02
#define SW_MAJOR 0x01
#define SW_MINOR 0x10
/* Adjust to suit whatever pin your hardware uses to enter the bootloader */
/* ATmega128 has two UARTS so two pins are used to enter bootloader and select UART */
/* BL0... means UART0, BL1... means UART1 */
#ifdef __AVR_ATmega128__
#define BL_DDR DDRF
#define BL_PORT PORTF
#define BL_PIN PINF
#define BL0 PINF7
#define BL1 PINF6
#else
/* other ATmegas have only one UART, so only one pin is defined to enter bootloader */
#define BL_DDR DDRD
#define BL_PORT PORTD
#define BL_PIN PIND
#define BL PIND6
#endif
/* onboard LED is used to indicate, that the bootloader was entered (3x flashing) */
/* if monitor functions are included, LED goes on after monitor was entered */
#ifdef __AVR_ATmega128__
/* Onboard LED is connected to pin PB7 (e.g. Crumb128, PROBOmega128, Savvy128) */
#define LED_DDR DDRB
#define LED_PORT PORTB
#define LED_PIN PINB
#define LED PINB7
#else
/* Onboard LED is connected to pin PB2 (e.g. Crumb8, Crumb168) */
#define LED_DDR DDRB
#define LED_PORT PORTB
#define LED_PIN PINB
/* 20060803: hacked by DojoCorp, LED pin is B5 in Arduino */
/* #define LED PINB2 */
#define LED PINB5
#endif
/* monitor functions will only be compiled when using ATmega128, due to bootblock size constraints */
#ifdef __AVR_ATmega128__
#define MONITOR
#endif
/* define various device id's */
/* manufacturer byte is always the same */
#define SIG1 0x1E // Yep, Atmel is the only manufacturer of AVR micros. Single source :(
#if defined __AVR_ATmega128__
#define SIG2 0x97
#define SIG3 0x02
#define PAGE_SIZE 0x80U //128 words
#elif defined __AVR_ATmega64__
#define SIG2 0x96
#define SIG3 0x02
#define PAGE_SIZE 0x80U //128 words
#elif defined __AVR_ATmega32__
#define SIG2 0x95
#define SIG3 0x02
#define PAGE_SIZE 0x40U //64 words
#elif defined __AVR_ATmega16__
#define SIG2 0x94
#define SIG3 0x03
#define PAGE_SIZE 0x40U //64 words
#elif defined __AVR_ATmega8__
#define SIG2 0x93
#define SIG3 0x07
#define PAGE_SIZE 0x20U //32 words
#elif defined __AVR_ATmega88__
#define SIG2 0x93
#define SIG3 0x0a
#define PAGE_SIZE 0x20U //32 words
#elif defined __AVR_ATmega168__
#define SIG2 0x94
#define SIG3 0x06
#define PAGE_SIZE 0x40U //64 words
#elif defined __AVR_ATmega162__
#define SIG2 0x94
#define SIG3 0x04
#define PAGE_SIZE 0x40U //64 words
#elif defined __AVR_ATmega163__
#define SIG2 0x94
#define SIG3 0x02
#define PAGE_SIZE 0x40U //64 words
#elif defined __AVR_ATmega169__
#define SIG2 0x94
#define SIG3 0x05
#define PAGE_SIZE 0x40U //64 words
#elif defined __AVR_ATmega8515__
#define SIG2 0x93
#define SIG3 0x06
#define PAGE_SIZE 0x20U //32 words
#elif defined __AVR_ATmega8535__
#define SIG2 0x93
#define SIG3 0x08
#define PAGE_SIZE 0x20U //32 words
#endif
/* function prototypes */
void putch(char);
char getch(void);
void getNch(uint8_t);
void byte_response(uint8_t);
void nothing_response(void);
char gethex(void);
void puthex(char);
void flash_led(uint8_t);
/* some variables */
union address_union {
uint16_t word;
uint8_t byte[2];
} address;
union length_union {
uint16_t word;
uint8_t byte[2];
} length;
struct flags_struct {
unsigned eeprom : 1;
unsigned rampz : 1;
} flags;
uint8_t buff[256];
uint8_t address_high;
uint8_t pagesz=0x80;
uint8_t i;
uint8_t bootuart = 0;
uint8_t error_count = 0;
void (*app_start)(void) = 0x0000;
/* main program starts here */
int main(void)
{
uint8_t ch,ch2;
uint16_t w;
asm volatile("nop\n\t");
/* set pin direction for bootloader pin and enable pullup */
/* for ATmega128, two pins need to be initialized */
#ifdef __AVR_ATmega128__
BL_DDR &= ~_BV(BL0);
BL_DDR &= ~_BV(BL1);
BL_PORT |= _BV(BL0);
BL_PORT |= _BV(BL1);
#else
/* We run the bootloader regardless of the state of this pin. Thus, don't
put it in a different state than the other pins. --DAM, 070709
BL_DDR &= ~_BV(BL);
BL_PORT |= _BV(BL);
*/
#endif
#ifdef __AVR_ATmega128__
/* check which UART should be used for booting */
if(bit_is_clear(BL_PIN, BL0)) {
bootuart = 1;
}
else if(bit_is_clear(BL_PIN, BL1)) {
bootuart = 2;
}
#endif
/* check if flash is programmed already, if not start bootloader anyway */
if(pgm_read_byte_near(0x0000) != 0xFF) {
#ifdef __AVR_ATmega128__
/* no UART was selected, start application */
if(!bootuart) {
app_start();
}
#else
/* check if bootloader pin is set low */
/* we don't start this part neither for the m8, nor m168 */
//if(bit_is_set(BL_PIN, BL)) {
// app_start();
// }
#endif
}
#ifdef __AVR_ATmega128__
/* no bootuart was selected, default to uart 0 */
if(!bootuart) {
bootuart = 1;
}
#endif
/* initialize UART(s) depending on CPU defined */
#ifdef __AVR_ATmega128__
if(bootuart == 1) {
UBRR0L = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1);
UBRR0H = (F_CPU/(BAUD_RATE*16L)-1) >> 8;
UCSR0A = 0x00;
UCSR0C = 0x06;
UCSR0B = _BV(TXEN0)|_BV(RXEN0);
}
if(bootuart == 2) {
UBRR1L = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1);
UBRR1H = (F_CPU/(BAUD_RATE*16L)-1) >> 8;
UCSR1A = 0x00;
UCSR1C = 0x06;
UCSR1B = _BV(TXEN1)|_BV(RXEN1);
}
#elif defined __AVR_ATmega163__
UBRR = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1);
UBRRHI = (F_CPU/(BAUD_RATE*16L)-1) >> 8;
UCSRA = 0x00;
UCSRB = _BV(TXEN)|_BV(RXEN);
#elif defined __AVR_ATmega168__
UBRR0L = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1);
UBRR0H = (F_CPU/(BAUD_RATE*16L)-1) >> 8;
UCSR0B = (1<<RXEN0) | (1<<TXEN0);
UCSR0C = (1<<UCSZ00) | (1<<UCSZ01);
/* Enable internal pull-up resistor on pin D0 (RX), in order
to supress line noise that prevents the bootloader from
timing out (DAM: 20070509) */
DDRD &= ~_BV(PIND0);
PORTD |= _BV(PIND0);
#elif defined __AVR_ATmega8__
/* m8 */
UBRRH = (((F_CPU/BAUD_RATE)/16)-1)>>8; // set baud rate
UBRRL = (((F_CPU/BAUD_RATE)/16)-1);
UCSRB = (1<<RXEN)|(1<<TXEN); // enable Rx & Tx
UCSRC = (1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0); // config USART; 8N1
#else
/* m16,m32,m169,m8515,m8535 */
UBRRL = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1);
UBRRH = (F_CPU/(BAUD_RATE*16L)-1) >> 8;
UCSRA = 0x00;
UCSRC = 0x06;
UCSRB = _BV(TXEN)|_BV(RXEN);
#endif
/* set LED pin as output */
LED_DDR |= _BV(LED);
/* flash onboard LED to signal entering of bootloader */
#ifdef __AVR_ATmega128__
// 4x for UART0, 5x for UART1
flash_led(NUM_LED_FLASHES + bootuart);
#else
flash_led(NUM_LED_FLASHES);
#endif
/* 20050803: by DojoCorp, this is one of the parts provoking the
system to stop listening, cancelled from the original */
//putch('\0');
/* forever loop */
for (;;) {
/* get character from UART */
ch = getch();
/* A bunch of if...else if... gives smaller code than switch...case ! */
/* Hello is anyone home ? */
if(ch=='0') {
nothing_response();
}
/* Request programmer ID */
/* Not using PROGMEM string due to boot block in m128 being beyond 64kB boundry */
/* Would need to selectively manipulate RAMPZ, and it's only 9 characters anyway so who cares. */
else if(ch=='1') {
if (getch() == ' ') {
putch(0x14);
putch('A');
putch('V');
putch('R');
putch(' ');
putch('I');
putch('S');
putch('P');
putch(0x10);
} else {
if (++error_count == MAX_ERROR_COUNT)
app_start();
}
}
/* AVR ISP/STK500 board commands DON'T CARE so default nothing_response */
else if(ch=='@') {
ch2 = getch();
if (ch2>0x85) getch();
nothing_response();
}
/* AVR ISP/STK500 board requests */
else if(ch=='A') {
ch2 = getch();
if(ch2==0x80) byte_response(HW_VER); // Hardware version
else if(ch2==0x81) byte_response(SW_MAJOR); // Software major version
else if(ch2==0x82) byte_response(SW_MINOR); // Software minor version
else if(ch2==0x98) byte_response(0x03); // Unknown but seems to be required by avr studio 3.56
else byte_response(0x00); // Covers various unnecessary responses we don't care about
}
/* Device Parameters DON'T CARE, DEVICE IS FIXED */
else if(ch=='B') {
getNch(20);
nothing_response();
}
/* Parallel programming stuff DON'T CARE */
else if(ch=='E') {
getNch(5);
nothing_response();
}
/* Enter programming mode */
else if(ch=='P') {
nothing_response();
}
/* Leave programming mode */
else if(ch=='Q') {
nothing_response();
}
/* Erase device, don't care as we will erase one page at a time anyway. */
else if(ch=='R') {
nothing_response();
}
/* Set address, little endian. EEPROM in bytes, FLASH in words */
/* Perhaps extra address bytes may be added in future to support > 128kB FLASH. */
/* This might explain why little endian was used here, big endian used everywhere else. */
else if(ch=='U') {
address.byte[0] = getch();
address.byte[1] = getch();
nothing_response();
}
/* Universal SPI programming command, disabled. Would be used for fuses and lock bits. */
else if(ch=='V') {
getNch(4);
byte_response(0x00);
}
/* Write memory, length is big endian and is in bytes */
else if(ch=='d') {
length.byte[1] = getch();
length.byte[0] = getch();
flags.eeprom = 0;
if (getch() == 'E') flags.eeprom = 1;
for (w=0;w<length.word;w++) {
buff[w] = getch(); // Store data in buffer, can't keep up with serial data stream whilst programming pages
}
if (getch() == ' ') {
if (flags.eeprom) { //Write to EEPROM one byte at a time
for(w=0;w<length.word;w++) {
#ifdef __AVR_ATmega168__
while(EECR & (1<<EEPE));
EEAR = (uint16_t)(void *)address.word;
EEDR = buff[w];
EECR |= (1<<EEMPE);
EECR |= (1<<EEPE);
#else
eeprom_write_byte((void *)address.word,buff[w]);
#endif
address.word++;
}
}
else { //Write to FLASH one page at a time
if (address.byte[1]>127) address_high = 0x01; //Only possible with m128, m256 will need 3rd address byte. FIXME
else address_high = 0x00;
#ifdef __AVR_ATmega128__
RAMPZ = address_high;
#endif
address.word = address.word << 1; //address * 2 -> byte location
/* if ((length.byte[0] & 0x01) == 0x01) length.word++; //Even up an odd number of bytes */
if ((length.byte[0] & 0x01)) length.word++; //Even up an odd number of bytes
cli(); //Disable interrupts, just to be sure
// HACKME: EEPE used to be EEWE
while(bit_is_set(EECR,EEPE)); //Wait for previous EEPROM writes to complete
asm volatile(
"clr r17 \n\t" //page_word_count
"lds r30,address \n\t" //Address of FLASH location (in bytes)
"lds r31,address+1 \n\t"
"ldi r28,lo8(buff) \n\t" //Start of buffer array in RAM
"ldi r29,hi8(buff) \n\t"
"lds r24,length \n\t" //Length of data to be written (in bytes)
"lds r25,length+1 \n\t"
"length_loop: \n\t" //Main loop, repeat for number of words in block
"cpi r17,0x00 \n\t" //If page_word_count=0 then erase page
"brne no_page_erase \n\t"
"wait_spm1: \n\t"
"lds r16,%0 \n\t" //Wait for previous spm to complete
"andi r16,1 \n\t"
"cpi r16,1 \n\t"
"breq wait_spm1 \n\t"
"ldi r16,0x03 \n\t" //Erase page pointed to by Z
"sts %0,r16 \n\t"
"spm \n\t"
#ifdef __AVR_ATmega163__
".word 0xFFFF \n\t"
"nop \n\t"
#endif
"wait_spm2: \n\t"
"lds r16,%0 \n\t" //Wait for previous spm to complete
"andi r16,1 \n\t"
"cpi r16,1 \n\t"
"breq wait_spm2 \n\t"
"ldi r16,0x11 \n\t" //Re-enable RWW section
"sts %0,r16 \n\t"
"spm \n\t"
#ifdef __AVR_ATmega163__
".word 0xFFFF \n\t"
"nop \n\t"
#endif
"no_page_erase: \n\t"
"ld r0,Y+ \n\t" //Write 2 bytes into page buffer
"ld r1,Y+ \n\t"
"wait_spm3: \n\t"
"lds r16,%0 \n\t" //Wait for previous spm to complete
"andi r16,1 \n\t"
"cpi r16,1 \n\t"
"breq wait_spm3 \n\t"
"ldi r16,0x01 \n\t" //Load r0,r1 into FLASH page buffer
"sts %0,r16 \n\t"
"spm \n\t"
"inc r17 \n\t" //page_word_count++
"cpi r17,%1 \n\t"
"brlo same_page \n\t" //Still same page in FLASH
"write_page: \n\t"
"clr r17 \n\t" //New page, write current one first
"wait_spm4: \n\t"
"lds r16,%0 \n\t" //Wait for previous spm to complete
"andi r16,1 \n\t"
"cpi r16,1 \n\t"
"breq wait_spm4 \n\t"
#ifdef __AVR_ATmega163__
"andi r30,0x80 \n\t" // m163 requires Z6:Z1 to be zero during page write
#endif
"ldi r16,0x05 \n\t" //Write page pointed to by Z
"sts %0,r16 \n\t"
"spm \n\t"
#ifdef __AVR_ATmega163__
".word 0xFFFF \n\t"
"nop \n\t"
"ori r30,0x7E \n\t" // recover Z6:Z1 state after page write (had to be zero during write)
#endif
"wait_spm5: \n\t"
"lds r16,%0 \n\t" //Wait for previous spm to complete
"andi r16,1 \n\t"
"cpi r16,1 \n\t"
"breq wait_spm5 \n\t"
"ldi r16,0x11 \n\t" //Re-enable RWW section
"sts %0,r16 \n\t"
"spm \n\t"
#ifdef __AVR_ATmega163__
".word 0xFFFF \n\t"
"nop \n\t"
#endif
"same_page: \n\t"
"adiw r30,2 \n\t" //Next word in FLASH
"sbiw r24,2 \n\t" //length-2
"breq final_write \n\t" //Finished
"rjmp length_loop \n\t"
"final_write: \n\t"
"cpi r17,0 \n\t"
"breq block_done \n\t"
"adiw r24,2 \n\t" //length+2, fool above check on length after short page write
"rjmp write_page \n\t"
"block_done: \n\t"
"clr __zero_reg__ \n\t" //restore zero register
#if defined __AVR_ATmega168__
: "=m" (SPMCSR) : "M" (PAGE_SIZE) : "r0","r16","r17","r24","r25","r28","r29","r30","r31"
#else
: "=m" (SPMCR) : "M" (PAGE_SIZE) : "r0","r16","r17","r24","r25","r28","r29","r30","r31"
#endif
);
/* Should really add a wait for RWW section to be enabled, don't actually need it since we never */
/* exit the bootloader without a power cycle anyhow */
}
putch(0x14);
putch(0x10);
} else {
if (++error_count == MAX_ERROR_COUNT)
app_start();
}
}
/* Read memory block mode, length is big endian. */
else if(ch=='t') {
length.byte[1] = getch();
length.byte[0] = getch();
#if defined __AVR_ATmega128__
if (address.word>0x7FFF) flags.rampz = 1; // No go with m256, FIXME
else flags.rampz = 0;
#endif
if (getch() == 'E') flags.eeprom = 1;
else {
flags.eeprom = 0;
address.word = address.word << 1; // address * 2 -> byte location
}
if (getch() == ' ') { // Command terminator
putch(0x14);
for (w=0;w < length.word;w++) { // Can handle odd and even lengths okay
if (flags.eeprom) { // Byte access EEPROM read
#ifdef __AVR_ATmega168__
while(EECR & (1<<EEPE));
EEAR = (uint16_t)(void *)address.word;
EECR |= (1<<EERE);
putch(EEDR);
#else
putch(eeprom_read_byte((void *)address.word));
#endif
address.word++;
}
else {
if (!flags.rampz) putch(pgm_read_byte_near(address.word));
#if defined __AVR_ATmega128__
else putch(pgm_read_byte_far(address.word + 0x10000));
// Hmmmm, yuck FIXME when m256 arrvies
#endif
address.word++;
}
}
putch(0x10);
}
}
/* Get device signature bytes */
else if(ch=='u') {
if (getch() == ' ') {
putch(0x14);
putch(SIG1);
putch(SIG2);
putch(SIG3);
putch(0x10);
} else {
if (++error_count == MAX_ERROR_COUNT)
app_start();
}
}
/* Read oscillator calibration byte */
else if(ch=='v') {
byte_response(0x00);
}
#ifdef MONITOR
/* here come the extended monitor commands by Erik Lins */
/* check for three times exclamation mark pressed */
else if(ch=='!') {
ch = getch();
if(ch=='!') {
ch = getch();
if(ch=='!') {
#ifdef __AVR_ATmega128__
uint16_t extaddr;
#endif
uint8_t addrl, addrh;
#ifdef CRUMB128
PGM_P welcome = {"ATmegaBOOT / Crumb128 - (C) J.P.Kyle, E.Lins - 050815\n\r"};
#elif defined PROBOMEGA128
PGM_P welcome = {"ATmegaBOOT / PROBOmega128 - (C) J.P.Kyle, E.Lins - 050815\n\r"};
#elif defined SAVVY128
PGM_P welcome = {"ATmegaBOOT / Savvy128 - (C) J.P.Kyle, E.Lins - 050815\n\r"};
#endif
/* turn on LED */
LED_DDR |= _BV(LED);
LED_PORT &= ~_BV(LED);
/* print a welcome message and command overview */
for(i=0; welcome[i] != '\0'; ++i) {
putch(welcome[i]);
}
/* test for valid commands */
for(;;) {
putch('\n');
putch('\r');
putch(':');
putch(' ');
ch = getch();
putch(ch);
/* toggle LED */
if(ch == 't') {
if(bit_is_set(LED_PIN,LED)) {
LED_PORT &= ~_BV(LED);
putch('1');
} else {
LED_PORT |= _BV(LED);
putch('0');
}
}
/* read byte from address */
else if(ch == 'r') {
ch = getch(); putch(ch);
addrh = gethex();
addrl = gethex();
putch('=');
ch = *(uint8_t *)((addrh << 8) + addrl);
puthex(ch);
}
/* write a byte to address */
else if(ch == 'w') {
ch = getch(); putch(ch);
addrh = gethex();
addrl = gethex();
ch = getch(); putch(ch);
ch = gethex();
*(uint8_t *)((addrh << 8) + addrl) = ch;
}
/* read from uart and echo back */
else if(ch == 'u') {
for(;;) {
putch(getch());
}
}
#ifdef __AVR_ATmega128__
/* external bus loop */
else if(ch == 'b') {
putch('b');
putch('u');
putch('s');
MCUCR = 0x80;
XMCRA = 0;
XMCRB = 0;
extaddr = 0x1100;
for(;;) {
ch = *(volatile uint8_t *)extaddr;
if(++extaddr == 0) {
extaddr = 0x1100;
}
}
}
#endif
else if(ch == 'j') {
app_start();
}
}
/* end of monitor functions */
}
}
}
/* end of monitor */
#endif
else if (++error_count == MAX_ERROR_COUNT) {
app_start();
}
}
/* end of forever loop */
}
char gethex(void) {
char ah,al;
ah = getch(); putch(ah);
al = getch(); putch(al);
if(ah >= 'a') {
ah = ah - 'a' + 0x0a;
} else if(ah >= '0') {
ah -= '0';
}
if(al >= 'a') {
al = al - 'a' + 0x0a;
} else if(al >= '0') {
al -= '0';
}
return (ah << 4) + al;
}
void puthex(char ch) {
char ah,al;
ah = (ch & 0xf0) >> 4;
if(ah >= 0x0a) {
ah = ah - 0x0a + 'a';
} else {
ah += '0';
}
al = (ch & 0x0f);
if(al >= 0x0a) {
al = al - 0x0a + 'a';
} else {
al += '0';
}
putch(ah);
putch(al);
}
void putch(char ch)
{
#ifdef __AVR_ATmega128__
if(bootuart == 1) {
while (!(UCSR0A & _BV(UDRE0)));
UDR0 = ch;
}
else if (bootuart == 2) {
while (!(UCSR1A & _BV(UDRE1)));
UDR1 = ch;
}
#elif defined __AVR_ATmega168__
while (!(UCSR0A & _BV(UDRE0)));
UDR0 = ch;
#else
/* m8,16,32,169,8515,8535,163 */
while (!(UCSRA & _BV(UDRE)));
UDR = ch;
#endif
}
char getch(void)
{
#ifdef __AVR_ATmega128__
if(bootuart == 1) {
while(!(UCSR0A & _BV(RXC0)));
return UDR0;
}
else if(bootuart == 2) {
while(!(UCSR1A & _BV(RXC1)));
return UDR1;
}
return 0;
#elif defined __AVR_ATmega168__
uint32_t count = 0;
while(!(UCSR0A & _BV(RXC0))){
/* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/
/* HACKME:: here is a good place to count times*/
count++;
if (count > MAX_TIME_COUNT)
app_start();
}
return UDR0;
#else
/* m8,16,32,169,8515,8535,163 */
uint32_t count = 0;
while(!(UCSRA & _BV(RXC))){
/* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/
/* HACKME:: here is a good place to count times*/
count++;
if (count > MAX_TIME_COUNT)
app_start();
}
return UDR;
#endif
}
void getNch(uint8_t count)
{
uint8_t i;
for(i=0;i<count;i++) {
#ifdef __AVR_ATmega128__
if(bootuart == 1) {
while(!(UCSR0A & _BV(RXC0)));
UDR0;
}
else if(bootuart == 2) {
while(!(UCSR1A & _BV(RXC1)));
UDR1;
}
#elif defined __AVR_ATmega168__
while(!(UCSR0A & _BV(RXC0)));
UDR0;
#else
/* m8,16,32,169,8515,8535,163 */
/* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/
//while(!(UCSRA & _BV(RXC)));
//UDR;
uint8_t i;
for(i=0;i<count;i++) {
getch(); // need to handle time out
}
#endif
}
}
void byte_response(uint8_t val)
{
if (getch() == ' ') {
putch(0x14);
putch(val);
putch(0x10);
} else {
if (++error_count == MAX_ERROR_COUNT)
app_start();
}
}
void nothing_response(void)
{
if (getch() == ' ') {
putch(0x14);
putch(0x10);
} else {
if (++error_count == MAX_ERROR_COUNT)
app_start();
}
}
void flash_led(uint8_t count)
{
/* flash onboard LED three times to signal entering of bootloader */
/* l needs to be volatile or the delay loops below might get
optimized away if compiling with optimizations (DAM). */
volatile uint32_t l;
if (count == 0) {
count = 3;
}
for (i = 0; i < count; ++i) {
LED_PORT |= _BV(LED);
for(l = 0; l < (F_CPU / 1000); ++l);
LED_PORT &= ~_BV(LED);
for(l = 0; l < (F_CPU / 1000); ++l);
}
}
/* end of file ATmegaBOOT.c */

View file

@ -0,0 +1,84 @@
# Makefile for ATmegaBOOT
# E.Lins, 18.7.2005
# $Id$
# Instructions
#
# To build the bootloader for the LilyPad:
# make lily
# program name should not be changed...
PROGRAM = ATmegaBOOT_168
# enter the target CPU frequency
AVR_FREQ = 8000000L
# enter the parameters for the avrdude isp tool
ISPTOOL = stk500v2
ISPPORT = usb
ISPSPEED = -b 115200
MCU_TARGET = atmega168
LDSECTION = --section-start=.text=0x3800
# the efuse should really be 0xf8; since, however, only the lower
# three bits of that byte are used on the atmega168, avrdude gets
# confused if you specify 1's for the higher bits, see:
# http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/
#
# similarly, the lock bits should be 0xff instead of 0x3f (to
# unlock the bootloader section) and 0xcf instead of 0x0f (to
# lock it), but since the high two bits of the lock byte are
# unused, avrdude would get confused.
ISPFUSES = avrdude -c $(ISPTOOL) -p m168 -P $(ISPPORT) $(ISPSPEED) -e -u -U lock:w:0x3f:m -U efuse:w:0x00:m -U hfuse:w:0xdd:m -U lfuse:w:0xff:m
ISPFLASH = avrdude -c $(ISPTOOL) -p m168 -P $(ISPPORT) $(ISPSPEED) -U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x0f:m
OBJ = $(PROGRAM).o
OPTIMIZE = -O2
DEFS =
LIBS =
CC = avr-gcc
# Override is only needed by avr-lib build system.
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
override LDFLAGS = -Wl,$(LDSECTION)
#override LDFLAGS = -Wl,-Map,$(PROGRAM).map,$(LDSECTION)
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
all:
lily: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>1' '-DNUM_LED_FLASHES=3'
lily: $(PROGRAM).hex
$(PROGRAM).hex: $(PROGRAM).elf
$(OBJCOPY) -j .text -j .data -O ihex $< $@
$(PROGRAM).elf: $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
$(OBJ):
avr-gcc $(CFLAGS) $(LDFLAGS) -c -g -O2 -Wall -mmcu=atmega168 ATmegaBOOT.c -o ATmegaBOOT_168.o
%.lst: %.elf
$(OBJDUMP) -h -S $< > $@
%.srec: %.elf
$(OBJCOPY) -j .text -j .data -O srec $< $@
%.bin: %.elf
$(OBJCOPY) -j .text -j .data -O binary $< $@
clean:
rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex
install:
avrdude -p m168 -c stk500v2 -P /dev/cu.USA19H1b1P1.1 -e -u -U lock:w:0x3f:m -U efuse:w:0x00:m -U hfuse:w:0xdd:m -U lfuse:w:0xe2:m
avrdude -p m168 -c stk500v2 -P /dev/cu.USA19H1b1P1.1 -e -u -U flash:w:ATmegaBOOT_168.hex -U lock:w:0x0f:m

View file

@ -0,0 +1,239 @@
# Makefile for ATmegaBOOT
# E.Lins, 18.7.2005
# $Id$
#
# Instructions
#
# To make bootloader .hex file:
# make diecimila
# make lilypad
# make ng
# etc...
#
# To burn bootloader .hex file:
# make diecimila_isp
# make lilypad_isp
# make ng_isp
# etc...
# program name should not be changed...
PROGRAM = optiboot
# enter the parameters for the avrdude isp tool
ISPTOOL = stk500v2
ISPPORT = usb
ISPSPEED = -b 115200
MCU_TARGET = atmega168
LDSECTION = --section-start=.text=0x3e00
# the efuse should really be 0xf8; since, however, only the lower
# three bits of that byte are used on the atmega168, avrdude gets
# confused if you specify 1's for the higher bits, see:
# http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/
#
# similarly, the lock bits should be 0xff instead of 0x3f (to
# unlock the bootloader section) and 0xcf instead of 0x0f (to
# lock it), but since the high two bits of the lock byte are
# unused, avrdude would get confused.
ISPFUSES = avrdude -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
-e -u -U lock:w:0x3f:m -U efuse:w:0x$(EFUSE):m -U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m
ISPFLASH = avrdude -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
-U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x0f:m
STK500 = "C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe"
STK500-1 = $(STK500) -e -d$(MCU_TARGET) -pf -vf -if$(PROGRAM)_$(TARGET).hex \
-lFF -LFF -f$(HFUSE)$(LFUSE) -EF8 -ms -q -cUSB -I200kHz -s -wt
STK500-2 = $(STK500) -d$(MCU_TARGET) -ms -q -lCF -LCF -cUSB -I200kHz -s -wt
OBJ = $(PROGRAM).o
OPTIMIZE = -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls
DEFS =
LIBS =
CC = avr-gcc
# Override is only needed by avr-lib build system.
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
override LDFLAGS = -Wl,$(LDSECTION) -Wl,--relax -nostartfiles
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
# 20MHz clocked platforms
#
# These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue)
#
pro20: TARGET = pro_20mhz
pro20: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
pro20: AVR_FREQ = 20000000L
pro20: $(PROGRAM)_pro_20mhz.hex
pro20: $(PROGRAM)_pro_20mhz.lst
pro20_isp: pro20
pro20_isp: TARGET = pro_20mhz
pro20_isp: HFUSE = DD # 2.7V brownout
pro20_isp: LFUSE = C6 # Full swing xtal (20MHz) 258CK/14CK+4.1ms
pro20_isp: EFUSE = 02 # 512 byte boot
pro20_isp: isp
# 16MHz clocked platforms
#
# These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue)
#
pro16: TARGET = pro_16MHz
pro16: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
pro16: AVR_FREQ = 16000000L
pro16: $(PROGRAM)_pro_16MHz.hex
pro16: $(PROGRAM)_pro_16MHz.lst
pro16_isp: pro16
pro16_isp: TARGET = pro_16MHz
pro16_isp: HFUSE = DD # 2.7V brownout
pro16_isp: LFUSE = C6 # Full swing xtal (20MHz) 258CK/14CK+4.1ms
pro16_isp: EFUSE = 02 # 512 byte boot
pro16_isp: isp
# Diecimila and NG use identical bootloaders
#
diecimila: TARGET = diecimila
diecimila: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
diecimila: AVR_FREQ = 16000000L
diecimila: $(PROGRAM)_diecimila.hex
diecimila: $(PROGRAM)_diecimila.lst
diecimila_isp: diecimila
diecimila_isp: TARGET = diecimila
diecimila_isp: HFUSE = DD # 2.7V brownout
diecimila_isp: LFUSE = FF # Low power xtal (16MHz) 16KCK/14CK+65ms
diecimila_isp: EFUSE = 02 # 512 byte boot
diecimila_isp: isp
atmega328: TARGET = atmega328
atmega328: MCU_TARGET = atmega328p
atmega328: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
atmega328: AVR_FREQ = 16000000L
atmega328: LDSECTION = --section-start=.text=0x7e00
atmega328: $(PROGRAM)_atmega328.hex
atmega328: $(PROGRAM)_atmega328.lst
atmega328_isp: atmega328
atmega328_isp: TARGET = atmega328
atmega328_isp: MCU_TARGET = atmega328p
atmega328_isp: HFUSE = DE # 512 byte boot
atmega328_isp: LFUSE = FF # Low power xtal (16MHz) 16KCK/14CK+65ms
atmega328_isp: EFUSE = 05 # 2.7V brownout
atmega328_isp: isp
# 8MHz clocked platforms
#
# These are capable of 115200 baud
#
lilypad: TARGET = lilypad
lilypad: CFLAGS += '-DLED_START_FLASHES=3' '-DSOFT_UART' '-DBAUD_RATE=115200'
lilypad: AVR_FREQ = 8000000L
lilypad: $(PROGRAM)_lilypad.hex
lilypad: $(PROGRAM)_lilypad.lst
lilypad_isp: lilypad
lilypad_isp: TARGET = lilypad
lilypad_isp: HFUSE = DD # 2.7V brownout
lilypad_isp: LFUSE = E2 # Internal 8MHz osc (8MHz) Slow rising power
lilypad_isp: EFUSE = 02 # 512 byte boot
lilypad_isp: isp
lilypad_resonator: TARGET = lilypad_resonator
lilypad_resonator: CFLAGS += '-DLED_START_FLASHES=3' '-DSOFT_UART' '-DBAUD_RATE=115200'
lilypad_resonator: AVR_FREQ = 8000000L
lilypad_resonator: $(PROGRAM)_lilypad_resonator.hex
lilypad_resonator: $(PROGRAM)_lilypad_resonator.lst
lilypad_resonator_isp: lilypad_resonator
lilypad_resonator_isp: TARGET = lilypad_resonator
lilypad_resonator_isp: HFUSE = DD # 2.7V brownout
lilypad_resonator_isp: LFUSE = C6 # Full swing xtal (20MHz) 258CK/14CK+4.1ms
lilypad_resonator_isp: EFUSE = 02 # 512 byte boot
lilypad_resonator_isp: isp
pro8: TARGET = pro_8MHz
pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DSOFT_UART' '-DBAUD_RATE=115200'
pro8: AVR_FREQ = 8000000L
pro8: $(PROGRAM)_pro_8MHz.hex
pro8: $(PROGRAM)_pro_8MHz.lst
pro8_isp: pro8
pro8_isp: TARGET = pro_8MHz
pro8_isp: HFUSE = DD # 2.7V brownout
pro8_isp: LFUSE = C6 # Full swing xtal (20MHz) 258CK/14CK+4.1ms
pro8_isp: EFUSE = 02 # 512 byte boot
pro8_isp: isp
atmega328_pro8: TARGET = atmega328_pro_8MHz
atmega328_pro8: MCU_TARGET = atmega328p
atmega328_pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
atmega328_pro8: AVR_FREQ = 8000000L
atmega328_pro8: LDSECTION = --section-start=.text=0x7e00
atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.hex
atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.lst
atmega328_pro8_isp: atmega328_pro8
atmega328_pro8_isp: TARGET = atmega328_pro_8MHz
atmega328_pro8_isp: MCU_TARGET = atmega328p
atmega328_pro8_isp: HFUSE = DE # 512 byte boot
atmega328_pro8_isp: LFUSE = FF # Low power xtal (16MHz) 16KCK/14CK+65ms
atmega328_pro8_isp: EFUSE = 05 # 2.7V brownout
atmega328_pro8_isp: isp
# 1MHz clocked platforms
#
# These are capable of 9600 baud
#
luminet: TARGET = luminet
luminet: MCU_TARGET = attiny84
luminet: CFLAGS += '-DLED_START_FLASHES=3' '-DSOFT_UART' '-DBAUD_RATE=9600'
luminet: CFLAGS += '-DVIRTUAL_BOOT_PARTITION'
luminet: AVR_FREQ = 1000000L
luminet: LDSECTION = --section-start=.text=0x1d00
luminet: $(PROGRAM)_luminet.hex
luminet: $(PROGRAM)_luminet.lst
luminet_isp: luminet
luminet_isp: TARGET = luminet
luminet_isp: MCU_TARGET = attiny84
luminet_isp: HFUSE = DF # Brownout disabled
luminet_isp: LFUSE = 62 # 1MHz internal oscillator, slowly rising power
luminet_isp: EFUSE = FE # Self-programming enable
luminet_isp: isp
isp: $(TARGET)
$(ISPFUSES)
$(ISPFLASH)
isp-stk500: $(PROGRAM)_$(TARGET).hex
$(STK500-1)
$(STK500-2)
%.elf: $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
clean:
rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex
%.lst: %.elf
$(OBJDUMP) -h -S $< > $@
%.hex: %.elf
$(OBJCOPY) -j .text -j .data -O ihex $< $@
%.srec: %.elf
$(OBJCOPY) -j .text -j .data -O srec $< $@
%.bin: %.elf
$(OBJCOPY) -j .text -j .data -O binary $< $@

View file

@ -0,0 +1,13 @@
#!/bin/bash
make clean
make lilypad
make lilypad_resonator
make pro8
make pro16
make pro20
make diecimila
make ng
make atmega328
make atmega328_pro8
make luminet

View file

@ -0,0 +1,536 @@
/**********************************************************/
/* Optiboot bootloader for Arduino */
/* */
/* Heavily optimised bootloader that is faster and */
/* smaller than the Arduino standard bootloader */
/* */
/* Enhancements: */
/* Fits in 512 bytes, saving 1.5K of code space */
/* Background page erasing speeds up programming */
/* Higher baud rate speeds up programming */
/* Written almost entirely in C */
/* Customisable timeout with accurate timeconstant */
/* */
/* What you lose: */
/* Implements a skeleton STK500 protocol which is */
/* missing several features including EEPROM */
/* programming and non-page-aligned writes */
/* High baud rate breaks compatibility with standard */
/* Arduino flash settings */
/* */
/* Currently supports: */
/* ATmega168 based devices (Diecimila etc) */
/* ATmega328P based devices (Duemilanove etc) */
/* */
/* Does not support: */
/* ATmega1280 based devices (eg. Mega) */
/* */
/* Assumptions: */
/* The code makes several assumptions that reduce the */
/* code size. They are all true after a hardware reset, */
/* but may not be true if the bootloader is called by */
/* other means or on other hardware. */
/* No interrupts can occur */
/* UART and Timer 1 are set to their reset state */
/* SP points to RAMEND */
/* */
/* Code builds on code, libraries and optimisations from: */
/* stk500boot.c by Jason P. Kyle */
/* Arduino bootloader http://arduino.cc */
/* Spiff's 1K bootloader http://spiffie.org/know/arduino_1k_bootloader/bootloader.shtml */
/* avr-libc project http://nongnu.org/avr-libc */
/* Adaboot http://www.ladyada.net/library/arduino/bootloader.html */
/* AVR305 Atmel Application Note */
/* */
/* This program is free software; you can redistribute it */
/* and/or modify it under the terms of the GNU General */
/* Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or */
/* (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will */
/* be useful, but WITHOUT ANY WARRANTY; without even the */
/* implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public */
/* License for more details. */
/* */
/* You should have received a copy of the GNU General */
/* Public License along with this program; if not, write */
/* to the Free Software Foundation, Inc., */
/* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* */
/* Licence can be viewed at */
/* http://www.fsf.org/licenses/gpl.txt */
/* */
/**********************************************************/
#include <inttypes.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/boot.h>
//#define LED_DATA_FLASH
#ifndef LED_START_FLASHES
#define LED_START_FLASHES 0
#endif
/* Build-time variables */
/* BAUD_RATE Programming baud rate */
/* LED_NO_FLASHES Number of LED flashes on boot */
/* FLASH_TIME_MS Duration of each LED flash */
/* BOOT_TIMEOUT_MS Serial port wait time before exiting bootloader */
/* set the UART baud rate */
#ifndef BAUD_RATE
#define BAUD_RATE 19200
#endif
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
/* Onboard LED is connected to pin PB5 in Arduino NG, Diecimila, and Duemilanove */
#define LED_DDR DDRB
#define LED_PORT PORTB
#define LED_PIN PINB
#define LED PINB5
/* Ports for soft UART */
#ifdef SOFT_UART
#define UART_PORT PORTD
#define UART_PIN PIND
#define UART_DDR DDRD
#define UART_TX_BIT 1
#define UART_RX_BIT 0
#endif
#endif
#if defined(__AVR_ATtiny84__)
/* Onboard LED is connected to pin PB5 in Arduino NG, Diecimila, and Duemilanove */
#define LED_DDR DDRA
#define LED_PORT PORTA
#define LED_PIN PINA
#define LED PINA4
/* Ports for soft UART - left port only for now*/
#ifdef SOFT_UART
#define UART_PORT PORTA
#define UART_PIN PINA
#define UART_DDR DDRA
#define UART_TX_BIT 2
#define UART_RX_BIT 3
#endif
#endif
/* STK500 constants list, from AVRDUDE */
#define STK_OK 0x10
#define STK_FAILED 0x11 // Not used
#define STK_UNKNOWN 0x12 // Not used
#define STK_NODEVICE 0x13 // Not used
#define STK_INSYNC 0x14 // ' '
#define STK_NOSYNC 0x15 // Not used
#define ADC_CHANNEL_ERROR 0x16 // Not used
#define ADC_MEASURE_OK 0x17 // Not used
#define PWM_CHANNEL_ERROR 0x18 // Not used
#define PWM_ADJUST_OK 0x19 // Not used
#define CRC_EOP 0x20 // 'SPACE'
#define STK_GET_SYNC 0x30 // '0'
#define STK_GET_SIGN_ON 0x31 // '1'
#define STK_SET_PARAMETER 0x40 // '@'
#define STK_GET_PARAMETER 0x41 // 'A'
#define STK_SET_DEVICE 0x42 // 'B'
#define STK_SET_DEVICE_EXT 0x45 // 'E'
#define STK_ENTER_PROGMODE 0x50 // 'P'
#define STK_LEAVE_PROGMODE 0x51 // 'Q'
#define STK_CHIP_ERASE 0x52 // 'R'
#define STK_CHECK_AUTOINC 0x53 // 'S'
#define STK_LOAD_ADDRESS 0x55 // 'U'
#define STK_UNIVERSAL 0x56 // 'V'
#define STK_PROG_FLASH 0x60 // '`'
#define STK_PROG_DATA 0x61 // 'a'
#define STK_PROG_FUSE 0x62 // 'b'
#define STK_PROG_LOCK 0x63 // 'c'
#define STK_PROG_PAGE 0x64 // 'd'
#define STK_PROG_FUSE_EXT 0x65 // 'e'
#define STK_READ_FLASH 0x70 // 'p'
#define STK_READ_DATA 0x71 // 'q'
#define STK_READ_FUSE 0x72 // 'r'
#define STK_READ_LOCK 0x73 // 's'
#define STK_READ_PAGE 0x74 // 't'
#define STK_READ_SIGN 0x75 // 'u'
#define STK_READ_OSCCAL 0x76 // 'v'
#define STK_READ_FUSE_EXT 0x77 // 'w'
#define STK_READ_OSCCAL_EXT 0x78 // 'x'
/* Watchdog settings */
#define WATCHDOG_OFF (0)
#define WATCHDOG_16MS (_BV(WDE))
#define WATCHDOG_32MS (_BV(WDP0) | _BV(WDE))
#define WATCHDOG_64MS (_BV(WDP1) | _BV(WDE))
#define WATCHDOG_125MS (_BV(WDP1) | _BV(WDP0) | _BV(WDE))
#define WATCHDOG_250MS (_BV(WDP2) | _BV(WDE))
#define WATCHDOG_500MS (_BV(WDP2) | _BV(WDP0) | _BV(WDE))
#define WATCHDOG_1S (_BV(WDP2) | _BV(WDP1) | _BV(WDE))
#define WATCHDOG_2S (_BV(WDP2) | _BV(WDP1) | _BV(WDP0) | _BV(WDE))
#define WATCHDOG_4S (_BV(WDE3) | _BV(WDE))
#define WATCHDOG_8S (_BV(WDE3) | _BV(WDE0) | _BV(WDE))
/* Function Prototypes */
/* The main function is in init9, which removes the interrupt vector table */
/* we don't need. It is also 'naked', which means the compiler does not */
/* generate any entry or exit code itself. */
int main(void) __attribute__ ((naked)) __attribute__ ((section (".init9")));
void putch(char);
uint8_t getch(void);
static inline void getNch(uint8_t); /* "static inline" is a compiler hint to reduce code size */
void verifySpace();
static inline void flash_led(uint8_t);
uint8_t getLen();
static inline void watchdogReset();
void watchdogConfig(uint8_t x);
#ifdef SOFT_UART
void uartDelay() __attribute__ ((naked));
#endif
void appStart() __attribute__ ((naked));
/* C zero initialises all global variables. However, that requires */
/* These definitions are NOT zero initialised, but that doesn't matter */
/* This allows us to drop the zero init code, saving us memory */
#define buff ((uint8_t*)(0x100))
#define address (*(uint16_t*)(0x200))
#define length (*(uint8_t*)(0x202))
#ifdef VIRTUAL_BOOT_PARTITION
#define rstVect (*(uint16_t*)(0x204))
#define wdtVect (*(uint16_t*)(0x206))
#endif
/* main program starts here */
int main(void) {
// After the zero init loop, this is the first code to run.
//
// This code makes the following assumptions:
// No interrupts will execute
// SP points to RAMEND
// r1 contains zero
//
// If not, uncomment the following instructions:
// cli();
// SP=RAMEND; // This is done by hardware reset
// asm volatile ("clr __zero_reg__");
uint8_t ch;
#if LED_START_FLASHES > 0
// Set up Timer 1 for timeout counter
TCCR1B = _BV(CS12) | _BV(CS10); // div 1024
#endif
#ifndef SOFT_UART
UCSR0A = _BV(U2X0); //Double speed mode USART0
UCSR0B = _BV(RXEN0) | _BV(TXEN0);
UCSR0C = _BV(UCSZ00) | _BV(UCSZ01);
UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
#endif
// Adaboot no-wait mod
ch = MCUSR;
MCUSR = 0;
if (!(ch & _BV(EXTRF))) appStart();
// Set up watchdog to trigger after 500ms
watchdogConfig(WATCHDOG_500MS);
/* Set LED pin as output */
LED_DDR |= _BV(LED);
#ifdef SOFT_UART
/* Set TX pin as output */
UART_DDR |= _BV(UART_TX_BIT);
#endif
#if LED_START_FLASHES > 0
/* Flash onboard LED to signal entering of bootloader */
flash_led(LED_START_FLASHES * 2);
#endif
/* Forever loop */
for (;;) {
/* get character from UART */
ch = getch();
if(ch == STK_GET_PARAMETER) {
// GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy
getNch(1);
putch(0x03);
}
else if(ch == STK_SET_DEVICE) {
// SET DEVICE is ignored
getNch(20);
}
else if(ch == STK_SET_DEVICE_EXT) {
// SET DEVICE EXT is ignored
getNch(5);
}
else if(ch == STK_LOAD_ADDRESS) {
// LOAD ADDRESS
address = getch();
address = (address & 0xff) | (getch() << 8);
address += address; // Convert from word address to byte address
verifySpace();
}
else if(ch == STK_UNIVERSAL) {
// UNIVERSAL command is ignored
getNch(4);
putch(0x00);
}
/* Write memory, length is big endian and is in bytes */
else if(ch == STK_PROG_PAGE) {
// PROGRAM PAGE - we support flash programming only, not EEPROM
uint8_t *bufPtr;
uint16_t addrPtr;
getLen();
// Immediately start page erase - this will 4.5ms
boot_page_erase((uint16_t)(void*)address);
// While that is going on, read in page contents
bufPtr = buff;
do *bufPtr++ = getch();
while (--length);
// Read command terminator, start reply
verifySpace();
// If only a partial page is to be programmed, the erase might not be complete.
// So check that here
boot_spm_busy_wait();
#ifdef VIRTUAL_BOOT_PARTITION
if ((uint16_t)(void*)address == 0) {
// This is the reset vector page. We need to live-patch the code so the
// bootloader runs.
//
// Move RESET vector to WDT vector
uint16_t vect = buff[0] | (buff[1]<<8);
rstVect = vect;
wdtVect = buff[10] | (buff[11]<<8);
vect -= 4; // Instruction is a relative jump (rjmp), so recalculate.
buff[10] = vect & 0xff;
buff[11] = vect >> 8;
// Add jump to bootloader at RESET vector
buff[0] = 0x7f;
buff[1] = 0xce; // rjmp 0x1d00 instruction
}
#endif
// Copy buffer into programming buffer
bufPtr = buff;
addrPtr = (uint16_t)(void*)address;
ch = SPM_PAGESIZE / 2;
do {
uint16_t a;
a = *bufPtr++;
a |= (*bufPtr++) << 8;
boot_page_fill((uint16_t)(void*)addrPtr,a);
addrPtr += 2;
} while (--ch);
// Write from programming buffer
boot_page_write((uint16_t)(void*)address);
boot_spm_busy_wait();
#if defined(RWWSRE)
// Reenable read access to flash
boot_rww_enable();
#endif
}
/* Read memory block mode, length is big endian. */
else if(ch == STK_READ_PAGE) {
// READ PAGE - we only read flash
getLen();
verifySpace();
#ifdef VIRTUAL_BOOT_PARTITION
do {
// Undo vector patch in bottom page so verify passes
if (address == 0) ch=rstVect & 0xff;
else if (address == 1) ch=rstVect >> 8;
else if (address == 10) ch=wdtVect & 0xff;
else if (address == 11) ch=wdtVect >> 8;
else ch = pgm_read_byte_near(address);
address++;
putch(ch);
} while (--length);
#else
do putch(pgm_read_byte_near(address++));
while (--length);
#endif
}
/* Get device signature bytes */
else if(ch == STK_READ_SIGN) {
// READ SIGN - return what Avrdude wants to hear
verifySpace();
putch(SIGNATURE_0);
putch(SIGNATURE_1);
putch(SIGNATURE_2);
}
else if (ch == 'Q') {
// Adaboot no-wait mod
watchdogConfig(WATCHDOG_16MS);
verifySpace();
}
else {
// This covers the response to commands like STK_ENTER_PROGMODE
verifySpace();
}
putch(STK_OK);
}
}
void putch(char ch) {
#ifndef SOFT_UART
while (!(UCSR0A & _BV(UDRE0)));
UDR0 = ch;
#else
__asm__ __volatile__ (
" com %[ch]\n" // ones complement, carry set
" sec\n"
"1: brcc 2f\n"
" cbi %[uartPort],%[uartBit]\n"
" rjmp 3f\n"
"2: sbi %[uartPort],%[uartBit]\n"
" nop\n"
"3: rcall uartDelay\n"
" rcall uartDelay\n"
" lsr %[ch]\n"
" dec %[bitcnt]\n"
" brne 1b\n"
:
:
[bitcnt] "d" (10),
[ch] "r" (ch),
[uartPort] "I" (_SFR_IO_ADDR(UART_PORT)),
[uartBit] "I" (UART_TX_BIT)
:
"r25"
);
#endif
}
uint8_t getch(void) {
uint8_t ch;
watchdogReset();
#ifdef LED_DATA_FLASH
LED_PIN |= _BV(LED);
#endif
#ifdef SOFT_UART
__asm__ __volatile__ (
"1: sbic %[uartPin],%[uartBit]\n" // Wait for start edge
" rjmp 1b\n"
" rcall uartDelay\n" // Get to middle of start bit
"2: rcall uartDelay\n" // Wait 1 bit period
" rcall uartDelay\n" // Wait 1 bit period
" clc\n"
" sbic %[uartPin],%[uartBit]\n"
" sec\n"
" dec %[bitCnt]\n"
" breq 3f\n"
" ror %[ch]\n"
" rjmp 2b\n"
"3:\n"
:
[ch] "=r" (ch)
:
[bitCnt] "d" (9),
[uartPin] "I" (_SFR_IO_ADDR(UART_PIN)),
[uartBit] "I" (UART_RX_BIT)
:
"r25"
);
#else
while(!(UCSR0A & _BV(RXC0)));
ch = UDR0;
#endif
#ifdef LED_DATA_FLASH
LED_PIN |= _BV(LED);
#endif
return ch;
}
#ifdef SOFT_UART
//#define UART_B_VALUE (((F_CPU/BAUD_RATE)-23)/6)
#define UART_B_VALUE (((F_CPU/BAUD_RATE)-20)/6)
#if UART_B_VALUE > 255
#error Baud rate too slow for soft UART
#endif
void uartDelay() {
__asm__ __volatile__ (
"ldi r25,%[count]\n"
"1:dec r25\n"
"brne 1b\n"
"ret\n"
::[count] "M" (UART_B_VALUE)
);
}
#endif
void getNch(uint8_t count) {
do getch(); while (--count);
verifySpace();
}
void verifySpace() {
if (getch() != CRC_EOP) appStart();
putch(STK_INSYNC);
}
#if LED_START_FLASHES > 0
void flash_led(uint8_t count) {
do {
TCNT1 = -(F_CPU/(1024*16));
TIFR1 = _BV(TOV1);
while(!(TIFR1 & _BV(TOV1)));
LED_PIN |= _BV(LED);
watchdogReset();
} while (--count);
}
#endif
uint8_t getLen() {
getch();
length = getch();
return getch();
}
// Watchdog functions. These are only safe with interrupts turned off.
void watchdogReset() {
__asm__ __volatile__ (
"wdr\n"
);
}
void watchdogConfig(uint8_t x) {
WDTCSR = _BV(WDCE) | _BV(WDE);
WDTCSR = x;
}
void appStart() {
watchdogConfig(WATCHDOG_OFF);
__asm__ __volatile__ (
#ifdef VIRTUAL_BOOT_PARTITION
// Jump to WDT vector
"ldi r30,5\n"
"clr r31\n"
#else
// Jump to RST vector
"clr r30\n"
"clr r31\n"
#endif
"ijmp\n"
);
}

View file

@ -0,0 +1,33 @@
:107E000085E08093810082E08093C00088E18093C8
:107E1000C10086E08093C20080E18093C40084B7F3
:107E200014BE81FFD0D08DE0C8D0259A86E020E333
:107E30003CEF91E0309385002093840096BBB09B8B
:107E4000FECF1D9AA8958150A9F7DD24D394A5E013
:107E5000EA2EF1E1FF2EA4D0813421F481E0BED0DE
:107E600083E024C0823411F484E103C0853419F422
:107E700085E0B4D08AC08535A1F492D0082F10E0F7
:107E800010930102009300028BD090E0982F882776
:107E9000802B912B880F991F9093010280930002F1
:107EA00073C0863529F484E099D080E071D06DC02C
:107EB000843609F043C07CD0E0910002F0910102C9
:107EC00083E080935700E895C0E0D1E069D08993C2
:107ED000809102028150809302028823B9F778D002
:107EE00007B600FCFDCF4091000250910102A0E0D6
:107EF000B1E02C9130E011968C91119790E0982F81
:107F00008827822B932B1296FA010C01D0925700EE
:107F1000E89511244E5F5F4FF1E0A038BF0749F7A5
:107F2000E0910002F0910102E0925700E89507B657
:107F300000FCFDCFF0925700E89527C08437B9F4D4
:107F400037D046D0E0910002F09101023196F093D3
:107F50000102E09300023197E4918E2F19D08091B5
:107F60000202815080930202882361F70EC0853798
:107F700039F42ED08EE10CD085E90AD08FE096CF6F
:107F8000813511F488E019D023D080E101D063CF8E
:107F9000982F8091C00085FFFCCF9093C600089574
:107FA000A8958091C00087FFFCCF8091C6000895FE
:107FB000F7DFF6DF80930202F3CFE0E6F0E098E12E
:107FC00090838083089580E0F8DFEE27FF270994EF
:107FD000E7DF803209F0F7DF84E1DACF1F93182F53
:0C7FE000DFDF1150E9F7F4DF1F91089576
:0400000300007E007B
:00000001FF

View file

@ -0,0 +1,520 @@
optiboot_atmega328.elf: file format elf32-avr
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 000001ec 00007e00 00007e00 00000054 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .debug_aranges 00000028 00000000 00000000 00000240 2**0
CONTENTS, READONLY, DEBUGGING
2 .debug_pubnames 0000006a 00000000 00000000 00000268 2**0
CONTENTS, READONLY, DEBUGGING
3 .debug_info 00000269 00000000 00000000 000002d2 2**0
CONTENTS, READONLY, DEBUGGING
4 .debug_abbrev 00000196 00000000 00000000 0000053b 2**0
CONTENTS, READONLY, DEBUGGING
5 .debug_line 000003d3 00000000 00000000 000006d1 2**0
CONTENTS, READONLY, DEBUGGING
6 .debug_frame 00000090 00000000 00000000 00000aa4 2**2
CONTENTS, READONLY, DEBUGGING
7 .debug_str 00000135 00000000 00000000 00000b34 2**0
CONTENTS, READONLY, DEBUGGING
8 .debug_loc 000001d1 00000000 00000000 00000c69 2**0
CONTENTS, READONLY, DEBUGGING
9 .debug_ranges 00000068 00000000 00000000 00000e3a 2**0
CONTENTS, READONLY, DEBUGGING
Disassembly of section .text:
00007e00 <main>:
#ifdef VIRTUAL_BOOT_PARTITION
#define rstVect (*(uint16_t*)(0x204))
#define wdtVect (*(uint16_t*)(0x206))
#endif
/* main program starts here */
int main(void) {
7e00: 85 e0 ldi r24, 0x05 ; 5
7e02: 80 93 81 00 sts 0x0081, r24
#if LED_START_FLASHES > 0
// Set up Timer 1 for timeout counter
TCCR1B = _BV(CS12) | _BV(CS10); // div 1024
#endif
#ifndef SOFT_UART
UCSR0A = _BV(U2X0); //Double speed mode USART0
7e06: 82 e0 ldi r24, 0x02 ; 2
7e08: 80 93 c0 00 sts 0x00C0, r24
UCSR0B = _BV(RXEN0) | _BV(TXEN0);
7e0c: 88 e1 ldi r24, 0x18 ; 24
7e0e: 80 93 c1 00 sts 0x00C1, r24
UCSR0C = _BV(UCSZ00) | _BV(UCSZ01);
7e12: 86 e0 ldi r24, 0x06 ; 6
7e14: 80 93 c2 00 sts 0x00C2, r24
UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
7e18: 80 e1 ldi r24, 0x10 ; 16
7e1a: 80 93 c4 00 sts 0x00C4, r24
#endif
// Adaboot no-wait mod
ch = MCUSR;
7e1e: 84 b7 in r24, 0x34 ; 52
MCUSR = 0;
7e20: 14 be out 0x34, r1 ; 52
if (!(ch & _BV(EXTRF))) appStart();
7e22: 81 ff sbrs r24, 1
7e24: d0 d0 rcall .+416 ; 0x7fc6 <appStart>
// Set up watchdog to trigger after 500ms
watchdogConfig(WATCHDOG_500MS);
7e26: 8d e0 ldi r24, 0x0D ; 13
7e28: c8 d0 rcall .+400 ; 0x7fba <watchdogConfig>
/* Set LED pin as output */
LED_DDR |= _BV(LED);
7e2a: 25 9a sbi 0x04, 5 ; 4
7e2c: 86 e0 ldi r24, 0x06 ; 6
}
#if LED_START_FLASHES > 0
void flash_led(uint8_t count) {
do {
TCNT1 = -(F_CPU/(1024*16));
7e2e: 20 e3 ldi r18, 0x30 ; 48
7e30: 3c ef ldi r19, 0xFC ; 252
TIFR1 = _BV(TOV1);
7e32: 91 e0 ldi r25, 0x01 ; 1
}
#if LED_START_FLASHES > 0
void flash_led(uint8_t count) {
do {
TCNT1 = -(F_CPU/(1024*16));
7e34: 30 93 85 00 sts 0x0085, r19
7e38: 20 93 84 00 sts 0x0084, r18
TIFR1 = _BV(TOV1);
7e3c: 96 bb out 0x16, r25 ; 22
while(!(TIFR1 & _BV(TOV1)));
7e3e: b0 9b sbis 0x16, 0 ; 22
7e40: fe cf rjmp .-4 ; 0x7e3e <main+0x3e>
LED_PIN |= _BV(LED);
7e42: 1d 9a sbi 0x03, 5 ; 3
return getch();
}
// Watchdog functions. These are only safe with interrupts turned off.
void watchdogReset() {
__asm__ __volatile__ (
7e44: a8 95 wdr
TCNT1 = -(F_CPU/(1024*16));
TIFR1 = _BV(TOV1);
while(!(TIFR1 & _BV(TOV1)));
LED_PIN |= _BV(LED);
watchdogReset();
} while (--count);
7e46: 81 50 subi r24, 0x01 ; 1
7e48: a9 f7 brne .-22 ; 0x7e34 <main+0x34>
/* get character from UART */
ch = getch();
if(ch == STK_GET_PARAMETER) {
// GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy
getNch(1);
7e4a: dd 24 eor r13, r13
7e4c: d3 94 inc r13
boot_page_fill((uint16_t)(void*)addrPtr,a);
addrPtr += 2;
} while (--ch);
// Write from programming buffer
boot_page_write((uint16_t)(void*)address);
7e4e: a5 e0 ldi r26, 0x05 ; 5
7e50: ea 2e mov r14, r26
boot_spm_busy_wait();
#if defined(RWWSRE)
// Reenable read access to flash
boot_rww_enable();
7e52: f1 e1 ldi r31, 0x11 ; 17
7e54: ff 2e mov r15, r31
#endif
/* Forever loop */
for (;;) {
/* get character from UART */
ch = getch();
7e56: a4 d0 rcall .+328 ; 0x7fa0 <getch>
if(ch == STK_GET_PARAMETER) {
7e58: 81 34 cpi r24, 0x41 ; 65
7e5a: 21 f4 brne .+8 ; 0x7e64 <main+0x64>
// GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy
getNch(1);
7e5c: 81 e0 ldi r24, 0x01 ; 1
7e5e: be d0 rcall .+380 ; 0x7fdc <verifySpace+0xc>
putch(0x03);
7e60: 83 e0 ldi r24, 0x03 ; 3
7e62: 24 c0 rjmp .+72 ; 0x7eac <main+0xac>
}
else if(ch == STK_SET_DEVICE) {
7e64: 82 34 cpi r24, 0x42 ; 66
7e66: 11 f4 brne .+4 ; 0x7e6c <main+0x6c>
// SET DEVICE is ignored
getNch(20);
7e68: 84 e1 ldi r24, 0x14 ; 20
7e6a: 03 c0 rjmp .+6 ; 0x7e72 <main+0x72>
}
else if(ch == STK_SET_DEVICE_EXT) {
7e6c: 85 34 cpi r24, 0x45 ; 69
7e6e: 19 f4 brne .+6 ; 0x7e76 <main+0x76>
// SET DEVICE EXT is ignored
getNch(5);
7e70: 85 e0 ldi r24, 0x05 ; 5
7e72: b4 d0 rcall .+360 ; 0x7fdc <verifySpace+0xc>
7e74: 8a c0 rjmp .+276 ; 0x7f8a <main+0x18a>
}
else if(ch == STK_LOAD_ADDRESS) {
7e76: 85 35 cpi r24, 0x55 ; 85
7e78: a1 f4 brne .+40 ; 0x7ea2 <main+0xa2>
// LOAD ADDRESS
address = getch();
7e7a: 92 d0 rcall .+292 ; 0x7fa0 <getch>
7e7c: 08 2f mov r16, r24
7e7e: 10 e0 ldi r17, 0x00 ; 0
7e80: 10 93 01 02 sts 0x0201, r17
7e84: 00 93 00 02 sts 0x0200, r16
address = (address & 0xff) | (getch() << 8);
7e88: 8b d0 rcall .+278 ; 0x7fa0 <getch>
7e8a: 90 e0 ldi r25, 0x00 ; 0
7e8c: 98 2f mov r25, r24
7e8e: 88 27 eor r24, r24
7e90: 80 2b or r24, r16
7e92: 91 2b or r25, r17
address += address; // Convert from word address to byte address
7e94: 88 0f add r24, r24
7e96: 99 1f adc r25, r25
7e98: 90 93 01 02 sts 0x0201, r25
7e9c: 80 93 00 02 sts 0x0200, r24
7ea0: 73 c0 rjmp .+230 ; 0x7f88 <main+0x188>
verifySpace();
}
else if(ch == STK_UNIVERSAL) {
7ea2: 86 35 cpi r24, 0x56 ; 86
7ea4: 29 f4 brne .+10 ; 0x7eb0 <main+0xb0>
// UNIVERSAL command is ignored
getNch(4);
7ea6: 84 e0 ldi r24, 0x04 ; 4
7ea8: 99 d0 rcall .+306 ; 0x7fdc <verifySpace+0xc>
putch(0x00);
7eaa: 80 e0 ldi r24, 0x00 ; 0
7eac: 71 d0 rcall .+226 ; 0x7f90 <putch>
7eae: 6d c0 rjmp .+218 ; 0x7f8a <main+0x18a>
}
/* Write memory, length is big endian and is in bytes */
else if(ch == STK_PROG_PAGE) {
7eb0: 84 36 cpi r24, 0x64 ; 100
7eb2: 09 f0 breq .+2 ; 0x7eb6 <main+0xb6>
7eb4: 43 c0 rjmp .+134 ; 0x7f3c <main+0x13c>
// PROGRAM PAGE - we support flash programming only, not EEPROM
uint8_t *bufPtr;
uint16_t addrPtr;
getLen();
7eb6: 7c d0 rcall .+248 ; 0x7fb0 <getLen>
// Immediately start page erase - this will 4.5ms
boot_page_erase((uint16_t)(void*)address);
7eb8: e0 91 00 02 lds r30, 0x0200
7ebc: f0 91 01 02 lds r31, 0x0201
7ec0: 83 e0 ldi r24, 0x03 ; 3
7ec2: 80 93 57 00 sts 0x0057, r24
7ec6: e8 95 spm
7ec8: c0 e0 ldi r28, 0x00 ; 0
7eca: d1 e0 ldi r29, 0x01 ; 1
// While that is going on, read in page contents
bufPtr = buff;
do *bufPtr++ = getch();
7ecc: 69 d0 rcall .+210 ; 0x7fa0 <getch>
7ece: 89 93 st Y+, r24
while (--length);
7ed0: 80 91 02 02 lds r24, 0x0202
7ed4: 81 50 subi r24, 0x01 ; 1
7ed6: 80 93 02 02 sts 0x0202, r24
7eda: 88 23 and r24, r24
7edc: b9 f7 brne .-18 ; 0x7ecc <main+0xcc>
// Read command terminator, start reply
verifySpace();
7ede: 78 d0 rcall .+240 ; 0x7fd0 <verifySpace>
// If only a partial page is to be programmed, the erase might not be complete.
// So check that here
boot_spm_busy_wait();
7ee0: 07 b6 in r0, 0x37 ; 55
7ee2: 00 fc sbrc r0, 0
7ee4: fd cf rjmp .-6 ; 0x7ee0 <main+0xe0>
}
#endif
// Copy buffer into programming buffer
bufPtr = buff;
addrPtr = (uint16_t)(void*)address;
7ee6: 40 91 00 02 lds r20, 0x0200
7eea: 50 91 01 02 lds r21, 0x0201
7eee: a0 e0 ldi r26, 0x00 ; 0
7ef0: b1 e0 ldi r27, 0x01 ; 1
ch = SPM_PAGESIZE / 2;
do {
uint16_t a;
a = *bufPtr++;
7ef2: 2c 91 ld r18, X
7ef4: 30 e0 ldi r19, 0x00 ; 0
a |= (*bufPtr++) << 8;
7ef6: 11 96 adiw r26, 0x01 ; 1
7ef8: 8c 91 ld r24, X
7efa: 11 97 sbiw r26, 0x01 ; 1
7efc: 90 e0 ldi r25, 0x00 ; 0
7efe: 98 2f mov r25, r24
7f00: 88 27 eor r24, r24
7f02: 82 2b or r24, r18
7f04: 93 2b or r25, r19
#ifdef VIRTUAL_BOOT_PARTITION
#define rstVect (*(uint16_t*)(0x204))
#define wdtVect (*(uint16_t*)(0x206))
#endif
/* main program starts here */
int main(void) {
7f06: 12 96 adiw r26, 0x02 ; 2
ch = SPM_PAGESIZE / 2;
do {
uint16_t a;
a = *bufPtr++;
a |= (*bufPtr++) << 8;
boot_page_fill((uint16_t)(void*)addrPtr,a);
7f08: fa 01 movw r30, r20
7f0a: 0c 01 movw r0, r24
7f0c: d0 92 57 00 sts 0x0057, r13
7f10: e8 95 spm
7f12: 11 24 eor r1, r1
addrPtr += 2;
7f14: 4e 5f subi r20, 0xFE ; 254
7f16: 5f 4f sbci r21, 0xFF ; 255
} while (--ch);
7f18: f1 e0 ldi r31, 0x01 ; 1
7f1a: a0 38 cpi r26, 0x80 ; 128
7f1c: bf 07 cpc r27, r31
7f1e: 49 f7 brne .-46 ; 0x7ef2 <main+0xf2>
// Write from programming buffer
boot_page_write((uint16_t)(void*)address);
7f20: e0 91 00 02 lds r30, 0x0200
7f24: f0 91 01 02 lds r31, 0x0201
7f28: e0 92 57 00 sts 0x0057, r14
7f2c: e8 95 spm
boot_spm_busy_wait();
7f2e: 07 b6 in r0, 0x37 ; 55
7f30: 00 fc sbrc r0, 0
7f32: fd cf rjmp .-6 ; 0x7f2e <main+0x12e>
#if defined(RWWSRE)
// Reenable read access to flash
boot_rww_enable();
7f34: f0 92 57 00 sts 0x0057, r15
7f38: e8 95 spm
7f3a: 27 c0 rjmp .+78 ; 0x7f8a <main+0x18a>
#endif
}
/* Read memory block mode, length is big endian. */
else if(ch == STK_READ_PAGE) {
7f3c: 84 37 cpi r24, 0x74 ; 116
7f3e: b9 f4 brne .+46 ; 0x7f6e <main+0x16e>
// READ PAGE - we only read flash
getLen();
7f40: 37 d0 rcall .+110 ; 0x7fb0 <getLen>
verifySpace();
7f42: 46 d0 rcall .+140 ; 0x7fd0 <verifySpace>
else ch = pgm_read_byte_near(address);
address++;
putch(ch);
} while (--length);
#else
do putch(pgm_read_byte_near(address++));
7f44: e0 91 00 02 lds r30, 0x0200
7f48: f0 91 01 02 lds r31, 0x0201
7f4c: 31 96 adiw r30, 0x01 ; 1
7f4e: f0 93 01 02 sts 0x0201, r31
7f52: e0 93 00 02 sts 0x0200, r30
7f56: 31 97 sbiw r30, 0x01 ; 1
7f58: e4 91 lpm r30, Z+
7f5a: 8e 2f mov r24, r30
7f5c: 19 d0 rcall .+50 ; 0x7f90 <putch>
while (--length);
7f5e: 80 91 02 02 lds r24, 0x0202
7f62: 81 50 subi r24, 0x01 ; 1
7f64: 80 93 02 02 sts 0x0202, r24
7f68: 88 23 and r24, r24
7f6a: 61 f7 brne .-40 ; 0x7f44 <main+0x144>
7f6c: 0e c0 rjmp .+28 ; 0x7f8a <main+0x18a>
#endif
}
/* Get device signature bytes */
else if(ch == STK_READ_SIGN) {
7f6e: 85 37 cpi r24, 0x75 ; 117
7f70: 39 f4 brne .+14 ; 0x7f80 <main+0x180>
// READ SIGN - return what Avrdude wants to hear
verifySpace();
7f72: 2e d0 rcall .+92 ; 0x7fd0 <verifySpace>
putch(SIGNATURE_0);
7f74: 8e e1 ldi r24, 0x1E ; 30
7f76: 0c d0 rcall .+24 ; 0x7f90 <putch>
putch(SIGNATURE_1);
7f78: 85 e9 ldi r24, 0x95 ; 149
7f7a: 0a d0 rcall .+20 ; 0x7f90 <putch>
putch(SIGNATURE_2);
7f7c: 8f e0 ldi r24, 0x0F ; 15
7f7e: 96 cf rjmp .-212 ; 0x7eac <main+0xac>
}
else if (ch == 'Q') {
7f80: 81 35 cpi r24, 0x51 ; 81
7f82: 11 f4 brne .+4 ; 0x7f88 <main+0x188>
// Adaboot no-wait mod
watchdogConfig(WATCHDOG_16MS);
7f84: 88 e0 ldi r24, 0x08 ; 8
7f86: 19 d0 rcall .+50 ; 0x7fba <watchdogConfig>
verifySpace();
}
else {
// This covers the response to commands like STK_ENTER_PROGMODE
verifySpace();
7f88: 23 d0 rcall .+70 ; 0x7fd0 <verifySpace>
}
putch(STK_OK);
7f8a: 80 e1 ldi r24, 0x10 ; 16
7f8c: 01 d0 rcall .+2 ; 0x7f90 <putch>
7f8e: 63 cf rjmp .-314 ; 0x7e56 <main+0x56>
00007f90 <putch>:
}
}
void putch(char ch) {
7f90: 98 2f mov r25, r24
#ifndef SOFT_UART
while (!(UCSR0A & _BV(UDRE0)));
7f92: 80 91 c0 00 lds r24, 0x00C0
7f96: 85 ff sbrs r24, 5
7f98: fc cf rjmp .-8 ; 0x7f92 <putch+0x2>
UDR0 = ch;
7f9a: 90 93 c6 00 sts 0x00C6, r25
[uartBit] "I" (UART_TX_BIT)
:
"r25"
);
#endif
}
7f9e: 08 95 ret
00007fa0 <getch>:
return getch();
}
// Watchdog functions. These are only safe with interrupts turned off.
void watchdogReset() {
__asm__ __volatile__ (
7fa0: a8 95 wdr
[uartBit] "I" (UART_RX_BIT)
:
"r25"
);
#else
while(!(UCSR0A & _BV(RXC0)));
7fa2: 80 91 c0 00 lds r24, 0x00C0
7fa6: 87 ff sbrs r24, 7
7fa8: fc cf rjmp .-8 ; 0x7fa2 <getch+0x2>
ch = UDR0;
7faa: 80 91 c6 00 lds r24, 0x00C6
#ifdef LED_DATA_FLASH
LED_PIN |= _BV(LED);
#endif
return ch;
}
7fae: 08 95 ret
00007fb0 <getLen>:
} while (--count);
}
#endif
uint8_t getLen() {
getch();
7fb0: f7 df rcall .-18 ; 0x7fa0 <getch>
length = getch();
7fb2: f6 df rcall .-20 ; 0x7fa0 <getch>
7fb4: 80 93 02 02 sts 0x0202, r24
return getch();
}
7fb8: f3 cf rjmp .-26 ; 0x7fa0 <getch>
00007fba <watchdogConfig>:
"wdr\n"
);
}
void watchdogConfig(uint8_t x) {
WDTCSR = _BV(WDCE) | _BV(WDE);
7fba: e0 e6 ldi r30, 0x60 ; 96
7fbc: f0 e0 ldi r31, 0x00 ; 0
7fbe: 98 e1 ldi r25, 0x18 ; 24
7fc0: 90 83 st Z, r25
WDTCSR = x;
7fc2: 80 83 st Z, r24
}
7fc4: 08 95 ret
00007fc6 <appStart>:
void appStart() {
watchdogConfig(WATCHDOG_OFF);
7fc6: 80 e0 ldi r24, 0x00 ; 0
7fc8: f8 df rcall .-16 ; 0x7fba <watchdogConfig>
__asm__ __volatile__ (
7fca: ee 27 eor r30, r30
7fcc: ff 27 eor r31, r31
7fce: 09 94 ijmp
00007fd0 <verifySpace>:
do getch(); while (--count);
verifySpace();
}
void verifySpace() {
if (getch() != CRC_EOP) appStart();
7fd0: e7 df rcall .-50 ; 0x7fa0 <getch>
7fd2: 80 32 cpi r24, 0x20 ; 32
7fd4: 09 f0 breq .+2 ; 0x7fd8 <verifySpace+0x8>
7fd6: f7 df rcall .-18 ; 0x7fc6 <appStart>
putch(STK_INSYNC);
7fd8: 84 e1 ldi r24, 0x14 ; 20
}
7fda: da cf rjmp .-76 ; 0x7f90 <putch>
::[count] "M" (UART_B_VALUE)
);
}
#endif
void getNch(uint8_t count) {
7fdc: 1f 93 push r17
7fde: 18 2f mov r17, r24
00007fe0 <getNch>:
do getch(); while (--count);
7fe0: df df rcall .-66 ; 0x7fa0 <getch>
7fe2: 11 50 subi r17, 0x01 ; 1
7fe4: e9 f7 brne .-6 ; 0x7fe0 <getNch>
verifySpace();
7fe6: f4 df rcall .-24 ; 0x7fd0 <verifySpace>
}
7fe8: 1f 91 pop r17
7fea: 08 95 ret

View file

@ -0,0 +1,33 @@
:107E000085E08093810082E08093C00088E18093C8
:107E1000C10086E08093C20088E08093C40084B7EC
:107E200014BE81FFD0D08DE0C8D0259A86E028E12D
:107E30003EEF91E0309385002093840096BBB09B89
:107E4000FECF1D9AA8958150A9F7DD24D394A5E013
:107E5000EA2EF1E1FF2EA4D0813421F481E0BED0DE
:107E600083E024C0823411F484E103C0853419F422
:107E700085E0B4D08AC08535A1F492D0082F10E0F7
:107E800010930102009300028BD090E0982F882776
:107E9000802B912B880F991F9093010280930002F1
:107EA00073C0863529F484E099D080E071D06DC02C
:107EB000843609F043C07CD0E0910002F0910102C9
:107EC00083E080935700E895C0E0D1E069D08993C2
:107ED000809102028150809302028823B9F778D002
:107EE00007B600FCFDCF4091000250910102A0E0D6
:107EF000B1E02C9130E011968C91119790E0982F81
:107F00008827822B932B1296FA010C01D0925700EE
:107F1000E89511244E5F5F4FF1E0A038BF0749F7A5
:107F2000E0910002F0910102E0925700E89507B657
:107F300000FCFDCFF0925700E89527C08437B9F4D4
:107F400037D046D0E0910002F09101023196F093D3
:107F50000102E09300023197E4918E2F19D08091B5
:107F60000202815080930202882361F70EC0853798
:107F700039F42ED08EE10CD085E90AD08FE096CF6F
:107F8000813511F488E019D023D080E101D063CF8E
:107F9000982F8091C00085FFFCCF9093C600089574
:107FA000A8958091C00087FFFCCF8091C6000895FE
:107FB000F7DFF6DF80930202F3CFE0E6F0E098E12E
:107FC00090838083089580E0F8DFEE27FF270994EF
:107FD000E7DF803209F0F7DF84E1DACF1F93182F53
:0C7FE000DFDF1150E9F7F4DF1F91089576
:0400000300007E007B
:00000001FF

View file

@ -0,0 +1,520 @@
optiboot_atmega328_pro_8MHz.elf: file format elf32-avr
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 000001ec 00007e00 00007e00 00000054 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .debug_aranges 00000028 00000000 00000000 00000240 2**0
CONTENTS, READONLY, DEBUGGING
2 .debug_pubnames 0000006a 00000000 00000000 00000268 2**0
CONTENTS, READONLY, DEBUGGING
3 .debug_info 00000269 00000000 00000000 000002d2 2**0
CONTENTS, READONLY, DEBUGGING
4 .debug_abbrev 00000196 00000000 00000000 0000053b 2**0
CONTENTS, READONLY, DEBUGGING
5 .debug_line 000003d3 00000000 00000000 000006d1 2**0
CONTENTS, READONLY, DEBUGGING
6 .debug_frame 00000090 00000000 00000000 00000aa4 2**2
CONTENTS, READONLY, DEBUGGING
7 .debug_str 00000135 00000000 00000000 00000b34 2**0
CONTENTS, READONLY, DEBUGGING
8 .debug_loc 000001d1 00000000 00000000 00000c69 2**0
CONTENTS, READONLY, DEBUGGING
9 .debug_ranges 00000068 00000000 00000000 00000e3a 2**0
CONTENTS, READONLY, DEBUGGING
Disassembly of section .text:
00007e00 <main>:
#ifdef VIRTUAL_BOOT_PARTITION
#define rstVect (*(uint16_t*)(0x204))
#define wdtVect (*(uint16_t*)(0x206))
#endif
/* main program starts here */
int main(void) {
7e00: 85 e0 ldi r24, 0x05 ; 5
7e02: 80 93 81 00 sts 0x0081, r24
#if LED_START_FLASHES > 0
// Set up Timer 1 for timeout counter
TCCR1B = _BV(CS12) | _BV(CS10); // div 1024
#endif
#ifndef SOFT_UART
UCSR0A = _BV(U2X0); //Double speed mode USART0
7e06: 82 e0 ldi r24, 0x02 ; 2
7e08: 80 93 c0 00 sts 0x00C0, r24
UCSR0B = _BV(RXEN0) | _BV(TXEN0);
7e0c: 88 e1 ldi r24, 0x18 ; 24
7e0e: 80 93 c1 00 sts 0x00C1, r24
UCSR0C = _BV(UCSZ00) | _BV(UCSZ01);
7e12: 86 e0 ldi r24, 0x06 ; 6
7e14: 80 93 c2 00 sts 0x00C2, r24
UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
7e18: 88 e0 ldi r24, 0x08 ; 8
7e1a: 80 93 c4 00 sts 0x00C4, r24
#endif
// Adaboot no-wait mod
ch = MCUSR;
7e1e: 84 b7 in r24, 0x34 ; 52
MCUSR = 0;
7e20: 14 be out 0x34, r1 ; 52
if (!(ch & _BV(EXTRF))) appStart();
7e22: 81 ff sbrs r24, 1
7e24: d0 d0 rcall .+416 ; 0x7fc6 <appStart>
// Set up watchdog to trigger after 500ms
watchdogConfig(WATCHDOG_500MS);
7e26: 8d e0 ldi r24, 0x0D ; 13
7e28: c8 d0 rcall .+400 ; 0x7fba <watchdogConfig>
/* Set LED pin as output */
LED_DDR |= _BV(LED);
7e2a: 25 9a sbi 0x04, 5 ; 4
7e2c: 86 e0 ldi r24, 0x06 ; 6
}
#if LED_START_FLASHES > 0
void flash_led(uint8_t count) {
do {
TCNT1 = -(F_CPU/(1024*16));
7e2e: 28 e1 ldi r18, 0x18 ; 24
7e30: 3e ef ldi r19, 0xFE ; 254
TIFR1 = _BV(TOV1);
7e32: 91 e0 ldi r25, 0x01 ; 1
}
#if LED_START_FLASHES > 0
void flash_led(uint8_t count) {
do {
TCNT1 = -(F_CPU/(1024*16));
7e34: 30 93 85 00 sts 0x0085, r19
7e38: 20 93 84 00 sts 0x0084, r18
TIFR1 = _BV(TOV1);
7e3c: 96 bb out 0x16, r25 ; 22
while(!(TIFR1 & _BV(TOV1)));
7e3e: b0 9b sbis 0x16, 0 ; 22
7e40: fe cf rjmp .-4 ; 0x7e3e <main+0x3e>
LED_PIN |= _BV(LED);
7e42: 1d 9a sbi 0x03, 5 ; 3
return getch();
}
// Watchdog functions. These are only safe with interrupts turned off.
void watchdogReset() {
__asm__ __volatile__ (
7e44: a8 95 wdr
TCNT1 = -(F_CPU/(1024*16));
TIFR1 = _BV(TOV1);
while(!(TIFR1 & _BV(TOV1)));
LED_PIN |= _BV(LED);
watchdogReset();
} while (--count);
7e46: 81 50 subi r24, 0x01 ; 1
7e48: a9 f7 brne .-22 ; 0x7e34 <main+0x34>
/* get character from UART */
ch = getch();
if(ch == STK_GET_PARAMETER) {
// GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy
getNch(1);
7e4a: dd 24 eor r13, r13
7e4c: d3 94 inc r13
boot_page_fill((uint16_t)(void*)addrPtr,a);
addrPtr += 2;
} while (--ch);
// Write from programming buffer
boot_page_write((uint16_t)(void*)address);
7e4e: a5 e0 ldi r26, 0x05 ; 5
7e50: ea 2e mov r14, r26
boot_spm_busy_wait();
#if defined(RWWSRE)
// Reenable read access to flash
boot_rww_enable();
7e52: f1 e1 ldi r31, 0x11 ; 17
7e54: ff 2e mov r15, r31
#endif
/* Forever loop */
for (;;) {
/* get character from UART */
ch = getch();
7e56: a4 d0 rcall .+328 ; 0x7fa0 <getch>
if(ch == STK_GET_PARAMETER) {
7e58: 81 34 cpi r24, 0x41 ; 65
7e5a: 21 f4 brne .+8 ; 0x7e64 <main+0x64>
// GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy
getNch(1);
7e5c: 81 e0 ldi r24, 0x01 ; 1
7e5e: be d0 rcall .+380 ; 0x7fdc <verifySpace+0xc>
putch(0x03);
7e60: 83 e0 ldi r24, 0x03 ; 3
7e62: 24 c0 rjmp .+72 ; 0x7eac <main+0xac>
}
else if(ch == STK_SET_DEVICE) {
7e64: 82 34 cpi r24, 0x42 ; 66
7e66: 11 f4 brne .+4 ; 0x7e6c <main+0x6c>
// SET DEVICE is ignored
getNch(20);
7e68: 84 e1 ldi r24, 0x14 ; 20
7e6a: 03 c0 rjmp .+6 ; 0x7e72 <main+0x72>
}
else if(ch == STK_SET_DEVICE_EXT) {
7e6c: 85 34 cpi r24, 0x45 ; 69
7e6e: 19 f4 brne .+6 ; 0x7e76 <main+0x76>
// SET DEVICE EXT is ignored
getNch(5);
7e70: 85 e0 ldi r24, 0x05 ; 5
7e72: b4 d0 rcall .+360 ; 0x7fdc <verifySpace+0xc>
7e74: 8a c0 rjmp .+276 ; 0x7f8a <main+0x18a>
}
else if(ch == STK_LOAD_ADDRESS) {
7e76: 85 35 cpi r24, 0x55 ; 85
7e78: a1 f4 brne .+40 ; 0x7ea2 <main+0xa2>
// LOAD ADDRESS
address = getch();
7e7a: 92 d0 rcall .+292 ; 0x7fa0 <getch>
7e7c: 08 2f mov r16, r24
7e7e: 10 e0 ldi r17, 0x00 ; 0
7e80: 10 93 01 02 sts 0x0201, r17
7e84: 00 93 00 02 sts 0x0200, r16
address = (address & 0xff) | (getch() << 8);
7e88: 8b d0 rcall .+278 ; 0x7fa0 <getch>
7e8a: 90 e0 ldi r25, 0x00 ; 0
7e8c: 98 2f mov r25, r24
7e8e: 88 27 eor r24, r24
7e90: 80 2b or r24, r16
7e92: 91 2b or r25, r17
address += address; // Convert from word address to byte address
7e94: 88 0f add r24, r24
7e96: 99 1f adc r25, r25
7e98: 90 93 01 02 sts 0x0201, r25
7e9c: 80 93 00 02 sts 0x0200, r24
7ea0: 73 c0 rjmp .+230 ; 0x7f88 <main+0x188>
verifySpace();
}
else if(ch == STK_UNIVERSAL) {
7ea2: 86 35 cpi r24, 0x56 ; 86
7ea4: 29 f4 brne .+10 ; 0x7eb0 <main+0xb0>
// UNIVERSAL command is ignored
getNch(4);
7ea6: 84 e0 ldi r24, 0x04 ; 4
7ea8: 99 d0 rcall .+306 ; 0x7fdc <verifySpace+0xc>
putch(0x00);
7eaa: 80 e0 ldi r24, 0x00 ; 0
7eac: 71 d0 rcall .+226 ; 0x7f90 <putch>
7eae: 6d c0 rjmp .+218 ; 0x7f8a <main+0x18a>
}
/* Write memory, length is big endian and is in bytes */
else if(ch == STK_PROG_PAGE) {
7eb0: 84 36 cpi r24, 0x64 ; 100
7eb2: 09 f0 breq .+2 ; 0x7eb6 <main+0xb6>
7eb4: 43 c0 rjmp .+134 ; 0x7f3c <main+0x13c>
// PROGRAM PAGE - we support flash programming only, not EEPROM
uint8_t *bufPtr;
uint16_t addrPtr;
getLen();
7eb6: 7c d0 rcall .+248 ; 0x7fb0 <getLen>
// Immediately start page erase - this will 4.5ms
boot_page_erase((uint16_t)(void*)address);
7eb8: e0 91 00 02 lds r30, 0x0200
7ebc: f0 91 01 02 lds r31, 0x0201
7ec0: 83 e0 ldi r24, 0x03 ; 3
7ec2: 80 93 57 00 sts 0x0057, r24
7ec6: e8 95 spm
7ec8: c0 e0 ldi r28, 0x00 ; 0
7eca: d1 e0 ldi r29, 0x01 ; 1
// While that is going on, read in page contents
bufPtr = buff;
do *bufPtr++ = getch();
7ecc: 69 d0 rcall .+210 ; 0x7fa0 <getch>
7ece: 89 93 st Y+, r24
while (--length);
7ed0: 80 91 02 02 lds r24, 0x0202
7ed4: 81 50 subi r24, 0x01 ; 1
7ed6: 80 93 02 02 sts 0x0202, r24
7eda: 88 23 and r24, r24
7edc: b9 f7 brne .-18 ; 0x7ecc <main+0xcc>
// Read command terminator, start reply
verifySpace();
7ede: 78 d0 rcall .+240 ; 0x7fd0 <verifySpace>
// If only a partial page is to be programmed, the erase might not be complete.
// So check that here
boot_spm_busy_wait();
7ee0: 07 b6 in r0, 0x37 ; 55
7ee2: 00 fc sbrc r0, 0
7ee4: fd cf rjmp .-6 ; 0x7ee0 <main+0xe0>
}
#endif
// Copy buffer into programming buffer
bufPtr = buff;
addrPtr = (uint16_t)(void*)address;
7ee6: 40 91 00 02 lds r20, 0x0200
7eea: 50 91 01 02 lds r21, 0x0201
7eee: a0 e0 ldi r26, 0x00 ; 0
7ef0: b1 e0 ldi r27, 0x01 ; 1
ch = SPM_PAGESIZE / 2;
do {
uint16_t a;
a = *bufPtr++;
7ef2: 2c 91 ld r18, X
7ef4: 30 e0 ldi r19, 0x00 ; 0
a |= (*bufPtr++) << 8;
7ef6: 11 96 adiw r26, 0x01 ; 1
7ef8: 8c 91 ld r24, X
7efa: 11 97 sbiw r26, 0x01 ; 1
7efc: 90 e0 ldi r25, 0x00 ; 0
7efe: 98 2f mov r25, r24
7f00: 88 27 eor r24, r24
7f02: 82 2b or r24, r18
7f04: 93 2b or r25, r19
#ifdef VIRTUAL_BOOT_PARTITION
#define rstVect (*(uint16_t*)(0x204))
#define wdtVect (*(uint16_t*)(0x206))
#endif
/* main program starts here */
int main(void) {
7f06: 12 96 adiw r26, 0x02 ; 2
ch = SPM_PAGESIZE / 2;
do {
uint16_t a;
a = *bufPtr++;
a |= (*bufPtr++) << 8;
boot_page_fill((uint16_t)(void*)addrPtr,a);
7f08: fa 01 movw r30, r20
7f0a: 0c 01 movw r0, r24
7f0c: d0 92 57 00 sts 0x0057, r13
7f10: e8 95 spm
7f12: 11 24 eor r1, r1
addrPtr += 2;
7f14: 4e 5f subi r20, 0xFE ; 254
7f16: 5f 4f sbci r21, 0xFF ; 255
} while (--ch);
7f18: f1 e0 ldi r31, 0x01 ; 1
7f1a: a0 38 cpi r26, 0x80 ; 128
7f1c: bf 07 cpc r27, r31
7f1e: 49 f7 brne .-46 ; 0x7ef2 <main+0xf2>
// Write from programming buffer
boot_page_write((uint16_t)(void*)address);
7f20: e0 91 00 02 lds r30, 0x0200
7f24: f0 91 01 02 lds r31, 0x0201
7f28: e0 92 57 00 sts 0x0057, r14
7f2c: e8 95 spm
boot_spm_busy_wait();
7f2e: 07 b6 in r0, 0x37 ; 55
7f30: 00 fc sbrc r0, 0
7f32: fd cf rjmp .-6 ; 0x7f2e <main+0x12e>
#if defined(RWWSRE)
// Reenable read access to flash
boot_rww_enable();
7f34: f0 92 57 00 sts 0x0057, r15
7f38: e8 95 spm
7f3a: 27 c0 rjmp .+78 ; 0x7f8a <main+0x18a>
#endif
}
/* Read memory block mode, length is big endian. */
else if(ch == STK_READ_PAGE) {
7f3c: 84 37 cpi r24, 0x74 ; 116
7f3e: b9 f4 brne .+46 ; 0x7f6e <main+0x16e>
// READ PAGE - we only read flash
getLen();
7f40: 37 d0 rcall .+110 ; 0x7fb0 <getLen>
verifySpace();
7f42: 46 d0 rcall .+140 ; 0x7fd0 <verifySpace>
else ch = pgm_read_byte_near(address);
address++;
putch(ch);
} while (--length);
#else
do putch(pgm_read_byte_near(address++));
7f44: e0 91 00 02 lds r30, 0x0200
7f48: f0 91 01 02 lds r31, 0x0201
7f4c: 31 96 adiw r30, 0x01 ; 1
7f4e: f0 93 01 02 sts 0x0201, r31
7f52: e0 93 00 02 sts 0x0200, r30
7f56: 31 97 sbiw r30, 0x01 ; 1
7f58: e4 91 lpm r30, Z+
7f5a: 8e 2f mov r24, r30
7f5c: 19 d0 rcall .+50 ; 0x7f90 <putch>
while (--length);
7f5e: 80 91 02 02 lds r24, 0x0202
7f62: 81 50 subi r24, 0x01 ; 1
7f64: 80 93 02 02 sts 0x0202, r24
7f68: 88 23 and r24, r24
7f6a: 61 f7 brne .-40 ; 0x7f44 <main+0x144>
7f6c: 0e c0 rjmp .+28 ; 0x7f8a <main+0x18a>
#endif
}
/* Get device signature bytes */
else if(ch == STK_READ_SIGN) {
7f6e: 85 37 cpi r24, 0x75 ; 117
7f70: 39 f4 brne .+14 ; 0x7f80 <main+0x180>
// READ SIGN - return what Avrdude wants to hear
verifySpace();
7f72: 2e d0 rcall .+92 ; 0x7fd0 <verifySpace>
putch(SIGNATURE_0);
7f74: 8e e1 ldi r24, 0x1E ; 30
7f76: 0c d0 rcall .+24 ; 0x7f90 <putch>
putch(SIGNATURE_1);
7f78: 85 e9 ldi r24, 0x95 ; 149
7f7a: 0a d0 rcall .+20 ; 0x7f90 <putch>
putch(SIGNATURE_2);
7f7c: 8f e0 ldi r24, 0x0F ; 15
7f7e: 96 cf rjmp .-212 ; 0x7eac <main+0xac>
}
else if (ch == 'Q') {
7f80: 81 35 cpi r24, 0x51 ; 81
7f82: 11 f4 brne .+4 ; 0x7f88 <main+0x188>
// Adaboot no-wait mod
watchdogConfig(WATCHDOG_16MS);
7f84: 88 e0 ldi r24, 0x08 ; 8
7f86: 19 d0 rcall .+50 ; 0x7fba <watchdogConfig>
verifySpace();
}
else {
// This covers the response to commands like STK_ENTER_PROGMODE
verifySpace();
7f88: 23 d0 rcall .+70 ; 0x7fd0 <verifySpace>
}
putch(STK_OK);
7f8a: 80 e1 ldi r24, 0x10 ; 16
7f8c: 01 d0 rcall .+2 ; 0x7f90 <putch>
7f8e: 63 cf rjmp .-314 ; 0x7e56 <main+0x56>
00007f90 <putch>:
}
}
void putch(char ch) {
7f90: 98 2f mov r25, r24
#ifndef SOFT_UART
while (!(UCSR0A & _BV(UDRE0)));
7f92: 80 91 c0 00 lds r24, 0x00C0
7f96: 85 ff sbrs r24, 5
7f98: fc cf rjmp .-8 ; 0x7f92 <putch+0x2>
UDR0 = ch;
7f9a: 90 93 c6 00 sts 0x00C6, r25
[uartBit] "I" (UART_TX_BIT)
:
"r25"
);
#endif
}
7f9e: 08 95 ret
00007fa0 <getch>:
return getch();
}
// Watchdog functions. These are only safe with interrupts turned off.
void watchdogReset() {
__asm__ __volatile__ (
7fa0: a8 95 wdr
[uartBit] "I" (UART_RX_BIT)
:
"r25"
);
#else
while(!(UCSR0A & _BV(RXC0)));
7fa2: 80 91 c0 00 lds r24, 0x00C0
7fa6: 87 ff sbrs r24, 7
7fa8: fc cf rjmp .-8 ; 0x7fa2 <getch+0x2>
ch = UDR0;
7faa: 80 91 c6 00 lds r24, 0x00C6
#ifdef LED_DATA_FLASH
LED_PIN |= _BV(LED);
#endif
return ch;
}
7fae: 08 95 ret
00007fb0 <getLen>:
} while (--count);
}
#endif
uint8_t getLen() {
getch();
7fb0: f7 df rcall .-18 ; 0x7fa0 <getch>
length = getch();
7fb2: f6 df rcall .-20 ; 0x7fa0 <getch>
7fb4: 80 93 02 02 sts 0x0202, r24
return getch();
}
7fb8: f3 cf rjmp .-26 ; 0x7fa0 <getch>
00007fba <watchdogConfig>:
"wdr\n"
);
}
void watchdogConfig(uint8_t x) {
WDTCSR = _BV(WDCE) | _BV(WDE);
7fba: e0 e6 ldi r30, 0x60 ; 96
7fbc: f0 e0 ldi r31, 0x00 ; 0
7fbe: 98 e1 ldi r25, 0x18 ; 24
7fc0: 90 83 st Z, r25
WDTCSR = x;
7fc2: 80 83 st Z, r24
}
7fc4: 08 95 ret
00007fc6 <appStart>:
void appStart() {
watchdogConfig(WATCHDOG_OFF);
7fc6: 80 e0 ldi r24, 0x00 ; 0
7fc8: f8 df rcall .-16 ; 0x7fba <watchdogConfig>
__asm__ __volatile__ (
7fca: ee 27 eor r30, r30
7fcc: ff 27 eor r31, r31
7fce: 09 94 ijmp
00007fd0 <verifySpace>:
do getch(); while (--count);
verifySpace();
}
void verifySpace() {
if (getch() != CRC_EOP) appStart();
7fd0: e7 df rcall .-50 ; 0x7fa0 <getch>
7fd2: 80 32 cpi r24, 0x20 ; 32
7fd4: 09 f0 breq .+2 ; 0x7fd8 <verifySpace+0x8>
7fd6: f7 df rcall .-18 ; 0x7fc6 <appStart>
putch(STK_INSYNC);
7fd8: 84 e1 ldi r24, 0x14 ; 20
}
7fda: da cf rjmp .-76 ; 0x7f90 <putch>
::[count] "M" (UART_B_VALUE)
);
}
#endif
void getNch(uint8_t count) {
7fdc: 1f 93 push r17
7fde: 18 2f mov r17, r24
00007fe0 <getNch>:
do getch(); while (--count);
7fe0: df df rcall .-66 ; 0x7fa0 <getch>
7fe2: 11 50 subi r17, 0x01 ; 1
7fe4: e9 f7 brne .-6 ; 0x7fe0 <getNch>
verifySpace();
7fe6: f4 df rcall .-24 ; 0x7fd0 <verifySpace>
}
7fe8: 1f 91 pop r17
7fea: 08 95 ret

View file

@ -0,0 +1,33 @@
:103E000085E08093810082E08093C00088E1809308
:103E1000C10086E08093C20080E18093C40084B733
:103E200014BE81FFD0D08DE0C8D0259A86E020E373
:103E30003CEF91E0309385002093840096BBB09BCB
:103E4000FECF1D9AA8958150A9F7DD24D394A5E053
:103E5000EA2EF1E1FF2EA4D0813421F481E0BED01E
:103E600083E024C0823411F484E103C0853419F462
:103E700085E0B4D08AC08535A1F492D0082F10E037
:103E800010930102009300028BD090E0982F8827B6
:103E9000802B912B880F991F909301028093000231
:103EA00073C0863529F484E099D080E071D06DC06C
:103EB000843609F043C07CD0E0910002F091010209
:103EC00083E080935700E895C0E0D1E069D0899302
:103ED000809102028150809302028823B9F778D042
:103EE00007B600FCFDCF4091000250910102A0E016
:103EF000B1E02C9130E011968C91119790E0982FC1
:103F00008827822B932B1296FA010C01D09257002E
:103F1000E89511244E5F5F4FF1E0A038BF0749F7E5
:103F2000E0910002F0910102E0925700E89507B697
:103F300000FCFDCFF0925700E89527C08437B9F414
:103F400037D046D0E0910002F09101023196F09313
:103F50000102E09300023197E4918E2F19D08091F5
:103F60000202815080930202882361F70EC08537D8
:103F700039F42ED08EE10CD084E90AD086E096CFB9
:103F8000813511F488E019D023D080E101D063CFCE
:103F9000982F8091C00085FFFCCF9093C6000895B4
:103FA000A8958091C00087FFFCCF8091C60008953E
:103FB000F7DFF6DF80930202F3CFE0E6F0E098E16E
:103FC00090838083089580E0F8DFEE27FF2709942F
:103FD000E7DF803209F0F7DF84E1DACF1F93182F93
:0C3FE000DFDF1150E9F7F4DF1F910895B6
:0400000300003E00BB
:00000001FF

View file

@ -0,0 +1,520 @@
optiboot_diecimila.elf: file format elf32-avr
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 000001ec 00003e00 00003e00 00000054 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .debug_aranges 00000028 00000000 00000000 00000240 2**0
CONTENTS, READONLY, DEBUGGING
2 .debug_pubnames 0000006a 00000000 00000000 00000268 2**0
CONTENTS, READONLY, DEBUGGING
3 .debug_info 00000269 00000000 00000000 000002d2 2**0
CONTENTS, READONLY, DEBUGGING
4 .debug_abbrev 00000196 00000000 00000000 0000053b 2**0
CONTENTS, READONLY, DEBUGGING
5 .debug_line 000003d3 00000000 00000000 000006d1 2**0
CONTENTS, READONLY, DEBUGGING
6 .debug_frame 00000090 00000000 00000000 00000aa4 2**2
CONTENTS, READONLY, DEBUGGING
7 .debug_str 00000135 00000000 00000000 00000b34 2**0
CONTENTS, READONLY, DEBUGGING
8 .debug_loc 000001d1 00000000 00000000 00000c69 2**0
CONTENTS, READONLY, DEBUGGING
9 .debug_ranges 00000068 00000000 00000000 00000e3a 2**0
CONTENTS, READONLY, DEBUGGING
Disassembly of section .text:
00003e00 <main>:
#ifdef VIRTUAL_BOOT_PARTITION
#define rstVect (*(uint16_t*)(0x204))
#define wdtVect (*(uint16_t*)(0x206))
#endif
/* main program starts here */
int main(void) {
3e00: 85 e0 ldi r24, 0x05 ; 5
3e02: 80 93 81 00 sts 0x0081, r24
#if LED_START_FLASHES > 0
// Set up Timer 1 for timeout counter
TCCR1B = _BV(CS12) | _BV(CS10); // div 1024
#endif
#ifndef SOFT_UART
UCSR0A = _BV(U2X0); //Double speed mode USART0
3e06: 82 e0 ldi r24, 0x02 ; 2
3e08: 80 93 c0 00 sts 0x00C0, r24
UCSR0B = _BV(RXEN0) | _BV(TXEN0);
3e0c: 88 e1 ldi r24, 0x18 ; 24
3e0e: 80 93 c1 00 sts 0x00C1, r24
UCSR0C = _BV(UCSZ00) | _BV(UCSZ01);
3e12: 86 e0 ldi r24, 0x06 ; 6
3e14: 80 93 c2 00 sts 0x00C2, r24
UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
3e18: 80 e1 ldi r24, 0x10 ; 16
3e1a: 80 93 c4 00 sts 0x00C4, r24
#endif
// Adaboot no-wait mod
ch = MCUSR;
3e1e: 84 b7 in r24, 0x34 ; 52
MCUSR = 0;
3e20: 14 be out 0x34, r1 ; 52
if (!(ch & _BV(EXTRF))) appStart();
3e22: 81 ff sbrs r24, 1
3e24: d0 d0 rcall .+416 ; 0x3fc6 <appStart>
// Set up watchdog to trigger after 500ms
watchdogConfig(WATCHDOG_500MS);
3e26: 8d e0 ldi r24, 0x0D ; 13
3e28: c8 d0 rcall .+400 ; 0x3fba <watchdogConfig>
/* Set LED pin as output */
LED_DDR |= _BV(LED);
3e2a: 25 9a sbi 0x04, 5 ; 4
3e2c: 86 e0 ldi r24, 0x06 ; 6
}
#if LED_START_FLASHES > 0
void flash_led(uint8_t count) {
do {
TCNT1 = -(F_CPU/(1024*16));
3e2e: 20 e3 ldi r18, 0x30 ; 48
3e30: 3c ef ldi r19, 0xFC ; 252
TIFR1 = _BV(TOV1);
3e32: 91 e0 ldi r25, 0x01 ; 1
}
#if LED_START_FLASHES > 0
void flash_led(uint8_t count) {
do {
TCNT1 = -(F_CPU/(1024*16));
3e34: 30 93 85 00 sts 0x0085, r19
3e38: 20 93 84 00 sts 0x0084, r18
TIFR1 = _BV(TOV1);
3e3c: 96 bb out 0x16, r25 ; 22
while(!(TIFR1 & _BV(TOV1)));
3e3e: b0 9b sbis 0x16, 0 ; 22
3e40: fe cf rjmp .-4 ; 0x3e3e <main+0x3e>
LED_PIN |= _BV(LED);
3e42: 1d 9a sbi 0x03, 5 ; 3
return getch();
}
// Watchdog functions. These are only safe with interrupts turned off.
void watchdogReset() {
__asm__ __volatile__ (
3e44: a8 95 wdr
TCNT1 = -(F_CPU/(1024*16));
TIFR1 = _BV(TOV1);
while(!(TIFR1 & _BV(TOV1)));
LED_PIN |= _BV(LED);
watchdogReset();
} while (--count);
3e46: 81 50 subi r24, 0x01 ; 1
3e48: a9 f7 brne .-22 ; 0x3e34 <main+0x34>
/* get character from UART */
ch = getch();
if(ch == STK_GET_PARAMETER) {
// GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy
getNch(1);
3e4a: dd 24 eor r13, r13
3e4c: d3 94 inc r13
boot_page_fill((uint16_t)(void*)addrPtr,a);
addrPtr += 2;
} while (--ch);
// Write from programming buffer
boot_page_write((uint16_t)(void*)address);
3e4e: a5 e0 ldi r26, 0x05 ; 5
3e50: ea 2e mov r14, r26
boot_spm_busy_wait();
#if defined(RWWSRE)
// Reenable read access to flash
boot_rww_enable();
3e52: f1 e1 ldi r31, 0x11 ; 17
3e54: ff 2e mov r15, r31
#endif
/* Forever loop */
for (;;) {
/* get character from UART */
ch = getch();
3e56: a4 d0 rcall .+328 ; 0x3fa0 <getch>
if(ch == STK_GET_PARAMETER) {
3e58: 81 34 cpi r24, 0x41 ; 65
3e5a: 21 f4 brne .+8 ; 0x3e64 <main+0x64>
// GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy
getNch(1);
3e5c: 81 e0 ldi r24, 0x01 ; 1
3e5e: be d0 rcall .+380 ; 0x3fdc <verifySpace+0xc>
putch(0x03);
3e60: 83 e0 ldi r24, 0x03 ; 3
3e62: 24 c0 rjmp .+72 ; 0x3eac <main+0xac>
}
else if(ch == STK_SET_DEVICE) {
3e64: 82 34 cpi r24, 0x42 ; 66
3e66: 11 f4 brne .+4 ; 0x3e6c <main+0x6c>
// SET DEVICE is ignored
getNch(20);
3e68: 84 e1 ldi r24, 0x14 ; 20
3e6a: 03 c0 rjmp .+6 ; 0x3e72 <main+0x72>
}
else if(ch == STK_SET_DEVICE_EXT) {
3e6c: 85 34 cpi r24, 0x45 ; 69
3e6e: 19 f4 brne .+6 ; 0x3e76 <main+0x76>
// SET DEVICE EXT is ignored
getNch(5);
3e70: 85 e0 ldi r24, 0x05 ; 5
3e72: b4 d0 rcall .+360 ; 0x3fdc <verifySpace+0xc>
3e74: 8a c0 rjmp .+276 ; 0x3f8a <main+0x18a>
}
else if(ch == STK_LOAD_ADDRESS) {
3e76: 85 35 cpi r24, 0x55 ; 85
3e78: a1 f4 brne .+40 ; 0x3ea2 <main+0xa2>
// LOAD ADDRESS
address = getch();
3e7a: 92 d0 rcall .+292 ; 0x3fa0 <getch>
3e7c: 08 2f mov r16, r24
3e7e: 10 e0 ldi r17, 0x00 ; 0
3e80: 10 93 01 02 sts 0x0201, r17
3e84: 00 93 00 02 sts 0x0200, r16
address = (address & 0xff) | (getch() << 8);
3e88: 8b d0 rcall .+278 ; 0x3fa0 <getch>
3e8a: 90 e0 ldi r25, 0x00 ; 0
3e8c: 98 2f mov r25, r24
3e8e: 88 27 eor r24, r24
3e90: 80 2b or r24, r16
3e92: 91 2b or r25, r17
address += address; // Convert from word address to byte address
3e94: 88 0f add r24, r24
3e96: 99 1f adc r25, r25
3e98: 90 93 01 02 sts 0x0201, r25
3e9c: 80 93 00 02 sts 0x0200, r24
3ea0: 73 c0 rjmp .+230 ; 0x3f88 <main+0x188>
verifySpace();
}
else if(ch == STK_UNIVERSAL) {
3ea2: 86 35 cpi r24, 0x56 ; 86
3ea4: 29 f4 brne .+10 ; 0x3eb0 <main+0xb0>
// UNIVERSAL command is ignored
getNch(4);
3ea6: 84 e0 ldi r24, 0x04 ; 4
3ea8: 99 d0 rcall .+306 ; 0x3fdc <verifySpace+0xc>
putch(0x00);
3eaa: 80 e0 ldi r24, 0x00 ; 0
3eac: 71 d0 rcall .+226 ; 0x3f90 <putch>
3eae: 6d c0 rjmp .+218 ; 0x3f8a <main+0x18a>
}
/* Write memory, length is big endian and is in bytes */
else if(ch == STK_PROG_PAGE) {
3eb0: 84 36 cpi r24, 0x64 ; 100
3eb2: 09 f0 breq .+2 ; 0x3eb6 <main+0xb6>
3eb4: 43 c0 rjmp .+134 ; 0x3f3c <main+0x13c>
// PROGRAM PAGE - we support flash programming only, not EEPROM
uint8_t *bufPtr;
uint16_t addrPtr;
getLen();
3eb6: 7c d0 rcall .+248 ; 0x3fb0 <getLen>
// Immediately start page erase - this will 4.5ms
boot_page_erase((uint16_t)(void*)address);
3eb8: e0 91 00 02 lds r30, 0x0200
3ebc: f0 91 01 02 lds r31, 0x0201
3ec0: 83 e0 ldi r24, 0x03 ; 3
3ec2: 80 93 57 00 sts 0x0057, r24
3ec6: e8 95 spm
3ec8: c0 e0 ldi r28, 0x00 ; 0
3eca: d1 e0 ldi r29, 0x01 ; 1
// While that is going on, read in page contents
bufPtr = buff;
do *bufPtr++ = getch();
3ecc: 69 d0 rcall .+210 ; 0x3fa0 <getch>
3ece: 89 93 st Y+, r24
while (--length);
3ed0: 80 91 02 02 lds r24, 0x0202
3ed4: 81 50 subi r24, 0x01 ; 1
3ed6: 80 93 02 02 sts 0x0202, r24
3eda: 88 23 and r24, r24
3edc: b9 f7 brne .-18 ; 0x3ecc <main+0xcc>
// Read command terminator, start reply
verifySpace();
3ede: 78 d0 rcall .+240 ; 0x3fd0 <verifySpace>
// If only a partial page is to be programmed, the erase might not be complete.
// So check that here
boot_spm_busy_wait();
3ee0: 07 b6 in r0, 0x37 ; 55
3ee2: 00 fc sbrc r0, 0
3ee4: fd cf rjmp .-6 ; 0x3ee0 <main+0xe0>
}
#endif
// Copy buffer into programming buffer
bufPtr = buff;
addrPtr = (uint16_t)(void*)address;
3ee6: 40 91 00 02 lds r20, 0x0200
3eea: 50 91 01 02 lds r21, 0x0201
3eee: a0 e0 ldi r26, 0x00 ; 0
3ef0: b1 e0 ldi r27, 0x01 ; 1
ch = SPM_PAGESIZE / 2;
do {
uint16_t a;
a = *bufPtr++;
3ef2: 2c 91 ld r18, X
3ef4: 30 e0 ldi r19, 0x00 ; 0
a |= (*bufPtr++) << 8;
3ef6: 11 96 adiw r26, 0x01 ; 1
3ef8: 8c 91 ld r24, X
3efa: 11 97 sbiw r26, 0x01 ; 1
3efc: 90 e0 ldi r25, 0x00 ; 0
3efe: 98 2f mov r25, r24
3f00: 88 27 eor r24, r24
3f02: 82 2b or r24, r18
3f04: 93 2b or r25, r19
#ifdef VIRTUAL_BOOT_PARTITION
#define rstVect (*(uint16_t*)(0x204))
#define wdtVect (*(uint16_t*)(0x206))
#endif
/* main program starts here */
int main(void) {
3f06: 12 96 adiw r26, 0x02 ; 2
ch = SPM_PAGESIZE / 2;
do {
uint16_t a;
a = *bufPtr++;
a |= (*bufPtr++) << 8;
boot_page_fill((uint16_t)(void*)addrPtr,a);
3f08: fa 01 movw r30, r20
3f0a: 0c 01 movw r0, r24
3f0c: d0 92 57 00 sts 0x0057, r13
3f10: e8 95 spm
3f12: 11 24 eor r1, r1
addrPtr += 2;
3f14: 4e 5f subi r20, 0xFE ; 254
3f16: 5f 4f sbci r21, 0xFF ; 255
} while (--ch);
3f18: f1 e0 ldi r31, 0x01 ; 1
3f1a: a0 38 cpi r26, 0x80 ; 128
3f1c: bf 07 cpc r27, r31
3f1e: 49 f7 brne .-46 ; 0x3ef2 <main+0xf2>
// Write from programming buffer
boot_page_write((uint16_t)(void*)address);
3f20: e0 91 00 02 lds r30, 0x0200
3f24: f0 91 01 02 lds r31, 0x0201
3f28: e0 92 57 00 sts 0x0057, r14
3f2c: e8 95 spm
boot_spm_busy_wait();
3f2e: 07 b6 in r0, 0x37 ; 55
3f30: 00 fc sbrc r0, 0
3f32: fd cf rjmp .-6 ; 0x3f2e <main+0x12e>
#if defined(RWWSRE)
// Reenable read access to flash
boot_rww_enable();
3f34: f0 92 57 00 sts 0x0057, r15
3f38: e8 95 spm
3f3a: 27 c0 rjmp .+78 ; 0x3f8a <main+0x18a>
#endif
}
/* Read memory block mode, length is big endian. */
else if(ch == STK_READ_PAGE) {
3f3c: 84 37 cpi r24, 0x74 ; 116
3f3e: b9 f4 brne .+46 ; 0x3f6e <main+0x16e>
// READ PAGE - we only read flash
getLen();
3f40: 37 d0 rcall .+110 ; 0x3fb0 <getLen>
verifySpace();
3f42: 46 d0 rcall .+140 ; 0x3fd0 <verifySpace>
else ch = pgm_read_byte_near(address);
address++;
putch(ch);
} while (--length);
#else
do putch(pgm_read_byte_near(address++));
3f44: e0 91 00 02 lds r30, 0x0200
3f48: f0 91 01 02 lds r31, 0x0201
3f4c: 31 96 adiw r30, 0x01 ; 1
3f4e: f0 93 01 02 sts 0x0201, r31
3f52: e0 93 00 02 sts 0x0200, r30
3f56: 31 97 sbiw r30, 0x01 ; 1
3f58: e4 91 lpm r30, Z+
3f5a: 8e 2f mov r24, r30
3f5c: 19 d0 rcall .+50 ; 0x3f90 <putch>
while (--length);
3f5e: 80 91 02 02 lds r24, 0x0202
3f62: 81 50 subi r24, 0x01 ; 1
3f64: 80 93 02 02 sts 0x0202, r24
3f68: 88 23 and r24, r24
3f6a: 61 f7 brne .-40 ; 0x3f44 <main+0x144>
3f6c: 0e c0 rjmp .+28 ; 0x3f8a <main+0x18a>
#endif
}
/* Get device signature bytes */
else if(ch == STK_READ_SIGN) {
3f6e: 85 37 cpi r24, 0x75 ; 117
3f70: 39 f4 brne .+14 ; 0x3f80 <main+0x180>
// READ SIGN - return what Avrdude wants to hear
verifySpace();
3f72: 2e d0 rcall .+92 ; 0x3fd0 <verifySpace>
putch(SIGNATURE_0);
3f74: 8e e1 ldi r24, 0x1E ; 30
3f76: 0c d0 rcall .+24 ; 0x3f90 <putch>
putch(SIGNATURE_1);
3f78: 84 e9 ldi r24, 0x94 ; 148
3f7a: 0a d0 rcall .+20 ; 0x3f90 <putch>
putch(SIGNATURE_2);
3f7c: 86 e0 ldi r24, 0x06 ; 6
3f7e: 96 cf rjmp .-212 ; 0x3eac <main+0xac>
}
else if (ch == 'Q') {
3f80: 81 35 cpi r24, 0x51 ; 81
3f82: 11 f4 brne .+4 ; 0x3f88 <main+0x188>
// Adaboot no-wait mod
watchdogConfig(WATCHDOG_16MS);
3f84: 88 e0 ldi r24, 0x08 ; 8
3f86: 19 d0 rcall .+50 ; 0x3fba <watchdogConfig>
verifySpace();
}
else {
// This covers the response to commands like STK_ENTER_PROGMODE
verifySpace();
3f88: 23 d0 rcall .+70 ; 0x3fd0 <verifySpace>
}
putch(STK_OK);
3f8a: 80 e1 ldi r24, 0x10 ; 16
3f8c: 01 d0 rcall .+2 ; 0x3f90 <putch>
3f8e: 63 cf rjmp .-314 ; 0x3e56 <main+0x56>
00003f90 <putch>:
}
}
void putch(char ch) {
3f90: 98 2f mov r25, r24
#ifndef SOFT_UART
while (!(UCSR0A & _BV(UDRE0)));
3f92: 80 91 c0 00 lds r24, 0x00C0
3f96: 85 ff sbrs r24, 5
3f98: fc cf rjmp .-8 ; 0x3f92 <putch+0x2>
UDR0 = ch;
3f9a: 90 93 c6 00 sts 0x00C6, r25
[uartBit] "I" (UART_TX_BIT)
:
"r25"
);
#endif
}
3f9e: 08 95 ret
00003fa0 <getch>:
return getch();
}
// Watchdog functions. These are only safe with interrupts turned off.
void watchdogReset() {
__asm__ __volatile__ (
3fa0: a8 95 wdr
[uartBit] "I" (UART_RX_BIT)
:
"r25"
);
#else
while(!(UCSR0A & _BV(RXC0)));
3fa2: 80 91 c0 00 lds r24, 0x00C0
3fa6: 87 ff sbrs r24, 7
3fa8: fc cf rjmp .-8 ; 0x3fa2 <getch+0x2>
ch = UDR0;
3faa: 80 91 c6 00 lds r24, 0x00C6
#ifdef LED_DATA_FLASH
LED_PIN |= _BV(LED);
#endif
return ch;
}
3fae: 08 95 ret
00003fb0 <getLen>:
} while (--count);
}
#endif
uint8_t getLen() {
getch();
3fb0: f7 df rcall .-18 ; 0x3fa0 <getch>
length = getch();
3fb2: f6 df rcall .-20 ; 0x3fa0 <getch>
3fb4: 80 93 02 02 sts 0x0202, r24
return getch();
}
3fb8: f3 cf rjmp .-26 ; 0x3fa0 <getch>
00003fba <watchdogConfig>:
"wdr\n"
);
}
void watchdogConfig(uint8_t x) {
WDTCSR = _BV(WDCE) | _BV(WDE);
3fba: e0 e6 ldi r30, 0x60 ; 96
3fbc: f0 e0 ldi r31, 0x00 ; 0
3fbe: 98 e1 ldi r25, 0x18 ; 24
3fc0: 90 83 st Z, r25
WDTCSR = x;
3fc2: 80 83 st Z, r24
}
3fc4: 08 95 ret
00003fc6 <appStart>:
void appStart() {
watchdogConfig(WATCHDOG_OFF);
3fc6: 80 e0 ldi r24, 0x00 ; 0
3fc8: f8 df rcall .-16 ; 0x3fba <watchdogConfig>
__asm__ __volatile__ (
3fca: ee 27 eor r30, r30
3fcc: ff 27 eor r31, r31
3fce: 09 94 ijmp
00003fd0 <verifySpace>:
do getch(); while (--count);
verifySpace();
}
void verifySpace() {
if (getch() != CRC_EOP) appStart();
3fd0: e7 df rcall .-50 ; 0x3fa0 <getch>
3fd2: 80 32 cpi r24, 0x20 ; 32
3fd4: 09 f0 breq .+2 ; 0x3fd8 <verifySpace+0x8>
3fd6: f7 df rcall .-18 ; 0x3fc6 <appStart>
putch(STK_INSYNC);
3fd8: 84 e1 ldi r24, 0x14 ; 20
}
3fda: da cf rjmp .-76 ; 0x3f90 <putch>
::[count] "M" (UART_B_VALUE)
);
}
#endif
void getNch(uint8_t count) {
3fdc: 1f 93 push r17
3fde: 18 2f mov r17, r24
00003fe0 <getNch>:
do getch(); while (--count);
3fe0: df df rcall .-66 ; 0x3fa0 <getch>
3fe2: 11 50 subi r17, 0x01 ; 1
3fe4: e9 f7 brne .-6 ; 0x3fe0 <getNch>
verifySpace();
3fe6: f4 df rcall .-24 ; 0x3fd0 <verifySpace>
}
3fe8: 1f 91 pop r17
3fea: 08 95 ret

View file

@ -0,0 +1,34 @@
:103E000085E08093810084B714BE81FFE4D08DE00B
:103E1000DCD0259A519A86E028E13EEF91E030937C
:103E200085002093840096BBB09BFECF1D9AA89579
:103E30008150A9F7DD24D394A5E0EA2EF1E1FF2E0D
:103E4000ABD0813421F481E0D1D083E024C082342E
:103E500011F484E103C0853419F485E0C7D08AC029
:103E60008535A1F499D0082F10E01093010200933A
:103E7000000292D090E0982F8827802B912B880FFA
:103E8000991F909301028093000273C0863529F434
:103E900084E0ACD080E071D06DC0843609F043C0BE
:103EA0008FD0E0910002F091010283E080935700EF
:103EB000E895C0E0D1E070D08993809102028150F2
:103EC000809302028823B9F78BD007B600FCFDCFA0
:103ED0004091000250910102A0E0B1E02C9130E04D
:103EE00011968C91119790E0982F8827822B932B15
:103EF0001296FA010C01D0925700E89511244E5FFA
:103F00005F4FF1E0A038BF0749F7E0910002F09160
:103F10000102E0925700E89507B600FCFDCFF09251
:103F20005700E89527C08437B9F44AD059D0E091BA
:103F30000002F09101023196F0930102E093000239
:103F40003197E4918E2F19D0809102028150809395
:103F50000202882361F70EC0853739F441D08EE123
:103F60000CD084E90AD086E096CF813511F488E040
:103F70002CD036D080E101D063CF2AE030E08095AC
:103F8000089410F4599802C0599A000015D014D022
:103F900086952A95B1F70895A89529E030E04899CB
:103FA000FECF0AD009D008D08894489908942A9561
:103FB00011F08795F7CF089598E09A95F1F7089555
:103FC000EBDFEADF80930202E7CFE0E6F0E098E182
:103FD00090838083089580E0F8DFEE27FF2709941F
:103FE000DBDF803209F0F7DF84E1C7CF1F93182FA2
:0C3FF000D3DF1150E9F7F4DF1F910895B2
:0400000300003E00BB
:00000001FF

View file

@ -0,0 +1,533 @@
optiboot_lilypad.elf: file format elf32-avr
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 000001fc 00003e00 00003e00 00000054 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .debug_aranges 00000028 00000000 00000000 00000250 2**0
CONTENTS, READONLY, DEBUGGING
2 .debug_pubnames 00000078 00000000 00000000 00000278 2**0
CONTENTS, READONLY, DEBUGGING
3 .debug_info 00000277 00000000 00000000 000002f0 2**0
CONTENTS, READONLY, DEBUGGING
4 .debug_abbrev 00000194 00000000 00000000 00000567 2**0
CONTENTS, READONLY, DEBUGGING
5 .debug_line 000003bb 00000000 00000000 000006fb 2**0
CONTENTS, READONLY, DEBUGGING
6 .debug_frame 000000a0 00000000 00000000 00000ab8 2**2
CONTENTS, READONLY, DEBUGGING
7 .debug_str 0000013f 00000000 00000000 00000b58 2**0
CONTENTS, READONLY, DEBUGGING
8 .debug_loc 000001a0 00000000 00000000 00000c97 2**0
CONTENTS, READONLY, DEBUGGING
9 .debug_ranges 00000070 00000000 00000000 00000e37 2**0
CONTENTS, READONLY, DEBUGGING
Disassembly of section .text:
00003e00 <main>:
#ifdef VIRTUAL_BOOT_PARTITION
#define rstVect (*(uint16_t*)(0x204))
#define wdtVect (*(uint16_t*)(0x206))
#endif
/* main program starts here */
int main(void) {
3e00: 85 e0 ldi r24, 0x05 ; 5
3e02: 80 93 81 00 sts 0x0081, r24
UCSR0C = _BV(UCSZ00) | _BV(UCSZ01);
UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
#endif
// Adaboot no-wait mod
ch = MCUSR;
3e06: 84 b7 in r24, 0x34 ; 52
MCUSR = 0;
3e08: 14 be out 0x34, r1 ; 52
if (!(ch & _BV(EXTRF))) appStart();
3e0a: 81 ff sbrs r24, 1
3e0c: e4 d0 rcall .+456 ; 0x3fd6 <appStart>
// Set up watchdog to trigger after 500ms
watchdogConfig(WATCHDOG_500MS);
3e0e: 8d e0 ldi r24, 0x0D ; 13
3e10: dc d0 rcall .+440 ; 0x3fca <watchdogConfig>
/* Set LED pin as output */
LED_DDR |= _BV(LED);
3e12: 25 9a sbi 0x04, 5 ; 4
#ifdef SOFT_UART
/* Set TX pin as output */
UART_DDR |= _BV(UART_TX_BIT);
3e14: 51 9a sbi 0x0a, 1 ; 10
3e16: 86 e0 ldi r24, 0x06 ; 6
}
#if LED_START_FLASHES > 0
void flash_led(uint8_t count) {
do {
TCNT1 = -(F_CPU/(1024*16));
3e18: 28 e1 ldi r18, 0x18 ; 24
3e1a: 3e ef ldi r19, 0xFE ; 254
TIFR1 = _BV(TOV1);
3e1c: 91 e0 ldi r25, 0x01 ; 1
}
#if LED_START_FLASHES > 0
void flash_led(uint8_t count) {
do {
TCNT1 = -(F_CPU/(1024*16));
3e1e: 30 93 85 00 sts 0x0085, r19
3e22: 20 93 84 00 sts 0x0084, r18
TIFR1 = _BV(TOV1);
3e26: 96 bb out 0x16, r25 ; 22
while(!(TIFR1 & _BV(TOV1)));
3e28: b0 9b sbis 0x16, 0 ; 22
3e2a: fe cf rjmp .-4 ; 0x3e28 <main+0x28>
LED_PIN |= _BV(LED);
3e2c: 1d 9a sbi 0x03, 5 ; 3
return getch();
}
// Watchdog functions. These are only safe with interrupts turned off.
void watchdogReset() {
__asm__ __volatile__ (
3e2e: a8 95 wdr
TCNT1 = -(F_CPU/(1024*16));
TIFR1 = _BV(TOV1);
while(!(TIFR1 & _BV(TOV1)));
LED_PIN |= _BV(LED);
watchdogReset();
} while (--count);
3e30: 81 50 subi r24, 0x01 ; 1
3e32: a9 f7 brne .-22 ; 0x3e1e <main+0x1e>
/* get character from UART */
ch = getch();
if(ch == STK_GET_PARAMETER) {
// GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy
getNch(1);
3e34: dd 24 eor r13, r13
3e36: d3 94 inc r13
boot_page_fill((uint16_t)(void*)addrPtr,a);
addrPtr += 2;
} while (--ch);
// Write from programming buffer
boot_page_write((uint16_t)(void*)address);
3e38: a5 e0 ldi r26, 0x05 ; 5
3e3a: ea 2e mov r14, r26
boot_spm_busy_wait();
#if defined(RWWSRE)
// Reenable read access to flash
boot_rww_enable();
3e3c: f1 e1 ldi r31, 0x11 ; 17
3e3e: ff 2e mov r15, r31
#endif
/* Forever loop */
for (;;) {
/* get character from UART */
ch = getch();
3e40: ab d0 rcall .+342 ; 0x3f98 <getch>
if(ch == STK_GET_PARAMETER) {
3e42: 81 34 cpi r24, 0x41 ; 65
3e44: 21 f4 brne .+8 ; 0x3e4e <main+0x4e>
// GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy
getNch(1);
3e46: 81 e0 ldi r24, 0x01 ; 1
3e48: d1 d0 rcall .+418 ; 0x3fec <verifySpace+0xc>
putch(0x03);
3e4a: 83 e0 ldi r24, 0x03 ; 3
3e4c: 24 c0 rjmp .+72 ; 0x3e96 <main+0x96>
}
else if(ch == STK_SET_DEVICE) {
3e4e: 82 34 cpi r24, 0x42 ; 66
3e50: 11 f4 brne .+4 ; 0x3e56 <main+0x56>
// SET DEVICE is ignored
getNch(20);
3e52: 84 e1 ldi r24, 0x14 ; 20
3e54: 03 c0 rjmp .+6 ; 0x3e5c <main+0x5c>
}
else if(ch == STK_SET_DEVICE_EXT) {
3e56: 85 34 cpi r24, 0x45 ; 69
3e58: 19 f4 brne .+6 ; 0x3e60 <main+0x60>
// SET DEVICE EXT is ignored
getNch(5);
3e5a: 85 e0 ldi r24, 0x05 ; 5
3e5c: c7 d0 rcall .+398 ; 0x3fec <verifySpace+0xc>
3e5e: 8a c0 rjmp .+276 ; 0x3f74 <main+0x174>
}
else if(ch == STK_LOAD_ADDRESS) {
3e60: 85 35 cpi r24, 0x55 ; 85
3e62: a1 f4 brne .+40 ; 0x3e8c <main+0x8c>
// LOAD ADDRESS
address = getch();
3e64: 99 d0 rcall .+306 ; 0x3f98 <getch>
3e66: 08 2f mov r16, r24
3e68: 10 e0 ldi r17, 0x00 ; 0
3e6a: 10 93 01 02 sts 0x0201, r17
3e6e: 00 93 00 02 sts 0x0200, r16
address = (address & 0xff) | (getch() << 8);
3e72: 92 d0 rcall .+292 ; 0x3f98 <getch>
3e74: 90 e0 ldi r25, 0x00 ; 0
3e76: 98 2f mov r25, r24
3e78: 88 27 eor r24, r24
3e7a: 80 2b or r24, r16
3e7c: 91 2b or r25, r17
address += address; // Convert from word address to byte address
3e7e: 88 0f add r24, r24
3e80: 99 1f adc r25, r25
3e82: 90 93 01 02 sts 0x0201, r25
3e86: 80 93 00 02 sts 0x0200, r24
3e8a: 73 c0 rjmp .+230 ; 0x3f72 <main+0x172>
verifySpace();
}
else if(ch == STK_UNIVERSAL) {
3e8c: 86 35 cpi r24, 0x56 ; 86
3e8e: 29 f4 brne .+10 ; 0x3e9a <main+0x9a>
// UNIVERSAL command is ignored
getNch(4);
3e90: 84 e0 ldi r24, 0x04 ; 4
3e92: ac d0 rcall .+344 ; 0x3fec <verifySpace+0xc>
putch(0x00);
3e94: 80 e0 ldi r24, 0x00 ; 0
3e96: 71 d0 rcall .+226 ; 0x3f7a <putch>
3e98: 6d c0 rjmp .+218 ; 0x3f74 <main+0x174>
}
/* Write memory, length is big endian and is in bytes */
else if(ch == STK_PROG_PAGE) {
3e9a: 84 36 cpi r24, 0x64 ; 100
3e9c: 09 f0 breq .+2 ; 0x3ea0 <main+0xa0>
3e9e: 43 c0 rjmp .+134 ; 0x3f26 <main+0x126>
// PROGRAM PAGE - we support flash programming only, not EEPROM
uint8_t *bufPtr;
uint16_t addrPtr;
getLen();
3ea0: 8f d0 rcall .+286 ; 0x3fc0 <getLen>
// Immediately start page erase - this will 4.5ms
boot_page_erase((uint16_t)(void*)address);
3ea2: e0 91 00 02 lds r30, 0x0200
3ea6: f0 91 01 02 lds r31, 0x0201
3eaa: 83 e0 ldi r24, 0x03 ; 3
3eac: 80 93 57 00 sts 0x0057, r24
3eb0: e8 95 spm
3eb2: c0 e0 ldi r28, 0x00 ; 0
3eb4: d1 e0 ldi r29, 0x01 ; 1
// While that is going on, read in page contents
bufPtr = buff;
do *bufPtr++ = getch();
3eb6: 70 d0 rcall .+224 ; 0x3f98 <getch>
3eb8: 89 93 st Y+, r24
while (--length);
3eba: 80 91 02 02 lds r24, 0x0202
3ebe: 81 50 subi r24, 0x01 ; 1
3ec0: 80 93 02 02 sts 0x0202, r24
3ec4: 88 23 and r24, r24
3ec6: b9 f7 brne .-18 ; 0x3eb6 <main+0xb6>
// Read command terminator, start reply
verifySpace();
3ec8: 8b d0 rcall .+278 ; 0x3fe0 <verifySpace>
// If only a partial page is to be programmed, the erase might not be complete.
// So check that here
boot_spm_busy_wait();
3eca: 07 b6 in r0, 0x37 ; 55
3ecc: 00 fc sbrc r0, 0
3ece: fd cf rjmp .-6 ; 0x3eca <main+0xca>
}
#endif
// Copy buffer into programming buffer
bufPtr = buff;
addrPtr = (uint16_t)(void*)address;
3ed0: 40 91 00 02 lds r20, 0x0200
3ed4: 50 91 01 02 lds r21, 0x0201
3ed8: a0 e0 ldi r26, 0x00 ; 0
3eda: b1 e0 ldi r27, 0x01 ; 1
ch = SPM_PAGESIZE / 2;
do {
uint16_t a;
a = *bufPtr++;
3edc: 2c 91 ld r18, X
3ede: 30 e0 ldi r19, 0x00 ; 0
a |= (*bufPtr++) << 8;
3ee0: 11 96 adiw r26, 0x01 ; 1
3ee2: 8c 91 ld r24, X
3ee4: 11 97 sbiw r26, 0x01 ; 1
3ee6: 90 e0 ldi r25, 0x00 ; 0
3ee8: 98 2f mov r25, r24
3eea: 88 27 eor r24, r24
3eec: 82 2b or r24, r18
3eee: 93 2b or r25, r19
#ifdef VIRTUAL_BOOT_PARTITION
#define rstVect (*(uint16_t*)(0x204))
#define wdtVect (*(uint16_t*)(0x206))
#endif
/* main program starts here */
int main(void) {
3ef0: 12 96 adiw r26, 0x02 ; 2
ch = SPM_PAGESIZE / 2;
do {
uint16_t a;
a = *bufPtr++;
a |= (*bufPtr++) << 8;
boot_page_fill((uint16_t)(void*)addrPtr,a);
3ef2: fa 01 movw r30, r20
3ef4: 0c 01 movw r0, r24
3ef6: d0 92 57 00 sts 0x0057, r13
3efa: e8 95 spm
3efc: 11 24 eor r1, r1
addrPtr += 2;
3efe: 4e 5f subi r20, 0xFE ; 254
3f00: 5f 4f sbci r21, 0xFF ; 255
} while (--ch);
3f02: f1 e0 ldi r31, 0x01 ; 1
3f04: a0 38 cpi r26, 0x80 ; 128
3f06: bf 07 cpc r27, r31
3f08: 49 f7 brne .-46 ; 0x3edc <main+0xdc>
// Write from programming buffer
boot_page_write((uint16_t)(void*)address);
3f0a: e0 91 00 02 lds r30, 0x0200
3f0e: f0 91 01 02 lds r31, 0x0201
3f12: e0 92 57 00 sts 0x0057, r14
3f16: e8 95 spm
boot_spm_busy_wait();
3f18: 07 b6 in r0, 0x37 ; 55
3f1a: 00 fc sbrc r0, 0
3f1c: fd cf rjmp .-6 ; 0x3f18 <main+0x118>
#if defined(RWWSRE)
// Reenable read access to flash
boot_rww_enable();
3f1e: f0 92 57 00 sts 0x0057, r15
3f22: e8 95 spm
3f24: 27 c0 rjmp .+78 ; 0x3f74 <main+0x174>
#endif
}
/* Read memory block mode, length is big endian. */
else if(ch == STK_READ_PAGE) {
3f26: 84 37 cpi r24, 0x74 ; 116
3f28: b9 f4 brne .+46 ; 0x3f58 <main+0x158>
// READ PAGE - we only read flash
getLen();
3f2a: 4a d0 rcall .+148 ; 0x3fc0 <getLen>
verifySpace();
3f2c: 59 d0 rcall .+178 ; 0x3fe0 <verifySpace>
else ch = pgm_read_byte_near(address);
address++;
putch(ch);
} while (--length);
#else
do putch(pgm_read_byte_near(address++));
3f2e: e0 91 00 02 lds r30, 0x0200
3f32: f0 91 01 02 lds r31, 0x0201
3f36: 31 96 adiw r30, 0x01 ; 1
3f38: f0 93 01 02 sts 0x0201, r31
3f3c: e0 93 00 02 sts 0x0200, r30
3f40: 31 97 sbiw r30, 0x01 ; 1
3f42: e4 91 lpm r30, Z+
3f44: 8e 2f mov r24, r30
3f46: 19 d0 rcall .+50 ; 0x3f7a <putch>
while (--length);
3f48: 80 91 02 02 lds r24, 0x0202
3f4c: 81 50 subi r24, 0x01 ; 1
3f4e: 80 93 02 02 sts 0x0202, r24
3f52: 88 23 and r24, r24
3f54: 61 f7 brne .-40 ; 0x3f2e <main+0x12e>
3f56: 0e c0 rjmp .+28 ; 0x3f74 <main+0x174>
#endif
}
/* Get device signature bytes */
else if(ch == STK_READ_SIGN) {
3f58: 85 37 cpi r24, 0x75 ; 117
3f5a: 39 f4 brne .+14 ; 0x3f6a <main+0x16a>
// READ SIGN - return what Avrdude wants to hear
verifySpace();
3f5c: 41 d0 rcall .+130 ; 0x3fe0 <verifySpace>
putch(SIGNATURE_0);
3f5e: 8e e1 ldi r24, 0x1E ; 30
3f60: 0c d0 rcall .+24 ; 0x3f7a <putch>
putch(SIGNATURE_1);
3f62: 84 e9 ldi r24, 0x94 ; 148
3f64: 0a d0 rcall .+20 ; 0x3f7a <putch>
putch(SIGNATURE_2);
3f66: 86 e0 ldi r24, 0x06 ; 6
3f68: 96 cf rjmp .-212 ; 0x3e96 <main+0x96>
}
else if (ch == 'Q') {
3f6a: 81 35 cpi r24, 0x51 ; 81
3f6c: 11 f4 brne .+4 ; 0x3f72 <main+0x172>
// Adaboot no-wait mod
watchdogConfig(WATCHDOG_16MS);
3f6e: 88 e0 ldi r24, 0x08 ; 8
3f70: 2c d0 rcall .+88 ; 0x3fca <watchdogConfig>
verifySpace();
}
else {
// This covers the response to commands like STK_ENTER_PROGMODE
verifySpace();
3f72: 36 d0 rcall .+108 ; 0x3fe0 <verifySpace>
}
putch(STK_OK);
3f74: 80 e1 ldi r24, 0x10 ; 16
3f76: 01 d0 rcall .+2 ; 0x3f7a <putch>
3f78: 63 cf rjmp .-314 ; 0x3e40 <main+0x40>
00003f7a <putch>:
void putch(char ch) {
#ifndef SOFT_UART
while (!(UCSR0A & _BV(UDRE0)));
UDR0 = ch;
#else
__asm__ __volatile__ (
3f7a: 2a e0 ldi r18, 0x0A ; 10
3f7c: 30 e0 ldi r19, 0x00 ; 0
3f7e: 80 95 com r24
3f80: 08 94 sec
3f82: 10 f4 brcc .+4 ; 0x3f88 <putch+0xe>
3f84: 59 98 cbi 0x0b, 1 ; 11
3f86: 02 c0 rjmp .+4 ; 0x3f8c <putch+0x12>
3f88: 59 9a sbi 0x0b, 1 ; 11
3f8a: 00 00 nop
3f8c: 15 d0 rcall .+42 ; 0x3fb8 <uartDelay>
3f8e: 14 d0 rcall .+40 ; 0x3fb8 <uartDelay>
3f90: 86 95 lsr r24
3f92: 2a 95 dec r18
3f94: b1 f7 brne .-20 ; 0x3f82 <putch+0x8>
[uartBit] "I" (UART_TX_BIT)
:
"r25"
);
#endif
}
3f96: 08 95 ret
00003f98 <getch>:
return getch();
}
// Watchdog functions. These are only safe with interrupts turned off.
void watchdogReset() {
__asm__ __volatile__ (
3f98: a8 95 wdr
#ifdef LED_DATA_FLASH
LED_PIN |= _BV(LED);
#endif
return ch;
}
3f9a: 29 e0 ldi r18, 0x09 ; 9
3f9c: 30 e0 ldi r19, 0x00 ; 0
3f9e: 48 99 sbic 0x09, 0 ; 9
3fa0: fe cf rjmp .-4 ; 0x3f9e <getch+0x6>
3fa2: 0a d0 rcall .+20 ; 0x3fb8 <uartDelay>
3fa4: 09 d0 rcall .+18 ; 0x3fb8 <uartDelay>
3fa6: 08 d0 rcall .+16 ; 0x3fb8 <uartDelay>
3fa8: 88 94 clc
3faa: 48 99 sbic 0x09, 0 ; 9
3fac: 08 94 sec
3fae: 2a 95 dec r18
3fb0: 11 f0 breq .+4 ; 0x3fb6 <getch+0x1e>
3fb2: 87 95 ror r24
3fb4: f7 cf rjmp .-18 ; 0x3fa4 <getch+0xc>
3fb6: 08 95 ret
00003fb8 <uartDelay>:
#if UART_B_VALUE > 255
#error Baud rate too slow for soft UART
#endif
void uartDelay() {
__asm__ __volatile__ (
3fb8: 98 e0 ldi r25, 0x08 ; 8
3fba: 9a 95 dec r25
3fbc: f1 f7 brne .-4 ; 0x3fba <uartDelay+0x2>
3fbe: 08 95 ret
00003fc0 <getLen>:
} while (--count);
}
#endif
uint8_t getLen() {
getch();
3fc0: eb df rcall .-42 ; 0x3f98 <getch>
length = getch();
3fc2: ea df rcall .-44 ; 0x3f98 <getch>
3fc4: 80 93 02 02 sts 0x0202, r24
return getch();
}
3fc8: e7 cf rjmp .-50 ; 0x3f98 <getch>
00003fca <watchdogConfig>:
"wdr\n"
);
}
void watchdogConfig(uint8_t x) {
WDTCSR = _BV(WDCE) | _BV(WDE);
3fca: e0 e6 ldi r30, 0x60 ; 96
3fcc: f0 e0 ldi r31, 0x00 ; 0
3fce: 98 e1 ldi r25, 0x18 ; 24
3fd0: 90 83 st Z, r25
WDTCSR = x;
3fd2: 80 83 st Z, r24
}
3fd4: 08 95 ret
00003fd6 <appStart>:
void appStart() {
watchdogConfig(WATCHDOG_OFF);
3fd6: 80 e0 ldi r24, 0x00 ; 0
3fd8: f8 df rcall .-16 ; 0x3fca <watchdogConfig>
__asm__ __volatile__ (
3fda: ee 27 eor r30, r30
3fdc: ff 27 eor r31, r31
3fde: 09 94 ijmp
00003fe0 <verifySpace>:
do getch(); while (--count);
verifySpace();
}
void verifySpace() {
if (getch() != CRC_EOP) appStart();
3fe0: db df rcall .-74 ; 0x3f98 <getch>
3fe2: 80 32 cpi r24, 0x20 ; 32
3fe4: 09 f0 breq .+2 ; 0x3fe8 <verifySpace+0x8>
3fe6: f7 df rcall .-18 ; 0x3fd6 <appStart>
putch(STK_INSYNC);
3fe8: 84 e1 ldi r24, 0x14 ; 20
}
3fea: c7 cf rjmp .-114 ; 0x3f7a <putch>
::[count] "M" (UART_B_VALUE)
);
}
#endif
void getNch(uint8_t count) {
3fec: 1f 93 push r17
3fee: 18 2f mov r17, r24
00003ff0 <getNch>:
do getch(); while (--count);
3ff0: d3 df rcall .-90 ; 0x3f98 <getch>
3ff2: 11 50 subi r17, 0x01 ; 1
3ff4: e9 f7 brne .-6 ; 0x3ff0 <getNch>
verifySpace();
3ff6: f4 df rcall .-24 ; 0x3fe0 <verifySpace>
}
3ff8: 1f 91 pop r17
3ffa: 08 95 ret

View file

@ -0,0 +1,34 @@
:103E000085E08093810084B714BE81FFE4D08DE00B
:103E1000DCD0259A519A86E028E13EEF91E030937C
:103E200085002093840096BBB09BFECF1D9AA89579
:103E30008150A9F7DD24D394A5E0EA2EF1E1FF2E0D
:103E4000ABD0813421F481E0D1D083E024C082342E
:103E500011F484E103C0853419F485E0C7D08AC029
:103E60008535A1F499D0082F10E01093010200933A
:103E7000000292D090E0982F8827802B912B880FFA
:103E8000991F909301028093000273C0863529F434
:103E900084E0ACD080E071D06DC0843609F043C0BE
:103EA0008FD0E0910002F091010283E080935700EF
:103EB000E895C0E0D1E070D08993809102028150F2
:103EC000809302028823B9F78BD007B600FCFDCFA0
:103ED0004091000250910102A0E0B1E02C9130E04D
:103EE00011968C91119790E0982F8827822B932B15
:103EF0001296FA010C01D0925700E89511244E5FFA
:103F00005F4FF1E0A038BF0749F7E0910002F09160
:103F10000102E0925700E89507B600FCFDCFF09251
:103F20005700E89527C08437B9F44AD059D0E091BA
:103F30000002F09101023196F0930102E093000239
:103F40003197E4918E2F19D0809102028150809395
:103F50000202882361F70EC0853739F441D08EE123
:103F60000CD084E90AD086E096CF813511F488E040
:103F70002CD036D080E101D063CF2AE030E08095AC
:103F8000089410F4599802C0599A000015D014D022
:103F900086952A95B1F70895A89529E030E04899CB
:103FA000FECF0AD009D008D08894489908942A9561
:103FB00011F08795F7CF089598E09A95F1F7089555
:103FC000EBDFEADF80930202E7CFE0E6F0E098E182
:103FD00090838083089580E0F8DFEE27FF2709941F
:103FE000DBDF803209F0F7DF84E1C7CF1F93182FA2
:0C3FF000D3DF1150E9F7F4DF1F910895B2
:0400000300003E00BB
:00000001FF

View file

@ -0,0 +1,533 @@
optiboot_lilypad_resonator.elf: file format elf32-avr
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 000001fc 00003e00 00003e00 00000054 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .debug_aranges 00000028 00000000 00000000 00000250 2**0
CONTENTS, READONLY, DEBUGGING
2 .debug_pubnames 00000078 00000000 00000000 00000278 2**0
CONTENTS, READONLY, DEBUGGING
3 .debug_info 00000277 00000000 00000000 000002f0 2**0
CONTENTS, READONLY, DEBUGGING
4 .debug_abbrev 00000194 00000000 00000000 00000567 2**0
CONTENTS, READONLY, DEBUGGING
5 .debug_line 000003bb 00000000 00000000 000006fb 2**0
CONTENTS, READONLY, DEBUGGING
6 .debug_frame 000000a0 00000000 00000000 00000ab8 2**2
CONTENTS, READONLY, DEBUGGING
7 .debug_str 0000013f 00000000 00000000 00000b58 2**0
CONTENTS, READONLY, DEBUGGING
8 .debug_loc 000001a0 00000000 00000000 00000c97 2**0
CONTENTS, READONLY, DEBUGGING
9 .debug_ranges 00000070 00000000 00000000 00000e37 2**0
CONTENTS, READONLY, DEBUGGING
Disassembly of section .text:
00003e00 <main>:
#ifdef VIRTUAL_BOOT_PARTITION
#define rstVect (*(uint16_t*)(0x204))
#define wdtVect (*(uint16_t*)(0x206))
#endif
/* main program starts here */
int main(void) {
3e00: 85 e0 ldi r24, 0x05 ; 5
3e02: 80 93 81 00 sts 0x0081, r24
UCSR0C = _BV(UCSZ00) | _BV(UCSZ01);
UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
#endif
// Adaboot no-wait mod
ch = MCUSR;
3e06: 84 b7 in r24, 0x34 ; 52
MCUSR = 0;
3e08: 14 be out 0x34, r1 ; 52
if (!(ch & _BV(EXTRF))) appStart();
3e0a: 81 ff sbrs r24, 1
3e0c: e4 d0 rcall .+456 ; 0x3fd6 <appStart>
// Set up watchdog to trigger after 500ms
watchdogConfig(WATCHDOG_500MS);
3e0e: 8d e0 ldi r24, 0x0D ; 13
3e10: dc d0 rcall .+440 ; 0x3fca <watchdogConfig>
/* Set LED pin as output */
LED_DDR |= _BV(LED);
3e12: 25 9a sbi 0x04, 5 ; 4
#ifdef SOFT_UART
/* Set TX pin as output */
UART_DDR |= _BV(UART_TX_BIT);
3e14: 51 9a sbi 0x0a, 1 ; 10
3e16: 86 e0 ldi r24, 0x06 ; 6
}
#if LED_START_FLASHES > 0
void flash_led(uint8_t count) {
do {
TCNT1 = -(F_CPU/(1024*16));
3e18: 28 e1 ldi r18, 0x18 ; 24
3e1a: 3e ef ldi r19, 0xFE ; 254
TIFR1 = _BV(TOV1);
3e1c: 91 e0 ldi r25, 0x01 ; 1
}
#if LED_START_FLASHES > 0
void flash_led(uint8_t count) {
do {
TCNT1 = -(F_CPU/(1024*16));
3e1e: 30 93 85 00 sts 0x0085, r19
3e22: 20 93 84 00 sts 0x0084, r18
TIFR1 = _BV(TOV1);
3e26: 96 bb out 0x16, r25 ; 22
while(!(TIFR1 & _BV(TOV1)));
3e28: b0 9b sbis 0x16, 0 ; 22
3e2a: fe cf rjmp .-4 ; 0x3e28 <main+0x28>
LED_PIN |= _BV(LED);
3e2c: 1d 9a sbi 0x03, 5 ; 3
return getch();
}
// Watchdog functions. These are only safe with interrupts turned off.
void watchdogReset() {
__asm__ __volatile__ (
3e2e: a8 95 wdr
TCNT1 = -(F_CPU/(1024*16));
TIFR1 = _BV(TOV1);
while(!(TIFR1 & _BV(TOV1)));
LED_PIN |= _BV(LED);
watchdogReset();
} while (--count);
3e30: 81 50 subi r24, 0x01 ; 1
3e32: a9 f7 brne .-22 ; 0x3e1e <main+0x1e>
/* get character from UART */
ch = getch();
if(ch == STK_GET_PARAMETER) {
// GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy
getNch(1);
3e34: dd 24 eor r13, r13
3e36: d3 94 inc r13
boot_page_fill((uint16_t)(void*)addrPtr,a);
addrPtr += 2;
} while (--ch);
// Write from programming buffer
boot_page_write((uint16_t)(void*)address);
3e38: a5 e0 ldi r26, 0x05 ; 5
3e3a: ea 2e mov r14, r26
boot_spm_busy_wait();
#if defined(RWWSRE)
// Reenable read access to flash
boot_rww_enable();
3e3c: f1 e1 ldi r31, 0x11 ; 17
3e3e: ff 2e mov r15, r31
#endif
/* Forever loop */
for (;;) {
/* get character from UART */
ch = getch();
3e40: ab d0 rcall .+342 ; 0x3f98 <getch>
if(ch == STK_GET_PARAMETER) {
3e42: 81 34 cpi r24, 0x41 ; 65
3e44: 21 f4 brne .+8 ; 0x3e4e <main+0x4e>
// GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy
getNch(1);
3e46: 81 e0 ldi r24, 0x01 ; 1
3e48: d1 d0 rcall .+418 ; 0x3fec <verifySpace+0xc>
putch(0x03);
3e4a: 83 e0 ldi r24, 0x03 ; 3
3e4c: 24 c0 rjmp .+72 ; 0x3e96 <main+0x96>
}
else if(ch == STK_SET_DEVICE) {
3e4e: 82 34 cpi r24, 0x42 ; 66
3e50: 11 f4 brne .+4 ; 0x3e56 <main+0x56>
// SET DEVICE is ignored
getNch(20);
3e52: 84 e1 ldi r24, 0x14 ; 20
3e54: 03 c0 rjmp .+6 ; 0x3e5c <main+0x5c>
}
else if(ch == STK_SET_DEVICE_EXT) {
3e56: 85 34 cpi r24, 0x45 ; 69
3e58: 19 f4 brne .+6 ; 0x3e60 <main+0x60>
// SET DEVICE EXT is ignored
getNch(5);
3e5a: 85 e0 ldi r24, 0x05 ; 5
3e5c: c7 d0 rcall .+398 ; 0x3fec <verifySpace+0xc>
3e5e: 8a c0 rjmp .+276 ; 0x3f74 <main+0x174>
}
else if(ch == STK_LOAD_ADDRESS) {
3e60: 85 35 cpi r24, 0x55 ; 85
3e62: a1 f4 brne .+40 ; 0x3e8c <main+0x8c>
// LOAD ADDRESS
address = getch();
3e64: 99 d0 rcall .+306 ; 0x3f98 <getch>
3e66: 08 2f mov r16, r24
3e68: 10 e0 ldi r17, 0x00 ; 0
3e6a: 10 93 01 02 sts 0x0201, r17
3e6e: 00 93 00 02 sts 0x0200, r16
address = (address & 0xff) | (getch() << 8);
3e72: 92 d0 rcall .+292 ; 0x3f98 <getch>
3e74: 90 e0 ldi r25, 0x00 ; 0
3e76: 98 2f mov r25, r24
3e78: 88 27 eor r24, r24
3e7a: 80 2b or r24, r16
3e7c: 91 2b or r25, r17
address += address; // Convert from word address to byte address
3e7e: 88 0f add r24, r24
3e80: 99 1f adc r25, r25
3e82: 90 93 01 02 sts 0x0201, r25
3e86: 80 93 00 02 sts 0x0200, r24
3e8a: 73 c0 rjmp .+230 ; 0x3f72 <main+0x172>
verifySpace();
}
else if(ch == STK_UNIVERSAL) {
3e8c: 86 35 cpi r24, 0x56 ; 86
3e8e: 29 f4 brne .+10 ; 0x3e9a <main+0x9a>
// UNIVERSAL command is ignored
getNch(4);
3e90: 84 e0 ldi r24, 0x04 ; 4
3e92: ac d0 rcall .+344 ; 0x3fec <verifySpace+0xc>
putch(0x00);
3e94: 80 e0 ldi r24, 0x00 ; 0
3e96: 71 d0 rcall .+226 ; 0x3f7a <putch>
3e98: 6d c0 rjmp .+218 ; 0x3f74 <main+0x174>
}
/* Write memory, length is big endian and is in bytes */
else if(ch == STK_PROG_PAGE) {
3e9a: 84 36 cpi r24, 0x64 ; 100
3e9c: 09 f0 breq .+2 ; 0x3ea0 <main+0xa0>
3e9e: 43 c0 rjmp .+134 ; 0x3f26 <main+0x126>
// PROGRAM PAGE - we support flash programming only, not EEPROM
uint8_t *bufPtr;
uint16_t addrPtr;
getLen();
3ea0: 8f d0 rcall .+286 ; 0x3fc0 <getLen>
// Immediately start page erase - this will 4.5ms
boot_page_erase((uint16_t)(void*)address);
3ea2: e0 91 00 02 lds r30, 0x0200
3ea6: f0 91 01 02 lds r31, 0x0201
3eaa: 83 e0 ldi r24, 0x03 ; 3
3eac: 80 93 57 00 sts 0x0057, r24
3eb0: e8 95 spm
3eb2: c0 e0 ldi r28, 0x00 ; 0
3eb4: d1 e0 ldi r29, 0x01 ; 1
// While that is going on, read in page contents
bufPtr = buff;
do *bufPtr++ = getch();
3eb6: 70 d0 rcall .+224 ; 0x3f98 <getch>
3eb8: 89 93 st Y+, r24
while (--length);
3eba: 80 91 02 02 lds r24, 0x0202
3ebe: 81 50 subi r24, 0x01 ; 1
3ec0: 80 93 02 02 sts 0x0202, r24
3ec4: 88 23 and r24, r24
3ec6: b9 f7 brne .-18 ; 0x3eb6 <main+0xb6>
// Read command terminator, start reply
verifySpace();
3ec8: 8b d0 rcall .+278 ; 0x3fe0 <verifySpace>
// If only a partial page is to be programmed, the erase might not be complete.
// So check that here
boot_spm_busy_wait();
3eca: 07 b6 in r0, 0x37 ; 55
3ecc: 00 fc sbrc r0, 0
3ece: fd cf rjmp .-6 ; 0x3eca <main+0xca>
}
#endif
// Copy buffer into programming buffer
bufPtr = buff;
addrPtr = (uint16_t)(void*)address;
3ed0: 40 91 00 02 lds r20, 0x0200
3ed4: 50 91 01 02 lds r21, 0x0201
3ed8: a0 e0 ldi r26, 0x00 ; 0
3eda: b1 e0 ldi r27, 0x01 ; 1
ch = SPM_PAGESIZE / 2;
do {
uint16_t a;
a = *bufPtr++;
3edc: 2c 91 ld r18, X
3ede: 30 e0 ldi r19, 0x00 ; 0
a |= (*bufPtr++) << 8;
3ee0: 11 96 adiw r26, 0x01 ; 1
3ee2: 8c 91 ld r24, X
3ee4: 11 97 sbiw r26, 0x01 ; 1
3ee6: 90 e0 ldi r25, 0x00 ; 0
3ee8: 98 2f mov r25, r24
3eea: 88 27 eor r24, r24
3eec: 82 2b or r24, r18
3eee: 93 2b or r25, r19
#ifdef VIRTUAL_BOOT_PARTITION
#define rstVect (*(uint16_t*)(0x204))
#define wdtVect (*(uint16_t*)(0x206))
#endif
/* main program starts here */
int main(void) {
3ef0: 12 96 adiw r26, 0x02 ; 2
ch = SPM_PAGESIZE / 2;
do {
uint16_t a;
a = *bufPtr++;
a |= (*bufPtr++) << 8;
boot_page_fill((uint16_t)(void*)addrPtr,a);
3ef2: fa 01 movw r30, r20
3ef4: 0c 01 movw r0, r24
3ef6: d0 92 57 00 sts 0x0057, r13
3efa: e8 95 spm
3efc: 11 24 eor r1, r1
addrPtr += 2;
3efe: 4e 5f subi r20, 0xFE ; 254
3f00: 5f 4f sbci r21, 0xFF ; 255
} while (--ch);
3f02: f1 e0 ldi r31, 0x01 ; 1
3f04: a0 38 cpi r26, 0x80 ; 128
3f06: bf 07 cpc r27, r31
3f08: 49 f7 brne .-46 ; 0x3edc <main+0xdc>
// Write from programming buffer
boot_page_write((uint16_t)(void*)address);
3f0a: e0 91 00 02 lds r30, 0x0200
3f0e: f0 91 01 02 lds r31, 0x0201
3f12: e0 92 57 00 sts 0x0057, r14
3f16: e8 95 spm
boot_spm_busy_wait();
3f18: 07 b6 in r0, 0x37 ; 55
3f1a: 00 fc sbrc r0, 0
3f1c: fd cf rjmp .-6 ; 0x3f18 <main+0x118>
#if defined(RWWSRE)
// Reenable read access to flash
boot_rww_enable();
3f1e: f0 92 57 00 sts 0x0057, r15
3f22: e8 95 spm
3f24: 27 c0 rjmp .+78 ; 0x3f74 <main+0x174>
#endif
}
/* Read memory block mode, length is big endian. */
else if(ch == STK_READ_PAGE) {
3f26: 84 37 cpi r24, 0x74 ; 116
3f28: b9 f4 brne .+46 ; 0x3f58 <main+0x158>
// READ PAGE - we only read flash
getLen();
3f2a: 4a d0 rcall .+148 ; 0x3fc0 <getLen>
verifySpace();
3f2c: 59 d0 rcall .+178 ; 0x3fe0 <verifySpace>
else ch = pgm_read_byte_near(address);
address++;
putch(ch);
} while (--length);
#else
do putch(pgm_read_byte_near(address++));
3f2e: e0 91 00 02 lds r30, 0x0200
3f32: f0 91 01 02 lds r31, 0x0201
3f36: 31 96 adiw r30, 0x01 ; 1
3f38: f0 93 01 02 sts 0x0201, r31
3f3c: e0 93 00 02 sts 0x0200, r30
3f40: 31 97 sbiw r30, 0x01 ; 1
3f42: e4 91 lpm r30, Z+
3f44: 8e 2f mov r24, r30
3f46: 19 d0 rcall .+50 ; 0x3f7a <putch>
while (--length);
3f48: 80 91 02 02 lds r24, 0x0202
3f4c: 81 50 subi r24, 0x01 ; 1
3f4e: 80 93 02 02 sts 0x0202, r24
3f52: 88 23 and r24, r24
3f54: 61 f7 brne .-40 ; 0x3f2e <main+0x12e>
3f56: 0e c0 rjmp .+28 ; 0x3f74 <main+0x174>
#endif
}
/* Get device signature bytes */
else if(ch == STK_READ_SIGN) {
3f58: 85 37 cpi r24, 0x75 ; 117
3f5a: 39 f4 brne .+14 ; 0x3f6a <main+0x16a>
// READ SIGN - return what Avrdude wants to hear
verifySpace();
3f5c: 41 d0 rcall .+130 ; 0x3fe0 <verifySpace>
putch(SIGNATURE_0);
3f5e: 8e e1 ldi r24, 0x1E ; 30
3f60: 0c d0 rcall .+24 ; 0x3f7a <putch>
putch(SIGNATURE_1);
3f62: 84 e9 ldi r24, 0x94 ; 148
3f64: 0a d0 rcall .+20 ; 0x3f7a <putch>
putch(SIGNATURE_2);
3f66: 86 e0 ldi r24, 0x06 ; 6
3f68: 96 cf rjmp .-212 ; 0x3e96 <main+0x96>
}
else if (ch == 'Q') {
3f6a: 81 35 cpi r24, 0x51 ; 81
3f6c: 11 f4 brne .+4 ; 0x3f72 <main+0x172>
// Adaboot no-wait mod
watchdogConfig(WATCHDOG_16MS);
3f6e: 88 e0 ldi r24, 0x08 ; 8
3f70: 2c d0 rcall .+88 ; 0x3fca <watchdogConfig>
verifySpace();
}
else {
// This covers the response to commands like STK_ENTER_PROGMODE
verifySpace();
3f72: 36 d0 rcall .+108 ; 0x3fe0 <verifySpace>
}
putch(STK_OK);
3f74: 80 e1 ldi r24, 0x10 ; 16
3f76: 01 d0 rcall .+2 ; 0x3f7a <putch>
3f78: 63 cf rjmp .-314 ; 0x3e40 <main+0x40>
00003f7a <putch>:
void putch(char ch) {
#ifndef SOFT_UART
while (!(UCSR0A & _BV(UDRE0)));
UDR0 = ch;
#else
__asm__ __volatile__ (
3f7a: 2a e0 ldi r18, 0x0A ; 10
3f7c: 30 e0 ldi r19, 0x00 ; 0
3f7e: 80 95 com r24
3f80: 08 94 sec
3f82: 10 f4 brcc .+4 ; 0x3f88 <putch+0xe>
3f84: 59 98 cbi 0x0b, 1 ; 11
3f86: 02 c0 rjmp .+4 ; 0x3f8c <putch+0x12>
3f88: 59 9a sbi 0x0b, 1 ; 11
3f8a: 00 00 nop
3f8c: 15 d0 rcall .+42 ; 0x3fb8 <uartDelay>
3f8e: 14 d0 rcall .+40 ; 0x3fb8 <uartDelay>
3f90: 86 95 lsr r24
3f92: 2a 95 dec r18
3f94: b1 f7 brne .-20 ; 0x3f82 <putch+0x8>
[uartBit] "I" (UART_TX_BIT)
:
"r25"
);
#endif
}
3f96: 08 95 ret
00003f98 <getch>:
return getch();
}
// Watchdog functions. These are only safe with interrupts turned off.
void watchdogReset() {
__asm__ __volatile__ (
3f98: a8 95 wdr
#ifdef LED_DATA_FLASH
LED_PIN |= _BV(LED);
#endif
return ch;
}
3f9a: 29 e0 ldi r18, 0x09 ; 9
3f9c: 30 e0 ldi r19, 0x00 ; 0
3f9e: 48 99 sbic 0x09, 0 ; 9
3fa0: fe cf rjmp .-4 ; 0x3f9e <getch+0x6>
3fa2: 0a d0 rcall .+20 ; 0x3fb8 <uartDelay>
3fa4: 09 d0 rcall .+18 ; 0x3fb8 <uartDelay>
3fa6: 08 d0 rcall .+16 ; 0x3fb8 <uartDelay>
3fa8: 88 94 clc
3faa: 48 99 sbic 0x09, 0 ; 9
3fac: 08 94 sec
3fae: 2a 95 dec r18
3fb0: 11 f0 breq .+4 ; 0x3fb6 <getch+0x1e>
3fb2: 87 95 ror r24
3fb4: f7 cf rjmp .-18 ; 0x3fa4 <getch+0xc>
3fb6: 08 95 ret
00003fb8 <uartDelay>:
#if UART_B_VALUE > 255
#error Baud rate too slow for soft UART
#endif
void uartDelay() {
__asm__ __volatile__ (
3fb8: 98 e0 ldi r25, 0x08 ; 8
3fba: 9a 95 dec r25
3fbc: f1 f7 brne .-4 ; 0x3fba <uartDelay+0x2>
3fbe: 08 95 ret
00003fc0 <getLen>:
} while (--count);
}
#endif
uint8_t getLen() {
getch();
3fc0: eb df rcall .-42 ; 0x3f98 <getch>
length = getch();
3fc2: ea df rcall .-44 ; 0x3f98 <getch>
3fc4: 80 93 02 02 sts 0x0202, r24
return getch();
}
3fc8: e7 cf rjmp .-50 ; 0x3f98 <getch>
00003fca <watchdogConfig>:
"wdr\n"
);
}
void watchdogConfig(uint8_t x) {
WDTCSR = _BV(WDCE) | _BV(WDE);
3fca: e0 e6 ldi r30, 0x60 ; 96
3fcc: f0 e0 ldi r31, 0x00 ; 0
3fce: 98 e1 ldi r25, 0x18 ; 24
3fd0: 90 83 st Z, r25
WDTCSR = x;
3fd2: 80 83 st Z, r24
}
3fd4: 08 95 ret
00003fd6 <appStart>:
void appStart() {
watchdogConfig(WATCHDOG_OFF);
3fd6: 80 e0 ldi r24, 0x00 ; 0
3fd8: f8 df rcall .-16 ; 0x3fca <watchdogConfig>
__asm__ __volatile__ (
3fda: ee 27 eor r30, r30
3fdc: ff 27 eor r31, r31
3fde: 09 94 ijmp
00003fe0 <verifySpace>:
do getch(); while (--count);
verifySpace();
}
void verifySpace() {
if (getch() != CRC_EOP) appStart();
3fe0: db df rcall .-74 ; 0x3f98 <getch>
3fe2: 80 32 cpi r24, 0x20 ; 32
3fe4: 09 f0 breq .+2 ; 0x3fe8 <verifySpace+0x8>
3fe6: f7 df rcall .-18 ; 0x3fd6 <appStart>
putch(STK_INSYNC);
3fe8: 84 e1 ldi r24, 0x14 ; 20
}
3fea: c7 cf rjmp .-114 ; 0x3f7a <putch>
::[count] "M" (UART_B_VALUE)
);
}
#endif
void getNch(uint8_t count) {
3fec: 1f 93 push r17
3fee: 18 2f mov r17, r24
00003ff0 <getNch>:
do getch(); while (--count);
3ff0: d3 df rcall .-90 ; 0x3f98 <getch>
3ff2: 11 50 subi r17, 0x01 ; 1
3ff4: e9 f7 brne .-6 ; 0x3ff0 <getNch>
verifySpace();
3ff6: f4 df rcall .-24 ; 0x3fe0 <verifySpace>
}
3ff8: 1f 91 pop r17
3ffa: 08 95 ret

View file

@ -0,0 +1,42 @@
:101D000085E08EBD84B714BE81FF27D18DE021D13F
:101D1000D49AD29A86E023EC3FEF91E03DBD2CBDF2
:101D20009BB9589BFECFCC9AA8958150B9F7CC248B
:101D3000C39485E0E82E0FE7D02E1EECF12EF0D0F4
:101D4000813421F481E014D183E024C0823411F481
:101D500084E103C0853419F485E00AD1CFC085350C
:101D6000A1F4DED0082F10E01093010200930002CE
:101D7000D7D090E0982F8827802B912B880F991F20
:101D80009093010280930002B8C0863529F484E064
:101D9000EFD080E0B6D0B2C0843609F06EC0D4D0A7
:101DA000E0910002F091010283E080935700E895F2
:101DB000C0E0D1E0B5D08993809102028150809338
:101DC00002028823B9F7CED007B600FCFDCF809180
:101DD000000290910102892B41F580910001209130
:101DE000010130E0322F222790E0282B392B30934D
:101DF00005022093040240910A0180910B0190E0BA
:101E0000982F882750E0842B952B9093070280937E
:101E100006022450304020930A01232F33272093B9
:101E20000B01D0920001F09201014091000250910B
:101E30000102A0E0B1E02C9130E011968C91119755
:101E400090E0982F8827822B932B1296FA010C0191
:101E5000C0925700E89511244E5F5F4FF1E0A03427
:101E6000BF0749F7E0910002F0910102E0925700AC
:101E7000E89507B600FCFDCF41C0843789F564D0F2
:101E800071D0E0910002F0910102309719F4209195
:101E9000040213C0E130F10519F4209105020DC0D0
:101EA000EA30F10519F42091060207C0EB30F10584
:101EB00019F42091070201C02491809100029091B1
:101EC000010201969093010280930002822F19D0A3
:101ED00080910202815080930202882391F60EC005
:101EE000853739F43FD08EE10CD083E90AD08CE0FD
:101EF00051CF813511F488E02CD034D080E101D06D
:101F00001ECF2AE030E08095089410F4DA9802C0E1
:101F1000DA9A000015D014D086952A95B1F7089565
:101F2000A89529E030E0CB99FECF0AD009D008D09F
:101F30008894CB9908942A9511F08795F7CF089546
:101F40009EE09A95F1F70895EBDFEADF80930202B5
:101F5000E7CF98E191BD81BD089580E0FADFE5E02B
:101F6000FF270994DDDF803209F0F7DF84E1C9CF74
:101F70001F93182FD5DF1150E9F7F4DF1F91089553
:0400000300001D00DC
:00000001FF

View file

@ -0,0 +1,604 @@
optiboot_luminet.elf: file format elf32-avr
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000280 00001d00 00001d00 00000054 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .debug_aranges 00000028 00000000 00000000 000002d4 2**0
CONTENTS, READONLY, DEBUGGING
2 .debug_pubnames 00000078 00000000 00000000 000002fc 2**0
CONTENTS, READONLY, DEBUGGING
3 .debug_info 00000289 00000000 00000000 00000374 2**0
CONTENTS, READONLY, DEBUGGING
4 .debug_abbrev 000001a1 00000000 00000000 000005fd 2**0
CONTENTS, READONLY, DEBUGGING
5 .debug_line 00000435 00000000 00000000 0000079e 2**0
CONTENTS, READONLY, DEBUGGING
6 .debug_frame 000000a0 00000000 00000000 00000bd4 2**2
CONTENTS, READONLY, DEBUGGING
7 .debug_str 00000144 00000000 00000000 00000c74 2**0
CONTENTS, READONLY, DEBUGGING
8 .debug_loc 00000194 00000000 00000000 00000db8 2**0
CONTENTS, READONLY, DEBUGGING
9 .debug_ranges 00000088 00000000 00000000 00000f4c 2**0
CONTENTS, READONLY, DEBUGGING
Disassembly of section .text:
00001d00 <main>:
#ifdef VIRTUAL_BOOT_PARTITION
#define rstVect (*(uint16_t*)(0x204))
#define wdtVect (*(uint16_t*)(0x206))
#endif
/* main program starts here */
int main(void) {
1d00: 85 e0 ldi r24, 0x05 ; 5
1d02: 8e bd out 0x2e, r24 ; 46
UCSR0C = _BV(UCSZ00) | _BV(UCSZ01);
UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
#endif
// Adaboot no-wait mod
ch = MCUSR;
1d04: 84 b7 in r24, 0x34 ; 52
MCUSR = 0;
1d06: 14 be out 0x34, r1 ; 52
if (!(ch & _BV(EXTRF))) appStart();
1d08: 81 ff sbrs r24, 1
1d0a: 27 d1 rcall .+590 ; 0x1f5a <appStart>
// Set up watchdog to trigger after 500ms
watchdogConfig(WATCHDOG_500MS);
1d0c: 8d e0 ldi r24, 0x0D ; 13
1d0e: 21 d1 rcall .+578 ; 0x1f52 <watchdogConfig>
/* Set LED pin as output */
LED_DDR |= _BV(LED);
1d10: d4 9a sbi 0x1a, 4 ; 26
#ifdef SOFT_UART
/* Set TX pin as output */
UART_DDR |= _BV(UART_TX_BIT);
1d12: d2 9a sbi 0x1a, 2 ; 26
1d14: 86 e0 ldi r24, 0x06 ; 6
}
#if LED_START_FLASHES > 0
void flash_led(uint8_t count) {
do {
TCNT1 = -(F_CPU/(1024*16));
1d16: 23 ec ldi r18, 0xC3 ; 195
1d18: 3f ef ldi r19, 0xFF ; 255
TIFR1 = _BV(TOV1);
1d1a: 91 e0 ldi r25, 0x01 ; 1
}
#if LED_START_FLASHES > 0
void flash_led(uint8_t count) {
do {
TCNT1 = -(F_CPU/(1024*16));
1d1c: 3d bd out 0x2d, r19 ; 45
1d1e: 2c bd out 0x2c, r18 ; 44
TIFR1 = _BV(TOV1);
1d20: 9b b9 out 0x0b, r25 ; 11
while(!(TIFR1 & _BV(TOV1)));
1d22: 58 9b sbis 0x0b, 0 ; 11
1d24: fe cf rjmp .-4 ; 0x1d22 <main+0x22>
LED_PIN |= _BV(LED);
1d26: cc 9a sbi 0x19, 4 ; 25
return getch();
}
// Watchdog functions. These are only safe with interrupts turned off.
void watchdogReset() {
__asm__ __volatile__ (
1d28: a8 95 wdr
TCNT1 = -(F_CPU/(1024*16));
TIFR1 = _BV(TOV1);
while(!(TIFR1 & _BV(TOV1)));
LED_PIN |= _BV(LED);
watchdogReset();
} while (--count);
1d2a: 81 50 subi r24, 0x01 ; 1
1d2c: b9 f7 brne .-18 ; 0x1d1c <main+0x1c>
/* get character from UART */
ch = getch();
if(ch == STK_GET_PARAMETER) {
// GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy
getNch(1);
1d2e: cc 24 eor r12, r12
1d30: c3 94 inc r12
boot_page_fill((uint16_t)(void*)addrPtr,a);
addrPtr += 2;
} while (--ch);
// Write from programming buffer
boot_page_write((uint16_t)(void*)address);
1d32: 85 e0 ldi r24, 0x05 ; 5
1d34: e8 2e mov r14, r24
vect -= 4; // Instruction is a relative jump (rjmp), so recalculate.
buff[10] = vect & 0xff;
buff[11] = vect >> 8;
// Add jump to bootloader at RESET vector
buff[0] = 0x7f;
1d36: 0f e7 ldi r16, 0x7F ; 127
1d38: d0 2e mov r13, r16
buff[1] = 0xce; // rjmp 0x1d00 instruction
1d3a: 1e ec ldi r17, 0xCE ; 206
1d3c: f1 2e mov r15, r17
#endif
/* Forever loop */
for (;;) {
/* get character from UART */
ch = getch();
1d3e: f0 d0 rcall .+480 ; 0x1f20 <getch>
if(ch == STK_GET_PARAMETER) {
1d40: 81 34 cpi r24, 0x41 ; 65
1d42: 21 f4 brne .+8 ; 0x1d4c <main+0x4c>
// GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy
getNch(1);
1d44: 81 e0 ldi r24, 0x01 ; 1
1d46: 14 d1 rcall .+552 ; 0x1f70 <verifySpace+0xc>
putch(0x03);
1d48: 83 e0 ldi r24, 0x03 ; 3
1d4a: 24 c0 rjmp .+72 ; 0x1d94 <main+0x94>
}
else if(ch == STK_SET_DEVICE) {
1d4c: 82 34 cpi r24, 0x42 ; 66
1d4e: 11 f4 brne .+4 ; 0x1d54 <main+0x54>
// SET DEVICE is ignored
getNch(20);
1d50: 84 e1 ldi r24, 0x14 ; 20
1d52: 03 c0 rjmp .+6 ; 0x1d5a <main+0x5a>
}
else if(ch == STK_SET_DEVICE_EXT) {
1d54: 85 34 cpi r24, 0x45 ; 69
1d56: 19 f4 brne .+6 ; 0x1d5e <main+0x5e>
// SET DEVICE EXT is ignored
getNch(5);
1d58: 85 e0 ldi r24, 0x05 ; 5
1d5a: 0a d1 rcall .+532 ; 0x1f70 <verifySpace+0xc>
1d5c: cf c0 rjmp .+414 ; 0x1efc <main+0x1fc>
}
else if(ch == STK_LOAD_ADDRESS) {
1d5e: 85 35 cpi r24, 0x55 ; 85
1d60: a1 f4 brne .+40 ; 0x1d8a <main+0x8a>
// LOAD ADDRESS
address = getch();
1d62: de d0 rcall .+444 ; 0x1f20 <getch>
1d64: 08 2f mov r16, r24
1d66: 10 e0 ldi r17, 0x00 ; 0
1d68: 10 93 01 02 sts 0x0201, r17
1d6c: 00 93 00 02 sts 0x0200, r16
address = (address & 0xff) | (getch() << 8);
1d70: d7 d0 rcall .+430 ; 0x1f20 <getch>
1d72: 90 e0 ldi r25, 0x00 ; 0
1d74: 98 2f mov r25, r24
1d76: 88 27 eor r24, r24
1d78: 80 2b or r24, r16
1d7a: 91 2b or r25, r17
address += address; // Convert from word address to byte address
1d7c: 88 0f add r24, r24
1d7e: 99 1f adc r25, r25
1d80: 90 93 01 02 sts 0x0201, r25
1d84: 80 93 00 02 sts 0x0200, r24
1d88: b8 c0 rjmp .+368 ; 0x1efa <main+0x1fa>
verifySpace();
}
else if(ch == STK_UNIVERSAL) {
1d8a: 86 35 cpi r24, 0x56 ; 86
1d8c: 29 f4 brne .+10 ; 0x1d98 <main+0x98>
// UNIVERSAL command is ignored
getNch(4);
1d8e: 84 e0 ldi r24, 0x04 ; 4
1d90: ef d0 rcall .+478 ; 0x1f70 <verifySpace+0xc>
putch(0x00);
1d92: 80 e0 ldi r24, 0x00 ; 0
1d94: b6 d0 rcall .+364 ; 0x1f02 <putch>
1d96: b2 c0 rjmp .+356 ; 0x1efc <main+0x1fc>
}
/* Write memory, length is big endian and is in bytes */
else if(ch == STK_PROG_PAGE) {
1d98: 84 36 cpi r24, 0x64 ; 100
1d9a: 09 f0 breq .+2 ; 0x1d9e <main+0x9e>
1d9c: 6e c0 rjmp .+220 ; 0x1e7a <main+0x17a>
// PROGRAM PAGE - we support flash programming only, not EEPROM
uint8_t *bufPtr;
uint16_t addrPtr;
getLen();
1d9e: d4 d0 rcall .+424 ; 0x1f48 <getLen>
// Immediately start page erase - this will 4.5ms
boot_page_erase((uint16_t)(void*)address);
1da0: e0 91 00 02 lds r30, 0x0200
1da4: f0 91 01 02 lds r31, 0x0201
1da8: 83 e0 ldi r24, 0x03 ; 3
1daa: 80 93 57 00 sts 0x0057, r24
1dae: e8 95 spm
1db0: c0 e0 ldi r28, 0x00 ; 0
1db2: d1 e0 ldi r29, 0x01 ; 1
// While that is going on, read in page contents
bufPtr = buff;
do *bufPtr++ = getch();
1db4: b5 d0 rcall .+362 ; 0x1f20 <getch>
1db6: 89 93 st Y+, r24
while (--length);
1db8: 80 91 02 02 lds r24, 0x0202
1dbc: 81 50 subi r24, 0x01 ; 1
1dbe: 80 93 02 02 sts 0x0202, r24
1dc2: 88 23 and r24, r24
1dc4: b9 f7 brne .-18 ; 0x1db4 <main+0xb4>
// Read command terminator, start reply
verifySpace();
1dc6: ce d0 rcall .+412 ; 0x1f64 <verifySpace>
// If only a partial page is to be programmed, the erase might not be complete.
// So check that here
boot_spm_busy_wait();
1dc8: 07 b6 in r0, 0x37 ; 55
1dca: 00 fc sbrc r0, 0
1dcc: fd cf rjmp .-6 ; 0x1dc8 <main+0xc8>
#ifdef VIRTUAL_BOOT_PARTITION
if ((uint16_t)(void*)address == 0) {
1dce: 80 91 00 02 lds r24, 0x0200
1dd2: 90 91 01 02 lds r25, 0x0201
1dd6: 89 2b or r24, r25
1dd8: 41 f5 brne .+80 ; 0x1e2a <main+0x12a>
// This is the reset vector page. We need to live-patch the code so the
// bootloader runs.
//
// Move RESET vector to WDT vector
uint16_t vect = buff[0] | (buff[1]<<8);
1dda: 80 91 00 01 lds r24, 0x0100
1dde: 20 91 01 01 lds r18, 0x0101
1de2: 30 e0 ldi r19, 0x00 ; 0
1de4: 32 2f mov r19, r18
1de6: 22 27 eor r18, r18
1de8: 90 e0 ldi r25, 0x00 ; 0
1dea: 28 2b or r18, r24
1dec: 39 2b or r19, r25
rstVect = vect;
1dee: 30 93 05 02 sts 0x0205, r19
1df2: 20 93 04 02 sts 0x0204, r18
wdtVect = buff[10] | (buff[11]<<8);
1df6: 40 91 0a 01 lds r20, 0x010A
1dfa: 80 91 0b 01 lds r24, 0x010B
1dfe: 90 e0 ldi r25, 0x00 ; 0
1e00: 98 2f mov r25, r24
1e02: 88 27 eor r24, r24
1e04: 50 e0 ldi r21, 0x00 ; 0
1e06: 84 2b or r24, r20
1e08: 95 2b or r25, r21
1e0a: 90 93 07 02 sts 0x0207, r25
1e0e: 80 93 06 02 sts 0x0206, r24
vect -= 4; // Instruction is a relative jump (rjmp), so recalculate.
1e12: 24 50 subi r18, 0x04 ; 4
1e14: 30 40 sbci r19, 0x00 ; 0
buff[10] = vect & 0xff;
1e16: 20 93 0a 01 sts 0x010A, r18
buff[11] = vect >> 8;
1e1a: 23 2f mov r18, r19
1e1c: 33 27 eor r19, r19
1e1e: 20 93 0b 01 sts 0x010B, r18
// Add jump to bootloader at RESET vector
buff[0] = 0x7f;
1e22: d0 92 00 01 sts 0x0100, r13
buff[1] = 0xce; // rjmp 0x1d00 instruction
1e26: f0 92 01 01 sts 0x0101, r15
}
#endif
// Copy buffer into programming buffer
bufPtr = buff;
addrPtr = (uint16_t)(void*)address;
1e2a: 40 91 00 02 lds r20, 0x0200
1e2e: 50 91 01 02 lds r21, 0x0201
1e32: a0 e0 ldi r26, 0x00 ; 0
1e34: b1 e0 ldi r27, 0x01 ; 1
ch = SPM_PAGESIZE / 2;
do {
uint16_t a;
a = *bufPtr++;
1e36: 2c 91 ld r18, X
1e38: 30 e0 ldi r19, 0x00 ; 0
a |= (*bufPtr++) << 8;
1e3a: 11 96 adiw r26, 0x01 ; 1
1e3c: 8c 91 ld r24, X
1e3e: 11 97 sbiw r26, 0x01 ; 1
1e40: 90 e0 ldi r25, 0x00 ; 0
1e42: 98 2f mov r25, r24
1e44: 88 27 eor r24, r24
1e46: 82 2b or r24, r18
1e48: 93 2b or r25, r19
#ifdef VIRTUAL_BOOT_PARTITION
#define rstVect (*(uint16_t*)(0x204))
#define wdtVect (*(uint16_t*)(0x206))
#endif
/* main program starts here */
int main(void) {
1e4a: 12 96 adiw r26, 0x02 ; 2
ch = SPM_PAGESIZE / 2;
do {
uint16_t a;
a = *bufPtr++;
a |= (*bufPtr++) << 8;
boot_page_fill((uint16_t)(void*)addrPtr,a);
1e4c: fa 01 movw r30, r20
1e4e: 0c 01 movw r0, r24
1e50: c0 92 57 00 sts 0x0057, r12
1e54: e8 95 spm
1e56: 11 24 eor r1, r1
addrPtr += 2;
1e58: 4e 5f subi r20, 0xFE ; 254
1e5a: 5f 4f sbci r21, 0xFF ; 255
} while (--ch);
1e5c: f1 e0 ldi r31, 0x01 ; 1
1e5e: a0 34 cpi r26, 0x40 ; 64
1e60: bf 07 cpc r27, r31
1e62: 49 f7 brne .-46 ; 0x1e36 <main+0x136>
// Write from programming buffer
boot_page_write((uint16_t)(void*)address);
1e64: e0 91 00 02 lds r30, 0x0200
1e68: f0 91 01 02 lds r31, 0x0201
1e6c: e0 92 57 00 sts 0x0057, r14
1e70: e8 95 spm
boot_spm_busy_wait();
1e72: 07 b6 in r0, 0x37 ; 55
1e74: 00 fc sbrc r0, 0
1e76: fd cf rjmp .-6 ; 0x1e72 <main+0x172>
1e78: 41 c0 rjmp .+130 ; 0x1efc <main+0x1fc>
boot_rww_enable();
#endif
}
/* Read memory block mode, length is big endian. */
else if(ch == STK_READ_PAGE) {
1e7a: 84 37 cpi r24, 0x74 ; 116
1e7c: 89 f5 brne .+98 ; 0x1ee0 <main+0x1e0>
// READ PAGE - we only read flash
getLen();
1e7e: 64 d0 rcall .+200 ; 0x1f48 <getLen>
verifySpace();
1e80: 71 d0 rcall .+226 ; 0x1f64 <verifySpace>
#ifdef VIRTUAL_BOOT_PARTITION
do {
// Undo vector patch in bottom page so verify passes
if (address == 0) ch=rstVect & 0xff;
1e82: e0 91 00 02 lds r30, 0x0200
1e86: f0 91 01 02 lds r31, 0x0201
1e8a: 30 97 sbiw r30, 0x00 ; 0
1e8c: 19 f4 brne .+6 ; 0x1e94 <main+0x194>
1e8e: 20 91 04 02 lds r18, 0x0204
1e92: 13 c0 rjmp .+38 ; 0x1eba <main+0x1ba>
else if (address == 1) ch=rstVect >> 8;
1e94: e1 30 cpi r30, 0x01 ; 1
1e96: f1 05 cpc r31, r1
1e98: 19 f4 brne .+6 ; 0x1ea0 <main+0x1a0>
1e9a: 20 91 05 02 lds r18, 0x0205
1e9e: 0d c0 rjmp .+26 ; 0x1eba <main+0x1ba>
else if (address == 10) ch=wdtVect & 0xff;
1ea0: ea 30 cpi r30, 0x0A ; 10
1ea2: f1 05 cpc r31, r1
1ea4: 19 f4 brne .+6 ; 0x1eac <main+0x1ac>
1ea6: 20 91 06 02 lds r18, 0x0206
1eaa: 07 c0 rjmp .+14 ; 0x1eba <main+0x1ba>
else if (address == 11) ch=wdtVect >> 8;
1eac: eb 30 cpi r30, 0x0B ; 11
1eae: f1 05 cpc r31, r1
1eb0: 19 f4 brne .+6 ; 0x1eb8 <main+0x1b8>
1eb2: 20 91 07 02 lds r18, 0x0207
1eb6: 01 c0 rjmp .+2 ; 0x1eba <main+0x1ba>
else ch = pgm_read_byte_near(address);
1eb8: 24 91 lpm r18, Z+
address++;
1eba: 80 91 00 02 lds r24, 0x0200
1ebe: 90 91 01 02 lds r25, 0x0201
1ec2: 01 96 adiw r24, 0x01 ; 1
1ec4: 90 93 01 02 sts 0x0201, r25
1ec8: 80 93 00 02 sts 0x0200, r24
putch(ch);
1ecc: 82 2f mov r24, r18
1ece: 19 d0 rcall .+50 ; 0x1f02 <putch>
} while (--length);
1ed0: 80 91 02 02 lds r24, 0x0202
1ed4: 81 50 subi r24, 0x01 ; 1
1ed6: 80 93 02 02 sts 0x0202, r24
1eda: 88 23 and r24, r24
1edc: 91 f6 brne .-92 ; 0x1e82 <main+0x182>
1ede: 0e c0 rjmp .+28 ; 0x1efc <main+0x1fc>
while (--length);
#endif
}
/* Get device signature bytes */
else if(ch == STK_READ_SIGN) {
1ee0: 85 37 cpi r24, 0x75 ; 117
1ee2: 39 f4 brne .+14 ; 0x1ef2 <main+0x1f2>
// READ SIGN - return what Avrdude wants to hear
verifySpace();
1ee4: 3f d0 rcall .+126 ; 0x1f64 <verifySpace>
putch(SIGNATURE_0);
1ee6: 8e e1 ldi r24, 0x1E ; 30
1ee8: 0c d0 rcall .+24 ; 0x1f02 <putch>
putch(SIGNATURE_1);
1eea: 83 e9 ldi r24, 0x93 ; 147
1eec: 0a d0 rcall .+20 ; 0x1f02 <putch>
putch(SIGNATURE_2);
1eee: 8c e0 ldi r24, 0x0C ; 12
1ef0: 51 cf rjmp .-350 ; 0x1d94 <main+0x94>
}
else if (ch == 'Q') {
1ef2: 81 35 cpi r24, 0x51 ; 81
1ef4: 11 f4 brne .+4 ; 0x1efa <main+0x1fa>
// Adaboot no-wait mod
watchdogConfig(WATCHDOG_16MS);
1ef6: 88 e0 ldi r24, 0x08 ; 8
1ef8: 2c d0 rcall .+88 ; 0x1f52 <watchdogConfig>
verifySpace();
}
else {
// This covers the response to commands like STK_ENTER_PROGMODE
verifySpace();
1efa: 34 d0 rcall .+104 ; 0x1f64 <verifySpace>
}
putch(STK_OK);
1efc: 80 e1 ldi r24, 0x10 ; 16
1efe: 01 d0 rcall .+2 ; 0x1f02 <putch>
1f00: 1e cf rjmp .-452 ; 0x1d3e <main+0x3e>
00001f02 <putch>:
void putch(char ch) {
#ifndef SOFT_UART
while (!(UCSR0A & _BV(UDRE0)));
UDR0 = ch;
#else
__asm__ __volatile__ (
1f02: 2a e0 ldi r18, 0x0A ; 10
1f04: 30 e0 ldi r19, 0x00 ; 0
1f06: 80 95 com r24
1f08: 08 94 sec
1f0a: 10 f4 brcc .+4 ; 0x1f10 <putch+0xe>
1f0c: da 98 cbi 0x1b, 2 ; 27
1f0e: 02 c0 rjmp .+4 ; 0x1f14 <putch+0x12>
1f10: da 9a sbi 0x1b, 2 ; 27
1f12: 00 00 nop
1f14: 15 d0 rcall .+42 ; 0x1f40 <uartDelay>
1f16: 14 d0 rcall .+40 ; 0x1f40 <uartDelay>
1f18: 86 95 lsr r24
1f1a: 2a 95 dec r18
1f1c: b1 f7 brne .-20 ; 0x1f0a <putch+0x8>
[uartBit] "I" (UART_TX_BIT)
:
"r25"
);
#endif
}
1f1e: 08 95 ret
00001f20 <getch>:
return getch();
}
// Watchdog functions. These are only safe with interrupts turned off.
void watchdogReset() {
__asm__ __volatile__ (
1f20: a8 95 wdr
#ifdef LED_DATA_FLASH
LED_PIN |= _BV(LED);
#endif
return ch;
}
1f22: 29 e0 ldi r18, 0x09 ; 9
1f24: 30 e0 ldi r19, 0x00 ; 0
1f26: cb 99 sbic 0x19, 3 ; 25
1f28: fe cf rjmp .-4 ; 0x1f26 <getch+0x6>
1f2a: 0a d0 rcall .+20 ; 0x1f40 <uartDelay>
1f2c: 09 d0 rcall .+18 ; 0x1f40 <uartDelay>
1f2e: 08 d0 rcall .+16 ; 0x1f40 <uartDelay>
1f30: 88 94 clc
1f32: cb 99 sbic 0x19, 3 ; 25
1f34: 08 94 sec
1f36: 2a 95 dec r18
1f38: 11 f0 breq .+4 ; 0x1f3e <getch+0x1e>
1f3a: 87 95 ror r24
1f3c: f7 cf rjmp .-18 ; 0x1f2c <getch+0xc>
1f3e: 08 95 ret
00001f40 <uartDelay>:
#if UART_B_VALUE > 255
#error Baud rate too slow for soft UART
#endif
void uartDelay() {
__asm__ __volatile__ (
1f40: 9e e0 ldi r25, 0x0E ; 14
1f42: 9a 95 dec r25
1f44: f1 f7 brne .-4 ; 0x1f42 <uartDelay+0x2>
1f46: 08 95 ret
00001f48 <getLen>:
} while (--count);
}
#endif
uint8_t getLen() {
getch();
1f48: eb df rcall .-42 ; 0x1f20 <getch>
length = getch();
1f4a: ea df rcall .-44 ; 0x1f20 <getch>
1f4c: 80 93 02 02 sts 0x0202, r24
return getch();
}
1f50: e7 cf rjmp .-50 ; 0x1f20 <getch>
00001f52 <watchdogConfig>:
"wdr\n"
);
}
void watchdogConfig(uint8_t x) {
WDTCSR = _BV(WDCE) | _BV(WDE);
1f52: 98 e1 ldi r25, 0x18 ; 24
1f54: 91 bd out 0x21, r25 ; 33
WDTCSR = x;
1f56: 81 bd out 0x21, r24 ; 33
}
1f58: 08 95 ret
00001f5a <appStart>:
void appStart() {
watchdogConfig(WATCHDOG_OFF);
1f5a: 80 e0 ldi r24, 0x00 ; 0
1f5c: fa df rcall .-12 ; 0x1f52 <watchdogConfig>
__asm__ __volatile__ (
1f5e: e5 e0 ldi r30, 0x05 ; 5
1f60: ff 27 eor r31, r31
1f62: 09 94 ijmp
00001f64 <verifySpace>:
do getch(); while (--count);
verifySpace();
}
void verifySpace() {
if (getch() != CRC_EOP) appStart();
1f64: dd df rcall .-70 ; 0x1f20 <getch>
1f66: 80 32 cpi r24, 0x20 ; 32
1f68: 09 f0 breq .+2 ; 0x1f6c <verifySpace+0x8>
1f6a: f7 df rcall .-18 ; 0x1f5a <appStart>
putch(STK_INSYNC);
1f6c: 84 e1 ldi r24, 0x14 ; 20
}
1f6e: c9 cf rjmp .-110 ; 0x1f02 <putch>
::[count] "M" (UART_B_VALUE)
);
}
#endif
void getNch(uint8_t count) {
1f70: 1f 93 push r17
1f72: 18 2f mov r17, r24
00001f74 <getNch>:
do getch(); while (--count);
1f74: d5 df rcall .-86 ; 0x1f20 <getch>
1f76: 11 50 subi r17, 0x01 ; 1
1f78: e9 f7 brne .-6 ; 0x1f74 <getNch>
verifySpace();
1f7a: f4 df rcall .-24 ; 0x1f64 <verifySpace>
}
1f7c: 1f 91 pop r17
1f7e: 08 95 ret

View file

@ -0,0 +1,33 @@
:103E000085E08093810082E08093C00088E1809308
:103E1000C10086E08093C20080E18093C40084B733
:103E200014BE81FFD0D08DE0C8D0259A86E020E373
:103E30003CEF91E0309385002093840096BBB09BCB
:103E4000FECF1D9AA8958150A9F7DD24D394A5E053
:103E5000EA2EF1E1FF2EA4D0813421F481E0BED01E
:103E600083E024C0823411F484E103C0853419F462
:103E700085E0B4D08AC08535A1F492D0082F10E037
:103E800010930102009300028BD090E0982F8827B6
:103E9000802B912B880F991F909301028093000231
:103EA00073C0863529F484E099D080E071D06DC06C
:103EB000843609F043C07CD0E0910002F091010209
:103EC00083E080935700E895C0E0D1E069D0899302
:103ED000809102028150809302028823B9F778D042
:103EE00007B600FCFDCF4091000250910102A0E016
:103EF000B1E02C9130E011968C91119790E0982FC1
:103F00008827822B932B1296FA010C01D09257002E
:103F1000E89511244E5F5F4FF1E0A038BF0749F7E5
:103F2000E0910002F0910102E0925700E89507B697
:103F300000FCFDCFF0925700E89527C08437B9F414
:103F400037D046D0E0910002F09101023196F09313
:103F50000102E09300023197E4918E2F19D08091F5
:103F60000202815080930202882361F70EC08537D8
:103F700039F42ED08EE10CD084E90AD086E096CFB9
:103F8000813511F488E019D023D080E101D063CFCE
:103F9000982F8091C00085FFFCCF9093C6000895B4
:103FA000A8958091C00087FFFCCF8091C60008953E
:103FB000F7DFF6DF80930202F3CFE0E6F0E098E16E
:103FC00090838083089580E0F8DFEE27FF2709942F
:103FD000E7DF803209F0F7DF84E1DACF1F93182F93
:0C3FE000DFDF1150E9F7F4DF1F910895B6
:0400000300003E00BB
:00000001FF

View file

@ -0,0 +1,520 @@
optiboot_pro_16MHz.elf: file format elf32-avr
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 000001ec 00003e00 00003e00 00000054 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .debug_aranges 00000028 00000000 00000000 00000240 2**0
CONTENTS, READONLY, DEBUGGING
2 .debug_pubnames 0000006a 00000000 00000000 00000268 2**0
CONTENTS, READONLY, DEBUGGING
3 .debug_info 00000269 00000000 00000000 000002d2 2**0
CONTENTS, READONLY, DEBUGGING
4 .debug_abbrev 00000196 00000000 00000000 0000053b 2**0
CONTENTS, READONLY, DEBUGGING
5 .debug_line 000003d3 00000000 00000000 000006d1 2**0
CONTENTS, READONLY, DEBUGGING
6 .debug_frame 00000090 00000000 00000000 00000aa4 2**2
CONTENTS, READONLY, DEBUGGING
7 .debug_str 00000135 00000000 00000000 00000b34 2**0
CONTENTS, READONLY, DEBUGGING
8 .debug_loc 000001d1 00000000 00000000 00000c69 2**0
CONTENTS, READONLY, DEBUGGING
9 .debug_ranges 00000068 00000000 00000000 00000e3a 2**0
CONTENTS, READONLY, DEBUGGING
Disassembly of section .text:
00003e00 <main>:
#ifdef VIRTUAL_BOOT_PARTITION
#define rstVect (*(uint16_t*)(0x204))
#define wdtVect (*(uint16_t*)(0x206))
#endif
/* main program starts here */
int main(void) {
3e00: 85 e0 ldi r24, 0x05 ; 5
3e02: 80 93 81 00 sts 0x0081, r24
#if LED_START_FLASHES > 0
// Set up Timer 1 for timeout counter
TCCR1B = _BV(CS12) | _BV(CS10); // div 1024
#endif
#ifndef SOFT_UART
UCSR0A = _BV(U2X0); //Double speed mode USART0
3e06: 82 e0 ldi r24, 0x02 ; 2
3e08: 80 93 c0 00 sts 0x00C0, r24
UCSR0B = _BV(RXEN0) | _BV(TXEN0);
3e0c: 88 e1 ldi r24, 0x18 ; 24
3e0e: 80 93 c1 00 sts 0x00C1, r24
UCSR0C = _BV(UCSZ00) | _BV(UCSZ01);
3e12: 86 e0 ldi r24, 0x06 ; 6
3e14: 80 93 c2 00 sts 0x00C2, r24
UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
3e18: 80 e1 ldi r24, 0x10 ; 16
3e1a: 80 93 c4 00 sts 0x00C4, r24
#endif
// Adaboot no-wait mod
ch = MCUSR;
3e1e: 84 b7 in r24, 0x34 ; 52
MCUSR = 0;
3e20: 14 be out 0x34, r1 ; 52
if (!(ch & _BV(EXTRF))) appStart();
3e22: 81 ff sbrs r24, 1
3e24: d0 d0 rcall .+416 ; 0x3fc6 <appStart>
// Set up watchdog to trigger after 500ms
watchdogConfig(WATCHDOG_500MS);
3e26: 8d e0 ldi r24, 0x0D ; 13
3e28: c8 d0 rcall .+400 ; 0x3fba <watchdogConfig>
/* Set LED pin as output */
LED_DDR |= _BV(LED);
3e2a: 25 9a sbi 0x04, 5 ; 4
3e2c: 86 e0 ldi r24, 0x06 ; 6
}
#if LED_START_FLASHES > 0
void flash_led(uint8_t count) {
do {
TCNT1 = -(F_CPU/(1024*16));
3e2e: 20 e3 ldi r18, 0x30 ; 48
3e30: 3c ef ldi r19, 0xFC ; 252
TIFR1 = _BV(TOV1);
3e32: 91 e0 ldi r25, 0x01 ; 1
}
#if LED_START_FLASHES > 0
void flash_led(uint8_t count) {
do {
TCNT1 = -(F_CPU/(1024*16));
3e34: 30 93 85 00 sts 0x0085, r19
3e38: 20 93 84 00 sts 0x0084, r18
TIFR1 = _BV(TOV1);
3e3c: 96 bb out 0x16, r25 ; 22
while(!(TIFR1 & _BV(TOV1)));
3e3e: b0 9b sbis 0x16, 0 ; 22
3e40: fe cf rjmp .-4 ; 0x3e3e <main+0x3e>
LED_PIN |= _BV(LED);
3e42: 1d 9a sbi 0x03, 5 ; 3
return getch();
}
// Watchdog functions. These are only safe with interrupts turned off.
void watchdogReset() {
__asm__ __volatile__ (
3e44: a8 95 wdr
TCNT1 = -(F_CPU/(1024*16));
TIFR1 = _BV(TOV1);
while(!(TIFR1 & _BV(TOV1)));
LED_PIN |= _BV(LED);
watchdogReset();
} while (--count);
3e46: 81 50 subi r24, 0x01 ; 1
3e48: a9 f7 brne .-22 ; 0x3e34 <main+0x34>
/* get character from UART */
ch = getch();
if(ch == STK_GET_PARAMETER) {
// GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy
getNch(1);
3e4a: dd 24 eor r13, r13
3e4c: d3 94 inc r13
boot_page_fill((uint16_t)(void*)addrPtr,a);
addrPtr += 2;
} while (--ch);
// Write from programming buffer
boot_page_write((uint16_t)(void*)address);
3e4e: a5 e0 ldi r26, 0x05 ; 5
3e50: ea 2e mov r14, r26
boot_spm_busy_wait();
#if defined(RWWSRE)
// Reenable read access to flash
boot_rww_enable();
3e52: f1 e1 ldi r31, 0x11 ; 17
3e54: ff 2e mov r15, r31
#endif
/* Forever loop */
for (;;) {
/* get character from UART */
ch = getch();
3e56: a4 d0 rcall .+328 ; 0x3fa0 <getch>
if(ch == STK_GET_PARAMETER) {
3e58: 81 34 cpi r24, 0x41 ; 65
3e5a: 21 f4 brne .+8 ; 0x3e64 <main+0x64>
// GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy
getNch(1);
3e5c: 81 e0 ldi r24, 0x01 ; 1
3e5e: be d0 rcall .+380 ; 0x3fdc <verifySpace+0xc>
putch(0x03);
3e60: 83 e0 ldi r24, 0x03 ; 3
3e62: 24 c0 rjmp .+72 ; 0x3eac <main+0xac>
}
else if(ch == STK_SET_DEVICE) {
3e64: 82 34 cpi r24, 0x42 ; 66
3e66: 11 f4 brne .+4 ; 0x3e6c <main+0x6c>
// SET DEVICE is ignored
getNch(20);
3e68: 84 e1 ldi r24, 0x14 ; 20
3e6a: 03 c0 rjmp .+6 ; 0x3e72 <main+0x72>
}
else if(ch == STK_SET_DEVICE_EXT) {
3e6c: 85 34 cpi r24, 0x45 ; 69
3e6e: 19 f4 brne .+6 ; 0x3e76 <main+0x76>
// SET DEVICE EXT is ignored
getNch(5);
3e70: 85 e0 ldi r24, 0x05 ; 5
3e72: b4 d0 rcall .+360 ; 0x3fdc <verifySpace+0xc>
3e74: 8a c0 rjmp .+276 ; 0x3f8a <main+0x18a>
}
else if(ch == STK_LOAD_ADDRESS) {
3e76: 85 35 cpi r24, 0x55 ; 85
3e78: a1 f4 brne .+40 ; 0x3ea2 <main+0xa2>
// LOAD ADDRESS
address = getch();
3e7a: 92 d0 rcall .+292 ; 0x3fa0 <getch>
3e7c: 08 2f mov r16, r24
3e7e: 10 e0 ldi r17, 0x00 ; 0
3e80: 10 93 01 02 sts 0x0201, r17
3e84: 00 93 00 02 sts 0x0200, r16
address = (address & 0xff) | (getch() << 8);
3e88: 8b d0 rcall .+278 ; 0x3fa0 <getch>
3e8a: 90 e0 ldi r25, 0x00 ; 0
3e8c: 98 2f mov r25, r24
3e8e: 88 27 eor r24, r24
3e90: 80 2b or r24, r16
3e92: 91 2b or r25, r17
address += address; // Convert from word address to byte address
3e94: 88 0f add r24, r24
3e96: 99 1f adc r25, r25
3e98: 90 93 01 02 sts 0x0201, r25
3e9c: 80 93 00 02 sts 0x0200, r24
3ea0: 73 c0 rjmp .+230 ; 0x3f88 <main+0x188>
verifySpace();
}
else if(ch == STK_UNIVERSAL) {
3ea2: 86 35 cpi r24, 0x56 ; 86
3ea4: 29 f4 brne .+10 ; 0x3eb0 <main+0xb0>
// UNIVERSAL command is ignored
getNch(4);
3ea6: 84 e0 ldi r24, 0x04 ; 4
3ea8: 99 d0 rcall .+306 ; 0x3fdc <verifySpace+0xc>
putch(0x00);
3eaa: 80 e0 ldi r24, 0x00 ; 0
3eac: 71 d0 rcall .+226 ; 0x3f90 <putch>
3eae: 6d c0 rjmp .+218 ; 0x3f8a <main+0x18a>
}
/* Write memory, length is big endian and is in bytes */
else if(ch == STK_PROG_PAGE) {
3eb0: 84 36 cpi r24, 0x64 ; 100
3eb2: 09 f0 breq .+2 ; 0x3eb6 <main+0xb6>
3eb4: 43 c0 rjmp .+134 ; 0x3f3c <main+0x13c>
// PROGRAM PAGE - we support flash programming only, not EEPROM
uint8_t *bufPtr;
uint16_t addrPtr;
getLen();
3eb6: 7c d0 rcall .+248 ; 0x3fb0 <getLen>
// Immediately start page erase - this will 4.5ms
boot_page_erase((uint16_t)(void*)address);
3eb8: e0 91 00 02 lds r30, 0x0200
3ebc: f0 91 01 02 lds r31, 0x0201
3ec0: 83 e0 ldi r24, 0x03 ; 3
3ec2: 80 93 57 00 sts 0x0057, r24
3ec6: e8 95 spm
3ec8: c0 e0 ldi r28, 0x00 ; 0
3eca: d1 e0 ldi r29, 0x01 ; 1
// While that is going on, read in page contents
bufPtr = buff;
do *bufPtr++ = getch();
3ecc: 69 d0 rcall .+210 ; 0x3fa0 <getch>
3ece: 89 93 st Y+, r24
while (--length);
3ed0: 80 91 02 02 lds r24, 0x0202
3ed4: 81 50 subi r24, 0x01 ; 1
3ed6: 80 93 02 02 sts 0x0202, r24
3eda: 88 23 and r24, r24
3edc: b9 f7 brne .-18 ; 0x3ecc <main+0xcc>
// Read command terminator, start reply
verifySpace();
3ede: 78 d0 rcall .+240 ; 0x3fd0 <verifySpace>
// If only a partial page is to be programmed, the erase might not be complete.
// So check that here
boot_spm_busy_wait();
3ee0: 07 b6 in r0, 0x37 ; 55
3ee2: 00 fc sbrc r0, 0
3ee4: fd cf rjmp .-6 ; 0x3ee0 <main+0xe0>
}
#endif
// Copy buffer into programming buffer
bufPtr = buff;
addrPtr = (uint16_t)(void*)address;
3ee6: 40 91 00 02 lds r20, 0x0200
3eea: 50 91 01 02 lds r21, 0x0201
3eee: a0 e0 ldi r26, 0x00 ; 0
3ef0: b1 e0 ldi r27, 0x01 ; 1
ch = SPM_PAGESIZE / 2;
do {
uint16_t a;
a = *bufPtr++;
3ef2: 2c 91 ld r18, X
3ef4: 30 e0 ldi r19, 0x00 ; 0
a |= (*bufPtr++) << 8;
3ef6: 11 96 adiw r26, 0x01 ; 1
3ef8: 8c 91 ld r24, X
3efa: 11 97 sbiw r26, 0x01 ; 1
3efc: 90 e0 ldi r25, 0x00 ; 0
3efe: 98 2f mov r25, r24
3f00: 88 27 eor r24, r24
3f02: 82 2b or r24, r18
3f04: 93 2b or r25, r19
#ifdef VIRTUAL_BOOT_PARTITION
#define rstVect (*(uint16_t*)(0x204))
#define wdtVect (*(uint16_t*)(0x206))
#endif
/* main program starts here */
int main(void) {
3f06: 12 96 adiw r26, 0x02 ; 2
ch = SPM_PAGESIZE / 2;
do {
uint16_t a;
a = *bufPtr++;
a |= (*bufPtr++) << 8;
boot_page_fill((uint16_t)(void*)addrPtr,a);
3f08: fa 01 movw r30, r20
3f0a: 0c 01 movw r0, r24
3f0c: d0 92 57 00 sts 0x0057, r13
3f10: e8 95 spm
3f12: 11 24 eor r1, r1
addrPtr += 2;
3f14: 4e 5f subi r20, 0xFE ; 254
3f16: 5f 4f sbci r21, 0xFF ; 255
} while (--ch);
3f18: f1 e0 ldi r31, 0x01 ; 1
3f1a: a0 38 cpi r26, 0x80 ; 128
3f1c: bf 07 cpc r27, r31
3f1e: 49 f7 brne .-46 ; 0x3ef2 <main+0xf2>
// Write from programming buffer
boot_page_write((uint16_t)(void*)address);
3f20: e0 91 00 02 lds r30, 0x0200
3f24: f0 91 01 02 lds r31, 0x0201
3f28: e0 92 57 00 sts 0x0057, r14
3f2c: e8 95 spm
boot_spm_busy_wait();
3f2e: 07 b6 in r0, 0x37 ; 55
3f30: 00 fc sbrc r0, 0
3f32: fd cf rjmp .-6 ; 0x3f2e <main+0x12e>
#if defined(RWWSRE)
// Reenable read access to flash
boot_rww_enable();
3f34: f0 92 57 00 sts 0x0057, r15
3f38: e8 95 spm
3f3a: 27 c0 rjmp .+78 ; 0x3f8a <main+0x18a>
#endif
}
/* Read memory block mode, length is big endian. */
else if(ch == STK_READ_PAGE) {
3f3c: 84 37 cpi r24, 0x74 ; 116
3f3e: b9 f4 brne .+46 ; 0x3f6e <main+0x16e>
// READ PAGE - we only read flash
getLen();
3f40: 37 d0 rcall .+110 ; 0x3fb0 <getLen>
verifySpace();
3f42: 46 d0 rcall .+140 ; 0x3fd0 <verifySpace>
else ch = pgm_read_byte_near(address);
address++;
putch(ch);
} while (--length);
#else
do putch(pgm_read_byte_near(address++));
3f44: e0 91 00 02 lds r30, 0x0200
3f48: f0 91 01 02 lds r31, 0x0201
3f4c: 31 96 adiw r30, 0x01 ; 1
3f4e: f0 93 01 02 sts 0x0201, r31
3f52: e0 93 00 02 sts 0x0200, r30
3f56: 31 97 sbiw r30, 0x01 ; 1
3f58: e4 91 lpm r30, Z+
3f5a: 8e 2f mov r24, r30
3f5c: 19 d0 rcall .+50 ; 0x3f90 <putch>
while (--length);
3f5e: 80 91 02 02 lds r24, 0x0202
3f62: 81 50 subi r24, 0x01 ; 1
3f64: 80 93 02 02 sts 0x0202, r24
3f68: 88 23 and r24, r24
3f6a: 61 f7 brne .-40 ; 0x3f44 <main+0x144>
3f6c: 0e c0 rjmp .+28 ; 0x3f8a <main+0x18a>
#endif
}
/* Get device signature bytes */
else if(ch == STK_READ_SIGN) {
3f6e: 85 37 cpi r24, 0x75 ; 117
3f70: 39 f4 brne .+14 ; 0x3f80 <main+0x180>
// READ SIGN - return what Avrdude wants to hear
verifySpace();
3f72: 2e d0 rcall .+92 ; 0x3fd0 <verifySpace>
putch(SIGNATURE_0);
3f74: 8e e1 ldi r24, 0x1E ; 30
3f76: 0c d0 rcall .+24 ; 0x3f90 <putch>
putch(SIGNATURE_1);
3f78: 84 e9 ldi r24, 0x94 ; 148
3f7a: 0a d0 rcall .+20 ; 0x3f90 <putch>
putch(SIGNATURE_2);
3f7c: 86 e0 ldi r24, 0x06 ; 6
3f7e: 96 cf rjmp .-212 ; 0x3eac <main+0xac>
}
else if (ch == 'Q') {
3f80: 81 35 cpi r24, 0x51 ; 81
3f82: 11 f4 brne .+4 ; 0x3f88 <main+0x188>
// Adaboot no-wait mod
watchdogConfig(WATCHDOG_16MS);
3f84: 88 e0 ldi r24, 0x08 ; 8
3f86: 19 d0 rcall .+50 ; 0x3fba <watchdogConfig>
verifySpace();
}
else {
// This covers the response to commands like STK_ENTER_PROGMODE
verifySpace();
3f88: 23 d0 rcall .+70 ; 0x3fd0 <verifySpace>
}
putch(STK_OK);
3f8a: 80 e1 ldi r24, 0x10 ; 16
3f8c: 01 d0 rcall .+2 ; 0x3f90 <putch>
3f8e: 63 cf rjmp .-314 ; 0x3e56 <main+0x56>
00003f90 <putch>:
}
}
void putch(char ch) {
3f90: 98 2f mov r25, r24
#ifndef SOFT_UART
while (!(UCSR0A & _BV(UDRE0)));
3f92: 80 91 c0 00 lds r24, 0x00C0
3f96: 85 ff sbrs r24, 5
3f98: fc cf rjmp .-8 ; 0x3f92 <putch+0x2>
UDR0 = ch;
3f9a: 90 93 c6 00 sts 0x00C6, r25
[uartBit] "I" (UART_TX_BIT)
:
"r25"
);
#endif
}
3f9e: 08 95 ret
00003fa0 <getch>:
return getch();
}
// Watchdog functions. These are only safe with interrupts turned off.
void watchdogReset() {
__asm__ __volatile__ (
3fa0: a8 95 wdr
[uartBit] "I" (UART_RX_BIT)
:
"r25"
);
#else
while(!(UCSR0A & _BV(RXC0)));
3fa2: 80 91 c0 00 lds r24, 0x00C0
3fa6: 87 ff sbrs r24, 7
3fa8: fc cf rjmp .-8 ; 0x3fa2 <getch+0x2>
ch = UDR0;
3faa: 80 91 c6 00 lds r24, 0x00C6
#ifdef LED_DATA_FLASH
LED_PIN |= _BV(LED);
#endif
return ch;
}
3fae: 08 95 ret
00003fb0 <getLen>:
} while (--count);
}
#endif
uint8_t getLen() {
getch();
3fb0: f7 df rcall .-18 ; 0x3fa0 <getch>
length = getch();
3fb2: f6 df rcall .-20 ; 0x3fa0 <getch>
3fb4: 80 93 02 02 sts 0x0202, r24
return getch();
}
3fb8: f3 cf rjmp .-26 ; 0x3fa0 <getch>
00003fba <watchdogConfig>:
"wdr\n"
);
}
void watchdogConfig(uint8_t x) {
WDTCSR = _BV(WDCE) | _BV(WDE);
3fba: e0 e6 ldi r30, 0x60 ; 96
3fbc: f0 e0 ldi r31, 0x00 ; 0
3fbe: 98 e1 ldi r25, 0x18 ; 24
3fc0: 90 83 st Z, r25
WDTCSR = x;
3fc2: 80 83 st Z, r24
}
3fc4: 08 95 ret
00003fc6 <appStart>:
void appStart() {
watchdogConfig(WATCHDOG_OFF);
3fc6: 80 e0 ldi r24, 0x00 ; 0
3fc8: f8 df rcall .-16 ; 0x3fba <watchdogConfig>
__asm__ __volatile__ (
3fca: ee 27 eor r30, r30
3fcc: ff 27 eor r31, r31
3fce: 09 94 ijmp
00003fd0 <verifySpace>:
do getch(); while (--count);
verifySpace();
}
void verifySpace() {
if (getch() != CRC_EOP) appStart();
3fd0: e7 df rcall .-50 ; 0x3fa0 <getch>
3fd2: 80 32 cpi r24, 0x20 ; 32
3fd4: 09 f0 breq .+2 ; 0x3fd8 <verifySpace+0x8>
3fd6: f7 df rcall .-18 ; 0x3fc6 <appStart>
putch(STK_INSYNC);
3fd8: 84 e1 ldi r24, 0x14 ; 20
}
3fda: da cf rjmp .-76 ; 0x3f90 <putch>
::[count] "M" (UART_B_VALUE)
);
}
#endif
void getNch(uint8_t count) {
3fdc: 1f 93 push r17
3fde: 18 2f mov r17, r24
00003fe0 <getNch>:
do getch(); while (--count);
3fe0: df df rcall .-66 ; 0x3fa0 <getch>
3fe2: 11 50 subi r17, 0x01 ; 1
3fe4: e9 f7 brne .-6 ; 0x3fe0 <getNch>
verifySpace();
3fe6: f4 df rcall .-24 ; 0x3fd0 <verifySpace>
}
3fe8: 1f 91 pop r17
3fea: 08 95 ret

View file

@ -0,0 +1,33 @@
:103E000085E08093810082E08093C00088E1809308
:103E1000C10086E08093C20085E18093C40084B72E
:103E200014BE81FFD0D08DE0C8D0259A86E02CE367
:103E30003BEF91E0309385002093840096BBB09BCC
:103E4000FECF1D9AA8958150A9F7DD24D394A5E053
:103E5000EA2EF1E1FF2EA4D0813421F481E0BED01E
:103E600083E024C0823411F484E103C0853419F462
:103E700085E0B4D08AC08535A1F492D0082F10E037
:103E800010930102009300028BD090E0982F8827B6
:103E9000802B912B880F991F909301028093000231
:103EA00073C0863529F484E099D080E071D06DC06C
:103EB000843609F043C07CD0E0910002F091010209
:103EC00083E080935700E895C0E0D1E069D0899302
:103ED000809102028150809302028823B9F778D042
:103EE00007B600FCFDCF4091000250910102A0E016
:103EF000B1E02C9130E011968C91119790E0982FC1
:103F00008827822B932B1296FA010C01D09257002E
:103F1000E89511244E5F5F4FF1E0A038BF0749F7E5
:103F2000E0910002F0910102E0925700E89507B697
:103F300000FCFDCFF0925700E89527C08437B9F414
:103F400037D046D0E0910002F09101023196F09313
:103F50000102E09300023197E4918E2F19D08091F5
:103F60000202815080930202882361F70EC08537D8
:103F700039F42ED08EE10CD084E90AD086E096CFB9
:103F8000813511F488E019D023D080E101D063CFCE
:103F9000982F8091C00085FFFCCF9093C6000895B4
:103FA000A8958091C00087FFFCCF8091C60008953E
:103FB000F7DFF6DF80930202F3CFE0E6F0E098E16E
:103FC00090838083089580E0F8DFEE27FF2709942F
:103FD000E7DF803209F0F7DF84E1DACF1F93182F93
:0C3FE000DFDF1150E9F7F4DF1F910895B6
:0400000300003E00BB
:00000001FF

View file

@ -0,0 +1,520 @@
optiboot_pro_20mhz.elf: file format elf32-avr
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 000001ec 00003e00 00003e00 00000054 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .debug_aranges 00000028 00000000 00000000 00000240 2**0
CONTENTS, READONLY, DEBUGGING
2 .debug_pubnames 0000006a 00000000 00000000 00000268 2**0
CONTENTS, READONLY, DEBUGGING
3 .debug_info 00000269 00000000 00000000 000002d2 2**0
CONTENTS, READONLY, DEBUGGING
4 .debug_abbrev 00000196 00000000 00000000 0000053b 2**0
CONTENTS, READONLY, DEBUGGING
5 .debug_line 000003d3 00000000 00000000 000006d1 2**0
CONTENTS, READONLY, DEBUGGING
6 .debug_frame 00000090 00000000 00000000 00000aa4 2**2
CONTENTS, READONLY, DEBUGGING
7 .debug_str 00000135 00000000 00000000 00000b34 2**0
CONTENTS, READONLY, DEBUGGING
8 .debug_loc 000001d1 00000000 00000000 00000c69 2**0
CONTENTS, READONLY, DEBUGGING
9 .debug_ranges 00000068 00000000 00000000 00000e3a 2**0
CONTENTS, READONLY, DEBUGGING
Disassembly of section .text:
00003e00 <main>:
#ifdef VIRTUAL_BOOT_PARTITION
#define rstVect (*(uint16_t*)(0x204))
#define wdtVect (*(uint16_t*)(0x206))
#endif
/* main program starts here */
int main(void) {
3e00: 85 e0 ldi r24, 0x05 ; 5
3e02: 80 93 81 00 sts 0x0081, r24
#if LED_START_FLASHES > 0
// Set up Timer 1 for timeout counter
TCCR1B = _BV(CS12) | _BV(CS10); // div 1024
#endif
#ifndef SOFT_UART
UCSR0A = _BV(U2X0); //Double speed mode USART0
3e06: 82 e0 ldi r24, 0x02 ; 2
3e08: 80 93 c0 00 sts 0x00C0, r24
UCSR0B = _BV(RXEN0) | _BV(TXEN0);
3e0c: 88 e1 ldi r24, 0x18 ; 24
3e0e: 80 93 c1 00 sts 0x00C1, r24
UCSR0C = _BV(UCSZ00) | _BV(UCSZ01);
3e12: 86 e0 ldi r24, 0x06 ; 6
3e14: 80 93 c2 00 sts 0x00C2, r24
UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
3e18: 85 e1 ldi r24, 0x15 ; 21
3e1a: 80 93 c4 00 sts 0x00C4, r24
#endif
// Adaboot no-wait mod
ch = MCUSR;
3e1e: 84 b7 in r24, 0x34 ; 52
MCUSR = 0;
3e20: 14 be out 0x34, r1 ; 52
if (!(ch & _BV(EXTRF))) appStart();
3e22: 81 ff sbrs r24, 1
3e24: d0 d0 rcall .+416 ; 0x3fc6 <appStart>
// Set up watchdog to trigger after 500ms
watchdogConfig(WATCHDOG_500MS);
3e26: 8d e0 ldi r24, 0x0D ; 13
3e28: c8 d0 rcall .+400 ; 0x3fba <watchdogConfig>
/* Set LED pin as output */
LED_DDR |= _BV(LED);
3e2a: 25 9a sbi 0x04, 5 ; 4
3e2c: 86 e0 ldi r24, 0x06 ; 6
}
#if LED_START_FLASHES > 0
void flash_led(uint8_t count) {
do {
TCNT1 = -(F_CPU/(1024*16));
3e2e: 2c e3 ldi r18, 0x3C ; 60
3e30: 3b ef ldi r19, 0xFB ; 251
TIFR1 = _BV(TOV1);
3e32: 91 e0 ldi r25, 0x01 ; 1
}
#if LED_START_FLASHES > 0
void flash_led(uint8_t count) {
do {
TCNT1 = -(F_CPU/(1024*16));
3e34: 30 93 85 00 sts 0x0085, r19
3e38: 20 93 84 00 sts 0x0084, r18
TIFR1 = _BV(TOV1);
3e3c: 96 bb out 0x16, r25 ; 22
while(!(TIFR1 & _BV(TOV1)));
3e3e: b0 9b sbis 0x16, 0 ; 22
3e40: fe cf rjmp .-4 ; 0x3e3e <main+0x3e>
LED_PIN |= _BV(LED);
3e42: 1d 9a sbi 0x03, 5 ; 3
return getch();
}
// Watchdog functions. These are only safe with interrupts turned off.
void watchdogReset() {
__asm__ __volatile__ (
3e44: a8 95 wdr
TCNT1 = -(F_CPU/(1024*16));
TIFR1 = _BV(TOV1);
while(!(TIFR1 & _BV(TOV1)));
LED_PIN |= _BV(LED);
watchdogReset();
} while (--count);
3e46: 81 50 subi r24, 0x01 ; 1
3e48: a9 f7 brne .-22 ; 0x3e34 <main+0x34>
/* get character from UART */
ch = getch();
if(ch == STK_GET_PARAMETER) {
// GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy
getNch(1);
3e4a: dd 24 eor r13, r13
3e4c: d3 94 inc r13
boot_page_fill((uint16_t)(void*)addrPtr,a);
addrPtr += 2;
} while (--ch);
// Write from programming buffer
boot_page_write((uint16_t)(void*)address);
3e4e: a5 e0 ldi r26, 0x05 ; 5
3e50: ea 2e mov r14, r26
boot_spm_busy_wait();
#if defined(RWWSRE)
// Reenable read access to flash
boot_rww_enable();
3e52: f1 e1 ldi r31, 0x11 ; 17
3e54: ff 2e mov r15, r31
#endif
/* Forever loop */
for (;;) {
/* get character from UART */
ch = getch();
3e56: a4 d0 rcall .+328 ; 0x3fa0 <getch>
if(ch == STK_GET_PARAMETER) {
3e58: 81 34 cpi r24, 0x41 ; 65
3e5a: 21 f4 brne .+8 ; 0x3e64 <main+0x64>
// GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy
getNch(1);
3e5c: 81 e0 ldi r24, 0x01 ; 1
3e5e: be d0 rcall .+380 ; 0x3fdc <verifySpace+0xc>
putch(0x03);
3e60: 83 e0 ldi r24, 0x03 ; 3
3e62: 24 c0 rjmp .+72 ; 0x3eac <main+0xac>
}
else if(ch == STK_SET_DEVICE) {
3e64: 82 34 cpi r24, 0x42 ; 66
3e66: 11 f4 brne .+4 ; 0x3e6c <main+0x6c>
// SET DEVICE is ignored
getNch(20);
3e68: 84 e1 ldi r24, 0x14 ; 20
3e6a: 03 c0 rjmp .+6 ; 0x3e72 <main+0x72>
}
else if(ch == STK_SET_DEVICE_EXT) {
3e6c: 85 34 cpi r24, 0x45 ; 69
3e6e: 19 f4 brne .+6 ; 0x3e76 <main+0x76>
// SET DEVICE EXT is ignored
getNch(5);
3e70: 85 e0 ldi r24, 0x05 ; 5
3e72: b4 d0 rcall .+360 ; 0x3fdc <verifySpace+0xc>
3e74: 8a c0 rjmp .+276 ; 0x3f8a <main+0x18a>
}
else if(ch == STK_LOAD_ADDRESS) {
3e76: 85 35 cpi r24, 0x55 ; 85
3e78: a1 f4 brne .+40 ; 0x3ea2 <main+0xa2>
// LOAD ADDRESS
address = getch();
3e7a: 92 d0 rcall .+292 ; 0x3fa0 <getch>
3e7c: 08 2f mov r16, r24
3e7e: 10 e0 ldi r17, 0x00 ; 0
3e80: 10 93 01 02 sts 0x0201, r17
3e84: 00 93 00 02 sts 0x0200, r16
address = (address & 0xff) | (getch() << 8);
3e88: 8b d0 rcall .+278 ; 0x3fa0 <getch>
3e8a: 90 e0 ldi r25, 0x00 ; 0
3e8c: 98 2f mov r25, r24
3e8e: 88 27 eor r24, r24
3e90: 80 2b or r24, r16
3e92: 91 2b or r25, r17
address += address; // Convert from word address to byte address
3e94: 88 0f add r24, r24
3e96: 99 1f adc r25, r25
3e98: 90 93 01 02 sts 0x0201, r25
3e9c: 80 93 00 02 sts 0x0200, r24
3ea0: 73 c0 rjmp .+230 ; 0x3f88 <main+0x188>
verifySpace();
}
else if(ch == STK_UNIVERSAL) {
3ea2: 86 35 cpi r24, 0x56 ; 86
3ea4: 29 f4 brne .+10 ; 0x3eb0 <main+0xb0>
// UNIVERSAL command is ignored
getNch(4);
3ea6: 84 e0 ldi r24, 0x04 ; 4
3ea8: 99 d0 rcall .+306 ; 0x3fdc <verifySpace+0xc>
putch(0x00);
3eaa: 80 e0 ldi r24, 0x00 ; 0
3eac: 71 d0 rcall .+226 ; 0x3f90 <putch>
3eae: 6d c0 rjmp .+218 ; 0x3f8a <main+0x18a>
}
/* Write memory, length is big endian and is in bytes */
else if(ch == STK_PROG_PAGE) {
3eb0: 84 36 cpi r24, 0x64 ; 100
3eb2: 09 f0 breq .+2 ; 0x3eb6 <main+0xb6>
3eb4: 43 c0 rjmp .+134 ; 0x3f3c <main+0x13c>
// PROGRAM PAGE - we support flash programming only, not EEPROM
uint8_t *bufPtr;
uint16_t addrPtr;
getLen();
3eb6: 7c d0 rcall .+248 ; 0x3fb0 <getLen>
// Immediately start page erase - this will 4.5ms
boot_page_erase((uint16_t)(void*)address);
3eb8: e0 91 00 02 lds r30, 0x0200
3ebc: f0 91 01 02 lds r31, 0x0201
3ec0: 83 e0 ldi r24, 0x03 ; 3
3ec2: 80 93 57 00 sts 0x0057, r24
3ec6: e8 95 spm
3ec8: c0 e0 ldi r28, 0x00 ; 0
3eca: d1 e0 ldi r29, 0x01 ; 1
// While that is going on, read in page contents
bufPtr = buff;
do *bufPtr++ = getch();
3ecc: 69 d0 rcall .+210 ; 0x3fa0 <getch>
3ece: 89 93 st Y+, r24
while (--length);
3ed0: 80 91 02 02 lds r24, 0x0202
3ed4: 81 50 subi r24, 0x01 ; 1
3ed6: 80 93 02 02 sts 0x0202, r24
3eda: 88 23 and r24, r24
3edc: b9 f7 brne .-18 ; 0x3ecc <main+0xcc>
// Read command terminator, start reply
verifySpace();
3ede: 78 d0 rcall .+240 ; 0x3fd0 <verifySpace>
// If only a partial page is to be programmed, the erase might not be complete.
// So check that here
boot_spm_busy_wait();
3ee0: 07 b6 in r0, 0x37 ; 55
3ee2: 00 fc sbrc r0, 0
3ee4: fd cf rjmp .-6 ; 0x3ee0 <main+0xe0>
}
#endif
// Copy buffer into programming buffer
bufPtr = buff;
addrPtr = (uint16_t)(void*)address;
3ee6: 40 91 00 02 lds r20, 0x0200
3eea: 50 91 01 02 lds r21, 0x0201
3eee: a0 e0 ldi r26, 0x00 ; 0
3ef0: b1 e0 ldi r27, 0x01 ; 1
ch = SPM_PAGESIZE / 2;
do {
uint16_t a;
a = *bufPtr++;
3ef2: 2c 91 ld r18, X
3ef4: 30 e0 ldi r19, 0x00 ; 0
a |= (*bufPtr++) << 8;
3ef6: 11 96 adiw r26, 0x01 ; 1
3ef8: 8c 91 ld r24, X
3efa: 11 97 sbiw r26, 0x01 ; 1
3efc: 90 e0 ldi r25, 0x00 ; 0
3efe: 98 2f mov r25, r24
3f00: 88 27 eor r24, r24
3f02: 82 2b or r24, r18
3f04: 93 2b or r25, r19
#ifdef VIRTUAL_BOOT_PARTITION
#define rstVect (*(uint16_t*)(0x204))
#define wdtVect (*(uint16_t*)(0x206))
#endif
/* main program starts here */
int main(void) {
3f06: 12 96 adiw r26, 0x02 ; 2
ch = SPM_PAGESIZE / 2;
do {
uint16_t a;
a = *bufPtr++;
a |= (*bufPtr++) << 8;
boot_page_fill((uint16_t)(void*)addrPtr,a);
3f08: fa 01 movw r30, r20
3f0a: 0c 01 movw r0, r24
3f0c: d0 92 57 00 sts 0x0057, r13
3f10: e8 95 spm
3f12: 11 24 eor r1, r1
addrPtr += 2;
3f14: 4e 5f subi r20, 0xFE ; 254
3f16: 5f 4f sbci r21, 0xFF ; 255
} while (--ch);
3f18: f1 e0 ldi r31, 0x01 ; 1
3f1a: a0 38 cpi r26, 0x80 ; 128
3f1c: bf 07 cpc r27, r31
3f1e: 49 f7 brne .-46 ; 0x3ef2 <main+0xf2>
// Write from programming buffer
boot_page_write((uint16_t)(void*)address);
3f20: e0 91 00 02 lds r30, 0x0200
3f24: f0 91 01 02 lds r31, 0x0201
3f28: e0 92 57 00 sts 0x0057, r14
3f2c: e8 95 spm
boot_spm_busy_wait();
3f2e: 07 b6 in r0, 0x37 ; 55
3f30: 00 fc sbrc r0, 0
3f32: fd cf rjmp .-6 ; 0x3f2e <main+0x12e>
#if defined(RWWSRE)
// Reenable read access to flash
boot_rww_enable();
3f34: f0 92 57 00 sts 0x0057, r15
3f38: e8 95 spm
3f3a: 27 c0 rjmp .+78 ; 0x3f8a <main+0x18a>
#endif
}
/* Read memory block mode, length is big endian. */
else if(ch == STK_READ_PAGE) {
3f3c: 84 37 cpi r24, 0x74 ; 116
3f3e: b9 f4 brne .+46 ; 0x3f6e <main+0x16e>
// READ PAGE - we only read flash
getLen();
3f40: 37 d0 rcall .+110 ; 0x3fb0 <getLen>
verifySpace();
3f42: 46 d0 rcall .+140 ; 0x3fd0 <verifySpace>
else ch = pgm_read_byte_near(address);
address++;
putch(ch);
} while (--length);
#else
do putch(pgm_read_byte_near(address++));
3f44: e0 91 00 02 lds r30, 0x0200
3f48: f0 91 01 02 lds r31, 0x0201
3f4c: 31 96 adiw r30, 0x01 ; 1
3f4e: f0 93 01 02 sts 0x0201, r31
3f52: e0 93 00 02 sts 0x0200, r30
3f56: 31 97 sbiw r30, 0x01 ; 1
3f58: e4 91 lpm r30, Z+
3f5a: 8e 2f mov r24, r30
3f5c: 19 d0 rcall .+50 ; 0x3f90 <putch>
while (--length);
3f5e: 80 91 02 02 lds r24, 0x0202
3f62: 81 50 subi r24, 0x01 ; 1
3f64: 80 93 02 02 sts 0x0202, r24
3f68: 88 23 and r24, r24
3f6a: 61 f7 brne .-40 ; 0x3f44 <main+0x144>
3f6c: 0e c0 rjmp .+28 ; 0x3f8a <main+0x18a>
#endif
}
/* Get device signature bytes */
else if(ch == STK_READ_SIGN) {
3f6e: 85 37 cpi r24, 0x75 ; 117
3f70: 39 f4 brne .+14 ; 0x3f80 <main+0x180>
// READ SIGN - return what Avrdude wants to hear
verifySpace();
3f72: 2e d0 rcall .+92 ; 0x3fd0 <verifySpace>
putch(SIGNATURE_0);
3f74: 8e e1 ldi r24, 0x1E ; 30
3f76: 0c d0 rcall .+24 ; 0x3f90 <putch>
putch(SIGNATURE_1);
3f78: 84 e9 ldi r24, 0x94 ; 148
3f7a: 0a d0 rcall .+20 ; 0x3f90 <putch>
putch(SIGNATURE_2);
3f7c: 86 e0 ldi r24, 0x06 ; 6
3f7e: 96 cf rjmp .-212 ; 0x3eac <main+0xac>
}
else if (ch == 'Q') {
3f80: 81 35 cpi r24, 0x51 ; 81
3f82: 11 f4 brne .+4 ; 0x3f88 <main+0x188>
// Adaboot no-wait mod
watchdogConfig(WATCHDOG_16MS);
3f84: 88 e0 ldi r24, 0x08 ; 8
3f86: 19 d0 rcall .+50 ; 0x3fba <watchdogConfig>
verifySpace();
}
else {
// This covers the response to commands like STK_ENTER_PROGMODE
verifySpace();
3f88: 23 d0 rcall .+70 ; 0x3fd0 <verifySpace>
}
putch(STK_OK);
3f8a: 80 e1 ldi r24, 0x10 ; 16
3f8c: 01 d0 rcall .+2 ; 0x3f90 <putch>
3f8e: 63 cf rjmp .-314 ; 0x3e56 <main+0x56>
00003f90 <putch>:
}
}
void putch(char ch) {
3f90: 98 2f mov r25, r24
#ifndef SOFT_UART
while (!(UCSR0A & _BV(UDRE0)));
3f92: 80 91 c0 00 lds r24, 0x00C0
3f96: 85 ff sbrs r24, 5
3f98: fc cf rjmp .-8 ; 0x3f92 <putch+0x2>
UDR0 = ch;
3f9a: 90 93 c6 00 sts 0x00C6, r25
[uartBit] "I" (UART_TX_BIT)
:
"r25"
);
#endif
}
3f9e: 08 95 ret
00003fa0 <getch>:
return getch();
}
// Watchdog functions. These are only safe with interrupts turned off.
void watchdogReset() {
__asm__ __volatile__ (
3fa0: a8 95 wdr
[uartBit] "I" (UART_RX_BIT)
:
"r25"
);
#else
while(!(UCSR0A & _BV(RXC0)));
3fa2: 80 91 c0 00 lds r24, 0x00C0
3fa6: 87 ff sbrs r24, 7
3fa8: fc cf rjmp .-8 ; 0x3fa2 <getch+0x2>
ch = UDR0;
3faa: 80 91 c6 00 lds r24, 0x00C6
#ifdef LED_DATA_FLASH
LED_PIN |= _BV(LED);
#endif
return ch;
}
3fae: 08 95 ret
00003fb0 <getLen>:
} while (--count);
}
#endif
uint8_t getLen() {
getch();
3fb0: f7 df rcall .-18 ; 0x3fa0 <getch>
length = getch();
3fb2: f6 df rcall .-20 ; 0x3fa0 <getch>
3fb4: 80 93 02 02 sts 0x0202, r24
return getch();
}
3fb8: f3 cf rjmp .-26 ; 0x3fa0 <getch>
00003fba <watchdogConfig>:
"wdr\n"
);
}
void watchdogConfig(uint8_t x) {
WDTCSR = _BV(WDCE) | _BV(WDE);
3fba: e0 e6 ldi r30, 0x60 ; 96
3fbc: f0 e0 ldi r31, 0x00 ; 0
3fbe: 98 e1 ldi r25, 0x18 ; 24
3fc0: 90 83 st Z, r25
WDTCSR = x;
3fc2: 80 83 st Z, r24
}
3fc4: 08 95 ret
00003fc6 <appStart>:
void appStart() {
watchdogConfig(WATCHDOG_OFF);
3fc6: 80 e0 ldi r24, 0x00 ; 0
3fc8: f8 df rcall .-16 ; 0x3fba <watchdogConfig>
__asm__ __volatile__ (
3fca: ee 27 eor r30, r30
3fcc: ff 27 eor r31, r31
3fce: 09 94 ijmp
00003fd0 <verifySpace>:
do getch(); while (--count);
verifySpace();
}
void verifySpace() {
if (getch() != CRC_EOP) appStart();
3fd0: e7 df rcall .-50 ; 0x3fa0 <getch>
3fd2: 80 32 cpi r24, 0x20 ; 32
3fd4: 09 f0 breq .+2 ; 0x3fd8 <verifySpace+0x8>
3fd6: f7 df rcall .-18 ; 0x3fc6 <appStart>
putch(STK_INSYNC);
3fd8: 84 e1 ldi r24, 0x14 ; 20
}
3fda: da cf rjmp .-76 ; 0x3f90 <putch>
::[count] "M" (UART_B_VALUE)
);
}
#endif
void getNch(uint8_t count) {
3fdc: 1f 93 push r17
3fde: 18 2f mov r17, r24
00003fe0 <getNch>:
do getch(); while (--count);
3fe0: df df rcall .-66 ; 0x3fa0 <getch>
3fe2: 11 50 subi r17, 0x01 ; 1
3fe4: e9 f7 brne .-6 ; 0x3fe0 <getNch>
verifySpace();
3fe6: f4 df rcall .-24 ; 0x3fd0 <verifySpace>
}
3fe8: 1f 91 pop r17
3fea: 08 95 ret

View file

@ -0,0 +1,34 @@
:103E000085E08093810084B714BE81FFE4D08DE00B
:103E1000DCD0259A519A86E028E13EEF91E030937C
:103E200085002093840096BBB09BFECF1D9AA89579
:103E30008150A9F7DD24D394A5E0EA2EF1E1FF2E0D
:103E4000ABD0813421F481E0D1D083E024C082342E
:103E500011F484E103C0853419F485E0C7D08AC029
:103E60008535A1F499D0082F10E01093010200933A
:103E7000000292D090E0982F8827802B912B880FFA
:103E8000991F909301028093000273C0863529F434
:103E900084E0ACD080E071D06DC0843609F043C0BE
:103EA0008FD0E0910002F091010283E080935700EF
:103EB000E895C0E0D1E070D08993809102028150F2
:103EC000809302028823B9F78BD007B600FCFDCFA0
:103ED0004091000250910102A0E0B1E02C9130E04D
:103EE00011968C91119790E0982F8827822B932B15
:103EF0001296FA010C01D0925700E89511244E5FFA
:103F00005F4FF1E0A038BF0749F7E0910002F09160
:103F10000102E0925700E89507B600FCFDCFF09251
:103F20005700E89527C08437B9F44AD059D0E091BA
:103F30000002F09101023196F0930102E093000239
:103F40003197E4918E2F19D0809102028150809395
:103F50000202882361F70EC0853739F441D08EE123
:103F60000CD084E90AD086E096CF813511F488E040
:103F70002CD036D080E101D063CF2AE030E08095AC
:103F8000089410F4599802C0599A000015D014D022
:103F900086952A95B1F70895A89529E030E04899CB
:103FA000FECF0AD009D008D08894489908942A9561
:103FB00011F08795F7CF089598E09A95F1F7089555
:103FC000EBDFEADF80930202E7CFE0E6F0E098E182
:103FD00090838083089580E0F8DFEE27FF2709941F
:103FE000DBDF803209F0F7DF84E1C7CF1F93182FA2
:0C3FF000D3DF1150E9F7F4DF1F910895B2
:0400000300003E00BB
:00000001FF

View file

@ -0,0 +1,533 @@
optiboot_pro_8MHz.elf: file format elf32-avr
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 000001fc 00003e00 00003e00 00000054 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .debug_aranges 00000028 00000000 00000000 00000250 2**0
CONTENTS, READONLY, DEBUGGING
2 .debug_pubnames 00000078 00000000 00000000 00000278 2**0
CONTENTS, READONLY, DEBUGGING
3 .debug_info 00000277 00000000 00000000 000002f0 2**0
CONTENTS, READONLY, DEBUGGING
4 .debug_abbrev 00000194 00000000 00000000 00000567 2**0
CONTENTS, READONLY, DEBUGGING
5 .debug_line 000003bb 00000000 00000000 000006fb 2**0
CONTENTS, READONLY, DEBUGGING
6 .debug_frame 000000a0 00000000 00000000 00000ab8 2**2
CONTENTS, READONLY, DEBUGGING
7 .debug_str 0000013f 00000000 00000000 00000b58 2**0
CONTENTS, READONLY, DEBUGGING
8 .debug_loc 000001a0 00000000 00000000 00000c97 2**0
CONTENTS, READONLY, DEBUGGING
9 .debug_ranges 00000070 00000000 00000000 00000e37 2**0
CONTENTS, READONLY, DEBUGGING
Disassembly of section .text:
00003e00 <main>:
#ifdef VIRTUAL_BOOT_PARTITION
#define rstVect (*(uint16_t*)(0x204))
#define wdtVect (*(uint16_t*)(0x206))
#endif
/* main program starts here */
int main(void) {
3e00: 85 e0 ldi r24, 0x05 ; 5
3e02: 80 93 81 00 sts 0x0081, r24
UCSR0C = _BV(UCSZ00) | _BV(UCSZ01);
UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
#endif
// Adaboot no-wait mod
ch = MCUSR;
3e06: 84 b7 in r24, 0x34 ; 52
MCUSR = 0;
3e08: 14 be out 0x34, r1 ; 52
if (!(ch & _BV(EXTRF))) appStart();
3e0a: 81 ff sbrs r24, 1
3e0c: e4 d0 rcall .+456 ; 0x3fd6 <appStart>
// Set up watchdog to trigger after 500ms
watchdogConfig(WATCHDOG_500MS);
3e0e: 8d e0 ldi r24, 0x0D ; 13
3e10: dc d0 rcall .+440 ; 0x3fca <watchdogConfig>
/* Set LED pin as output */
LED_DDR |= _BV(LED);
3e12: 25 9a sbi 0x04, 5 ; 4
#ifdef SOFT_UART
/* Set TX pin as output */
UART_DDR |= _BV(UART_TX_BIT);
3e14: 51 9a sbi 0x0a, 1 ; 10
3e16: 86 e0 ldi r24, 0x06 ; 6
}
#if LED_START_FLASHES > 0
void flash_led(uint8_t count) {
do {
TCNT1 = -(F_CPU/(1024*16));
3e18: 28 e1 ldi r18, 0x18 ; 24
3e1a: 3e ef ldi r19, 0xFE ; 254
TIFR1 = _BV(TOV1);
3e1c: 91 e0 ldi r25, 0x01 ; 1
}
#if LED_START_FLASHES > 0
void flash_led(uint8_t count) {
do {
TCNT1 = -(F_CPU/(1024*16));
3e1e: 30 93 85 00 sts 0x0085, r19
3e22: 20 93 84 00 sts 0x0084, r18
TIFR1 = _BV(TOV1);
3e26: 96 bb out 0x16, r25 ; 22
while(!(TIFR1 & _BV(TOV1)));
3e28: b0 9b sbis 0x16, 0 ; 22
3e2a: fe cf rjmp .-4 ; 0x3e28 <main+0x28>
LED_PIN |= _BV(LED);
3e2c: 1d 9a sbi 0x03, 5 ; 3
return getch();
}
// Watchdog functions. These are only safe with interrupts turned off.
void watchdogReset() {
__asm__ __volatile__ (
3e2e: a8 95 wdr
TCNT1 = -(F_CPU/(1024*16));
TIFR1 = _BV(TOV1);
while(!(TIFR1 & _BV(TOV1)));
LED_PIN |= _BV(LED);
watchdogReset();
} while (--count);
3e30: 81 50 subi r24, 0x01 ; 1
3e32: a9 f7 brne .-22 ; 0x3e1e <main+0x1e>
/* get character from UART */
ch = getch();
if(ch == STK_GET_PARAMETER) {
// GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy
getNch(1);
3e34: dd 24 eor r13, r13
3e36: d3 94 inc r13
boot_page_fill((uint16_t)(void*)addrPtr,a);
addrPtr += 2;
} while (--ch);
// Write from programming buffer
boot_page_write((uint16_t)(void*)address);
3e38: a5 e0 ldi r26, 0x05 ; 5
3e3a: ea 2e mov r14, r26
boot_spm_busy_wait();
#if defined(RWWSRE)
// Reenable read access to flash
boot_rww_enable();
3e3c: f1 e1 ldi r31, 0x11 ; 17
3e3e: ff 2e mov r15, r31
#endif
/* Forever loop */
for (;;) {
/* get character from UART */
ch = getch();
3e40: ab d0 rcall .+342 ; 0x3f98 <getch>
if(ch == STK_GET_PARAMETER) {
3e42: 81 34 cpi r24, 0x41 ; 65
3e44: 21 f4 brne .+8 ; 0x3e4e <main+0x4e>
// GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy
getNch(1);
3e46: 81 e0 ldi r24, 0x01 ; 1
3e48: d1 d0 rcall .+418 ; 0x3fec <verifySpace+0xc>
putch(0x03);
3e4a: 83 e0 ldi r24, 0x03 ; 3
3e4c: 24 c0 rjmp .+72 ; 0x3e96 <main+0x96>
}
else if(ch == STK_SET_DEVICE) {
3e4e: 82 34 cpi r24, 0x42 ; 66
3e50: 11 f4 brne .+4 ; 0x3e56 <main+0x56>
// SET DEVICE is ignored
getNch(20);
3e52: 84 e1 ldi r24, 0x14 ; 20
3e54: 03 c0 rjmp .+6 ; 0x3e5c <main+0x5c>
}
else if(ch == STK_SET_DEVICE_EXT) {
3e56: 85 34 cpi r24, 0x45 ; 69
3e58: 19 f4 brne .+6 ; 0x3e60 <main+0x60>
// SET DEVICE EXT is ignored
getNch(5);
3e5a: 85 e0 ldi r24, 0x05 ; 5
3e5c: c7 d0 rcall .+398 ; 0x3fec <verifySpace+0xc>
3e5e: 8a c0 rjmp .+276 ; 0x3f74 <main+0x174>
}
else if(ch == STK_LOAD_ADDRESS) {
3e60: 85 35 cpi r24, 0x55 ; 85
3e62: a1 f4 brne .+40 ; 0x3e8c <main+0x8c>
// LOAD ADDRESS
address = getch();
3e64: 99 d0 rcall .+306 ; 0x3f98 <getch>
3e66: 08 2f mov r16, r24
3e68: 10 e0 ldi r17, 0x00 ; 0
3e6a: 10 93 01 02 sts 0x0201, r17
3e6e: 00 93 00 02 sts 0x0200, r16
address = (address & 0xff) | (getch() << 8);
3e72: 92 d0 rcall .+292 ; 0x3f98 <getch>
3e74: 90 e0 ldi r25, 0x00 ; 0
3e76: 98 2f mov r25, r24
3e78: 88 27 eor r24, r24
3e7a: 80 2b or r24, r16
3e7c: 91 2b or r25, r17
address += address; // Convert from word address to byte address
3e7e: 88 0f add r24, r24
3e80: 99 1f adc r25, r25
3e82: 90 93 01 02 sts 0x0201, r25
3e86: 80 93 00 02 sts 0x0200, r24
3e8a: 73 c0 rjmp .+230 ; 0x3f72 <main+0x172>
verifySpace();
}
else if(ch == STK_UNIVERSAL) {
3e8c: 86 35 cpi r24, 0x56 ; 86
3e8e: 29 f4 brne .+10 ; 0x3e9a <main+0x9a>
// UNIVERSAL command is ignored
getNch(4);
3e90: 84 e0 ldi r24, 0x04 ; 4
3e92: ac d0 rcall .+344 ; 0x3fec <verifySpace+0xc>
putch(0x00);
3e94: 80 e0 ldi r24, 0x00 ; 0
3e96: 71 d0 rcall .+226 ; 0x3f7a <putch>
3e98: 6d c0 rjmp .+218 ; 0x3f74 <main+0x174>
}
/* Write memory, length is big endian and is in bytes */
else if(ch == STK_PROG_PAGE) {
3e9a: 84 36 cpi r24, 0x64 ; 100
3e9c: 09 f0 breq .+2 ; 0x3ea0 <main+0xa0>
3e9e: 43 c0 rjmp .+134 ; 0x3f26 <main+0x126>
// PROGRAM PAGE - we support flash programming only, not EEPROM
uint8_t *bufPtr;
uint16_t addrPtr;
getLen();
3ea0: 8f d0 rcall .+286 ; 0x3fc0 <getLen>
// Immediately start page erase - this will 4.5ms
boot_page_erase((uint16_t)(void*)address);
3ea2: e0 91 00 02 lds r30, 0x0200
3ea6: f0 91 01 02 lds r31, 0x0201
3eaa: 83 e0 ldi r24, 0x03 ; 3
3eac: 80 93 57 00 sts 0x0057, r24
3eb0: e8 95 spm
3eb2: c0 e0 ldi r28, 0x00 ; 0
3eb4: d1 e0 ldi r29, 0x01 ; 1
// While that is going on, read in page contents
bufPtr = buff;
do *bufPtr++ = getch();
3eb6: 70 d0 rcall .+224 ; 0x3f98 <getch>
3eb8: 89 93 st Y+, r24
while (--length);
3eba: 80 91 02 02 lds r24, 0x0202
3ebe: 81 50 subi r24, 0x01 ; 1
3ec0: 80 93 02 02 sts 0x0202, r24
3ec4: 88 23 and r24, r24
3ec6: b9 f7 brne .-18 ; 0x3eb6 <main+0xb6>
// Read command terminator, start reply
verifySpace();
3ec8: 8b d0 rcall .+278 ; 0x3fe0 <verifySpace>
// If only a partial page is to be programmed, the erase might not be complete.
// So check that here
boot_spm_busy_wait();
3eca: 07 b6 in r0, 0x37 ; 55
3ecc: 00 fc sbrc r0, 0
3ece: fd cf rjmp .-6 ; 0x3eca <main+0xca>
}
#endif
// Copy buffer into programming buffer
bufPtr = buff;
addrPtr = (uint16_t)(void*)address;
3ed0: 40 91 00 02 lds r20, 0x0200
3ed4: 50 91 01 02 lds r21, 0x0201
3ed8: a0 e0 ldi r26, 0x00 ; 0
3eda: b1 e0 ldi r27, 0x01 ; 1
ch = SPM_PAGESIZE / 2;
do {
uint16_t a;
a = *bufPtr++;
3edc: 2c 91 ld r18, X
3ede: 30 e0 ldi r19, 0x00 ; 0
a |= (*bufPtr++) << 8;
3ee0: 11 96 adiw r26, 0x01 ; 1
3ee2: 8c 91 ld r24, X
3ee4: 11 97 sbiw r26, 0x01 ; 1
3ee6: 90 e0 ldi r25, 0x00 ; 0
3ee8: 98 2f mov r25, r24
3eea: 88 27 eor r24, r24
3eec: 82 2b or r24, r18
3eee: 93 2b or r25, r19
#ifdef VIRTUAL_BOOT_PARTITION
#define rstVect (*(uint16_t*)(0x204))
#define wdtVect (*(uint16_t*)(0x206))
#endif
/* main program starts here */
int main(void) {
3ef0: 12 96 adiw r26, 0x02 ; 2
ch = SPM_PAGESIZE / 2;
do {
uint16_t a;
a = *bufPtr++;
a |= (*bufPtr++) << 8;
boot_page_fill((uint16_t)(void*)addrPtr,a);
3ef2: fa 01 movw r30, r20
3ef4: 0c 01 movw r0, r24
3ef6: d0 92 57 00 sts 0x0057, r13
3efa: e8 95 spm
3efc: 11 24 eor r1, r1
addrPtr += 2;
3efe: 4e 5f subi r20, 0xFE ; 254
3f00: 5f 4f sbci r21, 0xFF ; 255
} while (--ch);
3f02: f1 e0 ldi r31, 0x01 ; 1
3f04: a0 38 cpi r26, 0x80 ; 128
3f06: bf 07 cpc r27, r31
3f08: 49 f7 brne .-46 ; 0x3edc <main+0xdc>
// Write from programming buffer
boot_page_write((uint16_t)(void*)address);
3f0a: e0 91 00 02 lds r30, 0x0200
3f0e: f0 91 01 02 lds r31, 0x0201
3f12: e0 92 57 00 sts 0x0057, r14
3f16: e8 95 spm
boot_spm_busy_wait();
3f18: 07 b6 in r0, 0x37 ; 55
3f1a: 00 fc sbrc r0, 0
3f1c: fd cf rjmp .-6 ; 0x3f18 <main+0x118>
#if defined(RWWSRE)
// Reenable read access to flash
boot_rww_enable();
3f1e: f0 92 57 00 sts 0x0057, r15
3f22: e8 95 spm
3f24: 27 c0 rjmp .+78 ; 0x3f74 <main+0x174>
#endif
}
/* Read memory block mode, length is big endian. */
else if(ch == STK_READ_PAGE) {
3f26: 84 37 cpi r24, 0x74 ; 116
3f28: b9 f4 brne .+46 ; 0x3f58 <main+0x158>
// READ PAGE - we only read flash
getLen();
3f2a: 4a d0 rcall .+148 ; 0x3fc0 <getLen>
verifySpace();
3f2c: 59 d0 rcall .+178 ; 0x3fe0 <verifySpace>
else ch = pgm_read_byte_near(address);
address++;
putch(ch);
} while (--length);
#else
do putch(pgm_read_byte_near(address++));
3f2e: e0 91 00 02 lds r30, 0x0200
3f32: f0 91 01 02 lds r31, 0x0201
3f36: 31 96 adiw r30, 0x01 ; 1
3f38: f0 93 01 02 sts 0x0201, r31
3f3c: e0 93 00 02 sts 0x0200, r30
3f40: 31 97 sbiw r30, 0x01 ; 1
3f42: e4 91 lpm r30, Z+
3f44: 8e 2f mov r24, r30
3f46: 19 d0 rcall .+50 ; 0x3f7a <putch>
while (--length);
3f48: 80 91 02 02 lds r24, 0x0202
3f4c: 81 50 subi r24, 0x01 ; 1
3f4e: 80 93 02 02 sts 0x0202, r24
3f52: 88 23 and r24, r24
3f54: 61 f7 brne .-40 ; 0x3f2e <main+0x12e>
3f56: 0e c0 rjmp .+28 ; 0x3f74 <main+0x174>
#endif
}
/* Get device signature bytes */
else if(ch == STK_READ_SIGN) {
3f58: 85 37 cpi r24, 0x75 ; 117
3f5a: 39 f4 brne .+14 ; 0x3f6a <main+0x16a>
// READ SIGN - return what Avrdude wants to hear
verifySpace();
3f5c: 41 d0 rcall .+130 ; 0x3fe0 <verifySpace>
putch(SIGNATURE_0);
3f5e: 8e e1 ldi r24, 0x1E ; 30
3f60: 0c d0 rcall .+24 ; 0x3f7a <putch>
putch(SIGNATURE_1);
3f62: 84 e9 ldi r24, 0x94 ; 148
3f64: 0a d0 rcall .+20 ; 0x3f7a <putch>
putch(SIGNATURE_2);
3f66: 86 e0 ldi r24, 0x06 ; 6
3f68: 96 cf rjmp .-212 ; 0x3e96 <main+0x96>
}
else if (ch == 'Q') {
3f6a: 81 35 cpi r24, 0x51 ; 81
3f6c: 11 f4 brne .+4 ; 0x3f72 <main+0x172>
// Adaboot no-wait mod
watchdogConfig(WATCHDOG_16MS);
3f6e: 88 e0 ldi r24, 0x08 ; 8
3f70: 2c d0 rcall .+88 ; 0x3fca <watchdogConfig>
verifySpace();
}
else {
// This covers the response to commands like STK_ENTER_PROGMODE
verifySpace();
3f72: 36 d0 rcall .+108 ; 0x3fe0 <verifySpace>
}
putch(STK_OK);
3f74: 80 e1 ldi r24, 0x10 ; 16
3f76: 01 d0 rcall .+2 ; 0x3f7a <putch>
3f78: 63 cf rjmp .-314 ; 0x3e40 <main+0x40>
00003f7a <putch>:
void putch(char ch) {
#ifndef SOFT_UART
while (!(UCSR0A & _BV(UDRE0)));
UDR0 = ch;
#else
__asm__ __volatile__ (
3f7a: 2a e0 ldi r18, 0x0A ; 10
3f7c: 30 e0 ldi r19, 0x00 ; 0
3f7e: 80 95 com r24
3f80: 08 94 sec
3f82: 10 f4 brcc .+4 ; 0x3f88 <putch+0xe>
3f84: 59 98 cbi 0x0b, 1 ; 11
3f86: 02 c0 rjmp .+4 ; 0x3f8c <putch+0x12>
3f88: 59 9a sbi 0x0b, 1 ; 11
3f8a: 00 00 nop
3f8c: 15 d0 rcall .+42 ; 0x3fb8 <uartDelay>
3f8e: 14 d0 rcall .+40 ; 0x3fb8 <uartDelay>
3f90: 86 95 lsr r24
3f92: 2a 95 dec r18
3f94: b1 f7 brne .-20 ; 0x3f82 <putch+0x8>
[uartBit] "I" (UART_TX_BIT)
:
"r25"
);
#endif
}
3f96: 08 95 ret
00003f98 <getch>:
return getch();
}
// Watchdog functions. These are only safe with interrupts turned off.
void watchdogReset() {
__asm__ __volatile__ (
3f98: a8 95 wdr
#ifdef LED_DATA_FLASH
LED_PIN |= _BV(LED);
#endif
return ch;
}
3f9a: 29 e0 ldi r18, 0x09 ; 9
3f9c: 30 e0 ldi r19, 0x00 ; 0
3f9e: 48 99 sbic 0x09, 0 ; 9
3fa0: fe cf rjmp .-4 ; 0x3f9e <getch+0x6>
3fa2: 0a d0 rcall .+20 ; 0x3fb8 <uartDelay>
3fa4: 09 d0 rcall .+18 ; 0x3fb8 <uartDelay>
3fa6: 08 d0 rcall .+16 ; 0x3fb8 <uartDelay>
3fa8: 88 94 clc
3faa: 48 99 sbic 0x09, 0 ; 9
3fac: 08 94 sec
3fae: 2a 95 dec r18
3fb0: 11 f0 breq .+4 ; 0x3fb6 <getch+0x1e>
3fb2: 87 95 ror r24
3fb4: f7 cf rjmp .-18 ; 0x3fa4 <getch+0xc>
3fb6: 08 95 ret
00003fb8 <uartDelay>:
#if UART_B_VALUE > 255
#error Baud rate too slow for soft UART
#endif
void uartDelay() {
__asm__ __volatile__ (
3fb8: 98 e0 ldi r25, 0x08 ; 8
3fba: 9a 95 dec r25
3fbc: f1 f7 brne .-4 ; 0x3fba <uartDelay+0x2>
3fbe: 08 95 ret
00003fc0 <getLen>:
} while (--count);
}
#endif
uint8_t getLen() {
getch();
3fc0: eb df rcall .-42 ; 0x3f98 <getch>
length = getch();
3fc2: ea df rcall .-44 ; 0x3f98 <getch>
3fc4: 80 93 02 02 sts 0x0202, r24
return getch();
}
3fc8: e7 cf rjmp .-50 ; 0x3f98 <getch>
00003fca <watchdogConfig>:
"wdr\n"
);
}
void watchdogConfig(uint8_t x) {
WDTCSR = _BV(WDCE) | _BV(WDE);
3fca: e0 e6 ldi r30, 0x60 ; 96
3fcc: f0 e0 ldi r31, 0x00 ; 0
3fce: 98 e1 ldi r25, 0x18 ; 24
3fd0: 90 83 st Z, r25
WDTCSR = x;
3fd2: 80 83 st Z, r24
}
3fd4: 08 95 ret
00003fd6 <appStart>:
void appStart() {
watchdogConfig(WATCHDOG_OFF);
3fd6: 80 e0 ldi r24, 0x00 ; 0
3fd8: f8 df rcall .-16 ; 0x3fca <watchdogConfig>
__asm__ __volatile__ (
3fda: ee 27 eor r30, r30
3fdc: ff 27 eor r31, r31
3fde: 09 94 ijmp
00003fe0 <verifySpace>:
do getch(); while (--count);
verifySpace();
}
void verifySpace() {
if (getch() != CRC_EOP) appStart();
3fe0: db df rcall .-74 ; 0x3f98 <getch>
3fe2: 80 32 cpi r24, 0x20 ; 32
3fe4: 09 f0 breq .+2 ; 0x3fe8 <verifySpace+0x8>
3fe6: f7 df rcall .-18 ; 0x3fd6 <appStart>
putch(STK_INSYNC);
3fe8: 84 e1 ldi r24, 0x14 ; 20
}
3fea: c7 cf rjmp .-114 ; 0x3f7a <putch>
::[count] "M" (UART_B_VALUE)
);
}
#endif
void getNch(uint8_t count) {
3fec: 1f 93 push r17
3fee: 18 2f mov r17, r24
00003ff0 <getNch>:
do getch(); while (--count);
3ff0: d3 df rcall .-90 ; 0x3f98 <getch>
3ff2: 11 50 subi r17, 0x01 ; 1
3ff4: e9 f7 brne .-6 ; 0x3ff0 <getNch>
verifySpace();
3ff6: f4 df rcall .-24 ; 0x3fe0 <verifySpace>
}
3ff8: 1f 91 pop r17
3ffa: 08 95 ret

Some files were not shown because too many files have changed in this diff Show more