Sketch:Export Compiled Library

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?

Thanks
Robert/Cross Roads

My understanding of that file is the same as yours.

I use it with the tiny's with virtualboot, so the one with bootloader is expected to be totally bogus, so I never tested the ones with bootloader.

What does the flash look like vis-a-vis when you upload the same code via serial to a freshly bootloaded board?

"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.

Hi Robert,

Could it be a location of code problem? The bootloader has to start in a specific location, right?

This just sounds like the type of problem I had hacking IBM PC's in Ancient History...
Hmmm...

I mean, the contents of the flash as read via ISP

This is the blink with bootloader file being loaded:

:100000000C945C000C946E000C946E000C946E00CA
:100010000C946E000C946E000C946E000C946E00A8
:100020000C946E000C946E000C946E000C946E0098
:100030000C946E000C946E000C946E000C946E0088
:100040000C9414010C946E000C946E000C946E00D1
:100050000C946E000C946E000C946E000C946E0068
:100060000C946E000C946E00000000002400270029
:100070002A0000000000250028002B0004040404CE
:100080000404040402020202020203030303030342
:10009000010204081020408001020408102001021F
:1000A00004081020000000080002010000030407FB
:1000B000000000000000000011241FBECFEFD8E0B8
:1000C000DEBFCDBF21E0A0E0B1E001C01D92A930AC
:1000D000B207E1F70E945E010C94CD010C94000080
:1000E000E1EBF0E02491EDE9F0E09491E9E8F0E053
:1000F000E491EE2309F43BC0222339F1233091F03F
:1001000038F42130A9F0223001F524B52F7D12C03A
:10011000273091F02830A1F02430B9F420918000EC
:100120002F7D03C0209180002F77209380000DC089
:1001300024B52F7724BD09C02091B0002F7703C0CC
:100140002091B0002F7D2093B000F0E0EE0FFF1F54
:10015000EE58FF4FA591B4912FB7F894EC9181110F
:1001600003C090959E2301C09E2B9C932FBF0895A2
:100170003FB7F8948091050190910601A091070185
:10018000B091080126B5A89B05C02F3F19F0019634
:10019000A11DB11D3FBFBA2FA92F982F8827820F0D
:1001A000911DA11DB11DBC01CD0142E0660F771F5D
:1001B000881F991F4A95D1F708958F929F92AF9209
:1001C000BF92CF92DF92EF92FF920E94B8004B0154
:1001D0005C018AEFC82ED12CE12CF12C0E94B800D2
:1001E000DC01CB0188199909AA09BB09883E934013
:1001F000A105B10558F021E0C21AD108E108F108C3
:1002000088EE880E83E0981EA11CB11CC114D10495
:10021000E104F10419F7FF90EF90DF90CF90BF90C9
:10022000AF909F908F9008951F920F920FB60F92EC
:1002300011242F933F938F939F93AF93BF938091FC
:10024000010190910201A0910301B091040130914C
:10025000000123E0230F2D3720F40196A11DB11DCD
:1002600005C026E8230F0296A11DB11D20930001B1
:100270008093010190930201A0930301B0930401C4
:100280008091050190910601A0910701B0910801AC
:100290000196A11DB11D8093050190930601A093C5
:1002A0000701B0930801BF91AF919F918F913F914A
:1002B0002F910F900FBE0F901F901895789484B5D2
:1002C000826084BD84B5816084BD85B5826085BD52
:1002D00085B5816085BD80916E00816080936E00E0
:1002E00010928100809181008260809381008091D2
:1002F0008100816080938100809180008160809383
:1003000080008091B10084608093B1008091B00042
:1003100081608093B00080917A00846080937A003D
:1003200080917A00826080937A0080917A00816067
:1003300080937A0080917A00806880937A0010928E
:10034000C100EDE9F0E02491E9E8F0E08491882330
:1003500099F090E0880F991FFC01E859FF4FA59193
:10036000B491FC01EE58FF4F859194918FB7F894AA
:10037000EC91E22BEC938FBFC0E0D0E081E00E94D3
:1003800070000E94DD0080E00E9470000E94DD008D
:0E0390002097A1F30E940000F1CFF894FFCF58
:107E0000112484B714BE81FFF0D085E080938100F7
:107E100082E08093C00088E18093C10086E0809377
:107E2000C20080E18093C4008EE0C9D0259A86E02C
:107E300020E33CEF91E0309385002093840096BBD3
:107E4000B09BFECF1D9AA8958150A9F7CC24DD24C4
:107E500088248394B5E0AB2EA1E19A2EF3E0BF2EE7
:107E6000A2D0813461F49FD0082FAFD0023811F036
:107E7000013811F484E001C083E08DD089C08234E0
:107E800011F484E103C0853419F485E0A6D080C0E4
:107E9000853579F488D0E82EFF2485D0082F10E0AE
:107EA000102F00270E291F29000F111F8ED06801E7
:107EB0006FC0863521F484E090D080E0DECF843638
:107EC00009F040C070D06FD0082F6DD080E0C81688
:107ED00080E7D80618F4F601B7BEE895C0E0D1E017
:107EE00062D089930C17E1F7F0E0CF16F0E7DF06D8
:107EF00018F0F601B7BEE89568D007B600FCFDCFD4
:107F0000A601A0E0B1E02C9130E011968C91119780
:107F100090E0982F8827822B932B1296FA010C0160
:107F200087BEE89511244E5F5F4FF1E0A038BF0790
:107F300051F7F601A7BEE89507B600FCFDCF97BE46
:107F4000E89526C08437B1F42ED02DD0F82E2BD052
:107F50003CD0F601EF2C8F010F5F1F4F84911BD097
:107F6000EA94F801C1F70894C11CD11CFA94CF0C13
:107F7000D11C0EC0853739F428D08EE10CD085E9AC
:107F80000AD08FE07ACF813511F488E018D01DD067
:107F900080E101D065CF982F8091C00085FFFCCF94
:107FA0009093C60008958091C00087FFFCCF809118
:107FB000C00084FD01C0A8958091C6000895E0E648
:107FC000F0E098E1908380830895EDDF803219F02E
:107FD00088E0F5DFFFCF84E1DECF1F93182FE3DFCA
:107FE0001150E9F7F2DF1F91089580E0E8DFEE27F6
:047FF000FF270994CA
:027FFE00040479
:0400000300007E007B
:00000001FF

I did this procedure a few weeks, and flashed the _with_bootloader.hex file to an ATmega324A and ATmega1284 using an avrispmkii. Worked like a charm :slight_smile:

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:

:107E0000112484B714BE81FFF0D085E080938100F7
:107E100082E08093C00088E18093C10086E0809377
:107E2000C20080E18093C4008EE0C9D0259A86E02C
:107E300020E33CEF91E0309385002093840096BBD3
:107E4000B09BFECF1D9AA8958150A9F7CC24DD24C4
:107E500088248394B5E0AB2EA1E19A2EF3E0BF2EE7
:107E6000A2D0813461F49FD0082FAFD0023811F036
:107E7000013811F484E001C083E08DD089C08234E0
:107E800011F484E103C0853419F485E0A6D080C0E4
:107E9000853579F488D0E82EFF2485D0082F10E0AE
:107EA000102F00270E291F29000F111F8ED06801E7
:107EB0006FC0863521F484E090D080E0DECF843638
:107EC00009F040C070D06FD0082F6DD080E0C81688
:107ED00080E7D80618F4F601B7BEE895C0E0D1E017
:107EE00062D089930C17E1F7F0E0CF16F0E7DF06D8
:107EF00018F0F601B7BEE89568D007B600FCFDCFD4
:107F0000A601A0E0B1E02C9130E011968C91119780
:107F100090E0982F8827822B932B1296FA010C0160
:107F200087BEE89511244E5F5F4FF1E0A038BF0790
:107F300051F7F601A7BEE89507B600FCFDCF97BE46
:107F4000E89526C08437B1F42ED02DD0F82E2BD052
:107F50003CD0F601EF2C8F010F5F1F4F84911BD097
:107F6000EA94F801C1F70894C11CD11CFA94CF0C13
:107F7000D11C0EC0853739F428D08EE10CD085E9AC
:107F80000AD08FE07ACF813511F488E018D01DD067
:107F900080E101D065CF982F8091C00085FFFCCF94
:107FA0009093C60008958091C00087FFFCCF809118
:107FB000C00084FD01C0A8958091C6000895E0E648
:107FC000F0E098E1908380830895EDDF803219F02E
:107FD00088E0F5DFFFCF84E1DECF1F93182FE3DFCA
:107FE0001150E9F7F2DF1F91089580E0E8DFEE27F6
:047FF000FF270994CA
:027FFE00040479
:0400000300007E007B
:00000001FF

Optiboot from 1.6.5:

:107E0000112484B714BE81FFF0D085E080938100F7

 :107E100082E08093C00088E18093C10086E0809377

 :107E2000C20080E18093C4008EE0C9D0259A86E02C

 :107E300020E33CEF91E0309385002093840096BBD3

 :107E4000B09BFECF1D9AA8958150A9F7CC24DD24C4

 :107E500088248394B5E0AB2EA1E19A2EF3E0BF2EE7

 :107E6000A2D0813461F49FD0082FAFD0023811F036

 :107E7000013811F484E001C083E08DD089C08234E0

 :107E800011F484E103C0853419F485E0A6D080C0E4

 :107E9000853579F488D0E82EFF2485D0082F10E0AE

 :107EA000102F00270E291F29000F111F8ED06801E7

 :107EB0006FC0863521F484E090D080E0DECF843638

 :107EC00009F040C070D06FD0082F6DD080E0C81688

 :107ED00080E7D80618F4F601B7BEE895C0E0D1E017

 :107EE00062D089930C17E1F7F0E0CF16F0E7DF06D8

 :107EF00018F0F601B7BEE89568D007B600FCFDCFD4

 :107F0000A601A0E0B1E02C9130E011968C91119780

 :107F100090E0982F8827822B932B1296FA010C0160

 :107F200087BEE89511244E5F5F4FF1E0A038BF0790

 :107F300051F7F601A7BEE89507B600FCFDCF97BE46

 :107F4000E89526C08437B1F42ED02DD0F82E2BD052

 :107F50003CD0F601EF2C8F010F5F1F4F84911BD097

 :107F6000EA94F801C1F70894C11CD11CFA94CF0C13

 :107F7000D11C0EC0853739F428D08EE10CD085E9AC

 :107F80000AD08FE07ACF813511F488E018D01DD067

 :107F900080E101D065CF982F8091C00085FFFCCF94

 :107FA0009093C60008958091C00087FFFCCF809118

 :107FB000C00084FD01C0A8958091C6000895E0E648

 :107FC000F0E098E1908380830895EDDF803219F02E

 :107FD00088E0F5DFFFCF84E1DECF1F93182FE3DFCA

 :107FE0001150E9F7F2DF1F91089580E0E8DFEE27F6

 :047FF000FF270994CA

 :027FFE00040479

 :0400000300007E007B

 :00000001FF

Looks like the same stuff to me. Fuses then?

uno.bootloader.low_fuses=0xFF

uno.bootloader.high_fuses=0xDE

uno.bootloader.extended_fuses=0x05

uno.bootloader.unlock_bits=0x3F

uno.bootloader.lock_bits=0x0F

vs
What Nick has in here for the hex uploader program. Been a while since I looked at this for this card:

http://www.crossroadsfencing.com/BobuinoRev17/

If your hex file has the sketch and the bootloader (and it looks like it does) you need to make sure that your fuses tell it to run the bootloader.

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.

hexFileUploader1.25g.txt (46.6 KB)

@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).

That's a simple enough thing to try. Will check when I get home.

uno.bootloader.high_fuses=0xDE

That should boot into the bootloader.

Agreed, where do I put in the 1.25g code?

Resetting alone does not kickoff the bootloader per reply #10.

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?

Brute force, this didn't do it:

    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

This works for me on Linux and makes sure everything is setup right for a Uno.

avrdude -patmega328p -cusbasp -Pusb -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m
avrdude -patmega328p -cusbasp -Pusb -Uflash:w:/home/kprims/Blink/Blink.ino.with_bootloader.standard.hex:i -Ulock:w:0x0F:m

Thanks, not really what I need tho. I have a standalone programmer, code runs on a '328P board.
The code behind in the Programmer:

The board

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

:frowning:

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??

Thanks!

Regards, Terry King
...In The Woods in Vermont, USA
terry@yourduino.com