Program your micro-controllers in a fast and robust high-level language.

Related tags

Miscellaneous toit

Toit language implementation

This repository contains the Toit language implementation. It is fully open source and consists of the compiler, virtual machine, and standard libraries that together enable Toit programs to run on an ESP32.

We use GitHub Discussions to discuss and learn and we follow a code of conduct in all our community interactions.


The Toit language is the foundation for the Toit platform that brings robust serviceability to your ESP32-based devices. You can read more about the language and the standard libraries in the platform documentation:


The Toit compiler, the virtual machine, and all the supporting infrastructure is licensed under the LGPL-2.1 license. The standard libraries contained in the lib/ directory are licensed under the MIT license. The examples contained in the examples/ directory are licensed under the 0BSD license.

Certain subdirectories are under their own open source licenses, detailed in those directories. These subdirectories are:

  • Every subdirectory under src/third_party
  • Every subdirectory under src/compiler/third_party
  • Every subdirectory under lib/font/x11_100dpi
  • The subdirectory lib/font/matthew_welch



The VM has a requirement to ESP-IDF, both for Linux and ESP32 builds (for Linux it's for the MBedTLS implementation).

We recommend you use Toitware's ESP-IDF fork that comes with a few changes:

  • Custom malloc implementation.
  • Allocation-fixes for UART, etc.
  • LWIP fixes.
git clone
pushd esp-idf/
git checkout patch-head-4.3-3
git submodule update --init --recursive

Remember to add it to your ENV as IDF_PATH:

export IDF_PATH=...

ESP32 tools

Install the ESP32 tools, if you want to build an image for an ESP32.

On Linux:


For other platforms see

Update your environment variables:


Build for Linux

Make sure IDF_PATH is set, as described above.

Then run the following commands at the root of your checkout.

make build/host/bin/toitvm

You should then be able to execute a toit file:

build/host/bin/toitvm examples/hello.toit

Build for ESP32

Make sure the environment variables for the ESP32 tools are set, as described in the dependencies section.

Build an image for your ESP32 device that can be flashed using

make esp32

By default, the image boots up and runs examples/hello.toit. You can use your own entry point and specify it through the ESP32_ENTRY make variable:

make esp32 ESP32_ENTRY=examples/mandelbrot.toit

Configuring WiFi for the ESP32

You can easily configure the ESP32's builtin WiFi by setting the ESP32_WIFI_SSID and ESP32_WIFI_PASSWORD make variables:

make esp32 ESP32_ENTRY=examples/http.toit ESP32_WIFI_SSID=myssid ESP32_WIFI_PASSWORD=mypassword

This allows the WiFi to automatically start up when a network interface is opened.


We welcome and value your open source contributions.

  • Elaborate on build requirements

    Elaborate on build requirements

    • add "Build system" section detailing generic build requirements;
      • gcc
      • golang
      • ninja
      • cmake
    • refer to above section in "Build for Linux"
    • use apt instead of apt-get in installation instructions
    opened by mikini 19
  • Issues about porting ESP32-S3 to toit

    Issues about porting ESP32-S3 to toit


    I am trying to port ESP32-S3 to toit, I mostly finish refactoring the Makefile, and compile final toit.bin. Now I meet an issues, system runs toit language binary failed, the log is:

    Invoking primitive 0::15
    Invoking primitive 0::15
    fatal: "Threw exception before entering last-chance catch clause"

    I add some log and find the _primitives is not initialized successfully, log is:


    Could any one give me some help ?

    opened by donghengqaz 14
  • ESP32 crash after jag run

    ESP32 crash after jag run

    I have got ESP32 crash after ~5th jag update after jag flash (just simple 4 line hello word). I am not able to reproduce it.

    Guru Meditation Error: Core  1 panic'ed (StoreProhibited). Exception was unhandled.
    Core  1 register dump:
    PC      : 0x400862a0  PS      : 0x00060a30  A0      : 0x801053dc  A1      : 0x3ffcadf0
    A2      : 0x0000008d  A3      : 0x00000000  A4      : 0x00000000  A5      : 0x00000000
    A6      : 0x3ffd489c  A7      : 0x3ffc8308  A8      : 0x3f430e86  A9      : 0x3f41225c
    A10     : 0x3f41225c  A11     : 0x00000000  A12     : 0x00000155  A13     : 0x3f41225c
    A14     : 0x3f41225c  A15     : 0x3f41225c  SAR     : 0x0000000c  EXCCAUSE: 0x0000001d
    EXCVADDR: 0x0000008d  LBEG    : 0x400818d1  LEND    : 0x400818d9  LCOUNT  : 0x00000027
    Backtrace:0x4008629d:0x3ffcadf0 0x401053d9:0x3ffcae70 0x4011315f:0x3ffcaea0 0x4011334e:0x3ffcaef0 0x40113381:0x3ffcaf20 0x4010701e:0x3ffcaf40 0x40107045:0x3ffcaf60
    ELF file SHA256: 49bc775c76ae2181
    opened by muhlpachr 14
  • Set: basic operations inconsistencies

    Set: basic operations inconsistencies


    consider the following program which creates Set variables.

    a) some operations are obviously allowed for a single item, but not for multiple items; so why allow it for a single item at all? b) some do not make sense at all (to me): such as true/false or null in a Set c) basically what I do derive from the test is: only and can be used in a Set. d) so either you should update the doc (and the compiler) and/or extend the operations allowed on a Set

    You should test also with .add and .remove operations. You should test also with List and Map. (I think when looking at the code you get the idea what to do)

    Uncommenting raises the exception, all uncommented lines do not cause an exception.

    main: exception := catch: sett/Set := {}

        sett = {true}
        //sett = {true, false}  => EXCEPTION -> LOOKUP_FAILED ...
        sett = {1}
        sett = {1, 2}
        sett = {"a"}
        sett = {"a", "b"}
        sett = {"a", 1}
        //sett = {"a", true}    => EXCEPTION -> LOOKUP_FAILED ...
        //sett = {1, true}      => EXCEPTION -> LOOKUP_FAILED ...
        sett = {null}
        //sett = {null, ""}     => EXCEPTION -> LOOKUP_FAILED ...
        //sett = {null, "a"}    => EXCEPTION -> LOOKUP_FAILED ...
        //sett = {null, 1}      => EXCEPTION -> LOOKUP_FAILED ...
        sett = {[2, 2, 2]}
        sett = {[2, 2, 2], [2, 2, 2]}
        //sett = {[2, 2, 2], [1, 1, 1]} => EXCEPTION -> LOOKUP_FAILED ...
        sett = {{2}}
        sett = {{2, 2}}
        sett = {{2}, {2}}
        sett = {{2, 2}, {2, 2}}
        //sett = {{1}, {2}}
        //sett = {{1, 1}, {2, 2}}
        sett = {[2]}
        sett = {[2, 2]}
        sett = {[2], [2]}
        sett = {[2, 2], [2, 2]}
        //sett = {[1], [2]}      => EXCEPTION -> LOOKUP_FAILED ...
        //sett = {[1, 1], [2, 2]} => EXCEPTION -> LOOKUP_FAILED ...
        sett = {{"x": "X"}}
        //sett = {{"x": "X"}, {"y": "Y"}} {"x": "X"}   => EXCEPTION -> LOOKUP_FAILED ...
        //sett = {{"x": "X"}, 1} => EXCEPTION -> LOOKUP_FAILED ...
    if exception:
        print "EXCEPTION -> $exception ..."
        print "D O N E !!!"
    print "test 1"
    opened by lutzbickhardt 13
  • BLE Documentation

    BLE Documentation

    Andreas Spiess complains in its Youtube-Review that the Documentation contains a Bluetooth Tutorial but misses to explain or show how to actually transmit data - he failed there (he got only manufacturer data to work)

    I had the same issue. Some days ago I discovered by accident that the repo contains a perfect and dead simple example.

    Easy fix: Add something like this one-liner to the docs

    "Find a working example here:"

    at the end of the BLE Tutorial


    opened by nivoc 11
  • BLE server

    BLE server

    This implements a BLE server for toit.

    Special care has been taken to keep backwards compatibility and to keep the number of new primitives to a minimum.

    The main idea is to setup the ble config in a separate resource group and when the Device is initialised then setup the nimble host stack.

    To separate client connections and connections made to other server, a small rearrangement of the original implementation had to be changed, so that the connection and disconnection events are send on the GATT resource.

    Added an example of how to use the lib.

    opened by mikkeldamsgaard 9
  • Add 64-bit RISC-V/Linux platform support

    Add 64-bit RISC-V/Linux platform support

    Note, this does not include support for embedded RISC-V devices; a full Linux environment is expected. I will be evaluating support for the ESP32-C3 in the next few weeks.

    See status tracker for capabilities. See feature request for development history

    Resolves #43

    opened by dsobotta 9
  • App crashes when subscribing to a device:* pubsub topic

    App crashes when subscribing to a device:* pubsub topic


    I was playing around with the local pubsub mechanism as it is described in the tutorial. However, when I deploy my subscriber app, I'm receiving following exception after ~7 seconds:

    EXCEPTION error. 
    COAP ERROR 132: failed to find subscription with ID: 00000000-0000-0000-0000-000000000000
      0: Client.read_response_     <sdk>/coap/client.toit:177:7
      1: Client.stream_read        <sdk>/coap/client.toit:82:12
      2: Stream_.receive           system/kernel/console/v2_client.toit:201:20
      3: PubSubFetch_.receive      system/kernel/console/v2_client.toit:137:20
      4: ConsoleConnector.fill_pubsub_queues_.<block>.<block> system/kernel/console_connector.toit:542:58
      5: ConsoleConnector.fill_pubsub_queues_.<block> system/kernel/console_connector.toit:539:5
      6: ConsoleConnector.fill_pubsub_queues_ system/kernel/console_connector.toit:520:3
      7: ConsoleConnector.process_pubsub_.<block> system/kernel/console_connector.toit:513:7
      8: ConsoleConnector.process_pubsub_ system/kernel/console_connector.toit:510:3
      9:<block>.<block>.<block>.<block> system/kernel/console_connector.toit:275:17
     10: Task_.with_deadline_.<block> <sdk>/core/task.toit:79:21
     11: Task_.with_deadline_      <sdk>/core/task.toit:73:3
     12: with_timeout              <sdk>/core/utils.toit:174:15
     17: catch                     <sdk>/core/exceptions.toit:87:10
     18:<block>.<block> system/kernel/console_connector.toit:257:16
     19:<block> system/kernel/console_connector.toit:235:37
     20: Connection.with_client.<block>.<block>.<block> system/kernel/connection.toit:48:16
     21: Connection.with_client.<block>.<block> system/kernel/connection.toit:45:7
     22: Connection.with_client.<block> system/kernel/connection.toit:44:15
     23:<block> system/kernel/component.toit:131:19
     24:         system/kernel/component.toit:128:3
     25: Connection.with_client    system/kernel/connection.toit:44:13
     26:      system/kernel/console_connector.toit:235:10
     27: ConsoleSyncJob.run_.<block> system/kernel/scheduler.toit:419:26
     28: ConsoleSyncJob.run_       system/kernel/scheduler.toit:415:3
     29: ConsoleSyncJob.start.<lambda>.<block>.<block> system/kernel/scheduler.toit:410:11
     30: catch.<block>             <sdk>/core/exceptions.toit:114:10
     31: catch                     <sdk>/core/exceptions.toit:112:1
     32: catch                     <sdk>/core/exceptions.toit:87:10
     33: ConsoleSyncJob.start.<lambda>.<block> system/kernel/scheduler.toit:409:9
     34: ConsoleSyncJob.start.<lambda> system/kernel/scheduler.toit:407:25

    Unfortunately this makes the entire app crash. It neither works if I execute the code via the toit console nor when I deploy my code as a job. I also added the subscription to my *.yaml file as it otherwise complained that the PUBSUB topic was not set up. Also with device-memory: prefix it did not work.

    I'm clueless and have no idea what I could have done wrong...

    opened by rbedemann 8
  • Migrated to builds of esp32 (including ESP32S3 and ESP32C3 ports).

    Migrated to builds of esp32 (including ESP32S3 and ESP32C3 ports).

    Testet it out on esp32 only. The esp32c3 and esp32s3 does not yet compile. That will be work in progress. The general idea is to have toolchains/idf/CMakeLists.txt as the "idf-component" and then the toolchain/esp32 project includes this as a normal component and we let do the compile. To enable this, some ligt modifications to existing cmake needed to be done, mostly adding working directories and surrounded blocks that is not needed and disturbs idf with an appropriate condition.

    opened by mikkeldamsgaard 7
  • ESP32-D0WDQ6 crash after flash

    ESP32-D0WDQ6 crash after flash

    PS C:\Users\michal\test> jag flash
    v COM13
    Enter WiFi network (SSID): ros2p
    Enter WiFi password for 'ros2p': ******
    Flashing device over serial on port 'COM13' ... v3.0
    Serial port COM13
    Chip is ESP32-D0WDQ6 (revision 1)
    Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
    Crystal is 40MHz
    MAC: 80:7d:3a:e4:d7:a0
    Uploading stub...
    Running stub...
    Stub running...
    Changing baud rate to 921600
    Configuring flash size...
    Auto-detected Flash size: 4MB
    Compressed 15392 bytes to 10770...
    Wrote 15392 bytes (10770 compressed) at 0x00001000 in 0.1 seconds (effective 877.9 kbit/s)...
    Hash of data verified.
    Compressed 3072 bytes to 119...
    Wrote 3072 bytes (119 compressed) at 0x00008000 in 0.0 seconds (effective 3120.2 kbit/s)...
    Hash of data verified.
    Compressed 1102176 bytes to 727320...
    Wrote 1102176 bytes (727320 compressed) at 0x00010000 in 10.7 seconds (effective 826.2 kbit/s)...
    Hash of data verified.
    Hard resetting via RTS pin...
    PS C:\Users\michal\test> jag monitor
    Starting serial monitor of port 'COM13' ...
    ets Jun  8 2016 00:22:57
    rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
    configsip: 0, SPIWP:0xee
    mode:DIO, clock div:2
    ho 0 tail 12 room 4
    entry 0x400805c8
    clearing RTC memory: RTC memory is in inconsistent state
    [flash reg] address 0x3f430000, size 0x00200000
    Decode system message with:
    Decode system message with:
    [jaguar] ERROR: rebooting due to
    Entering deep sleep for 1000ms
    ets Jun  8 2016 00:22:57
    jag version
    Version:         v1.0.3
    SDK version:     v1.6.6
    Build date:      2022-02-10T16:35:08Z
    EXCEPTION error.
      0: flash_kv_init_            <sdk>/device_impl.toit:103:3
      1: KeyValue_                 <sdk>/device_impl.toit:88:14
      2: FlashStore_.init_         <sdk>/device_impl.toit:37:17
      3: FlashStore_.instance      <sdk>/device_impl.toit:42:46
      4: FlashStore.get            <sdk>/device.toit:59:28
      5: ProgramManager.last       /home/runner/work/jaguar/jaguar/src/programs.toit:31:23
      6: serve.<block>             /home/runner/work/jaguar/jaguar/src/jaguar.toit:61:21
      7: catch.<block>             <sdk>/core/exceptions.toit:114:10
      8: catch                     <sdk>/core/exceptions.toit:112:1
      9: catch                     <sdk>/core/exceptions.toit:63:10
     10: serve                     /home/runner/work/jaguar/jaguar/src/jaguar.toit:60:16
     11: main.<block>.<block>      /home/runner/work/jaguar/jaguar/src/jaguar.toit:32:33
     12: catch.<block>             <sdk>/core/exceptions.toit:114:10
     13: catch                     <sdk>/core/exceptions.toit:112:1
     14: catch                     <sdk>/core/exceptions.toit:63:10
     15: main.<block>              /home/runner/work/jaguar/jaguar/src/jaguar.toit:32:18
     16: main                      /home/runner/work/jaguar/jaguar/src/jaguar.toit:29:1
     17: __entry__.<lambda>        <sdk>/core/entry.toit:48:20
    EXCEPTION error.
      0: flash_kv_init_            <sdk>/device_impl.toit:103:3
      1: KeyValue_                 <sdk>/device_impl.toit:88:14
      2: FlashStore_.init_         <sdk>/device_impl.toit:37:17
      3: FlashStore_.instance      <sdk>/device_impl.toit:42:46
      4: FlashStore.delete         <sdk>/device.toit:67:21
      5: ProgramManager.last=      /home/runner/work/jaguar/jaguar/src/programs.toit:39:14
      6: serve                     /home/runner/work/jaguar/jaguar/src/jaguar.toit:73:18
      7: main.<block>.<block>      /home/runner/work/jaguar/jaguar/src/jaguar.toit:32:33
      8: catch.<block>             <sdk>/core/exceptions.toit:114:10
      9: catch                     <sdk>/core/exceptions.toit:112:1
     10: catch                     <sdk>/core/exceptions.toit:63:10
     11: main.<block>              /home/runner/work/jaguar/jaguar/src/jaguar.toit:32:18
     12: main                      /home/runner/work/jaguar/jaguar/src/jaguar.toit:29:1
     13: __entry__.<lambda>        <sdk>/core/entry.toit:48:20
    opened by muhlpachr 7
  • Add make flash target

    Add make flash target

    PR for issue #51. Adds make flash target.

    make flash can be called with ESP32_ENTRY, ESP32_WIFI_PASSWORD, ESP32_WIFI_SSID as with make esp32 and additionally adds ESP32_PORT, which is required, to specify the port the ESP32 is connected to.

    To compile new changes and flash to device: make flash ESP32_PORT=/dev/ttyS17 ESP32_WIFI_PASSWORD=password ESP32_WIFI_SSID=ssid ESP32_ENTRY=examples/hello.toit

    Assumes python is installed, IDF_PATH is valid, particular ESP32 can communicate at 921600 baud, and user has permission to access the device (sudo adduser $USER dialout on most systems).

    opened by justind000 7
  • Rewrite 'pin.wait_for'.

    Rewrite 'pin.wait_for'.

    When calling wait_for we now return a "timestamp". Whenever there is an edge-detection we notify listeners. The listeners can use this timestamp to know whether the edge-transition happened after they subscribed or before. If it was before, they know that the requested level was achieved. The edge-transition might actually indicate that the pin is now at the non-requested input level, but we still know that the pin was at least once at the state we are looking for.

    opened by floitsch 0
  • MessageEncoder probably leaks memory when there are errors during encoding.

    MessageEncoder probably leaks memory when there are errors during encoding.

    The destructor needs to clean up, and there needs to be a dont_free() method for use when its allocations have been handed over to the system (put in the Message).

    opened by erikcorry 1
  • Optimize access to elements of list slices

    Optimize access to elements of list slices

    The case isn't handled in the Interpreter::fast_at helper yet:

    opened by kasperl 0
Toit language
Toit language
RRxIO - Robust Radar Visual/Thermal Inertial Odometry: Robust and accurate state estimation even in challenging visual conditions.

RRxIO - Robust Radar Visual/Thermal Inertial Odometry RRxIO offers robust and accurate state estimation even in challenging visual conditions. RRxIO c

Christopher Doer 61 Nov 11, 2022
High-level interface for low-level programming

Singeli Singeli is now able to compile useful programs to C, but it's very rough around the edges, with poor error reporting. We are beginning to use

Marshall Lochbaum 38 Nov 12, 2022
An AI for playing NES Tetris at a high level. Based primarily on search & heuristic, with high quality board evaluation through value iteration.

StackRabbit An AI that plays NES Tetris at a high level. Primarily based on search & heuristic, with high-quality board eval through value iteration.

Greg Cannon 229 Nov 20, 2022
A Visual Studio extension that provides enhanced support for editing High Level Shading Language (HLSL) files

HLSL Tools for Visual Studio This extension is for Visual Studio 2017 / 2019. Go here for the Visual Studio Code extension. HLSL Tools is a Visual Stu

Tim Jones 427 Nov 22, 2022
weggli is a fast and robust semantic search tool for C and C++ codebases. It is designed to help security researchers identify interesting functionality in large codebases.

weggli is a fast and robust semantic search tool for C and C++ codebases. It is designed to help security researchers identify interesting functionality in large codebases.

Google Project Zero 2k Nov 21, 2022
A water tank level sensor **Built With WisBlock** to detect overflow and low level conditions.

RAK12014 Laser TOF sensor coming soon WisBlock Watertank Level Sensor Watertank Overflow detection using the RAKwireless WisBlock modules. It implemen

Bernd Giesecke 3 Feb 3, 2022
Connect 8Bit controllers to the PSVita

8BitVita Basically just X1Vita but with 8bitdo vid, pid, & mappings. Compatible 8bitdo controllers: Lite, Pro, Pro+, Pro 2, & Zero 2. Download: https:

Ibrahim 26 Aug 20, 2022
Automated hydroponics with Home Assistant & ESP8266 controllers

ESPonics Automated hydroponics with ESP8266 microcontrollers & Home Assistant I absolutely want to credit Reddit user u/ghoofman for both the inspirat

jjensn 16 Aug 27, 2022
Windows kernel-mode driver emulating well-known USB game controllers.

Windows kernel-mode driver emulating well-known USB game controllers.

Virtual Gamepad Emulation Framework 1.7k Nov 23, 2022
An IOS module that fakes Wiimotes from the input of USB game controllers

fakemote An IOS module that fakes Wiimotes from the input of USB game controllers. Supported USB game controllers Device Name Vendor Name Vendor ID Pr

Sergi Granell 90 Nov 18, 2022
ControllaBLE - A retro-controllers to Bluetooth BLE adapter

ControllaBLE - A retro-controllers to Bluetooth BLE adapter This is an ESP32 based controller adapter that outputs as a dual joypad through Bluetooth

null 14 Oct 16, 2022
Grafana/Prometheus exporter for EPEVER/EPSOLAR Tracer solar charge controllers

epever_exporter epever_exporter is a standalone program written in C that can query Epever/Epsolar Tracer solar charge controllers and output metrics

Cédric Félizard 1 Nov 23, 2021
Tiny implementation of the GNU/Linux CGroupFS (sans resource controllers) as a PUFFS or FUSE filesystem for BSD platforms

CGrpFS CGrpFS is a tiny implementation of the GNU/Linux CGroup filesystem for BSD platforms. It takes the form of a either a PUFFS or FUSE filesystem,

null 13 Nov 8, 2022
Turn your ESP32 into a easy to use micro web-server allowing to interact with any GPIO by simple http(s) calls.

WebhooksTriggeredESP32WiFi Turn your ESP32 into an easy to use and manage wireless micro web-server allowing it to process reliably and asynchronouly

JayDeLux 4 Jun 1, 2022
In this Program, I am using C language and creating All Patterns Program using Switch case

In this Program, I am using C language and creating All Patterns Program using Switch case. It has 15 pattern programs like a pyramid, half pyramid, etc...

Rudra_deep 1 Nov 13, 2021
A program to backup all of your game savefiles on your system, neatly, and into a single folder.

Savefile Saver I created this project as a solution to a simple, but annoying problem: Backing up my game savefiles. I wanted to be able to copy all o

Dominic Esposito 6 Oct 24, 2022
rlua -- High level bindings between Rust and Lua

rlua -- High level bindings between Rust and Lua

Amethyst Foundation 1.4k Nov 18, 2022
Bypass UAC at any level by abusing the Program Compatibility Assistant with RPC, WDI, and more Windows components

ByeIntegrity 8.0 The eighth Windows privilege escalation attack in the ByeIntegrity family. ByeIntegrity 8.0 is the most complex one I've created so f

Arush Agarampur 218 Nov 9, 2022