0
\$\begingroup\$

I have seen some micro controllers can be flashed with USB port alone with some driver software. But for some micro controllers we have additional interface hardware for flashing between the PC USB port and the micro controller pins. Why this difference? Specific example is arduino which can be flashed directly from the PC, whereas freescale micro controllers need additional hardware for flashing and debugging. Can all micro controllers be flashed with USB port alone with specific driver software?

\$\endgroup\$
  • 4
    \$\begingroup\$ Because some fish are grey and some fish are red. \$\endgroup\$ – Ignacio Vazquez-Abrams Dec 23 '15 at 6:22
  • \$\begingroup\$ Arduino can only be flashed directly because of a bootloader burned on the chip, and a USB to serial converter on the Arduino board... So I would argue it is not direct... \$\endgroup\$ – MadHatter Nov 24 '18 at 18:03
4
\$\begingroup\$

An arduino is not a plain micro-controller, so you are making a strange comparision here. An arduino Uno has a pre-installed bootloader in the Atmel ATmega328 micro-controller, plus an USB-to-serial interface (separate chip, for instance a CH340). With those two items added, ANY micro-controller can be flashed directly from a PC.

\$\endgroup\$
1
\$\begingroup\$

Not all MCU even have USB. But anyway, you are talking about boot loader, which is a piece of software that is preprogrammed, sometimes in ROM, and is ready to receive a file on power up. Sometimes from USB, sometimes from other ports. I think today really many kinds of MCUs come with simple boot loaders, but still not all of them.

\$\endgroup\$
  • \$\begingroup\$ No I am not saying about USB port on the micro controller. So, if I understand correctly boot loader is only for flashing the code, I cannot debug the code? For debugging I am assuming we should require some additional hardware interface like Jtag? \$\endgroup\$ – rajesh Dec 23 '15 at 6:42
  • \$\begingroup\$ JTAG is most common interface for debugging, but JTAG cable itself is not enough. You would also need development environment and source code. \$\endgroup\$ – Gregory Kornblum Dec 23 '15 at 6:44
0
\$\begingroup\$

It really is just about if the manufacture decided to put this feature on. Sometimes it is left out on smaller devices in order to save space or reduce power use as in most cases USB communication is done with a dedicated co-processor of some sort.

I also want to add not all free-scale boards need additional hardware. The K22F, K64F and KL25Z along with many other development boards they offer can be flashed over USB. I only list those as they are what i've recently used. The only thing is if you are running a RTOS then you may need additional hardware to view things like how much CPU time each thread is using. However you can still do the normal break-point style debugging on any of them with or without a RTOS.

\$\endgroup\$
  • \$\begingroup\$ I am sorry, I am confused, I am speaking in terms of both flashing and debugging. When I am saying debugging, I mean I can put breakpoints, watch variables etc. Can this be achieved without Jtag also? Please help. \$\endgroup\$ – rajesh Dec 23 '15 at 6:58
  • \$\begingroup\$ Freescale boards can debugging/flashing with their "OpenSDA" usb port. So if the board has this, then yes you can program and step though the code, place breakpoints while its running to look at variables and the state of the device. Jtag is sometimes needed for more advanced debugging when your running an RTOS, if you don't know what an RTOS even is, then do not worry about it. Here's a link to a walk though of how to do it \$\endgroup\$ – Dave851 Dec 23 '15 at 7:41
0
\$\begingroup\$

Whether a micro-controller can be flashed over USB or not depends upon its construction and whether original manufacturer allowed this or not. However it can be modified by end user as explained below.

Arduino is based on atmega IC from Atmel. In arduino UNO, they use Atmega328P. These ICs have been designed in way so as to listen on their SPI ports during start up for any incoming data/code. If they receive a valid data, they will get re-programmed. Arduino guys wrote a small piece of bootloader (consider a tiny OS for uC). This bootloader adds some extra features. It tells the micro-controller to listen on UART (Serial Tx Rx) pins as well for any valid code once the micro-controller restarts. And that's how arduino boards can be programmed over serial communication.

Also, arduino isn't directly being flashed over USB directly. It's being programmed over serial. Arduino has some extra circuit - USB to Serial converter. This is responsible for converting the USB data (which goes from your PC) into Serial data (which can be understood by atmega 328).

If you start writing your custom bootloader, you can use some other features as well. For ex - Your bootloader code can force the IC to start as i2c slave with a predefined address and some i2c master can send code to it. Or, you can implement software serial on pins other than Tx Rx to burn your code.

However, even with all these in place, what manufacturer has made will always stay unless manufacturer allows you to override that. For ex - Even though Arduino is flashed over Serial, you can still use SPI lined to dump code into it using ISP. This is what allows you to burn a fresh bootloader in case something bad happened to the bootloader code.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.