Pages: 1 2 [3] 4   Go Down
Author Topic: Question on difference between bootloaders?  (Read 5662 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Edison Member
*
Karma: 8
Posts: 1250
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

well I had a long post.. but then it seemed I had more questions..(trouble)


I think I need some help clarifying..

Difference between using Optiloader (the sketch).. using Arduino as ISP.. and choosing (for example) Uno with using the Optiboot bootloader?


If I make a new boards.txt entry.. similar to the Uno (but with some edits)... and still follow along with the same process as is I was burning a Nano or Duemilanove..... but instead choose this NEW entry I made..


its more or less the same as using Optiloader sketch.. (but instead of auto-detect stuff) I am manually choosing the bootloader 'option/entry' I want.....yes?



Is there any different between using Optiloader sketch vs choosing UNO form the boards .txt menu option and buring with Arduino as programmer?


I like that Optiboot seems to install the default BLINK sketch.. shows its 'working'.. and that the bootloader 'took' correctly...

Using the Arduno as ISP/ and burn bootloader option.. seems to give me more control over the specific bootoader option I want to burn/apply...




So if I stick with the Optiloader (sketch) way... there isnt much I can do....right?  (get that out of my head.. not the ONLY way to get/use the Optiboot bootloader....right?.. as I can manually apply/burn the UNO bootloader using the other steps...NOT the OPtiloader (sketch) approach)..

I think I get getting mixed up a bit on that...thats just different approaches for BURNING the bootloader...


Again to be clear.. doesnt matter that the board Im using as the bootloader, flashing JIG has a 16MHz crystal on it..
as long as the settings for the BOARD entry I make/use are all 'set' to be used in a 8MHz environment in the end.....correct?

that means:
optiboot_8MHz.maximum_size=30720
optiboot_8MHz.upload.speed=57600
optiboot_8MHz.build.f_cpu=8000000L


all need to be like above....?  (as well as name vaule and all prefix names changed)

a complete entry would be:

optiboot_8MHz.name=Optiboot @ 8MHz
optiboot_8MHz.upload.protocol=arduino
optiboot_8MHz.upload.maximum_size=32256
optiboot_8MHz.upload.speed=57600
optiboot_8MHz.bootloader.low_fuses=0xff
optiboot_8MHz.bootloader.high_fuses=0xde
optiboot_8MHz.bootloader.extended_fuses=0x05
optiboot_8MHz.bootloader.path=optiboot
optiboot_8MHz.bootloader.file=optiboot_atmega328.hex
optiboot_8MHz.bootloader.unlock_bits=0x3F
optiboot_8MHz.bootloader.lock_bits=0x0F
optiboot_8MHz.build.mcu=atmega328p
optiboot_8MHz.build.f_cpu=8000000L
optiboot_8MHz.build.core=arduino
optiboot_8MHz.build.variant=standard


yes?


Now..  I would use this option in my BOARDS menu if I was trying to burn an 8MHz bootloader to a FINAL circuit that will use an 8MHz clock...correct?....

Even if the board I was using to flash the chip was a 16MHz or a 8MHz board (as the intermediate JIG flashing board).. wouldnt matter.. as the FINAL board is still a 8MHz clocked circuit.....right?

I would not (as I thought earlier) have 2 different BOARD entries based on the clock/oscillator of the JIG board that will be used in flashing...(so Im clear)

* end board is still 8MHz board
* intermediate board used to flash blank chip is 16MHz... still same BOARDS entry?
* intermediate board used to flash blank chip is 8MHz... still same BOARDS entry?

(Im not talking about testing the boards.. purely flashing at this point only)..


I think Im just confusing myself more and more..LOL.. lots of info to digest here..

I was hoping it was easier than this!  smiley  

but ultimately.. flashing the chip using Optiloader (sketch).. gave it 16MHz clock..

I forget.. can I just put this in the 8MHz board and it'll work at half speed? (and hence the same...without problems?)
or do I need to go back.. make a new BOARD entry using the Optiboot bootloader (ie: edited UNO entry).. change the upload speed, to be half...and change the f_cpu to: 800000000000L .....  and re-flash (manually choosing that form BOARDS menu and Arduino as ISP)..
so that when I do remove the chip from the 16MHz JIG board..and put in the 8MHz resonator board.. there will be no problems?

(I need a nap!)



Logged


0
Offline Offline
Edison Member
*
Karma: 8
Posts: 1250
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

"Flashing a chip" and "running a bootloader" are two different instances. You may flash a chip with "any recommended crystal value" connected to it, afaik (provided you are using a standard programming method).

The processor must be running, so the set fuse values must correspond to the crystal used during programming.  Is so happens that the fuse values for 8MHz and 16MHz are the same, so in this case we can ignore the fact that we're using the "wrong" clock during programming.


ahh.. ok.. so it doesnt matter that Im using the 16MHz JIG board to flash these blank chips?  (as fuses are the same)

and I 'should' keep on using the Optiloader (sketch)??

or I should go back to Arduino as ISP.. and choose a new BOARDS.txt entry based of edited UNO entry..with these changes in it:

optiboot_8MHz.maximum_size=30720
optiboot_8MHz.upload.speed=57600
optiboot_8MHz.build.f_cpu=8000000L


and again.. it doesnt matter than Im using the 16MHz JIG board to flash bootloader with,.. as these settings are really here for the END (final) 8MHz PCB board the newly flashed chip is going in?

Im 'sorta' (faking) my own 8MHz version of the Optiboot bootloader by doing this..yes?  (I know not a legit, recompiled version like you said.. but close)



on the other hand though...

if the 16MHz JIG BOARD has no bearing this scenario at all..... then maybe just choosing the Arduino Pro/Pro-Mini from the board menu is more straight forward and purpose made for 8MHz..
« Last Edit: April 09, 2013, 03:17:38 pm by xl97 » Logged


Offline Offline
Faraday Member
**
Karma: 66
Posts: 2578
Now, More Than Ever
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Otherwise they do much the same thing.
ATmegaBOOT supports EEPROM.  Optiboot doesn't (and in fact will do bad things if you try to write EEPROM using it.)

So, no using EEPROM.h with a Uno or just if bootloaded with Optiboot?

And I shouldn't bootload a Nano (Gravitech) or Duemilenove with Optiboot?
Logged

"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 548
Posts: 27383
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

How does the bootloader impact any libraries the sketch uses?
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17303
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Otherwise they do much the same thing.
ATmegaBOOT supports EEPROM.  Optiboot doesn't (and in fact will do bad things if you try to write EEPROM using it.)

So, no using EEPROM.h with a Uno or just if bootloaded with Optiboot?

And I shouldn't bootload a Nano (Gravitech) or Duemilenove with Optiboot?

I run optiboot on both my Nano and Duemilenove boards, no problems.

Lefty
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 137
Posts: 6792
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
How does the bootloader impact any libraries the sketch uses?
It shouldn't impact it at all.  On the Arduino, the bootloader is implemented as a completely separate entity.  Arduino code never uses any functions from the bootloader, and the bootloader  attempts to start the sketch with the AVR in a close to a "just reset" state as possible.

One possible exception is that in v4.6 (not actually released on any Arduino), a patch was added that permits the sketch to determine the "reset cause" (ie powerup vs RESET)
http://code.google.com/p/optiboot/issues/detail?id=66&can=1
http://code.google.com/p/optiboot/source/detail?r=4c68314d6b15eae1bad09dd4591e630f367cd679
Logged

0
Offline Offline
Edison Member
*
Karma: 8
Posts: 1250
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I guess I have information overload at this point!  lol..


blank ATmega328p_AU (smd) chips

the only 'jig' I have is a 16MHz board: http://thecustomgeek.com/2012/07/09/one-square-inch-of-goodness/

However.. the END board this chip is getting installed into will be running/using an external 8MHz resonator.


Still unclear if I need to make a new BOARDS.txt entry... to somehow get a version of Optiboot on the chip?

Or

if I just choose Arduino Pro/Pro-Mini @ +3.3v / 8Mhz??

That would best match the END board specs  (+3.3v @ 8MHz)..

but DOES NOT MATCH the JIG/BOARD I am using the 'flash' this chip?


I've sorta been all over the map here.. LOL.. 

does the clock/crystal/oscillator in the board used to FLASH the chip matter at all?  (I think it was stated no..but am unclear)

using a 16MHz board to flash a chip that is going into a 8Mhz board is really confusing me here...  as to the exact steps a noob like myself should take here. smiley

thanks!
Logged


Rapa Nui
Offline Offline
Edison Member
*
Karma: 60
Posts: 2086
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Would you mind my asking you how do you plan to use the "goodness" board for flashing the bare blank 328p-au chip?
Logged

0
Offline Offline
Edison Member
*
Karma: 8
Posts: 1250
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@Pito-

sure..

the board came pre-assembled WITH-OUT the ATmega328P-AU soldered on...  (just the open/bare pads)

I have just been holding the chip down with my finger or weight or some kind and flashing the bootoader.


Logged


0
Offline Offline
Edison Member
*
Karma: 8
Posts: 1250
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

haha..ok.. hoping to get some time to jump back on this project tomorrow/this weekend.. smiley

still not clear

what will happen if I take this ATmega328P-AU chip that is flashed with Optiboot  (so Im guessing 16MHz) using the Optiloader sketch that was uploaded to my Arduino Duemilanove 2009 board....

the ATmega328P-AU chip was a blank.. and was placed (held in place by hand) in the 1ISoG board (jig)...


what will happen if I put this chip in a PCB that has a 8MHz resonator?  (not not a 16MHz crystal like the board had was used to flash bootloader to the chip and Optiboot is only 16MHz bootloader)


not work?

only work at half speed? (half of 16MHz = 8MHz would be ok then)


or should I just try using the Arduino bootloader and use the Pro/Pro-Mini.. which is spec'd at 8MHz.....??

Q: will I have a problem choosing the 8MHz Pro/Pro-Mini bootloader option when Im using a 16MHz board to flash?  (no because the fuse settings are the same?)

thanks!


Logged


SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 137
Posts: 6792
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
what will happen if I put this chip in a PCB that has a 8MHz resonator?
It should work (the bootloader only) at half speed.  So uploading sketches should work at 57600bps, for example.
This should have no effect on sketches, which could pick up a correct clock rate (8MHz) from a boards.txt modification, and run "correctly" at that speed.
Logged

0
Offline Offline
Edison Member
*
Karma: 8
Posts: 1250
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok.. so I know I have done the correct steps...

1.) Took Arduino Duemilanove 2009 board, uploaded Optiloader sketch.
2.) Connected the "JIG" board (1ISoG board..16MHz crystal on-board) to the Duemilanove
3.) Held a blank ATmega 328P-AU chip on the pads of the JIG board...
4.) RESET the Duemilanove... and watched serial monitor of the Optiloader sketch.  Bing, bang, boom...seems like it worked, as I get fuses set message at end... and then the blinking led on pin13.. (default sketch uploaded as well?)

At this point I have a (more less) UNO 'chip'.. (Optiloader bootloader @ 16Mhz...yes)


I then make a new BOARDS .txt entry..

Quote
optiboot_8MHz.name=Optiboot @ 8MHz
optiboot_8MHz.upload.protocol=arduino
optiboot_8MHz.upload.maximum_size=32256
optiboot_8MHz.upload.speed=57600
optiboot_8MHz.bootloader.low_fuses=0xff
optiboot_8MHz.bootloader.high_fuses=0xde
optiboot_8MHz.bootloader.extended_fuses=0x05
optiboot_8MHz.bootloader.path=optiboot
optiboot_8MHz.bootloader.file=optiboot_atmega328.hex
optiboot_8MHz.bootloader.unlock_bits=0x3F
optiboot_8MHz.bootloader.lock_bits=0x0F
optiboot_8MHz.build.mcu=atmega328p
optiboot_8MHz.build.f_cpu=8000000L
optiboot_8MHz.build.core=arduino
optiboot_8MHz.build.variant=standard



Install/solder the chip I just flashed into its final/target PCB.. which is set up to with an external 8MHz resonator...

connect to this PCB's FTDI header

open up Arduino IDE...  (make sure correct port is selected)

for the BOARDS choice.. I would then select this option: Optiboot @ 8MHz  from the menu.. whenever I wanted to upload sketches.


Do I have this right?




ALTERNATELY....

If I didnt ant to use the Optiloader sketch.. but instead wanted to take my Duemilanove 2009 board.. upload the Arduino as ISP from example sketches...

select right com port
select Duemilanove 2009 form boards
upload Arduino as ISP

(power down)

then..

connect my JIG board (1ISoG board) to Arduino Duemilanove 2009 board with Arduino as ISP sketch on it..

power everything on...


open Arduino IDE..

select correct com port

from boards menu, select the:   Optiboot @ 8MHz   entry?  

then BURN BOOTLOADER?

(assuming that wouldnt work?)


then.....

for uploading sketches.. install chip in its final PCB.. and follow same FTDI steps as above?

sorry for beating a dead horse here.. LOL

I just want to be clear on what I should be doing.. or eve the best approach... (knowing the end goal)


thanks!





edit:

I have another 'question'...

going forward here.. I am planning to re-design this 'final' pcb of my buddies to include a ICSP header of some kind....

so I can just assembled the whole board.. then flash bootloader in line.. as well as FTDI on the other headers..etc.

these will be running at +3.3v & 8MHZ resonators still... 

how can I go about getting a 8MHz version of Optiboot..without any messing around?

direct flash of bootloader to a 8MHz board..

is it as simple as a 'board.txt' edit?  like above?...

or do I need to re-compile the Optiboot bootloader (like previously mentioned?....and which I have no clue on how to do!)  LOL


thanks!
« Last Edit: April 12, 2013, 09:52:18 am by xl97 » Logged


Rapa Nui
Offline Offline
Edison Member
*
Karma: 60
Posts: 2086
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is that an issue for you to spend a while with building your own optiboot? You have got everything there already, so download the 5.0 zip file and omake it.. It is a 30minutes of effort worst case..
Just make a list of your requirements (mcu type, oscillator type, frequency, upload baudrate, LED pin number, number of flashes when entering the bootlader, upload process indication on the LED) and go for it.. People will help you when in doubt..
« Last Edit: April 12, 2013, 03:57:47 pm by pito » Logged

0
Offline Offline
Edison Member
*
Karma: 8
Posts: 1250
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have never even attempted to do anything liek this before.. LOL

I only mentioned it because it was brought up by another member..   smiley

Im open to whatever.. and willing to 'try'.  smiley-wink


Download the v5.0 (source) for Optiboot.....yes?   (I think there was a link just posted.. so I'll grab it)

but then...??

(make list you said)



mcu type = ATmega328P-AU
oscillator type = external ?
frequency  = 8MHz
upload baudrate = ??  (would this be the upload speed 57600?)
LED pin # = 13
# of flashes = anything

really just whatever is for +3.3v/8MHz  like the other.. (but for optiboot) hahaha..

but lets say I 'make' this file.. (somehow manage to make this happen correctly)..

can I flash this bootloader to a blank chip that is a 16MHz 'jig'?


the true problem is having a 16MHz board as a JIG.. but 8MHz board in the final usage/sketch uploading..etc..


whatever is best way to get me 'there'  smiley


thanks!


Logged


Rapa Nui
Offline Offline
Edison Member
*
Karma: 60
Posts: 2086
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
can I flash this bootloader to a blank chip that is a 16MHz 'jig'?
Yes, you can place your vanilla 328p smd chip onto the pads of your jig with 16MHz crystal and flash the bootloader..

I would highly recommend you to spend the effort and learn how to make your own optiboot version. I've just tried to do the same (I did it few times before however smiley ) and it took me 4 minutes.

Take out the "optiboot" folder from the "optiboot-v5.0.zip", rename it to "optiboot50" and put it into "../bootloaders" folder within your Arduino IDE folder tree (see below my example).

This is your definition for 8MHz (insert it into "../optiboot50/Makefile" file, ie. around line n.245 ):
Code:
atmega328_8M: TARGET = atmega328
atmega328_8M: MCU_TARGET = atmega328p
atmega328_8M: CFLAGS += $(COMMON_OPTIONS)
atmega328_8M: AVR_FREQ ?= 8000000L
atmega328_8M: LDSECTIONS  = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
atmega328_8M: $(PROGRAM)_atmega328_8M.hex
atmega328_8M: $(PROGRAM)_atmega328_8M.lst

When running XP, do Start->Run->cmd, change directory to the "../bootloaders/optiboot50 and type

Code:
omake atmega328_8M BAUD_RATE=57600 LED=B5

It may build the hex for you - "../bootloaders/optiboot50/optiboot_atmega328_8M.hex".
There could be an issue with path to the compiler, just ask then..

My example with your setup:
Code:
D:\ProgramFiles\arduino\arduino-152\hardware\arduino\avr\bootloaders\optiboot50>omake atmega328_8M BAUD_RATE=57600 LED=B5

D:\ProgramFiles\arduino\arduino-152\hardware\arduino\avr\bootloaders\optiboot50>..\..\..\..\tools\avr\utils\bin\make OS=windows ENV=arduino atmega328_8M BAUD_RATE=57600 LED=B5
BAUD RATE CHECK: Desired: 57600, Real: 58823, UBRRL = 16, Error=-2.1%
../../../../tools/avr/bin/avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -ms
hort-calls -mmcu=atmega328p -DF_CPU=8000000L  -DBAUD_RATE=57600 -DLED_START_FLASHES=3    -DLED=B5 -c -o optiboot.o optiboot.c
optiboot.c:256:2: warning: #warning BAUD_RATE error greater than -2%
../../../../tools/avr/bin/avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -ms
hort-calls -mmcu=atmega328p -DF_CPU=8000000L  -DBAUD_RATE=57600 -DLED_START_FLASHES=3    -DLED=B5 -W l,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe -Wl,--relax -Wl,--gc-sections -nostartfiles -nostdlib -o optiboot_atmega328_8M.elf optiboot.o
../../../../tools/avr/bin/avr-size optiboot_atmega328_8M.elf
   text    data     bss     dec     hex filename
    482       0       0     482     1e2 optiboot_atmega328_8M.elf
../../../../tools/avr/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=all
oc,load -O ihex optiboot_atmega328_8M.elf optiboot_atmega328_8M.hex
..\..\..\..\tools\avr\bin\avr-objdump -h -S optiboot_atmega328_8M.elf > optiboot_atmega328_8M.lst
rm optiboot.o optiboot_atmega328_8M.elf

D:\ProgramFiles\arduino\arduino-152\hardware\arduino\avr\bootloaders\optiboot50>

D:\ProgramFiles\arduino\arduino-152\hardware\arduino\avr\bootloaders\optiboot50>dir
 Volume in drive D is ND
 
 Directory of D:\ProgramFiles\arduino\arduino-152\hardware\arduino\avr\bootloaders\optiboot50

04/12/2013  23:41    <DIR>          .
04/12/2013  23:41    <DIR>          ..
04/04/2013  18:42             1,563 baudcheck.c
04/12/2013  23:41               700 baudcheck.tmp.sh
04/04/2013  18:42            34,011 boot.h
04/04/2013  18:42               372 makeall
04/12/2013  23:14            18,874 Makefile
04/04/2013  18:42             2,640 Makefile.isp
04/04/2013  18:42               111 omake
04/12/2013  23:13                63 omake.bat
04/04/2013  18:42            29,289 optiboot.c
04/04/2013  18:42             1,443 optiboot_atmega1280.hex
04/04/2013  18:42            19,513 optiboot_atmega1280.lst
04/04/2013  18:42             1,418 optiboot_atmega328.hex
04/04/2013  18:42            19,758 optiboot_atmega328.lst
04/12/2013  23:41             1,418 optiboot_atmega328_8M.hex
04/12/2013  23:41            20,347 optiboot_atmega328_8M.lst
04/04/2013  18:42             1,418 optiboot_atmega328_pro_8MHz.hex
04/04/2013  18:42            19,757 optiboot_atmega328_pro_8MHz.lst
04/04/2013  18:42             1,418 optiboot_atmega644p.hex
04/04/2013  18:42            19,757 optiboot_atmega644p.lst
04/04/2013  18:42            19,755 optiboot_diecimila.lst
04/04/2013  18:42             1,418 optiboot_lilypad.hex
04/04/2013  18:42            19,754 optiboot_lilypad.lst
04/04/2013  18:42             1,757 optiboot_luminet.hex
04/04/2013  18:42            23,026 optiboot_luminet.lst
04/04/2013  18:42             1,418 optiboot_pro_16MHz.hex
04/04/2013  18:42            19,755 optiboot_pro_16MHz.lst
04/04/2013  18:42             1,418 optiboot_pro_20mhz.hex
04/04/2013  18:42            19,755 optiboot_pro_20mhz.lst
04/04/2013  18:42             1,418 optiboot_pro_8MHz.hex
04/04/2013  18:42            19,754 optiboot_pro_8MHz.lst
04/04/2013  18:42            15,380 pin_defs.h
04/04/2013  18:42             3,902 README.TXT
04/04/2013  18:42             1,636 stk500.h
              33 File(s)        344,016 bytes
               2 Dir(s)  59,484,752,056,320 bytes free

D:\ProgramFiles\arduino\arduino-152\hardware\arduino\avr\bootloaders\optiboot50>

The oscillator type (and other stuff) is set with the fuses. So when burning in the .hex you have to flash the fuses as well..







* optiboot_atmega328_8M.hex (1.38 KB - downloaded 11 times.)
« Last Edit: April 12, 2013, 05:58:51 pm by pito » Logged

Pages: 1 2 [3] 4   Go Up
Jump to: