Electrical – Programming microcontroller using UART

ftdimicrocontrollerprogramminguartusb

I am trying to design a development board with a dialog micro. I am trying to remove the need for a programmer on this board. So that the user could simply plug in a usb cable and be able to communicate with the chip and boot it.
I have seen the arduino uses an additional micro (ATMEGA16U2) to do usb to uart and this feeds into the arduino's actual micro (ATMEGA328P-PU).
Apologies if the following comes across very stupid but for my own clarifications I have 2 questions:

Firstly, how is the first micro programmed to begin with? I'd imagine the chip comes empty so if I plug a USB at first it wouldn't see anything?

Secondly could I use an FTDI usb to serial chip to do the same thing? Would that not have been a simpler solution?

I am guessing once the communication between my laptop via usb to my micro via uart is initiated, I could then use any IDE to program this chip.

I have very basic prior experience working with micro's and would like to take this opportunity to improve on that.

Best Answer

Firstly, how is the first micro programmed to begin with?

In the factory with a programmer.

Secondly could I use an FTDI usb to serial chip to do the same thing?

The Atmega328 can be programmed using the SPI 'protocol'. To get an SPI stream out of a FTDI chip requires some nifty programming.

Most 'self programming' development kits have a basic boot program in a protected section of their FLASH memory. It is put there in the factory. It has SW to use an interface (UART, USB) which allow you to upload data into the remainder of the FLASH and jump to it. The protocol is proprietary but sometimes disclosed.

I could then use any IDE to program this chip.

No, your IDE would need to know what interface and what protocol to use. Also working with breakpoints and stepping through the code is unlikely to work. It is the reason why forking out some money for a decent (ICE) programmer is worth every penny.