0
\$\begingroup\$

I can write programs for an Arduino, and all I do is plug it in and click "upload". My compiled code gets into the ATMega's program memory. Easy right?

Well, I would like to know what exactly is happening in general. The microcontroller has some memory on it, so there exists some method of taking raw data from a USB cable and writing into the microcontorller as though it were a flash drive or something. However, I happen to know that this isn't possible unless a special bootloader program is already present on the microcontroller.

So now I'm confused. How could I upload programs to an Arduino if it didn't have the bootloader? How do I program other microcontrollers (such as an ARM) without the Arduino's user-friendly interface?

Bonus related question: from reading (and not understanding) a few web pages, I have found out that ARM is programmed through JTAG. What is this doing, exactly? The JTAG module sends data into the ARM, but exactly what data does it send? How can the ARM accept new code without some program already running on the ARM that interprets the JTAG data and writes it into the correct memory?

\$\endgroup\$
  • \$\begingroup\$ Datasheet says? \$\endgroup\$ – Ignacio Vazquez-Abrams Nov 18 '16 at 3:07
  • \$\begingroup\$ The chip I am using is this: st.com/content/ccc/resource/technical/document/datasheet/c5/ed/… If the information is there, I can't find it \$\endgroup\$ – Mahkoe Nov 18 '16 at 3:20
  • \$\begingroup\$ A bootloader can be a statemachine, with hooks into the rest of the MCU. Or a few words in firmware. \$\endgroup\$ – analogsystemsrf Mar 10 '17 at 17:19
  • \$\begingroup\$ An Arduino does have a bootloader, but how do you think the bootloader got onto the Arduino? \$\endgroup\$ – immibis Jan 24 '18 at 2:34
3
\$\begingroup\$

The ATmega µC series has various means to program it:

  • Self-programming. That's what the bootloader does. It loads data e.g. through the UART interface into RAM, then flashes the non-bootloader flash memory pages.
  • Parallel programming. Traditional method, you need a pretty special programming tool to do that. Only required when you disabled ISP programming because you wanted to use the RESET pin as a GPIO pin. Requires to remove the µC from the circuit.
  • ISP programming. That's the simplest method, requires a simple tool which you can easily build yourself, and some free programming software (avrdude). Sometimes requires to remove the µC from the circuit, but designers may take care when assigning GPIOs to avoid that.
  • DebugWire. ISP on steroids. Uses only the RESET pin, needs a fairly complex tool and a proprietary software until recently. Almost never requires to remove the µC from the circuit because the RESET pin usually is just that, RESET.

JTAG in contrary is a "standard" protocol and interface definition which can be used with a great number of chips. The original intention was to fill the flipflops representing the internal state of a device from outside. It's a testing interface. Nowadays it can be and is used for flash programming, too. The programming software needs to know every single thing how to program the specific chip, there's no standard for that.

Apart from the self-programming, all these programming methods are hard-wired into the chips. The earliest versions of JTAG have been nothing more than a 1000s-stages shift register.

\$\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.