mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-17 22:23:10 +03:00
Auto restart after upload (linux only for now). Auto reset/erase when uploading a new sketch.
This commit is contained in:
@ -30,6 +30,21 @@ arduino_due_x.build.variant_system_lib=libsam_sam3x8e_gcc_rel.a
|
||||
arduino_due_x.build.vid=0x2341
|
||||
arduino_due_x.build.pid=0x003e
|
||||
|
||||
arduino_due_x_r2.name=Arduino DueX R2 Dev. Ed.
|
||||
arduino_due_x_r2.upload.tool=bossac
|
||||
arduino_due_x_r2.upload.protocol=sam-ba
|
||||
arduino_due_x_r2.upload.maximum_size=524288
|
||||
arduino_due_x_r2.upload.use_1200bps_touch=true
|
||||
arduino_due_x_r2.build.mcu=cortex-m3
|
||||
arduino_due_x_r2.build.f_cpu=84000000L
|
||||
arduino_due_x_r2.build.core=arduino
|
||||
arduino_due_x_r2.build.extra_flags=-D__SAM3X8E__ -mthumb -DUSB_PID={build.pid} -DUSB_VID={build.vid} -DUSBCON
|
||||
arduino_due_x_r2.build.ldscript=linker_scripts/gcc/flash.ld
|
||||
arduino_due_x_r2.build.variant=arduino_due_x
|
||||
arduino_due_x_r2.build.variant_system_lib=libsam_sam3x8e_gcc_rel.a
|
||||
arduino_due_x_r2.build.vid=0x2341
|
||||
arduino_due_x_r2.build.pid=0x003e
|
||||
|
||||
##############################################################
|
||||
|
||||
adk2.name=Google ADK2
|
||||
|
@ -73,6 +73,38 @@ int WEAK CDC_GetInterface(uint8_t* interfaceNum)
|
||||
return USBD_SendControl(0,&_cdcInterface,sizeof(_cdcInterface));
|
||||
}
|
||||
|
||||
__attribute__ ((long_call, section (".ramfunc")))
|
||||
void banzai() {
|
||||
// Disable all interrupts
|
||||
__disable_irq();
|
||||
|
||||
// Set bootflag to run SAM-BA bootloader at restart
|
||||
const int EEFC_FCMD_CGPB = 0x0C;
|
||||
const int EEFC_KEY = 0x5A;
|
||||
while (EFC0->EEFC_FSR & EEFC_FSR_FRDY == 0);
|
||||
EFC0->EEFC_FCR =
|
||||
EEFC_FCR_FCMD(EEFC_FCMD_CGPB) |
|
||||
EEFC_FCR_FARG(1) |
|
||||
EEFC_FCR_FKEY(EEFC_KEY);
|
||||
while (EFC0->EEFC_FSR & EEFC_FSR_FRDY == 0);
|
||||
|
||||
// From here flash memory is no more available.
|
||||
|
||||
// Memory swap needs some time to stabilize
|
||||
volatile uint32_t i;
|
||||
for (i=0; i<1000000; i++);
|
||||
|
||||
// BANZAIIIIIII!!!
|
||||
const int RSTC_KEY = 0xA5;
|
||||
RSTC->RSTC_CR =
|
||||
RSTC_CR_KEY(RSTC_KEY) |
|
||||
RSTC_CR_PROCRST |
|
||||
RSTC_CR_PERRST |
|
||||
RSTC_CR_EXTRST;
|
||||
|
||||
while (true);
|
||||
}
|
||||
|
||||
bool WEAK CDC_Setup(Setup& setup)
|
||||
{
|
||||
uint8_t r = setup.bRequest;
|
||||
@ -99,31 +131,12 @@ bool WEAK CDC_Setup(Setup& setup)
|
||||
{
|
||||
_usbLineInfo.lineState = setup.wValueL;
|
||||
// auto-reset into the bootloader is triggered when the port, already
|
||||
// open at 1200 bps, is closed. this is the signal to start the watchdog
|
||||
// with a relatively long period so it can finish housekeeping tasks
|
||||
// like servicing endpoints before the sketch ends
|
||||
// open at 1200 bps, is closed.
|
||||
if (1200 == _usbLineInfo.dwDTERate)
|
||||
{
|
||||
// We check DTR state to determine if host port is open (bit 0 of lineState).
|
||||
if ((_usbLineInfo.lineState & 0x01) == 0)
|
||||
{
|
||||
/* TODO, AVR Stuff
|
||||
*(uint16_t *)0x0800 = 0x7777;
|
||||
wdt_enable(WDTO_120MS);
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
// Most OSs do some intermediate steps when configuring ports and DTR can
|
||||
// twiggle more than once before stabilizing.
|
||||
// To avoid spurious resets we set the watchdog to 250ms and eventually
|
||||
// cancel if DTR goes back high.
|
||||
/* TODO, AVR Stuff
|
||||
wdt_disable();
|
||||
wdt_reset();
|
||||
*(uint16_t *)0x0800 = 0x0;
|
||||
*/
|
||||
}
|
||||
banzai();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -131,7 +144,6 @@ bool WEAK CDC_Setup(Setup& setup)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int _serialPeek = -1;
|
||||
void Serial_::begin(uint32_t baud_count)
|
||||
{
|
||||
|
Reference in New Issue
Block a user