Skip to content
forked from toitlang/toit

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

License

Notifications You must be signed in to change notification settings

SpinlockLabs/toit

 
 

Repository files navigation

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.

References

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:

Licenses

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

Dependencies

ESP-IDF

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 https://github.com/toitware/esp-idf.git
pushd esp-idf/
git checkout patch-head-4.3-3
git submodule update --init --recursive
popd

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:

$IDF_PATH/install.sh

For other platforms, see Espressif's documentation.

Remember to update your environment variables:

. $IDF_PATH/export.sh

The build system will automatically use a 32-bit build of the Toit compiler to produce the correct executable image for the ESP32. Your build might fail if you're on a 64-bit Linux machine and you don't have the support for compiling 32-bit executables installed. You can install this support on most Linux distributions by installing the gcc-multilib and g++-multilib packages. If you use apt-get, you can use the following command:

sudo apt-get install gcc-multilib g++-multilib

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 esptool.py.

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.

Contributing

We welcome and value your open source contributions.

About

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

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 99.1%
  • Other 0.9%