void reback_to_boot(void) { //hal_watchdog_enable(); hal_watchdog_init(0); hal_watchdog_enable(); //hal_pm_reset(); }
static void jump_to_usbupgrade() { u8 * env_buffer = NULL; charsto_device_t *p_charsto = NULL; charsto_prot_status_t st_set = {0}; env_buffer = mtos_malloc(0x10000); if(env_buffer == NULL) { OS_PRINTF("env_buffer fail \n"); return; } p_charsto = (charsto_device_t *)dev_find_identifier(NULL, DEV_IDT_TYPE, \ SYS_DEV_TYPE_CHARSTO); if(NULL == p_charsto) { return; } charsto_read(p_charsto,UBOOT_ENV_ADDR,env_buffer,UBOOT_ENV_SIZE); OS_PRINTF("env end 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x \n", env_buffer[UBOOT_ENV_SIZE - 8],env_buffer[UBOOT_ENV_SIZE - 7], env_buffer[UBOOT_ENV_SIZE - 6], env_buffer[UBOOT_ENV_SIZE - 5],env_buffer[UBOOT_ENV_SIZE - 4], env_buffer[UBOOT_ENV_SIZE - 3],env_buffer[UBOOT_ENV_SIZE - 2], env_buffer[UBOOT_ENV_SIZE - 1]); env_buffer[UBOOT_ENV_SIZE - 1] = 0; env_buffer[UBOOT_ENV_SIZE - 2] = 0; env_buffer[UBOOT_ENV_SIZE - 3] = 0; env_buffer[UBOOT_ENV_SIZE - 4] = 0; env_buffer[UBOOT_ENV_SIZE - 5] = 1; st_set.prt_t = PRT_UNPROT_ALL; dev_io_ctrl(p_charsto, CHARSTO_IOCTRL_SET_STATUS, (u32)&st_set); charsto_erase(p_charsto, UBOOT_ENV_ADDR,1); charsto_writeonly(p_charsto, UBOOT_ENV_ADDR, env_buffer, UBOOT_ENV_SIZE); mtos_free(env_buffer); mtos_task_delay_ms(200); hal_watchdog_enable(); hal_pm_reset(); }
int main(void) { uint8_t addr; hal_sysinit(); hal_watchdog_enable(); addr = hal_get_addr(); // device address from DIP switches addr |= 0x00; // add the device class uart_init(addr); // timeout affects collision recovery, use address rand_seed(((uint16_t)addr << 8) | (uint16_t)addr); timer_init(switch_tick, addr); // init with system-wide unique value phc_init(input_cmd_start, input_payload, input_cmd_end); input_init(addr); input_mainloop(); return 0; // we won't get here }