After toit_start(), we have toit_esp32.cc to read. The first one is toit::start(). Toit here is just a namespace. As we know that toit supports OTA (over-the-air update) through WiFi and esp32 device is set to be a station (STA instead of AP).

What we have here is as follows:

  • RtcMemory::set_up();
  • FlashRegistry::set_up();
  • OS::set_up();
  • esp_partition_find_first();
  • setup_program(support_ota);
  • Scheduler::ExitState exit_state;
  • VM vm;
  • vm.load_platform_event_sources();
  • int groud_id = vm.scheduler()->next_group_id();
  • exit_state = vm.scheduler()->run_boot_program(program, null, group_id);
  • OS::tear_down();
  • FlashRegistry::tear_down();

After these, esp32 may go to deep sleep.