Page 1 of 1

Where to find any docs about upy FULL FEATURE PORTING guides?

Posted: Wed Apr 03, 2019 2:29 pm
by turoksama
Hi there,
I tried to build upy recently, it is really great! Amazing work.
After serial days hard work, I still have little idea about porting to a custom board, there are lots of boards can be refrenced though. Because not all of these boards support a particular feature, and don't know what to do about it, sometimes it is not there at all. I have made some modifications but not all of them because of lacking details.
There are confusing comments about some features too, e.g. :
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
#define MICROPY_HW_HAS_FLASH (1)
MICROPY_HW_HAS_FLASH - somewhere saids internal flash, but it is much more like to be SPIFLASH here???

And something comes up suddenly in mpconfigboard.h:

#define MICROPY_HW_SPIFLASH_SIZE_BITS (128 * 1024 * 1024)
#define MICROPY_HW_SPIFLASH_CS (pin_E11)
#define MICROPY_HW_SPIFLASH_SCK (pin_E10)
#define MICROPY_HW_SPIFLASH_MOSI (pin_E12)
#define MICROPY_HW_SPIFLASH_MISO (pin_E13)

What are the patterns of these definitions: "MICROPY_HW_SPIFLASH_CS" ???
Well, it is ued by

const mp_spiflash_config_t spiflash_config = {
.bus_kind = MP_SPIFLASH_BUS_SPI,
.bus.u_spi.cs = MICROPY_HW_SPIFLASH_CS,
.bus.u_spi.data = (void*)&soft_spi_bus,
.bus.u_spi.proto = &mp_soft_spi_proto,
.cache = &spi_bdev_cache,
};

in bdev.c, but without #include "mpconfigboard.h", did I miss something?

And so on.

Honestly speaking, it drives me crazy sometimes.

So, where can i find a full list of the upy detailed features?

Re: Where to find any docs about upy FULL FEATURE PORTING guides?

Posted: Wed Apr 03, 2019 3:48 pm
by dhylands
turoksama wrote:
Wed Apr 03, 2019 2:29 pm
Hi there,
I tried to build upy recently, it is really great! Amazing work.
After serial days hard work, I still have little idea about porting to a custom board, there are lots of boards can be refrenced though. Because not all of these boards support a particular feature, and don't know what to do about it, sometimes it is not there at all. I have made some modifications but not all of them because of lacking details.
There are confusing comments about some features too, e.g. :
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
#define MICROPY_HW_HAS_FLASH (1)
MICROPY_HW_HAS_FLASH - somewhere saids internal flash, but it is much more like to be SPIFLASH here???
I searched the stm32 C files for MICROPY_HW_HAS_FLASH and it only appears in one place:
https://github.com/micropython/micropyt ... pyb.c#L193
which is a module for accessing the internal flash (not SPI Flash)
turoksama wrote:
Wed Apr 03, 2019 2:29 pm
And something comes up suddenly in mpconfigboard.h:

#define MICROPY_HW_SPIFLASH_SIZE_BITS (128 * 1024 * 1024)
#define MICROPY_HW_SPIFLASH_CS (pin_E11)
#define MICROPY_HW_SPIFLASH_SCK (pin_E10)
#define MICROPY_HW_SPIFLASH_MOSI (pin_E12)
#define MICROPY_HW_SPIFLASH_MISO (pin_E13)

What are the patterns of these definitions: "MICROPY_HW_SPIFLASH_CS" ???
Well, it is ued by

const mp_spiflash_config_t spiflash_config = {
.bus_kind = MP_SPIFLASH_BUS_SPI,
.bus.u_spi.cs = MICROPY_HW_SPIFLASH_CS,
.bus.u_spi.data = (void*)&soft_spi_bus,
.bus.u_spi.proto = &mp_soft_spi_proto,
.cache = &spi_bdev_cache,
};

in bdev.c, but without #include "mpconfigboard.h", did I miss something?
The new PYBD boards come with SPI Flash.

mpconfigboard.h is #included from ports/stm32/mpconfigport.h, which is in turn #included from py/mpconfig.h which is #included from py/obj.h which is included in flashbdev.h

You can do:

Code: Select all

make BOARD=PYBV11 build-PYBV11/flashbdev.pp
and that will produce a text file which is the flashbdev.c file run through the preprocesor with all of the #includes fully expanded. This will show you where files are being #included from.
turoksama wrote:
Wed Apr 03, 2019 2:29 pm
And so on.

Honestly speaking, it drives me crazy sometimes.

So, where can i find a full list of the upy detailed features?
There is none. You need to examine the source code.

I normally start with the ports/stm32/boards/PYBV11/mpconfigboard.h file which tends to be fairly fully featured, so it includes most of the configuration settings. The PYBD board files (which haven't been merged into mainline yet) will have a few more features since it supports networking as well.

Re: Where to find any docs about upy FULL FEATURE PORTING guides?

Posted: Thu Apr 04, 2019 3:07 am
by turoksama
Hi,
Great, thank you!
Where can i find PYBD port?

Re: Where to find any docs about upy FULL FEATURE PORTING guides?

Posted: Thu Apr 04, 2019 3:25 am
by dhylands

Re: Where to find any docs about upy FULL FEATURE PORTING guides?

Posted: Thu Apr 04, 2019 3:59 am
by turoksama
dhylands wrote:
Thu Apr 04, 2019 3:25 am
See this thread: https://github.com/micropython/micropython/pull/4669
Yep, I found it too.
I'll look into that.
Thanks!