3. During a code download into the 328P, the USB output can be seen by selecting File:Preferences and turning on Verbose Outputs.There are 2 stages - the first is the output from the .ino to .hex creation process, the second is the transfer of the .hex to the bootloader code running on the '328P. The bootloader selfwrites the .hex contents into flash memory.4. The IDE talks converses with the bootloader on the 328P, see #3.Optionally, a Programmer can connect to the ICSP header and write the flash memory directly. A Programmer is another microcontroller with a USB port for receiving data from the PC. Or it can be a standalone programmer getting the .hex file from an SD card, such as this one I offer that runs code developed by member Nick Gammon:http://www.crossroadsfencing.com/BobuinoRev17/Rev7Battery_with_Arduino.jpg[/img]
What program is uploaded on it to convert the USB data to the .hex file..?
How does the Software recognise the Arduino and its details..?
What will be the USB output from the Arduino Software..?
If I use a different target microcontroller, how do I program it..?
I don't know much about a bootloader. What is it..? What does it contain..? How does it work..?
I want to learn more about Bootloaders, Memory Locations, Flash and other related topics... Can you please suggest a book..? Please make sure that it is available in India...
In layman's termsThe bootliader is a piece of software that is permanently loaded in the 328 micro. When the 328 is reset, the bootloader is started. It will monitor the serial communications for a while for specific commands that indicate an upload.If it sees these commands, it will switch to upload mode and the pc can upload the code after which it will start the loaded code.If these specific commands are not received, the bootloader will start the loaded application.
Source code is one good place to start: hardware\arduino\avr\bootloaders\optibootDatasheets and application notes are also great places to get information, if you are willing to invest the time to search through them and find the diamonds in the rough.
;-the routine writes one page of data from RAM to Flash; the first data location in RAM is pointed to by the Y pointer; the first data location in Flash is pointed to by the Z-pointer;-error handling is not included;-the routine must be placed inside the Boot space; (at least the Do_spm sub routine). Only code inside NRWW section can; be read during Self-Programming (Page Erase and Page Write).;-registers used: r0, r1, temp1 (r16), temp2 (r17), looplo (r24),; loophi (r25), spmcrval (r20); storing and restoring of registers is not included in the routine; register usage can be optimized at the expense of code size;-It is assumed that either the interrupt table is moved to the Boot; loader section or that the interrupts are disabled..equ PAGESIZEB = PAGESIZE*2;PAGESIZEB is page size in BYTES, notwords.org SMALLBOOTSTARTWrite_page:; Page Eraseldi spmcrval, (1<<PGERS) | (1<<SPMEN)call Do_spm; re-enable the RWW sectionldi spmcrval, (1<<RWWSRE) | (1<<SPMEN)call Do_spm; transfer data from RAM to Flash page bufferldi looplo, low(PAGESIZEB);init loop variableldi loophi, high(PAGESIZEB);not required forPAGESIZEB<=256Wrloop:ld r0, Y+ld r1, Y+ldi spmcrval, (1<<SPMEN)call Do_spmadiw ZH:ZL, 2sbiw loophi:looplo, 2;use subi for PAGESIZEB<=256brne Wrloop; execute Page Writesubi ZL, low(PAGESIZEB);restore pointersbci ZH, high(PAGESIZEB);not required for PAGESIZEB<=256ldi spmcrval, (1<<PGWRT) | (1<<SPMEN)call Do_spm; re-enable the RWW sectionldi spmcrval, (1<<RWWSRE) | (1<<SPMEN)call Do_spm; read back and check, optionalldi looplo, low(PAGESIZEB);init loop variableldi loophi, high(PAGESIZEB);not required forPAGESIZEB<=256subi YL, low(PAGESIZEB);restore pointersbci YH, high(PAGESIZEB)Rdloop:lpm r0, Z+ld r1, Y+cpse r0, r1jmp Errorsbiw loophi:looplo, 1;use subi for PAGESIZEB<=256brne Rdloop; return to RWW section; verify that RWW section is safe to readReturn:in temp1, SPMCSRsbrs temp1, RWWSB ; If RWWSB is set, the RWW section is notready yetret; re-enable the RWW sectionldi spmcrval, (1<<RWWSRE) | (1<<SPMEN)call Do_spmrjmp ReturnDo_spm:; check for previous SPM completeWait_spm:in temp1, SPMCSRsbrc temp1, SPMENrjmp Wait_spm; input: spmcrval determines SPM action; disable interrupts if enabled, store statusin temp2, SREGcli; check that no EEPROM write access is presentWait_ee:sbic EECR, EEPErjmp Wait_ee; SPM timed sequenceout SPMCSR, spmcrvalspm; restore SREG (to enable interrupts if originally enabled)out SREG, temp2ret
What are these specific commands..?