summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/library/sys.rst1
-rw-r--r--ports/unix/main.c4
-rw-r--r--py/modsys.c11
-rw-r--r--py/mpconfig.h9
-rw-r--r--shared/runtime/pyexec.c6
5 files changed, 24 insertions, 7 deletions
diff --git a/docs/library/sys.rst b/docs/library/sys.rst
index 1186af613..3efdce964 100644
--- a/docs/library/sys.rst
+++ b/docs/library/sys.rst
@@ -70,6 +70,7 @@ Constants
* *name* - string "micropython"
* *version* - tuple (major, minor, micro), e.g. (1, 7, 0)
+ * *_machine* - string describing the underlying machine
* *_mpy* - supported mpy file-format version (optional attribute)
This object is the recommended way to distinguish MicroPython from other
diff --git a/ports/unix/main.c b/ports/unix/main.c
index ea3154860..8d7fcf484 100644
--- a/ports/unix/main.c
+++ b/ports/unix/main.c
@@ -179,8 +179,8 @@ STATIC char *strjoin(const char *s1, int sep_char, const char *s2) {
STATIC int do_repl(void) {
mp_hal_stdout_tx_str(MICROPY_BANNER_NAME_AND_VERSION);
- mp_hal_stdout_tx_str("; " MICROPY_PY_SYS_PLATFORM " [" MICROPY_PLATFORM_COMPILER "] version\n"
- "Use Ctrl-D to exit, Ctrl-E for paste mode\n");
+ mp_hal_stdout_tx_str("; " MICROPY_BANNER_MACHINE);
+ mp_hal_stdout_tx_str("\nUse Ctrl-D to exit, Ctrl-E for paste mode\n");
#if MICROPY_USE_READLINE == 1
diff --git a/py/modsys.c b/py/modsys.c
index 12f3f0026..4ddc27fc5 100644
--- a/py/modsys.c
+++ b/py/modsys.c
@@ -36,6 +36,7 @@
#include "py/smallint.h"
#include "py/runtime.h"
#include "py/persistentcode.h"
+#include "extmod/moduplatform.h"
#include "genhdr/mpversion.h"
#if MICROPY_PY_SYS_SETTRACE
@@ -69,20 +70,24 @@ STATIC const mp_obj_tuple_t mp_sys_implementation_version_info_obj = {
3,
{ I(MICROPY_VERSION_MAJOR), I(MICROPY_VERSION_MINOR), I(MICROPY_VERSION_MICRO) }
};
+STATIC const MP_DEFINE_STR_OBJ(mp_sys_implementation_machine_obj, MICROPY_BANNER_MACHINE);
#if MICROPY_PERSISTENT_CODE_LOAD
#define SYS_IMPLEMENTATION_ELEMS \
MP_ROM_QSTR(MP_QSTR_micropython), \
MP_ROM_PTR(&mp_sys_implementation_version_info_obj), \
+ MP_ROM_PTR(&mp_sys_implementation_machine_obj), \
MP_ROM_INT(MPY_FILE_HEADER_INT)
#else
#define SYS_IMPLEMENTATION_ELEMS \
MP_ROM_QSTR(MP_QSTR_micropython), \
- MP_ROM_PTR(&mp_sys_implementation_version_info_obj)
+ MP_ROM_PTR(&mp_sys_implementation_version_info_obj), \
+ MP_ROM_PTR(&mp_sys_implementation_machine_obj)
#endif
#if MICROPY_PY_ATTRTUPLE
STATIC const qstr impl_fields[] = {
MP_QSTR_name,
MP_QSTR_version,
+ MP_QSTR__machine,
#if MICROPY_PERSISTENT_CODE_LOAD
MP_QSTR__mpy,
#endif
@@ -90,13 +95,13 @@ STATIC const qstr impl_fields[] = {
STATIC MP_DEFINE_ATTRTUPLE(
mp_sys_implementation_obj,
impl_fields,
- 2 + MICROPY_PERSISTENT_CODE_LOAD,
+ 3 + MICROPY_PERSISTENT_CODE_LOAD,
SYS_IMPLEMENTATION_ELEMS
);
#else
STATIC const mp_rom_obj_tuple_t mp_sys_implementation_obj = {
{&mp_type_tuple},
- 2 + MICROPY_PERSISTENT_CODE_LOAD,
+ 3 + MICROPY_PERSISTENT_CODE_LOAD,
{
SYS_IMPLEMENTATION_ELEMS
}
diff --git a/py/mpconfig.h b/py/mpconfig.h
index 0b190a997..b58cef309 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -1719,6 +1719,15 @@ typedef double mp_float_t;
#define MICROPY_BANNER_NAME_AND_VERSION "MicroPython " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE
#endif
+// String used for the second part of the banner, and sys.implementation._machine
+#ifndef MICROPY_BANNER_MACHINE
+#ifdef MICROPY_HW_BOARD_NAME
+#define MICROPY_BANNER_MACHINE MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME
+#else
+#define MICROPY_BANNER_MACHINE MICROPY_PY_SYS_PLATFORM " [" MICROPY_PLATFORM_COMPILER "] version"
+#endif
+#endif
+
// On embedded platforms, these will typically enable/disable irqs.
#ifndef MICROPY_BEGIN_ATOMIC_SECTION
#define MICROPY_BEGIN_ATOMIC_SECTION() (0)
diff --git a/shared/runtime/pyexec.c b/shared/runtime/pyexec.c
index eabf2f567..2763319c0 100644
--- a/shared/runtime/pyexec.c
+++ b/shared/runtime/pyexec.c
@@ -402,7 +402,8 @@ STATIC int pyexec_friendly_repl_process_char(int c) {
// reset friendly REPL
mp_hal_stdout_tx_str("\r\n");
mp_hal_stdout_tx_str(MICROPY_BANNER_NAME_AND_VERSION);
- mp_hal_stdout_tx_str("; " MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME "\r\n");
+ mp_hal_stdout_tx_str("; " MICROPY_BANNER_MACHINE);
+ mp_hal_stdout_tx_str("\r\n");
#if MICROPY_PY_BUILTINS_HELP
mp_hal_stdout_tx_str("Type \"help()\" for more information.\r\n");
#endif
@@ -554,7 +555,8 @@ int pyexec_friendly_repl(void) {
friendly_repl_reset:
mp_hal_stdout_tx_str(MICROPY_BANNER_NAME_AND_VERSION);
- mp_hal_stdout_tx_str("; " MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME "\r\n");
+ mp_hal_stdout_tx_str("; " MICROPY_BANNER_MACHINE);
+ mp_hal_stdout_tx_str("\r\n");
#if MICROPY_PY_BUILTINS_HELP
mp_hal_stdout_tx_str("Type \"help()\" for more information.\r\n");
#endif