riyadhalnur

I bought a Leonardo recently. I know how to burn the arduino bootloader on a new atmega8/168/328. what I can't find out is how to then upload my sketches on that processor using the Leonardo. the tutorial on the arduino site uses uno which has a removable microcontroller but the Leonardo doesn't have that option. how do I go about doing that?

reason for doing this - i'm building an arduino on a breadboard but I don't want to buy an FT232 breakout board

If your goal is just to run some code on the targets, you are better off without bootloader: just burn your compiled sketches with ArduinoISP (I assume you used that to burn the bootloader into the targets?)

If you really want to use the target as an arduino on a breadbord, and program it from the IDE etc... You'd need to run a sketch on the leo that copies everything received from Serial (usb) to Serial1 (the regular uart) and vice versa. You'd have to connect respectively tx/rx on the leo to rx/tx on your target.

You can even combine the two functionalities into one sketch and use a jumper to select between isp mode and usb2serial mode (I saw the idea here: http://arduino.cc/forum/index.php/topic,101690.0.html, though the situation with the leonardo is a bit simpler: augmenting a sketch (ArduinoISP) with USB to serial conversion instead of adapting a bootloader)

Uno and Leonardo can be used as true ISP programmers/basic debuggers for most target AVRs. You do not have to remove any chip and you do not need to burn any bootloader.The main idea is to use avrdude:see: http://arduino.cc/forum/index.php/topic,125248.0.html(Have enough patience and read the topic to the end.)When I have time I will make a step by step tutorial.

If your goal is just to run some code on the targets, you are better off without bootloader: just burn your compiled sketches with ArduinoISP (I assume you used that to burn the bootloader into the targets?)

If you really want to use the target as an arduino on a breadbord, and program it from the IDE etc... You'd need to run a sketch on the leo that copies everything received from Serial (usb) to Serial1 (the regular uart) and vice versa. You'd have to connect respectively tx/rx on the leo to rx/tx on your target.

You can even combine the two functionalities into one sketch and use a jumper to select between isp mode and usb2serial mode (I saw the idea here: http://arduino.cc/forum/index.php/topic,101690.0.html, though the situation with the leonardo is a bit simpler: augmenting a sketch (ArduinoISP) with USB to serial conversion instead of adapting a bootloader)

i saw the post about using the leonardo but the way to dit is not specified there...it woud be nice to get the sketch which will copy everything from Serial to Serial1

I tested it uploading a blink sketch to an atmega328p with some duemilanove bootloader.It requires some practice though: keep the target in reset. Hit the download icon. Release the reset button right after the compilation phase is done...

What we really need is autoreset support. I'll cook something...

What would also be nice is that the leo automatically sets Serial1's baud rate, when the pc sets the "baudrate" of the virtual com port.

kopfkopfkopfaffe

I'm really sorry for hijacking this thread, but if I had to define a topic for my problem, this would be exactly it.

So I've got this setup with an Atmega32U4 and an Atmega168 on a custom board. The Atmega32U4 is equipped with the Leonardo Bootloader (caterina) and works like a charm. The Atmega168 is supposed to run one of the other Arduino bootloaders. For my test setup, I use an old Duemilanove with an Atmega328.So what I'm trying to do right now is to use the /dev/ttyACMn interface of the Leonardo to program the Duemilanove which is connected to the secondary (serial1) UART.Or simply:

As you can see, the Due is reset when the first byte is received from the PC. My analysis seemed to show that the PC is sending the character '0' three times and waiting for the Arduino to reply. But even without the automatic reset, if I try it manually, it only shows me a bunch of sdk-failed errors. Any idea why this is not working? Is the /dev/ttyACMn really equal to the /dev/ttyUSBn or /dev/ttySn?

@kopfkopfkopfaffe: I am glad you ask. I just finished a write up of an experiment that exactly does that.

It is an improved version of sketch posted earlier in this thread.It now handles autoreset and sets the baud rate of the uart.It can be used to download sketches via the ide, but also to communicate with the sketch itself.A minor hack in the core is needed though.

riyadhalnur

PeterVH, your other tutorial on modifying the leonardo helped a lot. i made a breadboard arduino and programmed it via the leonardo but i coduln't do it via the IDE. it kept giving me device signature failures. so i used avrdude from cmd with the -F command at the end to override the signature check and everything worked perfectly

Good to hear, but I find it very suspicious you had to use -F. What signature did avrdude report? Was it 0 (then you still have a problem in your wiring or setup) or just not the signature for your target.

I read the post of riyadhalnur yesterday and did a test using an Uno not a Leonardo because I do not have one. I tried to check if using the -F option will change the error message thrown by avrdude in case a SPI connection is broken.The reported error changes but it remains an evident error.If I have good connections between Arduino and the target AVR no error is displayed.

Conclusion: -F does not fix anything as long as you have wrong SPI wiring and you do not get the "use -F" error message if you have good connections, excepting the case when the AVR oscillator (external) does not work or the target AVR is not powered!