stm32: Introduce MICROPY_PY_STM config to include or not the stm module.

By default the stm module is included in the build, but a board can now
define MICROPY_PY_STM to 0 to not include this module.  This reduces the
firmware by about 7k.
pull/1/head
Damien George 2018-04-24 12:01:49 +10:00
parent a60efa8202
commit 8a949ba599
4 changed files with 21 additions and 3 deletions

View File

@ -244,8 +244,10 @@ def main():
print("")
with open(args.qstr_filename, 'wt') as qstr_file:
print('#if MICROPY_PY_STM', file=qstr_file)
for qstr in sorted(needed_qstrs):
print('Q({})'.format(qstr), file=qstr_file)
print('#endif // MICROPY_PY_STM', file=qstr_file)
with open(args.mpz_filename, 'wt') as mpz_file:
for mpz in sorted(needed_mpzs):

View File

@ -30,9 +30,12 @@
#include "py/obj.h"
#include "py/objint.h"
#include "extmod/machine_mem.h"
#include "genhdr/modstm_mpz.h"
#include "portmodules.h"
#if MICROPY_PY_STM
#include "genhdr/modstm_mpz.h"
STATIC const mp_rom_map_elem_t stm_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_stm) },
@ -49,3 +52,5 @@ const mp_obj_module_t stm_module = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t*)&stm_module_globals,
};
#endif // MICROPY_PY_STM

View File

@ -32,6 +32,11 @@
/*****************************************************************************/
// Feature settings with defaults
// Whether to include the stm module, with peripheral register constants
#ifndef MICROPY_PY_STM
#define MICROPY_PY_STM (1)
#endif
// Whether to enable storage on the internal flash of the MCU
#ifndef MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (1)

View File

@ -186,6 +186,12 @@ extern const struct _mp_obj_module_t mp_module_usocket;
extern const struct _mp_obj_module_t mp_module_network;
extern const struct _mp_obj_module_t mp_module_onewire;
#if MICROPY_PY_STM
#define STM_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_stm), MP_ROM_PTR(&stm_module) },
#else
#define STM_BUILTIN_MODULE
#endif
#if MICROPY_PY_USOCKET
#define SOCKET_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_usocket), MP_ROM_PTR(&mp_module_usocket) },
#define SOCKET_BUILTIN_MODULE_WEAK_LINKS { MP_ROM_QSTR(MP_QSTR_socket), MP_ROM_PTR(&mp_module_usocket) },
@ -203,7 +209,7 @@ extern const struct _mp_obj_module_t mp_module_onewire;
#define MICROPY_PORT_BUILTIN_MODULES \
{ MP_ROM_QSTR(MP_QSTR_umachine), MP_ROM_PTR(&machine_module) }, \
{ MP_ROM_QSTR(MP_QSTR_pyb), MP_ROM_PTR(&pyb_module) }, \
{ MP_ROM_QSTR(MP_QSTR_stm), MP_ROM_PTR(&stm_module) }, \
STM_BUILTIN_MODULE \
{ MP_ROM_QSTR(MP_QSTR_uos), MP_ROM_PTR(&mp_module_uos) }, \
{ MP_ROM_QSTR(MP_QSTR_utime), MP_ROM_PTR(&mp_module_utime) }, \
SOCKET_BUILTIN_MODULE \
@ -233,7 +239,7 @@ extern const struct _mp_obj_module_t mp_module_onewire;
{ MP_ROM_QSTR(MP_QSTR_umachine), MP_ROM_PTR(&machine_module) }, \
{ MP_ROM_QSTR(MP_QSTR_machine), MP_ROM_PTR(&machine_module) }, \
{ MP_ROM_QSTR(MP_QSTR_pyb), MP_ROM_PTR(&pyb_module) }, \
{ MP_ROM_QSTR(MP_QSTR_stm), MP_ROM_PTR(&stm_module) }, \
STM_BUILTIN_MODULE \
#define MP_STATE_PORT MP_STATE_VM