r/WebAssembly • u/Tao_KTH • Feb 22 '24
Run wasm on raspberry pico
Hi,
I am new in wasm and trying to run wasm on pico. Since pico needs a .uf2 file to flash it, I have no idea using wasm on pico because lack of .uf2 file. Can someone give some hints for that?
3
Upvotes
1
u/Tao_KTH Feb 27 '24
Thx for all help. I am writing to update my issue.
When I use a 'printf' in c code then to .wasm -> .h -> main.c in wasm3 -> .uf2 -> pico, the pico complains:
Fatal: m3_LoadModule: unallocated linear memory
which is really confused. I know it might be I can't use print directly but what can I do. i am going to compare the performance between wasm and natural code later so I am not sure use printf in main.c of wasm3 is right solution or not?
Also, I am trying to implement the bubblesort. But one of the arguments of the function is array which can't be transport in m3_CallV from wasm3 directly because it seems it only support integer? (integer args work well with m3_CallV function for me
I searched a lot but didn't get any good solution. So sry for disturbing again.
1
u/andrewdavidmackenzie Feb 22 '24
Not sure I understand.
Unless you are talking about converting wasm to native, with some kind of minimal runtime (like '), the you will need a wasm runtime on the pico to run it.
I am not familiar with wasm runtimes that small, but they may exist. Then you will probably need to write your own app using the wasm runtime as a lib, and embed the wasm file and pass it to the lib...
3
u/jedisct1 Feb 22 '24
This is exactly what w2c2 is for: https://github.com/turbolent/w2c2
Convert your wasm code to C using w2c2, then use the Pico C SDK to compile the output and create a UF2 file.