Skip to content

h1romas4/m5stack-core2-wasm3-as

Repository files navigation

m5stack-core2-wasm3-as

M5Stack Core2(Xtensa) With Wasm3/AssemblyScript Demo.

Wasm1

See also: RISC-V version

m5stamp-c3dev

This is a development board for the M5Stamp C3 (RISC-V/FreeRTOS).

Twitter Video

Build

Require

get_idf

alias get_idf='. $HOME/esp/esp-idf/export.sh'
$ get_idf
Detecting the Python interpreter
... snip ...
Done! You can now compile ESP-IDF projects.
Go to the project directory and run:

  idf.py build

$ echo ${IDF_PATH}
/home/hiromasa/devel/toolchain/esp/esp-idf

$ xtensa-esp32-elf-gcc -v
Using built-in specs.
COLLECT_GCC=xtensa-esp32-elf-gcc
COLLECT_LTO_WRAPPER=/home/hiromasa/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/../libexec/gcc/xtensa-esp32-elf/8.4.0/lto-wrapper
lto-wrapper
Target: xtensa-esp32-elf
... snip ...
Thread model: posix
gcc version 8.4.0 (crosstool-NG esp-2021r2-patch5)

Build and Execute

  1. git clone and build
git clone --recursive https://github.com/h1romas4/m5stack-core2-wasm3-as
cd m5stack-core2-wasm3-as
idf.py build
  1. Write Partition table
idf.py partition-table-flash
  1. Write TypeType font to SPIFFS
parttool.py write_partition --partition-name=font --partition-subtype=spiffs --input resources/spiffs_font.bin
  1. Write WebAssembly(.wasm) to SPIFFS (WebAssembly Apps)
parttool.py write_partition --partition-name=wasm --partition-subtype=spiffs --input resources/spiffs_wasm.bin
  1. Restart M5Stack Core 2
idf.py flash monitor

Switch WebAssembly Apps

idf.py menuconfig

WebAssembly Apps - Select WebAssembly Apps

menuconfig

idf.py build flash monitor

Wasm2

Setup WiFi (Optional)

  1. Change WiFi Setting

nvs_partition.csv: Set own [ssid], [password]

key,type,encoding,value
wifi,namespace,,
ssid,data,string,[ssid]
passwd,data,string,[password]
  1. Create NVS Partition file
python ${IDF_PATH}/components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py generate nvs_partition.csv nvs_partition.bin 0x6000
  1. Write NVS Partition
esptool.py write_flash 0x9000 nvs_partition.bin
  1. Run

NTP synchronization is performed by pressing the "Center button" after the startup logo.

idf.py monitor

Build AssemblyScript

cd wasm/clockenv # or wasm/imu6886 or wasm/gpsgsv
npm install

Web Browser Development

npm run asbuild:web
npm run start
# http://localhost:1234/

Build and Flash

npm run asbuild
cd ../..
python ${IDF_PATH}/components/spiffs/spiffsgen.py 0x10000 resources/wasm resources/spiffs_wasm.bin
parttool.py write_partition --partition-name=wasm --partition-subtype=spiffs --input resources/spiffs_wasm.bin

Note

  • Create SPIFFS parteation file
# for TrueType font
python ${IDF_PATH}/components/spiffs/spiffsgen.py 0x100000 resources/font resources/spiffs_font.bin
# for .wasm binary
python ${IDF_PATH}/components/spiffs/spiffsgen.py 0x10000 resources/wasm resources/spiffs_wasm.bin

Dependencies

Thanks for all the open source.

Name Version License
esp-idf v4.4.6 BSD License
arduino-esp32 2.0.14 LGPL-2.1 License
M5Core2 0.1.8 MIT License
M5EPD 0.1.5 MIT License
lwgps v2.1.0 MIT License
Wasm3 master(045040a9) MIT License
AssemblyScript 0.27.22 Apache-2.0 License
源真ゴシック - SIL Open Font License 1.1

License

MIT License