Add Blue Pill

extensions
Volodymyr Shymanskyy 5 years ago
parent d3a8a27154
commit bcabd6bf70

@ -0,0 +1,17 @@
# Performance
```log
Function: fib(24) fib64(24) comments
----------------------------------------------------------------------------------------------------
ESP8266 LX106 @ 160MHz 288ms 299ms no TCO
ESP32 LX6 @ 240MHz 410ms 430ms no TCO
MXChip AZ3166 Arm M4 @ 100Mhz 651ms 713ms
WM W600 Arm M3 @ 80MHz 716ms 782ms stack used: 1952
WM W600, TCO off Arm M3 @ 80MHz 846ms 914ms stack used: 8168
BleNano2 (nRF52) Arm M4 @ 64MHz 1.19s 1.29s
Arduino MKR1000 Arm M0+ @ 48MHz 1.93s 2.06s no TCO
TinyBLE (nRF51) Arm M0 @ 16MHz 5.58s 5.93s no TCO, 16 Kb total RAM
BluePill Arm M3 @ 72MHz 7.62s 8.20s
HiFive1 (FE310) rv32imac @ 320MHz 9.10s 9.82s <- something wrong here?
Fomu rv32i @ 12MHz 25.2s 26.1s
```

@ -0,0 +1,11 @@
[env:bluepill]
platform = ststm32
board = bluepill_f103c8
framework = stm32cube
upload_protocol = stlink
lib_deps = jeeh
src_build_flags =
-Dd_m3FixedHeap=8192 -Dd_m3LogOutput=false
-Os -w -Wfatal-errors
-flto

@ -0,0 +1,12 @@
unsigned char fib_wasm[] = {
0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x0b, 0x02, 0x60,
0x01, 0x7f, 0x01, 0x7f, 0x60, 0x01, 0x7e, 0x01, 0x7e, 0x03, 0x03, 0x02,
0x00, 0x01, 0x07, 0x11, 0x02, 0x04, 0x5f, 0x66, 0x69, 0x62, 0x00, 0x00,
0x06, 0x5f, 0x66, 0x69, 0x62, 0x36, 0x34, 0x00, 0x01, 0x0a, 0x3d, 0x02,
0x1d, 0x00, 0x20, 0x00, 0x41, 0x02, 0x49, 0x04, 0x40, 0x20, 0x00, 0x0f,
0x0b, 0x20, 0x00, 0x41, 0x02, 0x6b, 0x10, 0x00, 0x20, 0x00, 0x41, 0x01,
0x6b, 0x10, 0x00, 0x6a, 0x0f, 0x0b, 0x1d, 0x00, 0x20, 0x00, 0x42, 0x02,
0x54, 0x04, 0x40, 0x20, 0x00, 0x0f, 0x0b, 0x20, 0x00, 0x42, 0x02, 0x7d,
0x10, 0x01, 0x20, 0x00, 0x42, 0x01, 0x7d, 0x10, 0x01, 0x7c, 0x0f, 0x0b
};
unsigned int fib_wasm_len = 108;

@ -0,0 +1 @@
../../../source

@ -0,0 +1,57 @@
#include "m3/m3.hpp"
#include "fib.wasm.h"
#include <jee.h>
#define FATAL(msg, ...) { puts("Fatal: " msg "\n"); return; }
void run_wasm()
{
M3Result result = c_m3Err_none;
u8* wasm = (u8*)fib_wasm;
u32 fsize = fib_wasm_len-1;
puts("Loading WebAssembly...\n");
IM3Module module;
result = m3_ParseModule (& module, wasm, fsize);
if (result) FATAL("m3_ParseModule: %s", result);
IM3Runtime env = m3_NewRuntime (1024);
if (!env) FATAL("m3_NewRuntime");
result = m3_LoadModule (env, module);
if (result) FATAL("m3_LoadModule: %s", result);
IM3Function f;
result = m3_FindFunction (&f, env, "_fib");
if (result) FATAL("m3_FindFunction: %s", result);
puts("Running...\n");
const char* i_argv[2] = { "24", NULL };
result = m3_CallWithArgs (f, 1, i_argv);
if (result) FATAL("m3_CallWithArgs: %s", result);
}
PinC<13> led;
int main()
{
enableSysTick();
led.mode(Pinmode::out);
puts("wasm3 on Arduino, build " __DATE__ " " __TIME__ "\n");
led = 0;
run_wasm();
led = 1;
//Serial.print("Elapsed: ");
//Serial.print(end - start);
//Serial.println(" ms");
}
Loading…
Cancel
Save