embeded/arduino(genuino)2017. 2. 11. 12:54

그렇게 궁금해 하던 오리지널 소스 발견!


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]

'embeded > arduino(genuino)' 카테고리의 다른 글

릴레이로 AC전원 스위치하기  (0) 2017.10.26
hoverlabs 사의 hover 제품  (0) 2017.07.17
avrdude arduino  (0) 2016.12.02
pwm ppm decode  (0) 2016.11.28
arduino clcd  (0) 2016.11.25
Posted by 구차니