Pages: [1] 2   Go Down
Author Topic: Made My Own Arduino Board - ATMEGA32U4 - Bootloader Questions  (Read 9579 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey Guys,

I am an Arduino Newb, but been in electronics for quite some time. I am by experience a HW designer (ASICS, FPGA, etc.). I made my own board ..based off using the ATMEGA32U4(Leonardo was my reference). My board is up and working, but I need to get a bootloader into it. I have quite rusty on programmerMCU's, so I need some guidance.

I also have the ATMEGA2560 (own it), but I only know of Leonardo by schematic, and it seems to be different that the other mainstream boards.

With the ATMEGA2560, it has another ATMEGA CPU for the USB-programming of arduino sketches. But with the leonardo, it uses a direct USB connection. S

I got my board on the jtag (AVR JTAGICE MKII), and Ican read and write to it...and I erased the original AVR bootloader on it and put on a bootloader what I thought was a leonardo bootloader that I found online.

WHERE IS THE LEONARDO/ATMEGA32U4 BOOTLOADER FOR ARDUINO? I found a file in thje arduino directory called Caterina-Leonardo, but this hex file is 76L in size, and the flash space for the ATMEGA32U4 is only 28K, so that can't be right...is it? if so, please explain.

So if someone can please explain the bootloader stuff for this MCU..thanks in advance...

Also, so once I get the bootloader in using JTAG on AVE JTAGICE MKII, what should the arduino SW see when I plug in the USB?

please give me some guidance...

Thanks! smiley
-Peter
Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 594
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

a .hex file is in Intel Hex format, it's ASCII, human readable, not binary. You need two ASCII characters to represent every actual byte, plus there's some overhead in the Intel Hex format to indicate address and checksums. So it's file size does not indicate the true size of memory you need.

also keep in mind, your microcontroller has 32K total, the bootloader can occupy up to 4K, thus you have 28K remaining for application. So your reasoning is wrong in your original post.
Logged

Freelance engineer, consultant, contractor. Graduated from UW in 2013.

Global Moderator
Online Online
Brattain Member
*****
Karma: 480
Posts: 18722
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm not an expert on programming the ATMEGA32U4 with a bootloader, but I do know it uses the PDI programming interface, for which you need a PDI programmer. I doubt the ATMEGA2560 will do that, although possibly with a suitable programmer installed. You would need connections to PDI, PDO and SCK as described on page 361 of the datasheet. Then you need a suitable programming sequence.

I don't know where the bootloader file is. I presume it is on the Arduino code site somewhere.

http://code.google.com/p/arduino/

or, here maybe:  

https://github.com/arduino/Arduino

If that isn't it, someone else might know.

Logged


Global Moderator
Online Online
Brattain Member
*****
Karma: 480
Posts: 18722
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This file:

https://github.com/arduino/Arduino/blob/master/hardware/arduino/bootloaders/caterina/Caterina-Leonardo.hex

seems to have a lot of 0xFF in it. It looks a bit like it also contains some default sketch.

Once you get past all that it seems to have code at 0x7000 to 0x8000 which would be 4096 bytes (4K) which sounds right for a bootloader.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am looking for someone who REALLY knows the answer. Please do not reply if you don't know or may have an idea. There has to be somebody who has put the bootloader on the Leonardo Board. 

Is the 'Catarina-Leonoard.hex' in the Arduino folder the legit arduino bootloader?

Why is this file 78KB if a bootloader is only ~4KB?

Thanks for the support,
-Peter

Logged

Global Moderator
Online Online
Brattain Member
*****
Karma: 480
Posts: 18722
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Why is this file 78KB if a bootloader is only ~4KB?

I explained that. What part of the explanation did you not understand?
Logged


Global Moderator
Online Online
Brattain Member
*****
Karma: 480
Posts: 18722
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

To repeat part of my explanation ...

Most of that file is just putting 0xFF into memory (filler in other words):

Code:
:20602000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF80
:20604000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF60
:20606000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF40
:20608000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF20
:2060A000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00

Plus since this is "readable" hex it will take 2 bytes in the file to put one byte into memory. Plus there is the address, the length, the sumcheck, etc. per line.
Logged


Forum Administrator
Offline Offline
God Member
*****
Karma: 52
Posts: 639
I find plain exciting
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@MrBeef

great attitude, I'm sure you'll make a lot of friends around here smiley

I would appreciate if you had a nicer way to deal with the people who are here to help you AND gave you a perfectly good answer.

Nick , as usual, is right. re-read his answers.

m
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey Nick,

Sorry didn't mean to be rude if it came off that way. As long as you're sure great..thanks for the help. The reason why I said that is because sometimes people on forums just babble(as the old saying goes "everything on the internet is true"). I guess I should have looked at your title and recognized you probably knew what you're saying.

So thanks on that..

So my next question is:

I made a board, which I want to use arduino SW on. It uses an ATMEGA32U4 and has basic features, but is not a copy of the Leonardo Schematic. I wish to load a bootloader for arduino, and then build support for it in Arduino using the 3rd-party as as I am supposed to.

I am a HW engineer, so I am pretty inexperienced for SW(I know C/C++, but haven't used it in 8 years), and the arduino structure.

How can I learn all of this?


So my next question is about the bootloaders...if I make a board using the ATMEGA32U4, and want to put on an Arduino bootloader, can I just use the leonardo(arduino & ATMEGA32U4)?

Here is what I did earlier just to see if I could get it working in Arduino... I found a company called MattairTech, and they have their own ATMEGA32U4. So I used a jtag programmer to load it. It seemed to work...then I installed their files into my arduino...and it can find my COM port, and the device board target. But when I go to load the board...it fails. Perhaps I am totally missing a detail or I have no idea what I am doing lol.

Let me know what you think and thank you for the help,
-Peter
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 533
Posts: 26942
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

This group here was one of the first to make pre-release Leonardo's.
http://vinciduino.com/
Do some reading, see what you can figure out.
Come back with what you find.

My expectation would be that one would load a bootloader the normal way, with an AVR ISP Programmer (such as Atmel AVR ISP MKii) connected to the pins that make up the ICSP header: SCK, MOSI, MISO, Reset, Gnd, Power (Note: MKii only senses the voltage, board must be powered otherwise). (There is a mod I've seen to MKii to connect power to the Vcc header pin so it will supply power - I've not hacked mine, I just supply external power - sometimes just using a 3 AA battery pack).
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.

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 533
Posts: 26942
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

Here's some discussion of the MKii mod
http://arduino.cc/forum/index.php?topic=114250.0
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.

Global Moderator
Online Online
Brattain Member
*****
Karma: 480
Posts: 18722
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I made a board, which I want to use arduino SW on. It uses an ATMEGA32U4 and has basic features, but is not a copy of the Leonardo Schematic. I wish to load a bootloader for arduino, and then build support for it in Arduino using the 3rd-party as as I am supposed to.

OK, well you've taken me out of my area of expertise with this bit. I have experience uploading bootloaders using things like the AVRISP and also my own software, eg.

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

and:

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


However, all those use SPI programming, whereas your chip uses PDI. Now I don't have a hardware PDI programmer, and although I have an AVR Dragon this model doesn't (seem to) support the PDI interface.

I attempted to make a PDI programmer using a Uno, but the documentation for the protocol is somewhat sparse, and I haven't succeeded yet.

If I had one, I could download the firmware from my Leonardo, and confirm whether or not it agrees with the hex file we were discussing.

Quote
But when I go to load the board...it fails. Perhaps I am totally missing a detail or I have no idea what I am doing lol.

This part is unclear. What did you load onto what, and what connections did you make?
Logged


Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 533
Posts: 26942
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

I've asked fm to jump in here with some of his vinciduino experience.
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.

Málaga, Spain
Offline Offline
Edison Member
*
Karma: 41
Posts: 2182
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi folks, I am off to work but it sounds like the JTAG fuse is set. As soon as I get back this afternoon I will good through the thread and see if I can contribute a bit to get that bootloader going. Do you have a schematic of the wiring.
Logged

   

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey fm,

Yeah I was messing with the fuses, and when I loaded a bootloader (MAttairtech CDC), the jtag shut off and didn't come back.

I think I am going to try to use my MEGA 2560 arduino to load a bootloader.

But I did attach the CPU page of the schematic, so you could see how different it is compared to a leonardo.

Cna I put the leonardo bootloader on this board and it will work the same? Is there anything inside the bootloader that would prevent me from using it? I don't know anything about booloaders.

Thanks,
-Peter


* Leo-Copy.jpg (299.84 KB, 1116x873 - viewed 144 times.)
Logged

Pages: [1] 2   Go Up
Jump to: