Jump to content

Confused about Arduino (microcontroller) terms

minibois

Hey,

 

Currently I am looking into make a custom PCB for a project I am working. This PCB will have an ATmega32U4 microcontroller on it, just like the Arduino (Pro) Micro uses.

I have been looking at some places online on how to flash that microcontroller, but I am just unsure on what I need to look for. Bootloader? Flashing? ISP header? I am just unsure what I am suppose to look for here.

The PCB will have a USB port (mini, if that matters) on it, to interface with a computer with. Preferably I would just like to install the Arduino IDE, maybe click a switch on the device and then just flash a new firmware/sketch to the MCU.

 

Questions:

- If I get a bare microcontroller, do I need to put a bootloader on it? How would I do that? What pins do I need to expose to do this easily?

- Once a bootloader is on the MCU, can I simply flash it via USB? What pins (on the MCU) are used for that?

- Should I just copy what the Arduino Micro uses for its connection to USB? Or do they have a bootloader on it, so it work with the Arduino IDE? https://www.arduino.cc/en/uploads/Main/arduino-micro-schematic.pdf

 

Anyone with some guidance, I would be very happy if you could share your wisdom! :) I am just kind of unsure as to what to Google and how to interpret what I am reading.

If anything was unclear, please ask away and I will clarify myself further!

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
Share on other sites

Link to post
Share on other sites

28 minutes ago, James Evens said:

Arduino uses one and useful for over the air updates.

Manufacturer depended. Simple solution buy the microchip programmer/debugger. More advance use another µC as programmer.

useful

Check the datasheet but I guess there is only one USB so yes

Thanks for your comment James.

So your have to put a bootloader on the ATmega chip and then it can be flashed using other methods, including the ISP header?

 

I think I will do some more research on how the Arduino Micro handles flashing and general connectivity over the same USB connection, because that is kind of what I am after.

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
Share on other sites

Link to post
Share on other sites

You can use a programmer to program stuff into the microcontroller, by simply writing data into the Flash memory inside the microcontroller.

 

If you buy a microcontroller, as a standalone chip, it's empty. You use a programmer connected to a couple pins on the microcontroller to program data into it.

Arduino boards have a bootloader preprogrammed, a very small application which just checks if you want to program something into the micro, or starts the code that was previously uploaded.

This way, the new code can be transferred into the microcontroller through the usb connector and the bootloader takes the data and puts it into the microcontroller flash memory then launched it.

You can program the bootloader and basically replicate an arduino or you can skip the bootloader and program your code using serial and a custom pin header.

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

if you want to use it just like an arduino you will have to load a bootloader witch will communicate with the arduino IDE. the best way to do this it normally to use the ISP header (i would suggest you add this to your board) using another hardware device called a ISP programmer witch can be found online fairly cheep or you could build your own using another arduino. once the bootloader is intsalled it will enable your usb port and you should be able to upload a Sketch using the arduino IDE.

here is a link to an old ben heck video that should help https://www.youtube.com/watch?v=ncobWc61wL4

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, minibois said:

Hey,

 

Currently I am looking into make a custom PCB for a project I am working. This PCB will have an ATmega32U4 microcontroller on it, just like the Arduino (Pro) Micro uses.

I have been looking at some places online on how to flash that microcontroller, but I am just unsure on what I need to look for. Bootloader? Flashing? ISP header? I am just unsure what I am suppose to look for here.

The PCB will have a USB port (mini, if that matters) on it, to interface with a computer with. Preferably I would just like to install the Arduino IDE, maybe click a switch on the device and then just flash a new firmware/sketch to the MCU.

 

Questions:

- If I get a bare microcontroller, do I need to put a bootloader on it? How would I do that? What pins do I need to expose to do this easily?

- Once a bootloader is on the MCU, can I simply flash it via USB? What pins (on the MCU) are used for that?

- Should I just copy what the Arduino Micro uses for its connection to USB? Or do they have a bootloader on it, so it work with the Arduino IDE? https://www.arduino.cc/en/uploads/Main/arduino-micro-schematic.pdf

 

Anyone with some guidance, I would be very happy if you could share your wisdom! :) I am just kind of unsure as to what to Google and how to interpret what I am reading.

If anything was unclear, please ask away and I will clarify myself further!

Sweet, custom Arduino stuff is always fun. What I would do if I were you, is find a working schematic for your chip, that includes the in circuit program headers, then work from there. NOTE! the all bootloaders are not the same, IE spakfun bootloader won't work in an adafuit board, the led pinouts are different, additional pin mapping stuff..... idk.

https://arduino.stackexchange.com/questions/473/how-do-i-burn-the-bootloader

https://github.com/michalmonday/supremeDuck/wiki/Flashing-bootloader-to-Atmega32U4-using-Arduino-IDE

 

I'm pretty sure you can flash the bootloader right from the arduino IDE, after you select the right board type. All you need is an in circuit serial programmer. Or program the sketch without the bootloader by using the icsp.

https://www.pololu.com/product/3172

https://www.pololu.com/docs/0J67/5.4

 

If your wanting to play with the ATmega32U4, I would clone the leonardo.

https://www.pololu.com/file/0J555/arduino-leonardo-schematic_3b.pdf

It already has the icsp headers broken out, and a bootloader. NOTE! if you plan on using the bootloader and the board files for the leonardo, use the same pin definitions in your design. The arduino 'pins' are mapped to the physical chip pins, so pin0 is not pin0, I hope this is clear.

 

After the bootloaders on your blank chip, your good to program with usb, it should be like talking to any other arduino at that point.

 

I would also google arduino clones to see how others are doing it, its super helpful.

 

Best of Luck!

 

EDIT: I'm dumb, the schematic you uploaded had the icsp header, I thought it was missing, at any rate, the above still applies.

Link to comment
Share on other sites

Link to post
Share on other sites

19 hours ago, hambobolubia said:

if you want to use it just like an arduino you will have to load a bootloader witch will communicate with the arduino IDE. the best way to do this it normally to use the ISP header (i would suggest you add this to your board) using another hardware device called a ISP programmer witch can be found online fairly cheep or you could build your own using another arduino. once the bootloader is intsalled it will enable your usb port and you should be able to upload a Sketch using the arduino IDE.

here is a link to an old ben heck video that should help https://www.youtube.com/watch?v=ncobWc61wL4

Thank you for the video link! This video proved to be very informative and held almost all the information I was looking for!

18 hours ago, RandleMcmurphy said:

Sweet, custom Arduino stuff is always fun

19 hours ago, hambobolubia said:

once the bootloader is intsalled it will enable your usb port and you should be able to upload a Sketch using the arduino IDE.

20 hours ago, mariushm said:

This way, the new code can be transferred into the microcontroller through the usb connector and the bootloader takes the data and puts it into the microcontroller flash memory then launched it.

Thank you all, for your very informative responses!

If I'm understanding this all correctly, the bootloader for an ATmega chip is kind of like a 'BIOS'? Without it, the microcontroller can't do anything and when you have it, it allows you to send code/sketches to it?

 

If that is the case, I think I understand the whole bootloader scenario. I think the sort of circuit that Ben Heck showed in the video linked above by hambobolubia has all the information I need on that part.

 

The second part I don't think I fully understand.

In the video, around  17:10, Ben Heck uses an FTDI chip to flash the program (Arduino/C code) to the ATmega chip. What I am just wondering, is that possible to do without the FTDI chip, just straight up via USB?

Just like how a 'normal Arduino' does?

20 hours ago, mariushm said:

Arduino boards have a bootloader preprogrammed, a very small application which just checks if you want to program something into the micro, or starts the code that was previously uploaded.

This way, the new code can be transferred into the microcontroller through the usb connector and the bootloader takes the data and puts it into the microcontroller flash memory then launched it.

Could you possibly please go into a little more detail on this part of your reply? Because what you wrote is like exactly what I want to achieve.

For the bootloader I will implement an ICSP header on the board (seems like the easiest way of programming the bootloader to it, so I don't have to fuss around with SMD sockets and such :P), but for the code it would be great to flash that via USB.

From what I can see, the different Arduino boards just have the USB connection D+ and D- go to the respective D+ and D- pins on the microcontroller. Seems like the other pins are just power and ground.

 

Would you happen to know where I could find some more resources on what to setup my PCB so it's possible to send new sketches/code to the ATmega chip?

 

(And once again, thanks to all of you for your help so far, it made a lot of information a lot more clear to me).

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
Share on other sites

Link to post
Share on other sites

  • 3 weeks later...

Here is is a really good video on the topic :).

 

https://www.youtube.com/watch?v=Sww1mek5rHU

 

(in-case the link doesn't work) Arduino Uno to ATmega328 - Shrinking your Arduino Projects by DroneBotWorkshop

 

Also it has a lot of extra info so here is a link to the approximate time stamp to what you were asking about the boot loader. (honestly the whole video is good for learning the UNOs architecture).

 

https://www.youtube.com/watch?v=Sww1mek5rHU&t=914s

(15mins, 14seconds into the video)

 

It does not cover how to load the boot loader onto a bare chip, you can also by a bare chip with the boot loader pre installed, and that's what many people do, but here is how to flash a boot loader from the Arduino website. (you will need supplies to do this)

 

https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard

 

Link to comment
Share on other sites

Link to post
Share on other sites

I know this is an older post at this point, but someone posted just the other day and I thought I'd chime in since I have flashed a bootloader on a custom pcb arduino myself a few years ago. It's not super hard, and is pretty well documented on the arduino website itself. https://www.arduino.cc/en/tutorial/arduinoISP

 

I should say, It's not hard if you have another arduino that you don't mind flashing to, to make it and ISP programmer. Just read through the entire page once, then go back to the parts that tell you what you actually have to do. **NOTE: I did this when the Arduino Uno was new, so I programmed a 328pu. Not quite the same chip, but should be easy enough to convert the same knowledge from that page. I should also note, I was flashing my own chips with and FTDI to USB converter cable. If you want usb functionality for programming with just a normal usb cable you'll have to have a circuit in place to transform from the serial signal to USB. I have not done this myself, so I can't tell you how to do it or give a link.

 

Personally at this point I'm just using Wemos Lolin d32 chips for my projects. They cost $5 each, are arduino compatible, have an ESP32 chip (meaning built in wifi/bluetooth), and even have a built in battery circuit (including charging through the micro-b port). Don't know if your project supports a premade chip like that or if you are doing it cause you just want to make your own circuit. They are quite useful though. They also can run at 240MHz and have 4MB of flash space. You do have to reference an external board library, but it's not super hard to set up. Anyway, good luck with your project!

Link to comment
Share on other sites

Link to post
Share on other sites

On 3/29/2020 at 1:00 AM, SomeLinuxPerson said:

Here is is a really good video on the topic :).

Thank you for the video link! I saw this video a bit ago and while it did have some useful information, it wasn't quite what I was looking for.

At the moment I have decided to implement an ICSP header on my board, so I could place a bootloader on the chip like that.

 

Do you happen to have any resources on how to flash code to an Atmega chip via USB? As in after I have the bootloader on it, how could I make it so I can put code on the chip?

This project will interface with a computer via USB (it will be an input device), so the PCB already connects the data lines of the USB ports to the data lines of the ATMega chip. Is this enough to program the code/sketch on it?

On 3/31/2020 at 1:22 AM, Caliber Mengsk said:

I know this is an older post at this point, but someone posted just the other day and I thought I'd chime in since I have flashed a bootloader on a custom pcb arduino myself a few years ago. It's not super hard, and is pretty well documented on the arduino website itself. https://www.arduino.cc/en/tutorial/arduinoISP

Thanks for the information!

I will probably be implementing an ICSP header so I can program the bootloader like this sown in your link:

image.png.9d04d0d7ca763269b54764b9733680c8.png

 

Do you happen to have any resources on how to flash code to an Atmega chip via USB? As in after I have the bootloader on it, how could I make it so I can put code on the chip?

This project will interface with a computer via USB (it will be an input device), so the PCB already connects the data lines of the USB ports to the data lines of the ATMega chip. Is this enough to program the code/sketch on it?

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
Share on other sites

Link to post
Share on other sites

I used a USB->FTDI serial converter cable and just had to attach the pins (5v, gnd, tx, and rx) in the right order. I really an not a super great resource for the nitty gritty of electronics. I more or less just followed the setting up an arduino on a breadboard guide (found here: https://www.arduino.cc/en/main/standalone ) and made a circuit instead of the bread board, then added a bunch of extra grounding pins (I was making an easy to use led controller out of it, where you could take prewired leds and just plug them in. Only having 1-2 grounds didn't work since there were like 20 different signals needing to connect). Hope this helps!

 

EDIT:

Oh, there's also a reset pin if I remember right coming out of the FTDI. The arduino needs to be reset and then have communication in a very short time to be programmed. It "can" be done by hand, but is very likely to fail, hence the reset pin being connected to ftdi.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×