Beispiel #1
0
void call_user_start()
{

	uint32 romaddr = 0, total_size = 0, boot_try = 3;
	INFO("ESPBOOT - New style Bootloader for ESP8266\r\n"
			 "Version: v0.1 - Release: 2015-Nov-01\r\n"
			 "Author: Tuan PM\r\n");

	load_boot_cfg(&boot_cfg);

	if(boot_cfg.new_rom_addr > 0)
	{
		if((romaddr = load(boot_cfg.new_rom_addr, boot_cfg.app_rom_addr)) > 0)
		{
			boot_cfg.new_rom_addr = 0;
			save_boot_cfg(&boot_cfg);
			INFO("ESPBOOT: everyting is ok, goto new app\r\n");
			boot_app(romaddr);
		}

		INFO("ESPBOOT: backup application at 0x%X\r\n", boot_cfg.backup_rom_addr);
		if((romaddr = load(boot_cfg.backup_rom_addr, boot_cfg.app_rom_addr)) > 0)
		{
			boot_cfg.new_rom_addr = 0;
			save_boot_cfg(&boot_cfg);
			INFO("ESPBOOT: everyting is ok, goto backup app\r\n");
			boot_app(romaddr);
		}
		INFO("ESPBOOT: Goto old application\r\n");
		boot_try = 3;
		while(boot_try-- > 0)
		{
			INFO("ESPBOOT: try boot application %d\r\n");
			if((romaddr = check_image(boot_cfg.app_rom_addr, &total_size)) > 0)
				boot_app(romaddr);
		}
		ERROR("ESPBOOT: Serious exception !!!\r\n");
	}

	while(boot_try-- > 0)
	{
		INFO("ESPBOOT: try boot application %d\r\n");
		if((romaddr = check_image(boot_cfg.app_rom_addr, &total_size)) > 0)
			boot_app(romaddr);
	}


	INFO("ESPBOOT: backup application at 0x%X\r\n", boot_cfg.backup_rom_addr);
	if((romaddr = load(boot_cfg.backup_rom_addr, boot_cfg.app_rom_addr)) > 0)
	{
		INFO("ESPBOOT: everyting is ok, goto backup app\r\n");
		boot_app(romaddr);
	}
	ERROR("Serious exception !!!");

}
Beispiel #2
0
void
bootloader_exec()
{
  process_boot_cmd();

  boot_app();

  /* Uh oh, we should have jumped to the app... */
  write_app_img(SP_RECOVERY_IMG);

  boot_app();

  chSysHalt();
}