Page 1 of 1

Removing modules from firmware image?

Posted: Thu Jan 20, 2022 10:00 pm
by ldmoretti
Hi:
I've got a custom board (STM32 based) and looking at the list from help('modules') I've got a few modules that I don't need. How do I remove them from my board without effecting the other default projects? I see some of them in the ports/stm32/boards/manafest.py file but removing them there would change the other STM32 based boards.

Examples ones I see that I don't think I need:
_onewire
lcd160cr
lcd160cr_test
dht
network
onewire
uselect
usocket

Re: Removing modules from firmware image?

Posted: Fri Jan 21, 2022 12:01 am
by dhylands
You can override the manifest that's used by using the FROZEN_MANIFEST variable.

If you look in the Makefile you'll see: https://github.com/micropython/micropyt ... kefile#L28

So you can create your own manifest.py file which contains:

Code: Select all

include("$(MPY_DIR)/extmod/uasyncio/manifest.py")
and then build the firmware using:

Code: Select all

make BOARD=YOUR_BOARD_NAME FROZEN_MANIFEST=~/mymanifest.py
For stuff like this, I normally create a GNUmakefile that would look something like:

Code: Select all

$(info using GNUmakefile)
BOARD = YOUR_BOARD_NAME
FROZEN_MANIFEST = ~/mymanifest.py

include Makefile
To remove uselect and uscockt, you can add the following to your board's mpconfigboard.h

Code: Select all

#define MICROPY_PY_UCOSKET (0)
#define MICROPY_PY_USELECT (0)
You probably don't want to remove uselect if you're planning on using uasyncio (but I'm not 100% on that).