{"id":14963222,"url":"https://github.com/vshymanskyy/wasm2mpy","last_synced_at":"2025-08-12T00:07:54.100Z","repository":{"id":254517958,"uuid":"846785662","full_name":"vshymanskyy/wasm2mpy","owner":"vshymanskyy","description":"Compile WebAssembly to native MicroPython modules","archived":false,"fork":false,"pushed_at":"2025-01-09T12:38:07.000Z","size":344,"stargazers_count":140,"open_issues_count":0,"forks_count":3,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-08-04T11:54:22.223Z","etag":null,"topics":["armv7","esp32","micropython","nrf52","raspberry-pi","rp2040","rp2350","wasm","webassembly","webassembly-runtime"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vshymanskyy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-24T00:41:06.000Z","updated_at":"2025-07-28T13:44:59.000Z","dependencies_parsed_at":"2024-09-17T00:38:52.785Z","dependency_job_id":"f986779a-a46a-4bac-b45d-1496ee7fc37f","html_url":"https://github.com/vshymanskyy/wasm2mpy","commit_stats":{"total_commits":101,"total_committers":1,"mean_commits":101.0,"dds":0.0,"last_synced_commit":"35fa4f3bdfe39fefcd89b73ab66c47ac08f6c100"},"previous_names":["vshymanskyy/wasm2mpy"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vshymanskyy/wasm2mpy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vshymanskyy%2Fwasm2mpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vshymanskyy%2Fwasm2mpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vshymanskyy%2Fwasm2mpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vshymanskyy%2Fwasm2mpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vshymanskyy","download_url":"https://codeload.github.com/vshymanskyy/wasm2mpy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vshymanskyy%2Fwasm2mpy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269976794,"owners_count":24506467,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["armv7","esp32","micropython","nrf52","raspberry-pi","rp2040","rp2350","wasm","webassembly","webassembly-runtime"],"created_at":"2024-09-24T13:31:11.786Z","updated_at":"2025-08-12T00:07:54.077Z","avatar_url":"https://github.com/vshymanskyy.png","language":"C","funding_links":[],"categories":["Development"],"sub_categories":["Code Generation"],"readme":"# \u003cimg height=\"48px\" src=\"/logo.png\"\u003e wasm2mpy\n\n[![StandWithUkraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md) \n[![Build status](https://img.shields.io/github/actions/workflow/status/vshymanskyy/wasm2mpy/build.yml?branch=main\u0026style=flat-square\u0026logo=github\u0026label=build)](https://github.com/vshymanskyy/wasm2mpy/actions) \n[![GitHub license](https://img.shields.io/badge/license-MIT-blue?style=flat-square)](https://github.com/vshymanskyy/wasm2mpy) \n[![Support vshymanskyy](https://img.shields.io/static/v1?label=support\u0026message=%E2%9D%A4\u0026color=%23fe8e86)](https://quicknote.io/da0a7d50-bb49-11ec-936a-6d7fd5a2de08) \n\n`wasm2mpy` enables developers to write code in statically compiled languages and run it on MicroPython-based embedded systems (such as ESP32, Raspberry Pi Pico, STM32, and nRF52) with near-native performance. Since MicroPython is relatively slow for computationally intensive applications, `wasm2mpy` provides the tools necessary to run demanding software, such as AI models and signal processing algorithms, more efficiently.\n\n## Status\n\n| App \\ Target      | x86/x64   | armv6m  | armv7m/+s/+d | esp8266[^2]  | esp32      | rv32imc  |\n|-------------------|-----------|----------|---------|----------|------------|----------|\n| 🚀 TypeScript[^1] | ✅✅    | ✅       | ✅✅✅      | ⚠️[^4]   | ✅         | ✅       |\n| 🤩 C++            | ✅✅    | ✅       | ✅✅✅      | 🟡       | ✅         | ✅       |\n| 🦀 Rust           | ✅✅    | ✅       | 🟡🟡✅      | ⚠️[^4]   | ✅         | ✅       |\n| 🤖 TinyGo         | ✅✅    | ✅       | 🟡🟡✅      | ⚠️[^4]   | ✅         | ✅       |\n| ⚡ Zig            | ✅✅    | ✅       | ✅✅✅      | ⚠️[^4]   | ✅         | ✅       |\n| ✨ Virgil         | ✅✅    | ✅       | ✅✅✅      | 🟡       | ✅         | ✅       |\n| ⚙ WAT            | ✅✅    | ✅       | ✅✅✅      | 🟡       | ✅         | ✅       |\n| 🇨 Coremark       | ✅✅    | 🚧       | ✅✅✅      | 🟡       | ✅         | ✅       |\n\n✅ builds and runs OK  \n🟡 builds OK, doesn't run  \n🚧 work in progress  \n\n[^1]: [AssemblyScript](https://www.assemblyscript.org)\n[^2]: `esp8266` requires the use of [`esp.set_native_code_location`](https://github.com/micropython/micropython/issues/14430#issuecomment-2332648018), and setting `WASM_PAGE_SIZE` to `8192` (or need to wait for [`WASM Custom Page Sizes`][1])\n[^4]: not enough memory to run, need to wait for [`WASM Custom Page Sizes`][1]\n\n## CoreMark results\n\n- **ESP32-C3** 160MHz: `179.791`\n- **STM32F405** 168MHz: `233.918`\n- **ESP32** 240MHz: `228.363`\n- **ESP32-S3** 240MHz: `271.573`\n- **BL616** 320MHz: `344.293`\n- **iMXRT1062** 600MHz: `1911.437`\n- **i5-8250U** 1.6GHz: `18696.248`\n\n## Upload and Run\n\nFollow the [build instructions](BUILDING.md)\n\n```sh\nmpremote cp zig.mpy :lib/\nmpremote exec \"import zig; zig.setup()\"\n⚡ Zig is running!\n```\n\n## Run any exported function\n\n\u003e [!NOTE]\n\u003e This requires adding some glue code to the runtime.  \n\u003e Glue code can be auto-generated, but for now it's a manual process.\n\nFor example, `test/simple.wasm` just adds 2 numbers:\n\n```wat\n(module\n    (func (export \"add\") (param i32 i32) (result i32)\n        (i32.add (local.get 0) (local.get 1))\n    )\n)\n```\n\n```log\nMicroPython v1.24.0-preview.224.g6c3dc0c0b on 2024-08-22; Raspberry Pi Pico W with RP2040\nType \"help()\" for more information.\n\u003e\u003e\u003e import simple\n\u003e\u003e\u003e simple.add(3, 4)\n7\n\u003e\u003e\u003e simple.add(10, 6)\n16\n```\n\n## Access WASM module memory\n\n```py\n\u003e\u003e\u003e import cpp\n\u003e\u003e\u003e cpp.setup()\n🤩 C++ is running!\n\u003e\u003e\u003e cpp._memory[4096:4096+32]\nbytearray(b' Blink\\x00\\xf0\\x9f\\xa4\\xa9 C++ is running!\\x00\\n\\x00\\x00\\x00')\n\u003e\u003e\u003e new_data = b\"Hello C++ world\"\n\u003e\u003e\u003e cpp._memory[4096+12:4096+12+len(new_data)] = new_data\n\u003e\u003e\u003e cpp.setup()\n🤩 Hello C++ world\n```\n\n## How It Works?\n\nThe idea is very similar to [embedded-wasm-apps](https://github.com/wasm3/embedded-wasm-apps):\n\n![image](https://github.com/wasm3/embedded-wasm-apps/blob/main/docs/how-it-works.png?raw=1)\n\n## TODO\n\n- [x] Support exports\n  - [ ] Auto-generate exports bindings\n- [x] Support imports\n- [x] Support memory\n- [x] [Support `.a` inputs for `mpy_ld`](https://github.com/micropython/micropython/pull/15838)\n- [ ] [XIP for native modules](https://github.com/micropython/micropython/pull/8381#issuecomment-2363022985)\n- [ ] TBD: Support globals\n- [x] Add RISC-V support: https://github.com/micropython/micropython/pull/15603\n- [ ] Optimize codegen\n  - [ ] Use `u32` instead of `u64` for mem addresses\n  - [ ] Use a directly addressable `.bss` section as memory (skip indirection)\n- [ ] Implement [WASM Custom Page Sizes][1]\n- [ ] Implement WASM Exceptions \n- [ ] Implement [WASM Stack Switching](https://github.com/WebAssembly/stack-switching/blob/main/proposals/stack-switching/Explainer.md)\n\n## Further reading\n\n- Discussions: [GitHub](https://github.com/orgs/micropython/discussions/15702), [Hacker News](https://news.ycombinator.com/item?id=41599579)\n- [wasm2c](https://github.com/WebAssembly/wabt/blob/main/wasm2c/README.md), [w2c2](https://github.com/turbolent/w2c2)\n- MicroPython [Native Modules](https://docs.micropython.org/en/latest/develop/natmod.html)\n- [Feasibility of WASM for MicroPython](https://github.com/micropython/micropython/issues/15270#issuecomment-2280942885)\n\n[1]: https://github.com/WebAssembly/custom-page-sizes/blob/main/proposals/custom-page-sizes/Overview.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvshymanskyy%2Fwasm2mpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvshymanskyy%2Fwasm2mpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvshymanskyy%2Fwasm2mpy/lists"}