Has anyone tried the Export Compiled Library Binary (sorry, typo there) command?
With an Uno, it creates a couple of .hex files,
fastBlinkUno1.ino.standard.hex
and
fastBlinkUno1.ino.with_bootloader.standard.hex
with fastBlinkUno1.ino as the sketch file for example.
I tried the one with a bootloader thinking it would load the sketch and the bootloader.
It that's the intent, it doesn't seem to work. The sketch is running, but it times out for serial downloads.
I tried serial downloads with IDEs 1.0.6, 1.6.9, 1.8, with an FTDI module on a standalone board and with a real Uno with 16U2 chip.
If I bootload the 2 boards, serial downloads work just fine.
Can anyone offer some guidance? Or am I misunderstanding what the file is?
"What does the flash look like vis-a-vis when you upload the same code via serial to a freshly bootloaded board?"
Downloading any variation of blink sketch flashes the L LED as expected.
I used different times to easily see by eye that it had changed - 1000/1000, 500/500, 250/250, 1000/100. Just something different each time.
Guess I'll take a look at the bootloader only file next and see how it compares - for 512 word bootloader, the code should be in 0xE00 - 0xFFF, which looks to be this section of code:
I seem to be losing the fuse settings then, or at least this one:
uno.bootloader.high_fuses=0xDE
11011110
7- External Reset Disable
6- debugWIRE Enable
5- Enable Serial Program and Data Downloading
4- Watchdog Timer Always On
3- EEPROM memory is preserved through the Chip Erase
2- Select Boot Size 1/0 = 256 words
1- Select Boot Size
0- Select Reset Vector
What's the best way to get those set? I don't follow where the fuse values get changed. I can see them getting checked, but I don't see where the value to be checked for is coming from. Sorry to be so dense about this, I get lost tracking where/what the different functions are doing.
@CrossRoads This may work, although it works for me without having to reset the clone Uno.
"I figured out the problem. Turns out the Arduino wasn't being reset after loading the code so it wouldn't startup properly, leading me to believe it wasn't working. I just had to hit the reset button and then the sketch code executed as normal. So, you can load the bootloader and sketch code at the same time without doing anything special and it will work as if you loaded the bootloader through ISP and sketch code through Arduino IDE. – Joey M Nov 30 '15 at 21:28"
Also if I use IDE 1.8.2 to flash the sketch and bootloader the fuses verify as 0. However they verify if I flash using an ISP programmer(Usbasp).
For example,
I download CODE00.HEX, which is just Optiboot.hex but renamed. The part is bootloaded, I can then install blink from the IDE with 1 second blinking.
I download CODE05.HEX. which is supposed to be 500mS on/off blink with bootloader. Board is blinking away.
I try to download another program from the IDE, same blink with 500mS times, it times out, see below.
Board is reset after the CODE05.HEX upload because I remove the cables and plug another in from the PC.
avrdude: Version 6.3, compiled on Dec 16 2016 at 13:33:19
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:\Arduino 1.8\hardware\tools\avr/etc/avrdude.conf"
Using Port : COM18
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x24
I can then put CODE00.HEX back on and download from the PC again. How can I modify 1.25g to get the HIGH fuse set?
Maybe here?
if (newval != 0xFF)
{
newval <<= 1;
fuses [fusenumber] &= ~0x07; // also program (clear) "boot into bootloader" bit
fuses [fusenumber] |= newval;
} // if valid
Add a define / ifdef thing to Not program bit 0, the "boot into bootloader" bit?
if (newval != 0xFF)
{
newval <<= 1;
//fuses [fusenumber] &= ~0x07; // also program (clear) "boot into bootloader" bit
fuses [fusenumber] = ~0xDE; // also program (clear) "boot into bootloader" bit 1.25h
// *****************
//fuses [fusenumber] |= newval; // 1.25g
} // if valid
Got it worked out. A former customer had worked this section for a Mega last fall, I had forgotten about.
I changed it to follow the Mega fuses and then copied the format for an Uno. Loads a sketch, and a bootloader so you can download other code now too from the IDE.
//TLZ - 09/13/16 - force new values into fuses for ATMEGA2560
if (strcmp (currentSignature.desc, "ATmega2560") == 0)
{
writeFuse (0xFF, writeLowFuseByte);
writeFuse (0xD8, writeHighFuseByte); // low bit clear for bootload kickoff
writeFuse (0xFD, writeExtendedFuseByte);
}
if (strcmp (currentSignature.desc, "ATmega328P") == 0)
{
writeFuse (0xFF, writeLowFuseByte);
writeFuse (0xDE, writeHighFuseByte); // low bit clear for bootload kickoff
writeFuse (0xF5, writeExtendedFuseByte);
}
Hi Robert,
I need to get the standalone programmer working to program bootloader+sketch.
I'm not clear what changes need to be made and where....
I suddenly NEED to have this work for a lot of UNO type boards that had the wrong bootloader loaded at the factory
I would like to show your Programmer and a good How-To on how to quickly load bootloaders, sketches and bootloader+sketches on ArduinoInfo.info IF you want to do that.
I think there are a lot of people who 'fix' Arduinos and experiment etc. I'd like to show how to load an SD card with bootloaders for most of the Arduino variants, the USB controllers on UNO, Mega etc., and a bootloader with a sketch that tests many things. What do you think??