Porównaj commity

...

4 Commity

Autor SHA1 Wiadomość Data
Engineer_Will 738e4d043c
Merge 3946cf52b5 into 9c7f0659e2 2024-04-24 13:59:21 +10:00
Damien George 9c7f0659e2 webassembly/api: Allocate code data on C heap when running Python code.
Otherwise Emscripten allocates it on the Emscripten C stack, which will
overflow for large amounts of code.

Fixes issue #14307.

Signed-off-by: Damien George <damien@micropython.org>
2024-04-24 13:15:54 +10:00
Damien George 45848f77ca webassembly/api: Fix waiting for Emscripten module to be loaded.
In modularize mode, the `_createMicroPythonModule()` constructor must be
await'ed on, before `Module` is ready to use.

Signed-off-by: Damien George <damien@micropython.org>
2024-04-24 13:15:54 +10:00
EngWill 3946cf52b5 ports/rp2/boards: Add some definition files for waveshare board.
Signed-off-by: EngWill <646689853@qq.com>
2023-10-26 13:49:39 +08:00
14 zmienionych plików z 143 dodań i 14 usunięć

Wyświetl plik

@ -0,0 +1,21 @@
{
"deploy": [
"../deploy.md"
],
"docs": "",
"features": [
"Dual-core",
"Battery Charging",
"External Flash",
"Display",
"USB-C"
],
"images": [
"rp2040-lcd-0.96-1.jpg"
],
"mcu": "rp2040",
"product": "Waveshare RP2040-LCD-0.96",
"thumbnail": "",
"url": "https://www.waveshare.com/product/rp2040-lcd-0.96.htm",
"vendor": "Waveshare"
}

Wyświetl plik

@ -0,0 +1,2 @@
# cmake file for Waveshare RP2040-LCD-0.96
set(PICO_BOARD waveshare_rp2040_lcd_0.96)

Wyświetl plik

@ -0,0 +1,12 @@
// url : https://www.waveshare.com/product/rp2040-lcd-0.96.htm
// wiki : https://www.waveshare.com/wiki/RP2040-LCD-0.96
// Board and hardware specific configuration
#define MICROPY_HW_BOARD_NAME "Waveshare RP2040-LCD-0.96"
#define MICROPY_HW_FLASH_STORAGE_BYTES (1408 * 1024)
#define MICROPY_HW_USB_VID (0x2E8A)
#define MICROPY_HW_USB_PID (0x1021)
#define MICROPY_HW_SPI1_SCK (10u)
#define MICROPY_HW_SPI1_MOSI (11u)
#define MICROPY_HW_SPI1_MISO (8u)

Wyświetl plik

@ -0,0 +1,20 @@
{
"deploy": [
"../deploy.md"
],
"docs": "",
"features": [
"Dual-core",
"Battery Charging",
"External Flash",
"USB-C"
],
"images": [
"rp2040-plus-1.jpg"
],
"mcu": "rp2040",
"product": "Waveshare RP2040-Plus",
"thumbnail": "",
"url": "https://www.waveshare.com/rp2040-plus.htm",
"vendor": "Waveshare"
}

Wyświetl plik

@ -0,0 +1,2 @@
# cmake file for Waveshar RP2040-Plus
set(PICO_BOARD waveshare_rp2040_plus_16mb)

Wyświetl plik

@ -0,0 +1,8 @@
// url : https://www.waveshare.com/product/rp2040-plus.htm
// wiki : https://www.waveshare.com/wiki/RP2040-Plus
// Board and hardware specific configuration
#define MICROPY_HW_BOARD_NAME "Waveshare RP2040-Plus"
#define MICROPY_HW_FLASH_STORAGE_BYTES (15 * 1024 * 1024)
#define MICROPY_HW_USB_VID (0x2E8A)
#define MICROPY_HW_USB_PID (0x1020)

Wyświetl plik

@ -0,0 +1,20 @@
{
"deploy": [
"../deploy.md"
],
"docs": "",
"features": [
"Dual-core",
"Battery Charging",
"External Flash",
"USB-C"
],
"images": [
"rp2040-plus-1.jpg"
],
"mcu": "rp2040",
"product": "Waveshare RP2040-Plus",
"thumbnail": "",
"url": "https://www.waveshare.com/rp2040-plus.htm",
"vendor": "Waveshare"
}

Wyświetl plik

@ -0,0 +1,3 @@
# cmake file for Waveshar RP2040-Plus
set(PICO_BOARD waveshare_rp2040_plus_4mb)

Wyświetl plik

@ -0,0 +1,8 @@
// url : https://www.waveshare.com/product/rp2040-plus.htm
// wiki : https://www.waveshare.com/wiki/RP2040-Plus
// Board and hardware specific configuration
#define MICROPY_HW_BOARD_NAME "Waveshare RP2040-Plus"
#define MICROPY_HW_FLASH_STORAGE_BYTES (3 * 1024 * 1024)
#define MICROPY_HW_USB_VID (0x2E8A)
#define MICROPY_HW_USB_PID (0x1020)

Wyświetl plik

@ -0,0 +1,19 @@
{
"deploy": [
"../deploy.md"
],
"docs": "",
"features": [
"Dual-core",
"External Flash",
"USB-C"
],
"images": [
"rp2040-zero-1.jpg"
],
"mcu": "rp2040",
"product": "Waveshare RP2040-Zero",
"thumbnail": "",
"url": "https://www.waveshare.com/product/rp2040-zero.htm",
"vendor": "Waveshare"
}

Wyświetl plik

@ -0,0 +1,2 @@
# cmake file for Waveshar RP2040-Zero
set(PICO_BOARD waveshare_rp2040_zero)

Wyświetl plik

@ -0,0 +1,8 @@
// url : https://www.waveshare.com/product/rp2040-zero.htm
// wiki : http://www.waveshare.com/wiki/RP2040-Zero
// Board and hardware specific configuration
#define MICROPY_HW_BOARD_NAME "Waveshare RP2040-Zero"
#define MICROPY_HW_FLASH_STORAGE_BYTES (1408 * 1024)
#define MICROPY_HW_USB_VID (0x2E8A)
#define MICROPY_HW_USB_PID (0x101F)

Wyświetl plik

@ -38,7 +38,7 @@ export async function loadMicroPython(options) {
{ heapsize: 1024 * 1024, linebuffer: true },
options,
);
const Module = {};
let Module = {};
Module.locateFile = (path, scriptDirectory) =>
url || scriptDirectory + path;
Module._textDecoder = new TextDecoder();
@ -83,11 +83,7 @@ export async function loadMicroPython(options) {
Module.stderr = (c) => stderr(new Uint8Array([c]));
}
}
const moduleLoaded = new Promise((r) => {
Module.postRun = r;
});
_createMicroPythonModule(Module);
await moduleLoaded;
Module = await _createMicroPythonModule(Module);
globalThis.Module = Module;
proxy_js_init();
const pyimport = (name) => {
@ -131,23 +127,31 @@ export async function loadMicroPython(options) {
},
pyimport: pyimport,
runPython(code) {
const len = Module.lengthBytesUTF8(code);
const buf = Module._malloc(len + 1);
Module.stringToUTF8(code, buf, len + 1);
const value = Module._malloc(3 * 4);
Module.ccall(
"mp_js_do_exec",
"number",
["string", "pointer"],
[code, value],
["pointer", "number", "pointer"],
[buf, len, value],
);
Module._free(buf);
return proxy_convert_mp_to_js_obj_jsside_with_free(value);
},
runPythonAsync(code) {
const len = Module.lengthBytesUTF8(code);
const buf = Module._malloc(len + 1);
Module.stringToUTF8(code, buf, len + 1);
const value = Module._malloc(3 * 4);
Module.ccall(
"mp_js_do_exec_async",
"number",
["string", "pointer"],
[code, value],
["pointer", "number", "pointer"],
[buf, len, value],
);
Module._free(buf);
return proxy_convert_mp_to_js_obj_jsside_with_free(value);
},
replInit() {

Wyświetl plik

@ -104,7 +104,7 @@ void mp_js_do_import(const char *name, uint32_t *out) {
}
}
void mp_js_do_exec(const char *src, uint32_t *out) {
void mp_js_do_exec(const char *src, size_t len, uint32_t *out) {
// Collect at the top-level, where there are no root pointers from stack/registers.
gc_collect_start();
gc_collect_end();
@ -112,7 +112,7 @@ void mp_js_do_exec(const char *src, uint32_t *out) {
mp_parse_input_kind_t input_kind = MP_PARSE_FILE_INPUT;
nlr_buf_t nlr;
if (nlr_push(&nlr) == 0) {
mp_lexer_t *lex = mp_lexer_new_from_str_len_dedent(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0);
mp_lexer_t *lex = mp_lexer_new_from_str_len_dedent(MP_QSTR__lt_stdin_gt_, src, len, 0);
qstr source_name = lex->source_name;
mp_parse_tree_t parse_tree = mp_parse(lex, input_kind);
mp_obj_t module_fun = mp_compile(&parse_tree, source_name, false);
@ -125,9 +125,9 @@ void mp_js_do_exec(const char *src, uint32_t *out) {
}
}
void mp_js_do_exec_async(const char *src, uint32_t *out) {
void mp_js_do_exec_async(const char *src, size_t len, uint32_t *out) {
mp_compile_allow_top_level_await = true;
mp_js_do_exec(src, out);
mp_js_do_exec(src, len, out);
mp_compile_allow_top_level_await = false;
}