Removing modules from firmware image?

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
ldmoretti
Posts: 5
Joined: Fri Mar 26, 2021 1:34 am

Removing modules from firmware image?

Post by ldmoretti » Thu Jan 20, 2022 10:00 pm

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

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Removing modules from firmware image?

Post by dhylands » Fri Jan 21, 2022 12:01 am

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).

Post Reply