Skip to content

Latest commit

 

History

History
97 lines (78 loc) · 2.59 KB

File metadata and controls

97 lines (78 loc) · 2.59 KB

Compiling for other platforms (RISC-V, ARM32, ARM64, WIN32, WIN64)

1) Environment setup (RISC-V example)

Install a Debian-based Linux distro (choose one)

2) Install dependencies

apt update
apt install git build-essential bc cmake python3 python3-pip python-is-python3 libffi-dev libssl-dev cargo golang ninja-build

3) Clone sources

#Toit
git clone https://github.com/toitlang/toit.git
cd toit/

#ESP-IDF
git submodule update --init --recursive

4) Compile Toit SDK

make all

5) Run examples

build/host/sdk/bin/toit.run examples/hello.toit
build/host/sdk/bin/toit.run examples/bubble_sort.toit
build/host/sdk/bin/toit.run examples/mandelbrot.toit


Cross-compiling

This section describes how to compile the Toit binaries (toit.compile and toit.run) for another architecture (like RISC-V).

1) Prepare host tools

Note: This is necessary to generate the snapshots that are part of the SDK.

Follow steps 2-4 above on the host.

2) Install cross-compile dependencies

apt update

#RISC-V 64 (fails to link on Arch Linux)
apt install g++-riscv64-linux-gnu gcc-riscv64-linux-gnu

#ARM 32 (template warnings on compile, but works)
apt install g++-arm-linux-gnueabihf gcc-arm-linux-gnueabihf

#ARM 64
apt install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu

#WIN 32
apt install g++-mingw-w64-i686 gcc-mingw-w64-i686

#WIN 64
apt install g++-mingw-w64-x86-64 gcc-mingw-w64-x86-64

3) Cross-compile Toit SDK

#Substitute <TARGET> with one of [arm32, arm64, riscv64, win32, win64]
make CROSS_ARCH=<TARGET> sdk-cross

For example, for Windows:

make CROSS_ARCH=win64 sdk-cross

4) Deploy

A complete Toit environment should now be ready for use on the target architecture

ᐅ find build/win64/sdk
build/win64/sdk
build/win64/sdk/bin
build/win64/sdk/bin/toit.run.exe
build/win64/sdk/bin/toit.compile.exe
build/win64/sdk/bin/toit.run.snapshot
build/win64/sdk/lib
build/win64/sdk/tools
build/win64/sdk/tools/firmware.exe
build/win64/sdk/tools/snapshot_to_image.exe
build/win64/sdk/tools/stacktrace.exe
build/win64/sdk/tools/system_message.exe
build/win64/sdk/tools/toitp.exe

Note: The sdk/lib directory is, by default, only a symlink to the 'lib' directory. For deployment the SDK needs to have the symlink replaced by a copy of the 'lib' directory.