I have two questions
- I'm trying to understand how program is loaded into Arduino when I use virtual serial port. Basically I want to understand how it is implemented in Arduino Environment. How program code is distinguished from just simple data transfered to Arduino through serial port? (The question is about technical explanation, not about how it is doable through Arduino IDE)
Second question is what is done inside Duemilanove bootloader? I haven't succeeded to find any good description of that. Could you please point me to any?
AWOL, thanks for pointing to the source. It really explains a lot.
So, what I was able to figure out from the code that Bootloader
does the following:
Initializes some processor parameters
Reads characters from UART (USB/COM port in our case)
in case there is 'd' character command sent to UART it reads
subsequent bytes which contain program code to be loaded
into flash memory.
(There are also some other commands could be sent to bootloader on startup)
Executes app_start function (which I guess is loaded user program)
As I understand a kind of RESET signal is sent to CPU when UART
communication is started, is it? Please correct me if I'm wrong somewhere.
As I understand a kind of RESET signal is sent to CPU when UART
communication is started, is it? Please correct me if I'm wrong somewhere.
Yes, When you click on upload the Arduino IDE toggles the DTR control signal on the virtual comm port just before handing off control to AVRDUDE program in the PC for performing the actual upload. On the Arduino board the USB serial conveter chip's (FTDI) DTR signal is wired through a capacitor to cause a hardware reset of the AVR chip, which then starts the bootloader program to become active.
Yes, When you click on upload the Arduino IDE toggles the DTR control signal on the virtual comm port just before handing off control to AVRDUDE program in the PC for performing the actual upload. On the Arduino board the USB serial conveter chip’s (FTDI) DTR signal is wired through a capacitor to cause a hardware reset of the AVR chip, which then starts the bootloader program to become active.
Wow, sounds good It means that I can restart AVR from USB
host by calling serialPort.setDTR(true);
BTW why this capacitor is used? I found it on the Duemillanove circuit
diagram. There is also some strange for me thing which is called RESET-EN coming from DRT. What does it mean?
The reset-en is a link that can be cut to disable the serial DTR reset. It gets in the way sometimes (everytime a serial link is established it flags DTR which then resets the Arduino, often not a desired behaviour.)