Magic when compiling MicroPython for NUCLEO_F767ZI

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
WZab
Posts: 25
Joined: Tue Jan 21, 2020 7:45 pm

Magic when compiling MicroPython for NUCLEO_F767ZI

Post by WZab » Sat Jun 12, 2021 8:21 pm

Hi,

I needed to compile the MicroPython for NUCLEO_F767ZI with Ethernet supporting DHCP and with threads support.
I use the master version (commit 3ab8806c0d2fe77e9785216563b419cfadff71b0)
My first attempt was to use:

Code: Select all

make BOARD=NUCLEO_F767ZI MICROPY_PY_LWIP=1 MICROPY_PY_THREAD=1 MICROPY_PY_THREAD_GIL=1
MicroPython compiled correctly, DHCP was working, but there was not _thread package available.

So I tried to add those parameters to the mpcofigboard.h

Code: Select all

// Note: if the board shows odd behaviour check the option bits and make sure nD
// set to make the 2MByte space continuous instead of divided into two 1MByte se

#define MICROPY_PY_THREAD (1)
#define MICROPY_PY_THREAD_GIL (1)
#define MICROPY_PY_LWIP (1)

#define MICROPY_HW_BOARD_NAME       "NUCLEO-F767ZI"
#define MICROPY_HW_MCU_NAME         "STM32F767"
Now the results are very interesting:

Code: Select all

make BOARD=NUCLEO_F767ZI
[...]
GEN build-NUCLEO_F767ZI/genhdr/qstr.i.last
In file included from ./mpconfigport.h:31,
                 from ../../py/mpconfig.h:62,
                 from ../../lib/oofatfs/ffconf.h:30,
                 from ../../lib/oofatfs/ff.h:33,
                 from ../../lib/oofatfs/ff.c:28:
boards/NUCLEO_F767ZI/mpconfigboard.h:6: error: "MICROPY_PY_LWIP" redefined [-Werror]
 #define MICROPY_PY_LWIP (1)
 
<command-line>: note: this is the location of the previous definition
In file included from ./mpconfigport.h:31,
                 from ../../py/mpconfig.h:62,
                 from ../../py/asmthumb.c:31:
boards/NUCLEO_F767ZI/mpconfigboard.h:6: error: "MICROPY_PY_LWIP" redefined [-Werror]
 #define MICROPY_PY_LWIP (1)
 
<command-line>: note: this is the location of the previous definition
In file included from ./mpconfigport.h:31,
                 from ../../py/mpconfig.h:62,
                 from ../../py/mpstate.h:31,
[...]
The above error is repeated many times.                 
The funny thing is that definitions of MICROPY_PY_THREAD and MICROPY_PY_THREAD_GIL in mpconfigboard.h are fully accepted.

So finally I had to build MicroPython for NUCLEO_F767ZI with:

Code: Select all

make BOARD=NUCLEO_F767ZI MICROPY_PY_LWIP=1 
And with the mpconfigboard.h containing the additional MICROPY_PY_THREAD and MICROPY_PY_THREAD_GIL definitions.

Code: Select all

// Note: if the board shows odd behaviour check the option bits and make sure nD
// set to make the 2MByte space continuous instead of divided into two 1MByte se

#define MICROPY_PY_THREAD (1)
#define MICROPY_PY_THREAD_GIL (1)

#define MICROPY_HW_BOARD_NAME       "NUCLEO-F767ZI"
#define MICROPY_HW_MCU_NAME         "STM32F767"
So compiled MicroPython uses DHCP and is _thread enabled.

Why MICROPY_PY_LWIP, MICROPY_PY_THREAD and MICROPY_PY_THREAD_GIL are treated in so inconsistent way?

TIA & Regards,
Wojtek

Post Reply