mirror of
https://github.com/openmv/openmv.git
synced 2025-09-26 23:09:13 +08:00
ports/mimxrt: Switch to new protocol.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit is contained in:
parent
d669bd7774
commit
b9e7f63906
@ -68,13 +68,13 @@
|
||||
#include "omv_boardconfig.h"
|
||||
#include "framebuffer.h"
|
||||
#include "omv_csi.h"
|
||||
#include "usbdbg.h"
|
||||
#include "tinyusb_debug.h"
|
||||
#include "fb_alloc.h"
|
||||
#include "dma_alloc.h"
|
||||
#include "file_utils.h"
|
||||
#include "mp_utils.h"
|
||||
#include "mimxrt_hal.h"
|
||||
#include "omv_protocol.h"
|
||||
|
||||
int main(void) {
|
||||
bool first_soft_reset = true;
|
||||
@ -110,7 +110,6 @@ soft_reset:
|
||||
#ifdef IMLIB_ENABLE_IMAGE_FILE_IO
|
||||
file_buffer_init0();
|
||||
#endif
|
||||
usbdbg_init();
|
||||
machine_adc_init();
|
||||
#if MICROPY_PY_MACHINE_SDCARD
|
||||
machine_sdcard_init0();
|
||||
@ -119,6 +118,7 @@ soft_reset:
|
||||
machine_i2s_init0();
|
||||
#endif
|
||||
machine_rtc_start();
|
||||
omv_protocol_init_default();
|
||||
|
||||
#if MICROPY_PY_LWIP
|
||||
// lwIP can only be initialized once, because the system timeout
|
||||
@ -173,51 +173,33 @@ soft_reset:
|
||||
tusb_init();
|
||||
}
|
||||
|
||||
// Run boot.py script.
|
||||
bool interrupted = mp_exec_bootscript("boot.py", true);
|
||||
|
||||
// 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;
|
||||
// Run boot.py every reset and main.py on first soft-reset
|
||||
if (pyexec_file_if_exists("boot.py") && first_soft_reset) {
|
||||
pyexec_file_if_exists("main.py");
|
||||
}
|
||||
|
||||
// If there's no script ready, just re-exec REPL
|
||||
while (!usbdbg_script_ready()) {
|
||||
nlr_buf_t nlr;
|
||||
if (nlr_push(&nlr) == 0) {
|
||||
// enable IDE interrupt
|
||||
usbdbg_set_irq_enabled(true);
|
||||
// run REPL
|
||||
if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
|
||||
if (pyexec_raw_repl() != 0) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (pyexec_friendly_repl() != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
nlr_pop();
|
||||
}
|
||||
while (!omv_protocol_exec_script()) {
|
||||
nlr_buf_t nlr;
|
||||
|
||||
if (nlr_push(&nlr) == 0) {
|
||||
// Enable Ctrl+C to interrupt script or REPL.
|
||||
mp_hal_set_interrupt_char(CHAR_CTRL_C);
|
||||
|
||||
if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
|
||||
if (pyexec_raw_repl() != 0) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (pyexec_friendly_repl() != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
nlr_pop();
|
||||
}
|
||||
}
|
||||
|
||||
if (usbdbg_script_ready()) {
|
||||
nlr_buf_t nlr;
|
||||
if (nlr_push(&nlr) == 0) {
|
||||
// Enable IDE interrupt
|
||||
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_plat_print, (mp_obj_t) nlr.ret_val);
|
||||
}
|
||||
}
|
||||
|
||||
soft_reset_exit:
|
||||
// soft reset
|
||||
mp_hal_set_interrupt_char(-1);
|
||||
mp_printf(MP_PYTHON_PRINTER, "MPY: soft reboot\n");
|
||||
#if MICROPY_PY_CSI
|
||||
omv_csi_abort_all();
|
||||
|
@ -105,7 +105,7 @@ SECTIONS
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(EXCLUDE_FILE(*fsl_flexspi.o *gc.o *vm.o *parse*.o *runtime*.o *map.o *mpirq.o ) .text*)
|
||||
*(EXCLUDE_FILE(*fsl_flexspi.o *gc.o *vm.o *parse*.o *runtime*.o *mpirq.o ) .text*)
|
||||
*(.rodata)
|
||||
*(.rodata*)
|
||||
*(.glue_7)
|
||||
|
@ -23,10 +23,22 @@
|
||||
*
|
||||
* MicroPython port config.
|
||||
*/
|
||||
#define MICROPY_NLR_RAISE_HOOK \
|
||||
do { \
|
||||
extern void fb_alloc_free_till_mark(); \
|
||||
fb_alloc_free_till_mark(); \
|
||||
#define MICROPY_NLR_RAISE_HOOK \
|
||||
do { \
|
||||
extern void fb_alloc_free_till_mark(); \
|
||||
fb_alloc_free_till_mark(); \
|
||||
} 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)
|
||||
|
@ -76,8 +76,8 @@ LDFLAGS = -mthumb \
|
||||
-mabi=aapcs-linux \
|
||||
-Wl,--print-memory-usage \
|
||||
-Wl,--gc-sections \
|
||||
-Wl,--wrap=mp_usbd_task \
|
||||
-Wl,--wrap=tud_cdc_rx_cb \
|
||||
-Wl,--wrap=tud_cdc_line_state_cb \
|
||||
-Wl,--wrap=mp_hal_stdio_poll \
|
||||
-Wl,--wrap=mp_hal_stdout_tx_strn \
|
||||
-Wl,-T$(BUILD)/$(LDSCRIPT).lds \
|
||||
@ -138,6 +138,7 @@ include lib/imlib/imlib.mk
|
||||
include lib/tflm/tflm.mk
|
||||
include ports/ports.mk
|
||||
include common/micropy.mk
|
||||
include protocol/protocol.mk
|
||||
|
||||
# Firmware objects from port.
|
||||
MPY_FIRM_OBJ += $(addprefix $(BUILD)/$(MICROPY_DIR)/,\
|
||||
|
Loading…
Reference in New Issue
Block a user