Skip to content

Commit

Permalink
bricks/_common/micropython: Support raw REPL.
Browse files Browse the repository at this point in the history
This is useful for development on builds without full pbsys integration, so we can run the nxt and ev3rt with mpremote.
  • Loading branch information
laurensvalk committed Oct 15, 2024
1 parent 3a5d824 commit 34bc5c4
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 3 deletions.
12 changes: 11 additions & 1 deletion bricks/_common/micropython.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions bricks/cityhub/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions bricks/debug/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions bricks/essentialhub/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions bricks/ev3/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions bricks/ev3rt/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions bricks/movehub/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions bricks/nxt/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions bricks/primehub/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions bricks/technichub/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions bricks/virtualhub/mpconfigvariant.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/pbio/platform/ev3rt/pbsysconfig.h
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/pbio/platform/nxt/pbsysconfig.h
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 34bc5c4

Please sign in to comment.