Building micropython with 240mhz

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
leosok
Posts: 18
Joined: Sun May 02, 2021 10:10 pm

Building micropython with 240mhz

Post by leosok » Wed Jun 22, 2022 8:08 pm

Hi,
I use a own build, to freeze my modules into the firmware. I copied GENERIC and changed appropriately, and my firmware builds and works. (Using the Boardname)

Code: Select all

---mpconfigboard.h---
#define MICROPY_HW_BOARD_NAME "ESP32 TTGO T-Display"
#define MICROPY_HW_MCU_NAME "ESP32"
Unfortunately this builds the standard 160mhz. I want to build with 240mhz.
So I added "boards/sdkconfig.240mhz" to "mpconfigboard.cmake". Unfortunatly the firmware is still 160mhz. How to fix this?

Code: Select all

set(SDKCONFIG_DEFAULTS
    boards/sdkconfig.base
    boards/sdkconfig.240mhz
    boards/sdkconfig.ble
)

if(NOT MICROPY_FROZEN_MANIFEST)
    set(MICROPY_FROZEN_MANIFEST ${MICROPY_PORT_DIR}/boards/manifest.py)
endif()

User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

Re: Building micropython with 240mhz

Post by scruss » Wed Jun 22, 2022 9:27 pm

Is it a problem to put the following in boot.py?

Code: Select all

import machine
machine.freq(240000000)

leosok
Posts: 18
Joined: Sun May 02, 2021 10:10 pm

Re: Building micropython with 240mhz

Post by leosok » Wed Jun 22, 2022 10:28 pm

Not really, and I did it. But compared to a "stock" build with 240mhz I still lose some time, because everything loaded before boot.py is worked on with 160mhz. I could even put it in _boot.py (which will be frozen).
Mostly I want to know how to do it "right". There must be a reason, why there is a "boards/sdkconfig.240mhz" file :-).

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Building micropython with 240mhz

Post by jimmo » Thu Jun 23, 2022 3:56 am

leosok wrote:
Wed Jun 22, 2022 8:08 pm
So I added "boards/sdkconfig.240mhz" to "mpconfigboard.cmake". Unfortunatly the firmware is still 160mhz. How to fix this?
This works on the UM_TINYPICO - just checked here. Did you do a `make clean` after changing mpconfigboard.cmake?
leosok wrote:
Wed Jun 22, 2022 10:28 pm
everything loaded before boot.py is worked on with 160mhz.
There shouldn't be very much that happens before boot.py that this would make a significant difference. But yeah, what you're doing with sdkconfig.240mhz is the correct way to solve this.

After a build, can you do

Code: Select all

$ cat build-$YOUR_BOARD/sdkconfig.combined | grep CONFIG_ESP32_DEFAULT_CPU_FREQ
[code]

and see that it's getting included into sdkconfig.combined?

leosok
Posts: 18
Joined: Sun May 02, 2021 10:10 pm

Re: Building micropython with 240mhz

Post by leosok » Thu Jun 23, 2022 12:16 pm

I think the problem is actually my build-directions. I'm doing it all with a bash-script running inside a docker, which has all the build-setup.

Code: Select all

# Build command is here:
cd /mpbuilder/micropython_src/ports/esp32
idf.py -D MICROPY_BOARD="$MICROPY_BOARD" -D USER_C_MODULES=/mpbuilder/st7789_mpy/st7789/micropython.cmake build
It seems the MICROPY_BOARD env is enough to produce the right "Tag" but not to actually use the files inside the "/build/boards/ESP32_TTGO_T_DISPLAY" directory.

Can you please tell me the build commands you used, to build UM_TINYPICO? Because there is no "build-$YOUR_BOARD/sdkconfig.combined" for me, I think it's just building the GENERIC board to "build" directory.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Building micropython with 240mhz

Post by jimmo » Thu Jun 23, 2022 12:22 pm

leosok wrote:
Thu Jun 23, 2022 12:16 pm
Can you please tell me the build commands you used, to build UM_TINYPICO? Because there is no "build-$YOUR_BOARD/sdkconfig.combined" for me, I think it's just building the GENERIC board to "build" directory.
I use the Makefile, so

Code: Select all

make -j BOARD=UM_TINYPICO
which is equivalent to

Code: Select all

idf.py -D MICROPY_BOARD=UM_TINYPICO -B build-UM_TINYPICO build
How are you building your final .bin file? Do you also pass the sdkconfig to makeimg.py (like the Makefile does).

leosok
Posts: 18
Joined: Sun May 02, 2021 10:10 pm

Re: Building micropython with 240mhz

Post by leosok » Thu Jun 23, 2022 12:31 pm

I do. I seem to be using the "GENERIC" though. But makeimg.py is only combining the bin-files from what I understand?!

Code: Select all

BUILD_DIR="/mpbuilder/micropython_src/ports/esp32/build"

# build the firmware
python3 makeimg.py \
        $BUILD_DIR/sdkconfig \
        $BUILD_DIR/bootloader/bootloader.bin \
        $BUILD_DIR/partition_table/partition-table.bin \
        $BUILD_DIR/micropython.bin \
        $BUILD_DIR/firmware.bin
I believe I did not use the makefile, because I need to add the USER_C_MODULES=/mpbuilder/st7789_mpy/st7789/micropython.cmake

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Building micropython with 240mhz

Post by jimmo » Thu Jun 23, 2022 1:51 pm

leosok wrote:
Thu Jun 23, 2022 12:31 pm
because I need to add the USER_C_MODULES=/mpbuilder/st7789_mpy/st7789/micropython.cmake
The Makefile also accepts the USER_C_MODULES argument.

Code: Select all

make BOARD=... USER_C_MODULES=...

leosok
Posts: 18
Joined: Sun May 02, 2021 10:10 pm

Re: Building micropython with 240mhz

Post by leosok » Thu Jun 23, 2022 2:50 pm

Thanks! I will try this once I'm back home (in a week)

leosok
Posts: 18
Joined: Sun May 02, 2021 10:10 pm

Re: Building micropython with 240mhz

Post by leosok » Tue Jul 05, 2022 10:49 pm

Hi jimmo,
happy to let you know that I built the firmware using

Code: Select all

make BOARD=... USER_C_MODULES=...
and it worked!

Post Reply