Go Down

Topic: ATmega32U4 to upload code to ATmega2560 (Read 358 times) previous topic - next topic

profeta64

Hi Eveyone,

I am developing a custom board, where I placed an ATmega32U4 instead of the ATmega16U2 programmer.
I was looking how to program the m32u4 in order to perform the same tasks of the m16u2.


I tried the software inside the standard Arduino directory "firmware\atmegaxxu2\arduino-usbserial" modified the following values in the makefile:

Code: [Select]
MCU = atmega32u4
MCU_AVRDUDE = atmega32u4
MCU_DFU = atmega32u4

ARDUINO_MODEL_PID = 0x0010

LUFA_PATH = ../../


Using the LUFA library 100807 as suggested by the Readme file.

The compilation is performing almost correctly (i have to compile it twice)


I am using now a Leonardo and a Mega to verify if the solution is working.
The upload through USBASP to a Leonardo board is successfully performed.

Then I connected the serial of the Leonardo to the Mega, and the reset pin PD7 of Leonardo to the reset of the Mega.
The Mega is reset, but there is no programming.

I have some idea about the reason, maybe due to the double serial port of the 32u4...

No-one has experienced something like that?

3Dgeo

Hello,

I'm probably not the smartest person here to reply, but I just had to ask:
Why? Why ATmega32U4 and ATmega2560? Why 2 MCUs? Why not regular FTDI and ATmega2560?
Why not SAMD or STM32?  :o

CrossRoads

Atmega32U4 can be reprogrammed for other functions, instead of USB only. Atmega2560 by itself has no USB interface.

FTDI cannot be reprogrammed, and are pricey, $4.50 USD per chip in small quantities.  Price  hasn't changed in the 9+ years I have been active in Arduino. No crystal is needed.

Atmega32U4, $4.20/chip in small quantities. Adds up when buying thousands, millions. Crystal is needed.

Could argue the two chips are probably similar cost when buying for worldwide production. But the FTDI loses out on programmability. Then again, how many folks take advantage of that?

On the other hand, the Atmega32U4 seems easier to damage when there is any power fluctuation, while the FTDI seems sturdier in that respect.

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

3Dgeo

Exactly, so why spend almost 10usd when you can get STM32 or SAMD for over 2 USD and use their native USB for programming?

I honestly don't understand why people still uses Atmega2560 or Atmega32U4, they are way overpriced and lack of performance - those chips are just old at this point.

Also there is always an option not to include a programmer on the board, just make a port for programmer instead - this will reduce price as well.

pert

Exactly, so why spend almost 10usd when you can get STM32 or SAMD for over 2 USD and use their native USB for programming?
If you're designing a consumer product, that's definitely the way to go. However, I've come to the conclusion that the native USB boards are less beginner friendly for Arduino users than the ones with a separate USB chip. The reason is that it's not too difficult to break native USB with some code in your sketch and "brick" the board. It's easy enough for someone with a little experience to recover from that by manually resetting the board to activate the bootloader (especially with the newer boards that have the reset double tap feature), but the beginners don't know or understand that trick and so it results in a bad experience.

It's well worth it for a beginner with casual interest in Arduino to spend a little extra money in exchange for a board that will provide the most gentle learning curve.

Now that we have the option of the CH340, it's possible to add the separate USB chip without spending too much. You could argue that the need to install the CH340 driver results in more bad experiences for beginners than "bricked" native USB boards. I think this is mostly the result of the sellers of the boards that use these chips usually not bothering to provide documentation. Yes, the beginner would need to actually bother to read the documentation, but I think that it's natural and common for people to read readily accessible documentation on the first use of a product. Not so much when a previously working board has a mysterious malfunction after you upload a sketch.

dmjlambert

I prefer boards that have an FTDI Basic header like a Pro Mini, that let's me choose what adapter to use and I can use my Bluetooth adapter and just not fool with any cable to my computer.   If I want to mess with a cable then I'll use an FTDI basic.   But the OP is not making a board for me.

So far none of the discussion has involved solving the OP's problem with compiling and using the arduino-usbserial program on the ATmega32u4, which could be a learning experience.   So far, the feedback has been "why?"   If the OP is just a one-time poster who never comes back to comment, then we can't really explore the "why not?"  To start, we would need more info about "The compilation is performing almost correctly (i have to compile it twice)" and ask if he's done some sort of loop back or serial communications test between the 2 MCUs. 


Go Up