From 38503f1be4ea8c229d0862d83fb529c60e4fc8f3 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Fri, 5 Apr 2024 21:08:56 +0200 Subject: [PATCH] filestore: update README for latest info Signed-off-by: deadprogram --- filestore/README.md | 121 +++++++++++++++++++++++++++++++------------- 1 file changed, 85 insertions(+), 36 deletions(-) diff --git a/filestore/README.md b/filestore/README.md index 1460e4d..f7be4d7 100644 --- a/filestore/README.md +++ b/filestore/README.md @@ -6,21 +6,27 @@ Application that demonstrates how to use the onboard Flash storage on the hardwa ### Flash the board -#### PyBadge - -``` -$ mecha flash -i wasman -m pybadge -Building module hello -Done. - code data bss | flash ram - 64 19 4096 | 83 4115 -Building module ping -Done. - code data bss | flash ram - 9 0 0 | 9 0 +```bash +$ mecha flash -m pybadge +Building TinyGo module ping +Done. +code data bss | flash ram + 9 0 0 | 9 0 +Building Rust module pingrs +Done. +warning: unstable feature specified for `-Ctarget-feature`: `atomics` + | + = note: this feature is not stably supported; its behavior can change in the future +warning: unstable feature specified for `-Ctarget-feature`: `bulk-memory` + | + = note: this feature is not stably supported; its behavior can change in the future +warning: `pingrs` (lib) generated 2 warnings +Finished release [optimized] target(s) in 0.00s +Building Zig module pingzig +Done. Application built. Now flashing... - code data bss | flash ram - 131440 2124 6888 | 133564 9012 +code data bss | flash ram +342556 16812 7224 | 359368 2403 Connected to /dev/ttyACM0. Press Ctrl-C to exit. ==> @@ -28,25 +34,11 @@ Connected to /dev/ttyACM0. Press Ctrl-C to exit. You should see the `==>` prompt. See "How to use" below. -#### Gopher Badge - -``` -$ mecha flash -m gopher-badge - code data bss | flash ram - 139772 4 3632 | 139776 3636 -Connected to /dev/ttyACM0. Press Ctrl-C to exit. - -==> - -``` - -You should see the `==>` prompt. See "How to use" below. - ## How to use You should see a `==>` prompt. Try the `lsblk` command to see the Flash storage information: -``` +```bash ==> lsblk ------------------------------------- Device Information: @@ -60,7 +52,7 @@ This the the available Flash memory on your board in the extra space not being u Try the `ls` command. -``` +```bash ==> ls ------------------------------------- @@ -74,7 +66,7 @@ You do not yet have any WASM files in the Flash storage. Let's put one on the de The easiest way to do this is the included `savefile` program. Press `CTRL-C` to return to your shell, then run the following command (substitute the correct port name for `/dev/ttyACM0` as needed): -``` +```bash cd ./filestore go run ./savefile ./modules/ping.wasm /dev/ttyACM0 @@ -82,7 +74,7 @@ go run ./savefile ./modules/ping.wasm /dev/ttyACM0 Now connect again to the board, and now you should see the file listed using the `ls` command: -``` +```bash $ mecha monitor Connected to /dev/ttyACM0. Press Ctrl-C to exit. @@ -98,7 +90,7 @@ Connected to /dev/ttyACM0. Press Ctrl-C to exit. You can now load the module: -``` +```bash ==> load ping.wasm loading ping.wasm module loaded. @@ -106,14 +98,14 @@ module loaded. And then start it running: -``` +```bash ==> run module running. ``` Use the `ping` command: -``` +```bash ==> ping 3 Ping... pong @@ -123,4 +115,61 @@ Ping... pong ``` -Use the `halt` command to stop the module. You can load another module now. +Use the `halt` command to stop the module. + +```bash +==> halt +halting... +module halted. +``` + +You can load another module now. Let's try one written using Rust. + +First, transfer the compiled pingrs.wasm module to the board. Press `CTRL-C` to return to your shell, then run the following command: + +```bash +go run ./savefile ./modules/pingrs.wasm /dev/ttyACM0 +``` + +Now connect again to the board, and now you should see the file listed using the `ls` command, alongside the previously saved file: + +```bash +$ mecha monitor +Connected to /dev/ttyACM0. Press Ctrl-C to exit. + +==> ls + +------------------------------------- + File Store: +------------------------------------- +370 ping.wasm +324 pingrs.wasm +------------------------------------- +``` + +You can now load the Rust module: + +```bash +==> load pingrs.wasm +loading pingrs.wasm +module loaded. +``` + +start it running: + +```bash +==> run +module running. +``` + +And use the `ping` command to call the Rust module: + +```bash +==> ping 3 +Ping... +pong +Ping... +pong +Ping... +pong +```