Can we Simulate #BL602 #RustLang Firmware in a Web Browser with #WebAssembly? ... So we can make a PineDio Stack Simulator? 🤔
To compile #BL602 #RustLang Firmware into #WebAssembly ... 1️⃣ Change "no_std" to "libc" 2️⃣ Exclude the Panic Handler
https://github.com/lupyuen/bl602-simulator/blob/main/sdk_app_rust_gpio/rust/src/lib.rs
#BL602 #RustLang Firmware runs OK with #WebAssembly ... When we reused the WebAssembly Stubs from uLisp yay! 🎉
What drives the #BL602 #RustLang Simulator in #WebAssembly? A JSON Stream of Simulation Events!
https://lupyuen.github.io/articles/wasm#simulate-bl602-hardware
Composing JSON in C looks messy ... Let's convert to #RustLang
https://github.com/lupyuen/bl602-simulator/blob/main/wasm/wasm.c
Here's how we compose a JSON Stream of #BL602 Simulation Events in #RustLang
https://gist.github.com/lupyuen/cec1a423062556263a7ba02971862001
Here are the #RustLang Stubs that intercept calls to #BL602 IoT SDK ... And emit the JSON Stream of Events
https://github.com/lupyuen/bl602-simulator/blob/main/bl602-simulator/src/lib.rs#L85-L135
If #BL602 IoT SDK wasn't called correctly ... Our BL602 Simulator could show a helpful message 🤔
https://github.com/lupyuen/bl602-simulator/blob/main/bl602-simulator/src/lib.rs#L85-L109
How our #BL602 Simulator in #WebAssembly checks the GPIO Pin Config ... When setting the GPIO Pin Output
https://github.com/lupyuen/bl602-simulator/blob/main/bl602-simulator/src/lib.rs#L105-L136
If we set a GPIO Pin Output without configuring the GPIO for Output ... Our #BL602 #WebAssembly Simulator halts with a helpful message
https://github.com/lupyuen/bl602-simulator/blob/main/bl602-simulator/src/lib.rs#L105-L136
Running #BL602 #RustLang Firmware in a Web Browser with #WebAssembly ... All shall be explained in this article
Let's take this #BL602 #RustLang Blinky Firmware ... And make it run in a Web Browser with #WebAssembly
https://lupyuen.github.io/articles/rustsim?2#rust-firmware-for-bl602
Here's how we compile #BL602 #RustLang Firmware into #WebAssembly
https://lupyuen.github.io/articles/rustsim?3#build-bl602-firmware-for-webassembly
Compiling #BL602 #RustLang Firmware into #WebAssembly ... For linking with Emscripten
https://lupyuen.github.io/articles/rustsim?4#compile-rust-firmware-into-webassembly
Linking #BL602 Firmware with Emscripten ... So that it runs in #WebAssembly
https://lupyuen.github.io/articles/rustsim?5#link-rust-firmware-with-emscripten
How to Simulate #BL602 in #WebAssembly? With a JSON Stream of Simulation Events!
https://lupyuen.github.io/articles/rustsim?6#json-stream-of-simulation-events
Creating a #BL602 Simulation Event in #RustLang
https://lupyuen.github.io/articles/rustsim?7#generate-simulation-events
How we Intercept Calls to #BL602 IoT SDK ... So that they work on #WebAssembly
https://lupyuen.github.io/articles/rustsim?8#intercept-calls-to-bl602-iot-sdk
How we render the Simulated #BL602 in HTML
https://lupyuen.github.io/articles/rustsim?9#html-and-javascript-interface
#BL602 Simulator jumps from JavaScript to #WebAssembly to #RustLang ... And back!
https://lupyuen.github.io/articles/rustsim?10#run-rust-firmware
Added Rhai #RustLang Scripting Engine to #BL602 WebAssembly Simulator ... So that we can do interesting things 🤔
https://github.com/lupyuen/bl602-simulator/blob/main/bl602-script/src/lib.rs
Here's how we expose our #RustLang Functions to Rhai Script Engine
https://github.com/lupyuen/bl602-simulator/blob/main/bl602-script/src/lib.rs#L25-L88
How we handle #BL602 Simulation Events in JavaScript ... And blink the Simulated BL602 LED
https://lupyuen.github.io/articles/rustsim?11#handle-simulation-events
Will #BL602 Simulator make #Embedded Development easier? 🤔
https://lupyuen.github.io/articles/rustsim?12#run-bl602-firmware-in-simulator
Our #BL602 Simulator won't simulate all kinds of firmware ... But it might still be useful
https://lupyuen.github.io/articles/rustsim?15#easier-embedded-development
#BL602 Simulator tries to be helpful ... By validating the calls to BL602 IoT SDK
https://lupyuen.github.io/articles/rustsim?17#validate-calls-to-bl602-iot-sdk
How #BL602 Simulator validates calls to BL602 IoT SDK
https://lupyuen.github.io/articles/rustsim?18#validate-calls-to-bl602-iot-sdk
#BL602 Simulator will support Rhai Scripts ... A #RustLang-like Scripting Language
https://lupyuen.github.io/articles/rustsim?19#scripting-for-bl602-simulator
#BL602 Simulator will support Drag-and-Drop Scripting too!
https://lupyuen.github.io/articles/rustsim?20#drag-and-drop-scripting
@lupyuen yea ive checked it out.. my soul died a little on that day :)