Пример #1
0
void IRAM_ATTR SystemClass::internalApplyFirmwareUpdate(uint32_t readFlashOffset, uint32_t targetFlashOffset, int firmwareSize, bool outputDebug)
{
	uint32_t to = targetFlashOffset;
	uint32_t from = readFlashOffset;
	int size = firmwareSize;

	const int unit = INTERNAL_FLASH_SECTOR_SIZE;
	char buf[unit];

	while (size > 0)
	{
		int sect = to / unit;
		if (outputDebug) ets_uart_printf("write: 0x%X -> 0x%X (sect: %d), %d\n", from, to, sect, size);
		spi_flash_erase_sector(sect);
		//ets_uart_printf("ers.");
		spi_flash_read(from, (uint32*)buf, unit);
		//ets_uart_printf("read.");
		spi_flash_write(to, (uint32*)buf, unit);
		//ets_uart_printf("wr.\r\n");
		from += unit;
		to += unit;
		size -= unit;
	}

	if (outputDebug) ets_uart_printf("Firmware upgrade finished\n");

	((void (*)(void))0x40000080)(); // Hardcore reset vector

	ets_wdt_enable();
	while (1)
		; // Reboot anyway!
}
Пример #2
0
void ICACHE_FLASH_ATTR wdt_init(void)
{
//	RTC_MEM(0) = 0;
	ets_task(wdt_task, WDT_TASK_PRIO, &wdt_eventq, 1);
	ets_isr_attach(ETS_WDT_INUM , wdt_feed, NULL);
	INTC_EDGE_EN |= 1; // 0x3ff00004 |= 1
	ets_wdt_enable(2,3,3); // mode 2 (wdt isr), step 1680403 us
}
Пример #3
0
void user_init(void)
{
	uint8_t state=0;
	ets_wdt_enable();
	ets_wdt_disable();
	// Configure pin as a GPIO
	PIN_FUNC_SELECT(LED_GPIO_MUX, LED_GPIO_FUNC);
	for(;;)
	{
		GPIO_OUTPUT_SET(LED_GPIO, state);
		os_delay_us(DELAY);
		state ^=1;
		wdt_feed();
	}
}
Пример #4
0
void g35_tick(void){
	wdt_feed();
	ets_wdt_disable();
	tick_count++;
	if(tick_count > pattern_rotate_ticks && rotate_patterns){
		tick_count = 0;
		int old_pattern = cur_pattern;
		
		cur_pattern++;
		while(!(g35_patterns[cur_pattern].enabled)&&(cur_pattern!=old_pattern)){
			cur_pattern++;
			if(g35_patterns[cur_pattern].g35_pattern_ticker==NULL)
				cur_pattern=0;
		}
	}
	g35_patterns[cur_pattern].g35_pattern_ticker(tick_count);
	ets_wdt_enable();
}
Пример #5
0
bool ICACHE_FLASH_ATTR i2s_write_sample(uint32_t sample) {
  if (i2s_curr_slc_buf_pos==SLC_BUF_LEN || i2s_curr_slc_buf==NULL) {
    if(i2s_slc_queue_len == 0){
      while(1){
        if(i2s_slc_queue_len > 0){
          break;
        } else {
          ets_wdt_disable();
          ets_wdt_enable();
        }
      }
    }
    ETS_SLC_INTR_DISABLE();
    i2s_curr_slc_buf = (uint32_t *)i2s_slc_queue_next_item();
    ETS_SLC_INTR_ENABLE();
    i2s_curr_slc_buf_pos=0;
  }
  i2s_curr_slc_buf[i2s_curr_slc_buf_pos++]=sample;
  return true;
}
Пример #6
0
void main()
{
    int res = 9;
    struct eboot_command cmd;

    if (eboot_command_read(&cmd)) {
        cmd.action = ACTION_LOAD_APP;
        cmd.args[0] = 0;
        ets_putc('~');
    } else {
        ets_putc('@');
    }
    eboot_command_clear();

    if (cmd.action == ACTION_COPY_RAW) {
        ets_putc('c'); ets_putc('p'); ets_putc(':');
        ets_wdt_disable();
        res = copy_raw(cmd.args[0], cmd.args[1], cmd.args[2]);
        ets_wdt_enable();
        ets_putc('0'+res); ets_putc('\n');
        if (res == 0) {
            cmd.action = ACTION_LOAD_APP;
            cmd.args[0] = cmd.args[1];
        }
    }

    if (cmd.action == ACTION_LOAD_APP) {
        ets_putc('l'); ets_putc('d'); ets_putc('\n');
        res = load_app_from_flash_raw(cmd.args[0]);
        //we will get to this only on load fail
        ets_putc('e'); ets_putc(':'); ets_putc('0'+res); ets_putc('\n');
    }

    if (res) {
        SWRST;
    }

    while(true){}
}
Пример #7
0
void EspClass::wdtEnable(uint32_t timeout_ms)
{
    //todo find doku for ets_wdt_init may set the timeout
	ets_wdt_enable();
}
void EspClass::wdtEnable(int)
{
	ets_wdt_enable();
}