그렇게 궁금해 하던 오리지널 소스 발견!
int main(void) | | { | | init(); | |
| | initVariant(); | |
| | #if defined(USBCON) | | USBDevice.attach(); | | #endif | | | | setup(); | | | | for (;;) { | | loop(); | | if (serialEventRun) serialEventRun(); | | } | | | | return 0; | | } |
|
[링크 : https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/main.cpp]
[링크 : https://github.com/arduino/Arduino/tree/master/hardware/arduino/avr/cores/arduino]
[링크 : https://github.com/arduino/Arduino/tree/master/hardware/arduino/avr/bootloaders] AVR기반
[링크 : https://github.com/arduino/ArduinoCore-samd/tree/master/bootloaders/zero] ARM기반
2016/03/28 - [embeded/arduino(genuino)] - 아두이노 빌드 프로세스 & c/cpp
+
간단하게 말해서.. FT232 USB to RS232 칩에서 DTR를 감지하면 자동으로 리셋을 걸어버린다.
그런 이유로 아두이노 부트로더에만 업로드 하는 것이 있고,
아두이노 sketch쪽 스켈레톤 코드에는 특정 코드에서 리부팅 하는 부분이 없다.
Since the DTR signal goes from 5V to 0 at the moment a new connection to the Arduino is started, if you send this signal to the reset line of the Arduino's processor, it resets. |
[링크 : http://www.instructables.com/id/Overview-the-Arduino-sketch-uploading-process-and-/]
Data Terminal Ready (DTR) is a control signal in RS-232 serial communications, transmitted from data terminal equipment (DTE), such as a computer, to data communications equipment (DCE), for example a modem, to indicate that the terminal is ready for communications and the modem may initiate a communications channel.
[링크 : https://en.wikipedia.org/wiki/Data_Terminal_Ready]
[링크 : https://www.arduino.cc/en/uploads/Main/ArduinoNano30Schematic.pdf]
대충보면.. Makefile에서 sketch를 c로 변경해서 빌드할때 .text 섹션을 BOOT_START 주소로 옮기고 링킹하는 듯?
$ vi /usr/share/arduino/hardware/arduino/bootloaders/caterina/Makefile
#---------------- Linker Options ----------------
# -Wl,...: tell GCC to pass this to linker.
# -Map: create map file
# --cref: add cross reference to map file
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
LDFLAGS += -Wl,--section-start=.text=$(BOOT_START)
LDFLAGS += -Wl,--relax
LDFLAGS += -Wl,--gc-sections
LDFLAGS += $(EXTMEMOPTS)
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
#LDFLAGS += -T linker_script.x
-Wl,--section-start=.bootloader=0x1E000 |
[링크 : http://www.atmel.com/webdoc/AVRLibcReferenceManual/FAQ_1faq_reloc_code.html]