Go Down

Topic: Arduino translated to AVR? (Read 13862 times) previous topic - next topic

Coding Badly

not too sure what exactly needs to be modified to make the ArduinoISP sketch work.  I'll look through it.


I've attached a modified version of ArduinoISP.ino that I think will work.  Please report back if it does work.  (and, of course, if it does not work)

Quote
Should I just buy an AVR ISP to program the attiny's?


A dedicated programmer is certainly a handy thing but I believe you are, in the worst case, just a few lines of code away from something that will work.

Osgeld

I just use the .22 version

I wish someone could come up with a decent list of advantages of 1.0 other than the obvious broken libraries, broken examples, larger compiled code and just general jankyness
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL

Drc3p0



I've attached a modified version of ArduinoISP.ino that I think will work.  Please report back if it does work.  (and, of course, if it does not work)



Ok, so I uploaded the new ArduinoISP sketch to the arduino.
Then I inserted the capacitor to disable reset.
Opened the Blink Sketch and changed the 13's to 0's.
double-checked the wiring to the attiny.
chose board: 'ATtiny85 @ 8 MHz (internal oscillator; BOD disabled)' and the Programmer was 'Arduino as ISP'
Uploaded successful!
but the LED on pin 5 from the attiny does not blink.  I tried several LED's w/ and w/out a resistor and there is no blink.  Even tried a different attiny85 to make sure mine wasn't damaged for some reason.

what could be causing this? 

This is the sketch that I uploaded, as well as the Verbose Output:
Code: [Select]
/*
  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(0, OUTPUT);     
}

void loop() {
  digitalWrite(0, HIGH);   // set the LED on
  delay(1000);              // wait for a second
  digitalWrite(0, LOW);    // set the LED off
  delay(1000);              // wait for a second
}



Binary sketch size: 748 bytes (of a 8192 byte maximum)
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -pattiny85 -cstk500v1 -P/dev/tty.usbmodemfa141 -b19200 -Uflash:w:/var/folders/qk/qkj6-lNJEq8p-Fz5jk0-1U+++TI/-Tmp-/build8636959170477628617.tmp/Blink.cpp.hex:i

avrdude: Version 5.11, compiled on Sep  2 2011 at 18:52:52
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/Users/Darcyneal/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/tty.usbmodemfa141
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Recv: . [15]
avrdude: stk500_getsync(): not in sync: resp=0x15

avrdude done.  Thank you.






Coding Badly

Quote
Uploaded successful!


Excellent!  Congratulations!


Small adjustment to your steps...

Quote
...

double-checked the wiring to the attiny.

chose board: 'ATtiny85 @ 8 MHz (internal oscillator; BOD disabled)' and the Programmer was 'Arduino as ISP'

Perform a Burn Bootloader to change the fuses on the ATtiny85

Uploaded successful!

...



Quote
I tried several LED's w/ and w/out a resistor and there is no blink.


Always with a resistor.  Without a resistor can damage the processor.  I know the tutorials (even the MIT ones) frequently show without but that is a mistake.


Quote
what could be causing this?


My suspicion is that the processor is running at 1 MHz.  A program compiled to run at 8 MHz will run eight times slower if the processor is running at 1 MHz.  In other words, if you wait 16 seconds (snore!) the LED will blink. 

Add the step highlighted above and I think you ready to play.

Drc3p0






double-checked the wiring to the attiny.

chose board: 'ATtiny85 @ 8 MHz (internal oscillator; BOD disabled)' and the Programmer was 'Arduino as ISP'

Perform a Burn Bootloader to change the fuses on the ATtiny85



...



Went through the steps.  Here's the error readout...

Code: [Select]
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -pattiny85 -cstk500v1 -P/dev/tty.usbmodemfa141 -b19200 -e -Uefuse:w:0xFF:m -Uhfuse:w:0xD7:m -Ulfuse:w:0xE2:m

avrdude: Version 5.11, compiled on Sep  2 2011 at 18:52:52
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/Users/Darcyneal/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/tty.usbmodemfa141
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Recv: . [15]
avrdude: stk500_getsync(): not in sync: resp=0x15

avrdude done.  Thank you.

Coding Badly

Uploaded successful!


Argh!  Stupid brain!  What I read was that you successfully uploaded to the ATtiny85.  Sorry about the confusion.  Give me a minute to review...

Coding Badly


Try this...

• Prepare the Uno exactly the same way you did the last time (upload the modified ArduinoISP sketch; connect the capacitor)

• Load and prepare the same Blink sketch you have been using (or copy-then-paste the following)...

Code: [Select]

/*
  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(0, OUTPUT);     
}

void loop() {
  digitalWrite(0, HIGH);   // set the LED on
  delay(1000);              // wait for a second
  digitalWrite(0, LOW);    // set the LED off
  delay(1000);              // wait for a second
}


• Ensure the correct board is selected [ATtiny85 @ 8 MHz (internal oscillator; BOD disabled)]

• Ensure the correct programmer is selected (Arduino as ISP)

• Ensure the correct serial port is selected

• Click Verify to ensure the sketch compiles.  If it does not compile, resolve any problems.

• Click the reset button on the Uno.  The LED on pin 13 will blink a few times.  Wait for the blinking to stop.

• Click Upload


If that works, do this...

• Click the reset button on the Uno.  The LED on pin 13 will blink a few times.  Wait for the blinking to stop.

• Click Tools / Burn Bootloader


If that works, do this...

• Click the reset button on the Uno.  The LED on pin 13 will blink a few times.  Wait for the blinking to stop.

• Click Upload


At this point, if everything went well, the ATtiny85 should be toggling pin 0 about once a second.

Erni

#37
Jun 11, 2012, 01:20 pm Last Edit: Jun 11, 2012, 01:50 pm by Erni Reason: 1
I have tried the modified sketch in reply #30 but I get this error when I try to burn bootloader or upload blink sketch,
and the Error Led pin8 is on

Code: [Select]

avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36
        Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
        Copyright (c) 2007-2009 Joerg Wunsch

        System wide configuration file is "D:\Arduino_1_0\arduino-1.0-windows\arduino-1.0\hardware/tools/avr/etc/avrdude.conf"

        Using Port                    : \\.\COM20
        Using Programmer              : stk500v1
        Overriding Baud Rate          : 19200
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Recv: . [15]
avrdude: stk500_getsync(): not in sync: resp=0x15

avrdude done.  Thank you.



I have tried to lower the Baud rate to 19200 (as far as I remember this was an advice given in another thread)


To veryfy that my setup and connections are OK, I tried the exact same setup in version 0021, with success, burning bootloader, uploading blink sketch worked as expected.

I have checked the boards.txt in the ver. 1.0 installation, it looks like this:

Code: [Select]

###########################################################################

attiny85at8.name=ATtiny85 @ 8 MHz  (internal oscillator; BOD disabled)

# The following do NOT work...
# attiny85at8.upload.using=avrispv2
# attiny85at8.upload.using=Pololu USB AVR Programmer

# The following DO work (pick one)...
attiny85at8.upload.using=arduino:arduinoisp
# attiny85at8.upload.protocol=avrispv2
# attiny85at8.upload.using=pololu
#attiny85at8.upload.using=arduino:usbasp

attiny85at8.upload.maximum_size=8192

# Default clock (slowly rising power; long delay to clock; 8 MHz internal)
# Int. RC Osc. 8 MHz; Start-up time PWRDWN/RESET: 6 CK/14 CK + 64 ms; [CKSEL=0010 SUT=10]; default value
# Brown-out detection disabled; [BODLEVEL=111]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]

attiny85at8.bootloader.low_fuses=0xE2
attiny85at8.bootloader.high_fuses=0xD7
attiny85at8.bootloader.extended_fuses=0xFF
attiny85at8.bootloader.path=empty
attiny85at8.bootloader.file=empty85at8.hex

attiny85at8.build.mcu=attiny85
attiny85at8.build.f_cpu=8000000L
attiny85at8.build.core=tiny

###########################################################################

attiny85at1.name=ATtiny85 @ 1 MHz  (internal oscillator; BOD disabled)

# The following do NOT work...
# attiny85at1.upload.using=avrispv2
# attiny85at1.upload.using=Pololu USB AVR Programmer

# The following DO work (pick one)...
attiny85at1.upload.using=arduino:arduinoisp
# attiny85at1.upload.protocol=avrispv2
# attiny85at1.upload.using=pololu

attiny85at1.upload.maximum_size=8192

# Default clock (slowly rising power; long delay to clock; 8 MHz internal; divide clock by 8)
# Int. RC Osc. 8 MHz; Start-up time PWRDWN/RESET: 6 CK/14 CK + 64 ms; [CKSEL=0010 SUT=10]; default value
# Divide clock by 8 internally; [CKDIV8=0]
# Brown-out detection disabled; [BODLEVEL=111]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]

attiny85at1.bootloader.low_fuses=0x62
attiny85at1.bootloader.high_fuses=0xD7
attiny85at1.bootloader.extended_fuses=0xFF
attiny85at1.bootloader.path=empty
attiny85at1.bootloader.file=empty85at1.hex

attiny85at1.build.mcu=attiny85
attiny85at1.build.f_cpu=1000000L
attiny85at1.build.core=tiny

###########################################################################


Edit:
This is the thread about lowering the baud rate
http://arduino.cc/forum/index.php/topic,94609.0.html

and this about changing the delay in the heartbeat
http://arduino.cc/forum/index.php/topic,108270.msg813132.html#msg813132

but as far as I can see this is implimentet in the modified sketch

Drc3p0



If that works, do this...

• Click the reset button on the Uno.  The LED on pin 13 will blink a few times.  Wait for the blinking to stop.

• Click Tools / Burn Bootloader

I went through the steps as indicated, and when I tried to burn the boot loader, I received an error message, which was the same error message that I had posted previously, and it also happens to be the same as the error message that Erni posted. 

Coding Badly


Does this version work any better?

Coding Badly

I have tried the modified sketch in reply #30 but I get this error when I try to burn bootloader or upload blink sketch,


Before posting were you having the same problem as @Drc3p0?  Did you see avrdude output identical to this...
http://arduino.cc/forum/index.php/topic,108797.msg820859.html#msg820859

Erni

Quote
Does this version work any better?


Success... it works !!, I have tried burn bootloader and uploading blink sketch .. no problems.

A minor problem, the hartbeat LED dosn't beat

Quote
Before posting were you having the same problem as @Drc3p0?  Did you see avrdude output identical to this...
http://arduino.cc/forum/index.php/topic,108797.msg820859.html#msg820859


Hmm I could check, bur maybe it is less interesting, now you have solved the problem.

Once again, thank you Coding Badly for maintaining the tiny core !

bperrybap

To resolve these sync errors (not related to auto reset)
wouldn't it be easier to just bump the RX buffer size in HardwareSerial down in the core code
to avoid all these RX buffering issues?
(even it is just temporary just to build the ArduinoISP sketch?)

You can have all the buffering in the world in the sketch but if the sketch can't drain the
hardware serial rx buffer fast enough it doesn't matter.

avrdude is bursting the data using a 128 byte pages/chunks + 1 byte cmd + 1 byte memory type + 2 bytes length + 1 bye sync char
for a total of 133 bytes.
It will wait up to 5 seconds for a sync response and another 5 seconds for a successful write.
So as long as you have 133 bytes of rx buffer you can take up to 5 seconds to burn the 128 bytes to flash
after you report "IN SYNC" back to avrdude.

As it is now, in pre 1.0 you have 128 bytes of RX buffer so it tends to work because but in 1.0 you now only have 64 bytes with the
arduino supplied core.
If the sketch can keep up it can work, but in reality it doesn't 100% of the time particularly on 1.0 using the arduino 1.0 core
and the heartbeat function.
The transfer time of a byte at 115200 is 87us
64 bytes is about 5.5ms
The heartbeat function does a delay of 20ms, depending on the timing of when that occurs,
you just blew out your HardwareSerial RX buffer even if the buffer is 128  bytes.


If you bumped the rx buffer up to 256 bytes then there would be no rx buffering issue including when using
the heartbeat function as the RX buffer could accommodate all 133 characters with no loss.

Wouldn't it be a lot simple to just bump RX buffer size by editing HardwareSerial.cpp and changing
SERIAL_BUFFER_SIZE or RX_BUFFER_SIZE (depending on core and version) from 64 to 256 ?

That way you totally eliminate any possible rx buffer overruns.

--- bill

Coding Badly

A minor problem, the hartbeat LED dosn't beat


The hearbeat code was removed.  This problem is essentially the same as the "not compatible with 1.0" problem.  The sad part is that I had offered a ready-to-use replacement that solves that problem and this one.

When I have time I'll post a replacement with a working heartbeat.


Quote
Before posting were you having the same problem as @Drc3p0?

Hmm I could check,


Don't.  We'll just wait to hear from @Drc3p0.


Quote
Once again, thank you Coding Badly for maintaining the tiny core !


You are welcome!  Hopefully, someday, version 2 will be finished.

Coding Badly

To resolve these sync errors (not related to auto reset)
wouldn't it be easier to just bump the RX buffer size in HardwareSerial down in the core code
to avoid all these RX buffering issues?


The solution is much simpler than that: Change heartbeat to blink-without-delay.  I am sad to say I am not joking.  Because of the way both sides work (avrdude sends then waits; ArduinoISP waits, buffers, then writes) a bigger buffer is really not necessary.  I've used a modified ArduinoISP, without problems, at 9600, 19200, 250K baud and 125K, 250K, 1M SPI bitrates.

Go Up