BOOT LOADER

I hope some one will build ans sell such a fast and easy boot loader for the UNO chip . I am sure it will have a good market ..

Elico

elico: I wonder why installing a boot loader directly on a blank ATmaga from the IDE is not an option at arduino UNO ??

Is it so complicated matter ? Is the change needed so big ?

Well, you tell me where the bootloader would come from?

In order to make a chip that could install its own bootloader you would need a second chip, either with the bootloader on it, or with code to install the bootloader on the first chip. So how does the code get on the second chip? Well you would need a third chip to install the bootloader on the second chip. But what about the third chip you ask? Well I'm glad you did, because that brings us to the fourth chip...

You can do it right now if you buy the external hardware (an ICSP programmer) ... that is effectively the "second chip". They could supply one with each Uno, if they didn't mind doubling the price.

Well Nick you did it again. You put your finger on the solution. [quote author=Nick Gammon link=topic=107791.msg812186#msg812186 date=1338498970] In order to make a chip that could install its own bootloader you would need a second chip, ... [/quote]

The Uno has just that. The Uno has 2 chips on it. It also has 2 ISP headers. So you just need to add the programming software to the USB interface chip. You would need a jumper to let the interface chip know which program to run. I would use what Arduino calls pin D10. Start by setting it to input and write it HIGH. Then read it. If it is connected to ground via a jumper then it should work in the usual USB to serial mode. If it is HIGH then it is connected to the reset pin of the primary chip (via the jumper moved to the other position). You are now ready to down load your new bootloader.

You probably can not modify an existing UNO but it would be great and cheap improvement for the next revision, if there are any more revisions.

Yes I suppose you could do that. But say the bootloader is changed (to fix some bug) then you need an external programmer to change the USB interface chip (to upload the new bootloader-uploading code). So you've just shifted the problem along one chip. Let's put it like this: say you have a Uno board with the USB chip programmed to install bootloaders, you may as well supply it with the bootloader installed as well (on the main chip).

The sort of situation where people need to buy blank chips and install bootloaders, is one where they would have a spare board around to put the bootloader on the chip. As I describe here:

http://www.gammon.com.au/forum/?id=11635

The whole thing about bootloaders is that it is a chicken-and-egg situation. Without a bootloader "burner" (ie. an ICSP programmer) you can't install a bootloader, nor indeed can you make a device that makes bootloader burners. Thankfully the word has plenty of them now.

elico: I hope some one will build ans sell such a fast and easy boot loader for the UNO chip . I am sure it will have a good market ..

Well I suggest you make one then.

Yes who knows ...

i really think that the next UNO will include the following (and mre) 1> A ZIP socket for the main chip . 2> An easy way to burn the boot loader on a blank ATmega .

Looks to me it is possible and really needed to developers .

Elico

I really don't think either will be included. For most users, a zif socket simply isn't needed, and would increase the cost. As has been said, a USBasp, for under $10, including adaptor, makes burning a bootloader easy, and, again, most users won't need to do it, when buying a new chip with a bootloader already installed will be enough.

To solve your need for an easy way to remove/replace the atmega, just buy an extra 28 pin IC header.

Place your IC in the header then plug that header onto the board header... Some IC headers are quite easy to separate from each other, and if its not, then you don't have to worry about damaging the IC pins when levering it off.

Mine are used now and separate quite easily. It also holds in tight enough for a quality connection.

elico: i really think that the next UNO will include the following (and mre) 1> A ZIP socket for the main chip . 2> An easy way to burn the boot loader on a blank ATmega .

What is a ZIP socket? Do you mean a ZIF (Zero Insertion Force) socket?

Well here is the first problem:

As you can see, the ZIF socket is big. So it is higher than the headers you plug the shields into. So none of the existing shields will work. Unless you make the whole thing much larger.

Next, ZIF sockets are expensive. I am seeing quotes of around $16 on Digi-Key.

So you are saying you think the next Uno should be somewhat larger, not compatible with existing shields, and cost 50% more? Is that it?

2> An easy way to burn the boot loader on a blank ATmega .

Why, exactly? Do you think people will buy Unos and then buy extra blank chips and want to hit a button and have the bootloader programmed? Why not just buy this for example:

https://www.adafruit.com/products/462

Was just coming to post this one, for $13: http://evilmadscience.com/productsmenu/tinykitlist/253 - similar to the adafuit one.

[quote author=Nick Gammon link=topic=107791.msg812349#msg812349 date=1338511017] The whole thing about bootloaders is that it is a chicken-and-egg situation. Without a bootloader "burner" (ie. an ICSP programmer) you can't install a bootloader, nor indeed can you make a device that makes bootloader burners. Thankfully the word has plenty of them now. [/quote]

I think I have a solution, or at least part of one.

Add the code to the "USB to Serial" chip to also function as a programmer. Most of the time it work as it has the the past. However, under some condition it behaves like a know ISP programmer.

Now if you want to program a blank chip, pop it into the UNO, connect MOSI, MISO and SCK. This signals are all present on both ISP headers. Set the condition and plug in the UNO to your computer. Open the IDE and program the blank chip.

Next question is, how do you get the "Programmer" code onto the "USB to Serial" chip? Easy, a script similar to the OptiLoader. As I understand it, the OptiLoader has the bootloader included in the program. In this case, it would have the "Programmer" code(HEX) as part of the script. When the sketch begins to execute it checks to see if an ATMega16U2 is connected to be programmed. If it is, it gets programmed. I would think that blinking the LED in different rates and patterns would be a good feed back for the different phases and statuses. Such as "Looking" for chip, "Found and Programming", "Done", "Not Found", "Failed to Program"...

The only thing remaining is, how to do tell the "16u2" to be a "Programmer"? It might try to read the chip signature via MOSI, MISO and SCK. If it can then it is connected as a programmer. The simplest is probably to use JP2. It contain 4 i/o pins, Connect 2 or ground 1 or something. One problem with this solution is that some UNO clones do have have a JP2.

Now, where did I make a fool of myself or might this actually work?

Yes, that might work. The target chip also needs reset held low. You might need to use one of the spare pins on JP2 to provide that signal, and the other one as the "please be an ISP" toggle.

I made a Optiloader board out of perfboard, 2 rows of female headers that fit a Boarduino http://www.adafruit.com/products/72, a ZIF socket from Si at http://evilmadscience.com/productsmenu/partsmenu/54-zif20, some 22pf caps, crystal, resistor , and reset swtch. I put a 6 pin male header & .1uf reset cap for programing the target chip (after removing BoArduino) that uses the same FTDI Friend http://www.adafruit.com/products/284 that the BoArduino uses for programing & power.. Just programmed 3 blank 328's today in less than a 2 minutes, including installing the Boarduino and programming it with WestfW's OptiLoader. Yeah, there are probably cheaper ways, but after having fun building the board it sure is fast. Plus, I use everything for other projects too. Wouldn't building your own bootloader be reinventing the wheel?

TomJ

[quote author=Nick Gammon link=topic=107791.msg851396#msg851396 date=1341612402] Yes, that might work. The target chip also needs reset held low. You might need to use one of the spare pins on JP2 to provide that signal, and the other one as the "please be an ISP" toggle. [/quote]

The reset is already there. "USB to Serial" processor uses PD7 to reset the target chip during flash programming. However, it does go through cap (C5), so if it must be "Held" low, then another solution is needed.

My first thought (just brainstorming here) is to replace (or bridge) C5 with a resistor, say 100 ohms, change the code in the "USB to Serial" to only pulse the DTR instead of holding it low. You can then hold it low when needed or pulse it to reset.

I am trying to be aware that the first version of the UNO and some clone boards do not have a JP2.

Maybe someone can say, how hard is it to read the "Target" signature? If it does not take too long to read, I would say that, that should be the "please be an ISP" switch. The act of using 3 female-female wires to connect the two ISP headers pin 1 to 1, 3 to 3 and 4 to 4 causes the processor to go into ISP mode.