Skip to content

Latest commit

 

History

History
63 lines (51 loc) · 1.85 KB

221005.startup_time.md

File metadata and controls

63 lines (51 loc) · 1.85 KB

2022-10-05

https://discordapp.com/channels/918498540232253480/918498540232253483/1027226257563324496

@3589810

Hi, I am thinking about using toit for a project that has a hard real-time requirement for the startup time below 1 second. How long does it take to start executing the first toit program/VM?
(ESP32 standard chip)

floitsch

Should be plenty of time. Let me make a small example to test start-up time.

main:
  print Time.monotonic_us

The monotonic_us is reset at start, when the device is powered on.
The output I get is: 93950
There might be a bit more overhead for the ESP32 booting up, but I'm pretty sure it's below 1s.
and the monotonic_us might even include that time.

@3589810

I could also take a second esp32 and measure the time it takes for the device to wake-up from deep-sleep (which is equivalent to reboot) and it setting a pin.
I'm pretty sure it would be pretty much the same.

kasperl

Deep sleep wakeup is likely faster. The bootloader spends extra time on full reboots verifying checksums.
(it's pretty significant)

3589810

Nice! Thank you for the quick response. -- Phil

floitsch

import esp32
import gpio

main:
  pin := gpio.Pin 27 --output
  pin.set 1
  print "sleeping 20s"
  sleep --ms=20_000
  print "going to sleep. wakeup with pin 18"
  esp32.enable_external_wakeup (1 << 26) true
  esp32.deep_sleep (Duration --h=24)
import gpio

main:
  in := gpio.Pin 26 --input --pull_down
  out := gpio.Pin 27 --output

  in.configure --input --pull_down

  now := Time.monotonic_us
  out.set 1
  in.wait_for 1
  done := Time.monotonic_us

  print "Took: $(done - now)us"

Took: 175880us
So 176ms from getting a signal on a pin to wake up from deep sleep, until setting a different pin in Toit.
If you need to start up from a power-on it might be slightly more, but not that much.