diff --git a/bricks/_common/micropython.c b/bricks/_common/micropython.c index acf44d76e..f87231103 100644 --- a/bricks/_common/micropython.c +++ b/bricks/_common/micropython.c @@ -128,8 +128,18 @@ static void run_repl(void) { if (nlr_push(&nlr) == 0) { nlr_set_abort(&nlr); - // Run the REPL. + // No need to set interrupt_char here, it is done by pyexec. + #if PYBRICKS_OPT_RAW_REPL + if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) { + // Compatibility with mpremote. + mp_printf(&mp_plat_print, "MPY: soft reboot\n"); + pyexec_raw_repl(); + } else { + pyexec_friendly_repl(); + } + #else // PYBRICKS_OPT_RAW_REPL pyexec_friendly_repl(); + #endif // PYBRICKS_OPT_RAW_REPL nlr_pop(); } else { // if vm abort diff --git a/bricks/cityhub/mpconfigport.h b/bricks/cityhub/mpconfigport.h index bb80d20e3..32b00c0c7 100644 --- a/bricks/cityhub/mpconfigport.h +++ b/bricks/cityhub/mpconfigport.h @@ -49,6 +49,7 @@ // Pybricks options #define PYBRICKS_OPT_COMPILER (1) +#define PYBRICKS_OPT_RAW_REPL (0) #define PYBRICKS_OPT_FLOAT (1) #define PYBRICKS_OPT_TERSE_ERR (0) #define PYBRICKS_OPT_EXTRA_MOD (1) diff --git a/bricks/debug/mpconfigport.h b/bricks/debug/mpconfigport.h index 35caf7897..6a8cdf768 100644 --- a/bricks/debug/mpconfigport.h +++ b/bricks/debug/mpconfigport.h @@ -42,6 +42,7 @@ // Pybricks options #define PYBRICKS_OPT_COMPILER (0) +#define PYBRICKS_OPT_RAW_REPL (0) #define PYBRICKS_OPT_FLOAT (0) #define PYBRICKS_OPT_TERSE_ERR (1) #define PYBRICKS_OPT_EXTRA_MOD (0) diff --git a/bricks/essentialhub/mpconfigport.h b/bricks/essentialhub/mpconfigport.h index 6512f7299..b232c29bd 100644 --- a/bricks/essentialhub/mpconfigport.h +++ b/bricks/essentialhub/mpconfigport.h @@ -50,6 +50,7 @@ // Pybricks options #define PYBRICKS_OPT_COMPILER (1) +#define PYBRICKS_OPT_RAW_REPL (0) #define PYBRICKS_OPT_FLOAT (1) #define PYBRICKS_OPT_TERSE_ERR (0) #define PYBRICKS_OPT_EXTRA_MOD (1) diff --git a/bricks/ev3/mpconfigport.h b/bricks/ev3/mpconfigport.h index 8b7d74235..5cb9075f2 100644 --- a/bricks/ev3/mpconfigport.h +++ b/bricks/ev3/mpconfigport.h @@ -45,6 +45,7 @@ // Pybricks options #define PYBRICKS_OPT_COMPILER (1) +#define PYBRICKS_OPT_RAW_REPL (0) #define PYBRICKS_OPT_FLOAT (0) #define PYBRICKS_OPT_TERSE_ERR (0) #define PYBRICKS_OPT_EXTRA_MOD (1) diff --git a/bricks/ev3rt/mpconfigport.h b/bricks/ev3rt/mpconfigport.h index 016414fb7..fd2ddaded 100644 --- a/bricks/ev3rt/mpconfigport.h +++ b/bricks/ev3rt/mpconfigport.h @@ -49,6 +49,7 @@ // Pybricks options #define PYBRICKS_OPT_COMPILER (1) +#define PYBRICKS_OPT_RAW_REPL (1) #define PYBRICKS_OPT_FLOAT (1) #define PYBRICKS_OPT_TERSE_ERR (0) #define PYBRICKS_OPT_EXTRA_MOD (1) diff --git a/bricks/movehub/mpconfigport.h b/bricks/movehub/mpconfigport.h index e64947da6..32a75ccfc 100644 --- a/bricks/movehub/mpconfigport.h +++ b/bricks/movehub/mpconfigport.h @@ -45,6 +45,7 @@ // Pybricks options #define PYBRICKS_OPT_COMPILER (0) +#define PYBRICKS_OPT_RAW_REPL (0) #define PYBRICKS_OPT_FLOAT (0) #define PYBRICKS_OPT_TERSE_ERR (1) #define PYBRICKS_OPT_EXTRA_MOD (0) diff --git a/bricks/nxt/mpconfigport.h b/bricks/nxt/mpconfigport.h index 2d7391bb1..289b1adcf 100644 --- a/bricks/nxt/mpconfigport.h +++ b/bricks/nxt/mpconfigport.h @@ -48,6 +48,7 @@ // Pybricks options #define PYBRICKS_OPT_COMPILER (1) +#define PYBRICKS_OPT_RAW_REPL (1) #define PYBRICKS_OPT_FLOAT (1) #define PYBRICKS_OPT_TERSE_ERR (0) #define PYBRICKS_OPT_EXTRA_MOD (1) diff --git a/bricks/primehub/mpconfigport.h b/bricks/primehub/mpconfigport.h index efa7e29b6..6ca0c5acb 100644 --- a/bricks/primehub/mpconfigport.h +++ b/bricks/primehub/mpconfigport.h @@ -51,6 +51,7 @@ // Pybricks options #define PYBRICKS_OPT_COMPILER (1) +#define PYBRICKS_OPT_RAW_REPL (0) #define PYBRICKS_OPT_FLOAT (1) #define PYBRICKS_OPT_TERSE_ERR (0) #define PYBRICKS_OPT_EXTRA_MOD (1) diff --git a/bricks/technichub/mpconfigport.h b/bricks/technichub/mpconfigport.h index 1e340f4c9..4e8870081 100644 --- a/bricks/technichub/mpconfigport.h +++ b/bricks/technichub/mpconfigport.h @@ -49,6 +49,7 @@ // Pybricks options #define PYBRICKS_OPT_COMPILER (1) +#define PYBRICKS_OPT_RAW_REPL (0) #define PYBRICKS_OPT_FLOAT (1) #define PYBRICKS_OPT_TERSE_ERR (0) #define PYBRICKS_OPT_EXTRA_MOD (1) diff --git a/bricks/virtualhub/mpconfigvariant.h b/bricks/virtualhub/mpconfigvariant.h index e3f116998..f39bc50f9 100644 --- a/bricks/virtualhub/mpconfigvariant.h +++ b/bricks/virtualhub/mpconfigvariant.h @@ -43,6 +43,7 @@ // Pybricks options #define PYBRICKS_OPT_COMPILER (1) +#define PYBRICKS_OPT_RAW_REPL (0) #define PYBRICKS_OPT_FLOAT (1) #define PYBRICKS_OPT_TERSE_ERR (0) #define PYBRICKS_OPT_EXTRA_MOD (1) diff --git a/lib/pbio/platform/ev3rt/pbsysconfig.h b/lib/pbio/platform/ev3rt/pbsysconfig.h index f5b83ecf9..eef0e225f 100644 --- a/lib/pbio/platform/ev3rt/pbsysconfig.h +++ b/lib/pbio/platform/ev3rt/pbsysconfig.h @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT // Copyright (c) 2020-2023 The Pybricks Authors -#define PBSYS_CONFIG_FEATURE_BUILTIN_USER_PROGRAM_REPL (0) +#define PBSYS_CONFIG_FEATURE_BUILTIN_USER_PROGRAM_REPL (1) #define PBSYS_CONFIG_FEATURE_BUILTIN_USER_PROGRAM_PORT_VIEW (0) #define PBSYS_CONFIG_FEATURE_BUILTIN_USER_PROGRAM_IMU_CALIBRATION (0) #define PBSYS_CONFIG_FEATURE_PROGRAM_FORMAT_MULTI_MPY_V6 (1) diff --git a/lib/pbio/platform/nxt/pbsysconfig.h b/lib/pbio/platform/nxt/pbsysconfig.h index b76db64c4..342154671 100644 --- a/lib/pbio/platform/nxt/pbsysconfig.h +++ b/lib/pbio/platform/nxt/pbsysconfig.h @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT // Copyright (c) 2020-2023 The Pybricks Authors -#define PBSYS_CONFIG_FEATURE_BUILTIN_USER_PROGRAM_REPL (0) +#define PBSYS_CONFIG_FEATURE_BUILTIN_USER_PROGRAM_REPL (1) #define PBSYS_CONFIG_FEATURE_BUILTIN_USER_PROGRAM_PORT_VIEW (0) #define PBSYS_CONFIG_FEATURE_BUILTIN_USER_PROGRAM_IMU_CALIBRATION (0) #define PBSYS_CONFIG_FEATURE_PROGRAM_FORMAT_MULTI_MPY_V6 (1)