mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
ports/rp2: Switch to mp_utils to initialize GC/Stack.
This commit is contained in:
parent
79019cce0d
commit
df3e885d6b
@ -70,7 +70,7 @@
|
|||||||
#include "extmod/vfs.h"
|
#include "extmod/vfs.h"
|
||||||
#include "extmod/vfs_fat.h"
|
#include "extmod/vfs_fat.h"
|
||||||
#endif
|
#endif
|
||||||
#include "boot_utils.h"
|
#include "mp_utils.h"
|
||||||
|
|
||||||
extern void pendsv_init(void);
|
extern void pendsv_init(void);
|
||||||
extern uint8_t __StackTop, __StackBottom;
|
extern uint8_t __StackTop, __StackBottom;
|
||||||
@ -146,9 +146,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
soft_reset:
|
soft_reset:
|
||||||
// Initialise stack extents and GC heap.
|
// Initialise stack extents and GC heap.
|
||||||
mp_stack_set_top(&__StackTop);
|
mp_init_gc_stack(&__StackBottom, &__StackTop, &gc_heap[0], &gc_heap[MP_ARRAY_SIZE(gc_heap)], 256);
|
||||||
mp_stack_set_limit(&__StackTop - &__StackBottom - 256);
|
|
||||||
gc_init(&gc_heap[0], &gc_heap[MP_ARRAY_SIZE(gc_heap)]);
|
|
||||||
|
|
||||||
// Initialise MicroPython runtime.
|
// Initialise MicroPython runtime.
|
||||||
mp_init();
|
mp_init();
|
||||||
@ -189,7 +187,7 @@ soft_reset:
|
|||||||
if (mp_vfs_mount_and_chdir_protected(bdev, mount_point) == -MP_ENODEV) {
|
if (mp_vfs_mount_and_chdir_protected(bdev, mount_point) == -MP_ENODEV) {
|
||||||
// Create a fresh filesystem.
|
// Create a fresh filesystem.
|
||||||
fs_user_mount_t *vfs = MP_OBJ_TYPE_GET_SLOT(&mp_fat_vfs_type, make_new) (&mp_fat_vfs_type, 1, 0, &bdev);
|
fs_user_mount_t *vfs = MP_OBJ_TYPE_GET_SLOT(&mp_fat_vfs_type, make_new) (&mp_fat_vfs_type, 1, 0, &bdev);
|
||||||
if (bootutils_init_filesystem(vfs) == 0) {
|
if (mp_init_filesystem(vfs) == 0) {
|
||||||
mp_vfs_mount_and_chdir_protected(bdev, mount_point);
|
mp_vfs_mount_and_chdir_protected(bdev, mount_point);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -211,11 +209,11 @@ soft_reset:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run boot.py script.
|
// Run boot.py script.
|
||||||
bool interrupted = bootutils_exec_bootscript("boot.py", true, false);
|
bool interrupted = mp_exec_bootscript("boot.py", true, false);
|
||||||
|
|
||||||
// Run main.py script on first soft-reset.
|
// Run main.py script on first soft-reset.
|
||||||
if (first_soft_reset && !interrupted && mp_vfs_import_stat("main.py")) {
|
if (first_soft_reset && !interrupted && mp_vfs_import_stat("main.py")) {
|
||||||
bootutils_exec_bootscript("main.py", true, false);
|
mp_exec_bootscript("main.py", true, false);
|
||||||
goto soft_reset_exit;
|
goto soft_reset_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,15 +287,6 @@ soft_reset_exit:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gc_collect(void) {
|
|
||||||
gc_collect_start();
|
|
||||||
gc_helper_collect_regs_and_stack();
|
|
||||||
#if MICROPY_PY_THREAD
|
|
||||||
mp_thread_gc_others();
|
|
||||||
#endif
|
|
||||||
gc_collect_end();
|
|
||||||
}
|
|
||||||
|
|
||||||
void nlr_jump_fail(void *val) {
|
void nlr_jump_fail(void *val) {
|
||||||
printf("FATAL: uncaught exception %p\n", val);
|
printf("FATAL: uncaught exception %p\n", val);
|
||||||
mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(val));
|
mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(val));
|
||||||
|
|||||||
@ -106,7 +106,7 @@ target_sources(${MICROPY_TARGET} PRIVATE
|
|||||||
${TOP_DIR}/${OMV_DIR}/common/usbdbg.c
|
${TOP_DIR}/${OMV_DIR}/common/usbdbg.c
|
||||||
${TOP_DIR}/${OMV_DIR}/common/tinyusb_debug.c
|
${TOP_DIR}/${OMV_DIR}/common/tinyusb_debug.c
|
||||||
${TOP_DIR}/${OMV_DIR}/common/file_utils.c
|
${TOP_DIR}/${OMV_DIR}/common/file_utils.c
|
||||||
${TOP_DIR}/${OMV_DIR}/common/boot_utils.c
|
${TOP_DIR}/${OMV_DIR}/common/mp_utils.c
|
||||||
${TOP_DIR}/${OMV_DIR}/common/sensor_utils.c
|
${TOP_DIR}/${OMV_DIR}/common/sensor_utils.c
|
||||||
|
|
||||||
${TOP_DIR}/${OMV_DIR}/sensors/ov2640.c
|
${TOP_DIR}/${OMV_DIR}/sensors/ov2640.c
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user