Pages: [1] 2   Go Down
Author Topic: Loading schetches on a fresh atmega8 with no bootloader.  (Read 4688 times)
0 Members and 1 Guest are viewing this topic.
Gatineau, Qu
Offline Offline
Jr. Member
**
Karma: 1
Posts: 94
Did you Arduino today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can I use my Uno and load the Arduino as ISP sketch on it.
Then use that Uno board to load a sketch to a fresh atmega8 (or any other) without any bootloader on it

If so...How would I do that?

If I understand things, the bootloader is used to program the controler without an ISP. Witch is great when developing with Uno board.

But after all is done and I want to put my sketch on a stand alone chip I'm going to use in my final build.
I don't really need a bootloader.......right?

Please educate me  smiley-red
Logged

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

Quote
I don't really need a bootloader.......right?

No you don't. However many of us develop our sketches on our arduino board and when done just pop the chip and install it in our standalone project and just install a fresh $6 328 chip (with bootloader) in the arduino. If a later update is needed, just pop the chip from the project and reinstall on the arduino board. That way no ISP programmer required nor a lot of thinking about how to burn the sketch into the chip without a bootloader.

So there are different methods of accomplishing the same task, and unless one needs the small space that the bootloader code takes up, I think it's just a choice made by the user on how they want to manage their projects.

Lefty
Logged

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

Sketches should work if programmed via ISP, as long as you have the fuses set NOT to start in the bootloader section.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 207
Posts: 12909
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@westfw...  Is that the "Boot Reset vector Enabled (default address=$0000); [BOOTRST=0]" fuse?
Logged

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

Yes.  Note that fuse value 1 is "not programmed", so you want BOOTRST=1 to disable the bootloader.
Logged

Gatineau, Qu
Offline Offline
Jr. Member
**
Karma: 1
Posts: 94
Did you Arduino today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK (please excuse my ignorance).

So If I wanted to use the Arduino IDE, load the Arduino as ISP to the Uno.
Then open my sketch and load it to a new chip (on a breadboard) that as no bootloader.
What do I need to do?

I guess it's a lot like loading the bootloader ..... but that is done by simply selecting the "Burn bootloader /w Arduino as ISP" option.

I guess what I'm trying to do would be more complicated........but I'm willing to try.  smiley-red
Logged

Offline Offline
Jr. Member
**
Karma: 1
Posts: 54
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Wait... I thought we had to have the Arduino bootloader on the chip to read the compiled sketches because I thought the firmware translated a few things..... Damn. If this is the case I just wasted a whole lot of time on well... Actually not wasted but could have been doing something else semi-productive  smiley-money

But you do have to have the bootloader to interact through rx and tx over serial with the IDE though correct? I was wondering if there was a hack to make the IDE use an avr programmer instead of just sending straight to serial.
Logged

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

No, the bootloader and the Arduino core are entirely separate, and the bootloader is not needed to run any sketches.

You can probably edit boards.txt and have the IDE use any programmer supported by AVRDUDE (which is a lot of choices!)  It already uses different protocols for Uno vs Mega...
Logged

Gatineau, Qu
Offline Offline
Jr. Member
**
Karma: 1
Posts: 94
Did you Arduino today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sketches should work if programmed via ISP, as long as you have the fuses set NOT to start in the bootloader section.


Sorry.....but I'm lost smiley-red
Logged

Offline Offline
Jr. Member
**
Karma: 1
Posts: 54
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sketches should work if programmed via ISP, as long as you have the fuses set NOT to start in the bootloader section.


Sorry.....but I'm lost smiley-red

1st - westfw, again thank you for clearing up some things man. I truly appreciate your knowledge.
2nd - on to help this guy out.

When dealing with avr microcontrollers you have what are called switches that are just codes that do certain things to the chip to either help it operate in certain ways, lock people from trying to reflash the chip or to try to pull code from the chip, or make it skip things, and etc.

There are 3 types of switches - high, low, and e-lock fuses.

Per each chip model, they differ both in what switches the chip comes with, and what address each switch is located (in software. you'll see in this example)

So say you want to make an Atmega8 use an external oscillator/crystal of 8 to 12mhz, you would set that fuse by writing the binary address -
0xF8

*These switches are also referred to as lock bits*

You can find a calculator to set them what you want them to be here:
http://frank.circleofcurrent.com/fusecalc/fusecalc.php

BE CAREFUL WHEN USING THIS! If you don't know what you want to use or don't understand certain sections that you chose for your chip, consult with us in the forums to ensure the settings are proper. One error can efficiently lock you out of the chip (which you could only unlock with an HVP (High Voltage Programmer) which are easy enough to make, but it'll cost you some cash in making one, and set you back a little while waiting on the parts to get to you unless you have them laying around.

Now on to bootloaders and etc.

Bootloaders are basically applications that can reside in a section of the chip you can "lock" into place (in the very beginning of the chip memory). You have to essentially "unlock" that portion of the chip first before you can burn the bootloader into place, and then you have to "lock" that bootloader into memory because if you do not, then when you try to upload a sketch to the chip, it will erase the bootloader *if you need that extra memory that a bootloader would take up, you could just unlock it, and just not re-lock the bootloader section so you could have more application space available to upload to the chip.

What does a bootloader do? Essentially they can be used for a number of reasons, but one of the more prominent reasons are to run a predefined set of instructions on boot to set the system up to help do a defined task. It could be to test the components it runs to ensure there are no errors, or even to expand the functionality of a chip.

Think of it like the bios of a computer. Basically same difference.

Computer
1/Turn on power
2/Bios run (start bootloader)
3/Bios test (ensure no big errors are going on with internal hardware)
4/provide user interface for changing hard drive on the fly or going into bios settings
5/point to the hard drive set as the master 1st boot drive as defined in settings
6/point to run the boot program on 1st boot drive at the start of the boot partition.

Atmega Chip
1/Turn on power
2/Is fuse selected to run bootloader first?
3a/If above bootloader fuse = no, then skip bootloader and run sketch (or hex file)
3b/If above bootloader fuse = yes, then run bootloader
4/do defined instructions in bootloader
5/point to start of unprotected (non-bootloader) memory
6/run sketch(or hex file.)
Logged

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

Good explanation.

Quote
Bootloaders are basically applications that can reside in a section of the chip you can "lock" into place (in the very beginning of the chip memory).
Chips like the atmega328 (with "boot section support") have the ability to put the bootloader at the END of memory, where it interferes less with a normal application (which will assume that IT is at the beginning of memory.)  So these chips have fuse bits that tell the chip just how much space at the end of memory is used by the bootloader (its size), AND there is an additional fuse bit that says "start at the beginning of the bootloader instead of at the address indicated by the reset vector" (which is at the beginning of memory.)  This makes both writing the bootloader easier, AND using it is much easier.  (You can implement a bootloader for a system that lacks this feature, but it gets complicated figuring out where the user's application starts, or you have to change the compilation to hard-wire that.)
Logged

Gatineau, Qu
Offline Offline
Jr. Member
**
Karma: 1
Posts: 94
Did you Arduino today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for all the help you guys. smiley-wink

After a bit of research this is what I think I need to do.

To upload sketches to atmega8 with no bootloader, modify the high fuse in the board.txt.
It is now at 0xca (with bootloader activated) and I should change it to 0xcb to turn the bootloader off.

Is that right?

And for the atmega328p.......from 0xde to 0xdf.......right?

When dealing with avr microcontrollers you have what are called switches that are just codes that do certain things to the chip to either help it operate in certain ways, lock people from trying to reflash the chip or to try to pull code from the chip, or make it skip things, and etc.

Lock people from trying to pull code from the chip.......interesting! I need to look into that.
Logged

Offline Offline
Jr. Member
**
Karma: 1
Posts: 54
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As far as modifying boards.txt to unlock and ignore the bootloader, I will leave that answer to westfw because I am really not sure if that is correct or not and i am not on my computer with the ide to find out.

On locking (all the flash) on the chip, it is used by manufacturers to deter people from removing the chip from whatever product it's in and either wiping it and using it as a multipurpose chip (like we use it for) or pulling their closed source code for hacking.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 207
Posts: 12909
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
and either wiping it and using it as a multipurpose chip (like we use it for)

No matter how the fuses are set, using a high-voltage programmer an AVR processor can always be erased.
Logged

Offline Offline
Jr. Member
**
Karma: 1
Posts: 54
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
and either wiping it and using it as a multipurpose chip (like we use it for)

No matter how the fuses are set, using a high-voltage programmer an AVR processor can always be erased.


Oh yeah, this is true. But it's just a slight deterant from doing so. Most people who are not that big into electronics wouldn't know how to unlock it. Tell you what though, it's good to have a HVP handi anyways, cause if you ever do accidentally lock yourself out of a chip (or do something like select the wrong oscillator type), you can always fix it smiley
Logged

Pages: [1] 2   Go Up
Jump to: