mirror of
https://github.com/openmv/openmv.git
synced 2025-09-26 23:09:13 +08:00
ports/stm32: Switch to new protocol.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit is contained in:
parent
3ad6f14996
commit
1b1855fcea
@ -79,10 +79,10 @@
|
|||||||
#include "omv_gpio.h"
|
#include "omv_gpio.h"
|
||||||
#include "omv_i2c.h"
|
#include "omv_i2c.h"
|
||||||
#include "omv_csi.h"
|
#include "omv_csi.h"
|
||||||
|
#include "omv_protocol.h"
|
||||||
#include "mp_utils.h"
|
#include "mp_utils.h"
|
||||||
#include "framebuffer.h"
|
#include "framebuffer.h"
|
||||||
|
|
||||||
#include "usbdbg.h"
|
|
||||||
#include "sdram.h"
|
#include "sdram.h"
|
||||||
#include "stm_xspi.h"
|
#include "stm_xspi.h"
|
||||||
#include "fb_alloc.h"
|
#include "fb_alloc.h"
|
||||||
@ -225,7 +225,7 @@ soft_reset:
|
|||||||
#if MICROPY_HW_ENABLE_CAN
|
#if MICROPY_HW_ENABLE_CAN
|
||||||
pyb_can_init0();
|
pyb_can_init0();
|
||||||
#endif
|
#endif
|
||||||
#if MICROPY_PY_PYB_LEGACY && MICROPY_HW_ENABLE_HW_I2C
|
#if MICROPY_PY_PYB_LEGACY && MICROPY_HW_ENABLE_HW_I2C
|
||||||
i2c_init0();
|
i2c_init0();
|
||||||
#endif
|
#endif
|
||||||
spi_init0();
|
spi_init0();
|
||||||
@ -245,7 +245,6 @@ soft_reset:
|
|||||||
#if MICROPY_HW_ENABLE_SERVO
|
#if MICROPY_HW_ENABLE_SERVO
|
||||||
servo_init();
|
servo_init();
|
||||||
#endif
|
#endif
|
||||||
usbdbg_init();
|
|
||||||
#if MICROPY_HW_ENABLE_SDCARD
|
#if MICROPY_HW_ENABLE_SDCARD
|
||||||
sdcard_init();
|
sdcard_init();
|
||||||
#endif
|
#endif
|
||||||
@ -297,6 +296,9 @@ soft_reset:
|
|||||||
mod_network_init();
|
mod_network_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Initialize OpenMV protocol
|
||||||
|
omv_protocol_init_default();
|
||||||
|
|
||||||
// Execute _boot.py to set up the filesystem.
|
// Execute _boot.py to set up the filesystem.
|
||||||
pyexec_frozen_module("_boot.py", false);
|
pyexec_frozen_module("_boot.py", false);
|
||||||
|
|
||||||
@ -326,24 +328,18 @@ soft_reset:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Run boot.py script.
|
// Run boot.py every reset and main.py on first soft-reset
|
||||||
bool interrupted = mp_exec_bootscript("boot.py", true);
|
if (pyexec_file_if_exists("boot.py") && first_soft_reset) {
|
||||||
|
pyexec_file_if_exists("main.py");
|
||||||
// Run main.py script on first soft-reset.
|
|
||||||
if (first_soft_reset && !interrupted && mp_vfs_import_stat("main.py")) {
|
|
||||||
mp_exec_bootscript("main.py", true);
|
|
||||||
goto soft_reset_exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there's no script ready, just re-exec REPL
|
while (!omv_protocol_exec_script()) {
|
||||||
while (!usbdbg_script_ready()) {
|
|
||||||
nlr_buf_t nlr;
|
nlr_buf_t nlr;
|
||||||
|
|
||||||
if (nlr_push(&nlr) == 0) {
|
if (nlr_push(&nlr) == 0) {
|
||||||
// enable IDE interrupt
|
// Enable Ctrl+C to interrupt script or REPL.
|
||||||
usbdbg_set_irq_enabled(true);
|
mp_hal_set_interrupt_char(CHAR_CTRL_C);
|
||||||
|
|
||||||
// run REPL
|
|
||||||
if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
|
if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
|
||||||
if (pyexec_raw_repl() != 0) {
|
if (pyexec_raw_repl() != 0) {
|
||||||
break;
|
break;
|
||||||
@ -353,31 +349,15 @@ soft_reset:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nlr_pop();
|
nlr_pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usbdbg_script_ready()) {
|
|
||||||
nlr_buf_t nlr;
|
|
||||||
if (nlr_push(&nlr) == 0) {
|
|
||||||
// Enable IDE interrupts
|
|
||||||
usbdbg_set_irq_enabled(true);
|
|
||||||
// Execute the script.
|
|
||||||
pyexec_str(usbdbg_get_script(), true);
|
|
||||||
// Disable IDE interrupts
|
|
||||||
usbdbg_set_irq_enabled(false);
|
|
||||||
nlr_pop();
|
|
||||||
} else {
|
|
||||||
mp_obj_print_exception(MP_PYTHON_PRINTER, (mp_obj_t) nlr.ret_val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
soft_reset_exit:
|
|
||||||
// soft reset
|
// soft reset
|
||||||
|
mp_hal_set_interrupt_char(-1);
|
||||||
mp_printf(MP_PYTHON_PRINTER, "MPY: soft reboot\n");
|
mp_printf(MP_PYTHON_PRINTER, "MPY: soft reboot\n");
|
||||||
#if MICROPY_PY_CSI
|
#if MICROPY_PY_CSI
|
||||||
omv_csi_abort_all();
|
omv_csi_abort_all();
|
||||||
#endif
|
#endif
|
||||||
#if MICROPY_PY_LWIP
|
#if MICROPY_PY_LWIP
|
||||||
systick_disable_dispatch(SYSTICK_DISPATCH_LWIP);
|
systick_disable_dispatch(SYSTICK_DISPATCH_LWIP);
|
||||||
|
@ -29,6 +29,19 @@
|
|||||||
fb_alloc_free_till_mark(); \
|
fb_alloc_free_till_mark(); \
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
|
|
||||||
|
#define MICROPY_BOARD_BEFORE_PYTHON_EXEC(input_kind, exec_flags) \
|
||||||
|
do { \
|
||||||
|
extern void stdio_channel_pyexec_hook(bool); \
|
||||||
|
stdio_channel_pyexec_hook(true); \
|
||||||
|
} while (0);
|
||||||
|
|
||||||
|
#define MICROPY_BOARD_AFTER_PYTHON_EXEC(input_kind, exec_flags, nlr, ret) \
|
||||||
|
do { \
|
||||||
|
extern void stdio_channel_pyexec_hook(bool); \
|
||||||
|
stdio_channel_pyexec_hook(false); \
|
||||||
|
} while (0);
|
||||||
|
|
||||||
#define MICROPY_ENABLE_VM_ABORT (1)
|
#define MICROPY_ENABLE_VM_ABORT (1)
|
||||||
#define MICROPY_OPT_COMPUTED_GOTO (1)
|
#define MICROPY_OPT_COMPUTED_GOTO (1)
|
||||||
#define MICROPY_GC_SPLIT_HEAP (1)
|
#define MICROPY_GC_SPLIT_HEAP (1)
|
||||||
|
@ -80,6 +80,10 @@ LDFLAGS = -mthumb \
|
|||||||
-mabi=aapcs-linux \
|
-mabi=aapcs-linux \
|
||||||
-Wl,--print-memory-usage \
|
-Wl,--print-memory-usage \
|
||||||
-Wl,--gc-sections \
|
-Wl,--gc-sections \
|
||||||
|
-Wl,--wrap=usbd_cdc_control \
|
||||||
|
-Wl,--wrap=usbd_cdc_receive \
|
||||||
|
-Wl,--wrap=mp_os_dupterm_rx_chr \
|
||||||
|
-Wl,--wrap=mp_hal_stdout_tx_strn \
|
||||||
-Wl,-T$(BUILD)/$(LDSCRIPT).lds \
|
-Wl,-T$(BUILD)/$(LDSCRIPT).lds \
|
||||||
-Wl,-Map=$(BUILD)/$(FIRMWARE).map
|
-Wl,-Map=$(BUILD)/$(FIRMWARE).map
|
||||||
|
|
||||||
@ -141,6 +145,7 @@ CFLAGS += $(HAL_CFLAGS) $(MPY_CFLAGS) $(OMV_CFLAGS)
|
|||||||
include lib/cmsis/cmsis.mk
|
include lib/cmsis/cmsis.mk
|
||||||
include lib/stm32/stm32.mk
|
include lib/stm32/stm32.mk
|
||||||
include common/common.mk
|
include common/common.mk
|
||||||
|
include protocol/protocol.mk
|
||||||
include drivers/drivers.mk
|
include drivers/drivers.mk
|
||||||
include lib/imlib/imlib.mk
|
include lib/imlib/imlib.mk
|
||||||
include lib/tflm/tflm.mk
|
include lib/tflm/tflm.mk
|
||||||
|
Loading…
Reference in New Issue
Block a user