From cafb59e4329770c68b3519c7c45c6f2e4b95dc0e Mon Sep 17 00:00:00 2001 From: Glenn Ruben Bakke Date: Sun, 19 Jul 2020 12:42:09 +0200 Subject: [PATCH 1/2] nrf: Split mpconfigport.h into multiple files. Splitting mpconfigport.h into multiple device specific files in order to facilitate variations between devices. Due to the fact that the devices might have variations in features and also variations in flash size it makes sense that some devices offers more functionality than others without being limited by restricted devices. For example more micropython features can be activated for nrf52840 with 1MB flash, compared to nrf51 with 256KB. --- ports/nrf/mpconfigdevice_nrf51822.h | 37 +++++++++++++++++++++++++++++ ports/nrf/mpconfigdevice_nrf52832.h | 37 +++++++++++++++++++++++++++++ ports/nrf/mpconfigdevice_nrf52840.h | 37 +++++++++++++++++++++++++++++ ports/nrf/mpconfigdevice_nrf9160.h | 37 +++++++++++++++++++++++++++++ ports/nrf/mpconfigport.h | 12 ++++++++++ 5 files changed, 160 insertions(+) create mode 100644 ports/nrf/mpconfigdevice_nrf51822.h create mode 100644 ports/nrf/mpconfigdevice_nrf52832.h create mode 100644 ports/nrf/mpconfigdevice_nrf52840.h create mode 100644 ports/nrf/mpconfigdevice_nrf9160.h diff --git a/ports/nrf/mpconfigdevice_nrf51822.h b/ports/nrf/mpconfigdevice_nrf51822.h new file mode 100644 index 0000000000000..55d540be98b90 --- /dev/null +++ b/ports/nrf/mpconfigdevice_nrf51822.h @@ -0,0 +1,37 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Board overridable build configuration. + +#ifndef MICROPY_MBFS +#define MICROPY_MBFS (1) +#endif + +#ifndef MICROPY_VFS +#define MICROPY_VFS (0) +#endif + +// Board overridable feature configuration. diff --git a/ports/nrf/mpconfigdevice_nrf52832.h b/ports/nrf/mpconfigdevice_nrf52832.h new file mode 100644 index 0000000000000..55d540be98b90 --- /dev/null +++ b/ports/nrf/mpconfigdevice_nrf52832.h @@ -0,0 +1,37 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Board overridable build configuration. + +#ifndef MICROPY_MBFS +#define MICROPY_MBFS (1) +#endif + +#ifndef MICROPY_VFS +#define MICROPY_VFS (0) +#endif + +// Board overridable feature configuration. diff --git a/ports/nrf/mpconfigdevice_nrf52840.h b/ports/nrf/mpconfigdevice_nrf52840.h new file mode 100644 index 0000000000000..55d540be98b90 --- /dev/null +++ b/ports/nrf/mpconfigdevice_nrf52840.h @@ -0,0 +1,37 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Board overridable build configuration. + +#ifndef MICROPY_MBFS +#define MICROPY_MBFS (1) +#endif + +#ifndef MICROPY_VFS +#define MICROPY_VFS (0) +#endif + +// Board overridable feature configuration. diff --git a/ports/nrf/mpconfigdevice_nrf9160.h b/ports/nrf/mpconfigdevice_nrf9160.h new file mode 100644 index 0000000000000..55d540be98b90 --- /dev/null +++ b/ports/nrf/mpconfigdevice_nrf9160.h @@ -0,0 +1,37 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Board overridable build configuration. + +#ifndef MICROPY_MBFS +#define MICROPY_MBFS (1) +#endif + +#ifndef MICROPY_VFS +#define MICROPY_VFS (0) +#endif + +// Board overridable feature configuration. diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index c5304b20d0d3e..e84709c49dda8 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -29,6 +29,18 @@ #include +#if defined(NRF51822) + #include "mpconfigdevice_nrf51822.h" +#elif defined(NRF52832) + #include "mpconfigdevice_nrf52832.h" +#elif defined(NRF52840) + #include "mpconfigdevice_nrf52840.h" +#elif defined(NRF9160) + #include "mpconfigdevice_nrf9160.h" +#else + #pragma error "Device not defined" +#endif + // options to control how MicroPython is built #ifndef MICROPY_VFS #define MICROPY_VFS (0) From 33add63b2b8d1f6a2e700c60b74e283f994ed5f3 Mon Sep 17 00:00:00 2001 From: Glenn Ruben Bakke Date: Sun, 19 Jul 2020 12:49:30 +0200 Subject: [PATCH 2/2] nrf: Enable more features for all targets. Enabling the following features for all targets, except for nrf51 targets compiled to be used with SoftDevice: - MICROPY_PY_ARRAY_SLICE_ASSIGN - MICROPY_PY_SYS_STDFILES - MICROPY_PY_UBINASCII --- ports/nrf/mpconfigdevice_nrf51822.h | 24 ++++++++++++++++++++++++ ports/nrf/mpconfigdevice_nrf52832.h | 12 ++++++++++++ ports/nrf/mpconfigdevice_nrf52840.h | 12 ++++++++++++ ports/nrf/mpconfigdevice_nrf9160.h | 12 ++++++++++++ ports/nrf/mpconfigport.h | 3 --- 5 files changed, 60 insertions(+), 3 deletions(-) diff --git a/ports/nrf/mpconfigdevice_nrf51822.h b/ports/nrf/mpconfigdevice_nrf51822.h index 55d540be98b90..2f85c9f4c5468 100644 --- a/ports/nrf/mpconfigdevice_nrf51822.h +++ b/ports/nrf/mpconfigdevice_nrf51822.h @@ -35,3 +35,27 @@ #endif // Board overridable feature configuration. + +#ifndef MICROPY_PY_ARRAY_SLICE_ASSIGN +#if defined(BLUETOOTH_SD) +#define MICROPY_PY_ARRAY_SLICE_ASSIGN (0) +#else +#define MICROPY_PY_ARRAY_SLICE_ASSIGN (1) +#endif +#endif + +#ifndef MICROPY_PY_SYS_STDFILES +#if defined(BLUETOOTH_SD) +#define MICROPY_PY_SYS_STDFILES (0) +#else +#define MICROPY_PY_SYS_STDFILES (1) +#endif +#endif + +#ifndef MICROPY_PY_UBINASCII +#if defined(BLUETOOTH_SD) +#define MICROPY_PY_UBINASCII (0) +#else +#define MICROPY_PY_UBINASCII (1) +#endif +#endif diff --git a/ports/nrf/mpconfigdevice_nrf52832.h b/ports/nrf/mpconfigdevice_nrf52832.h index 55d540be98b90..2bfd047ca1456 100644 --- a/ports/nrf/mpconfigdevice_nrf52832.h +++ b/ports/nrf/mpconfigdevice_nrf52832.h @@ -35,3 +35,15 @@ #endif // Board overridable feature configuration. + +#ifndef MICROPY_PY_ARRAY_SLICE_ASSIGN +#define MICROPY_PY_ARRAY_SLICE_ASSIGN (1) +#endif + +#ifndef MICROPY_PY_SYS_STDFILES +#define MICROPY_PY_SYS_STDFILES (1) +#endif + +#ifndef MICROPY_PY_UBINASCII +#define MICROPY_PY_UBINASCII (1) +#endif diff --git a/ports/nrf/mpconfigdevice_nrf52840.h b/ports/nrf/mpconfigdevice_nrf52840.h index 55d540be98b90..2bfd047ca1456 100644 --- a/ports/nrf/mpconfigdevice_nrf52840.h +++ b/ports/nrf/mpconfigdevice_nrf52840.h @@ -35,3 +35,15 @@ #endif // Board overridable feature configuration. + +#ifndef MICROPY_PY_ARRAY_SLICE_ASSIGN +#define MICROPY_PY_ARRAY_SLICE_ASSIGN (1) +#endif + +#ifndef MICROPY_PY_SYS_STDFILES +#define MICROPY_PY_SYS_STDFILES (1) +#endif + +#ifndef MICROPY_PY_UBINASCII +#define MICROPY_PY_UBINASCII (1) +#endif diff --git a/ports/nrf/mpconfigdevice_nrf9160.h b/ports/nrf/mpconfigdevice_nrf9160.h index 55d540be98b90..2bfd047ca1456 100644 --- a/ports/nrf/mpconfigdevice_nrf9160.h +++ b/ports/nrf/mpconfigdevice_nrf9160.h @@ -35,3 +35,15 @@ #endif // Board overridable feature configuration. + +#ifndef MICROPY_PY_ARRAY_SLICE_ASSIGN +#define MICROPY_PY_ARRAY_SLICE_ASSIGN (1) +#endif + +#ifndef MICROPY_PY_SYS_STDFILES +#define MICROPY_PY_SYS_STDFILES (1) +#endif + +#ifndef MICROPY_PY_UBINASCII +#define MICROPY_PY_UBINASCII (1) +#endif diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index e84709c49dda8..1197df016cce9 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -117,11 +117,9 @@ #define MICROPY_MODULE_BUILTIN_INIT (1) #define MICROPY_PY_ALL_SPECIAL_METHODS (0) #define MICROPY_PY_MICROPYTHON_MEM_INFO (1) -#define MICROPY_PY_ARRAY_SLICE_ASSIGN (0) #define MICROPY_PY_BUILTINS_SLICE_ATTRS (0) #define MICROPY_PY_SYS_EXIT (1) #define MICROPY_PY_SYS_MAXSIZE (1) -#define MICROPY_PY_SYS_STDFILES (0) #define MICROPY_PY_SYS_STDIO_BUFFER (0) #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0) #define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (0) @@ -129,7 +127,6 @@ #define MICROPY_PY_IO (0) #define MICROPY_PY_IO_FILEIO (0) #define MICROPY_PY_UERRNO (0) -#define MICROPY_PY_UBINASCII (0) #define MICROPY_PY_URANDOM (1) #define MICROPY_PY_URANDOM_EXTRA_FUNCS (1) #define MICROPY_PY_UCTYPES (0)