compiling for small RAM/ROM platforms

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
jgriessen
Posts: 103
Joined: Mon Sep 29, 2014 4:20 pm
Contact:

compiling for small RAM/ROM platforms

Post by jgriessen » Thu Mar 10, 2016 4:51 pm

Suppose you wanted to cost reduce a micropython application below even the "contributions guide" minimums for the project:
"we would like to maintain portability to much smaller MCU cores. The theoretical minimum requirements we'd like to maintain are 128K ROM/8K RAM".

Is there a way to leave off parts of micropython if they are not being used, or is that already done at linking time?

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

Re: compiling for small RAM/ROM platforms

Post by dhylands » Thu Mar 10, 2016 5:00 pm

One way of controlling features is by modifying mponfigport.h

Options set in py/mpconfig.h can all be overridden in mpconfigport.h

The port can choose not to include files it doesn't need.

Some places still need work. For example, I think its currently difficult to disable USB completely (on the stmhal port).

User avatar
jgriessen
Posts: 103
Joined: Mon Sep 29, 2014 4:20 pm
Contact:

Re: compiling for small RAM/ROM platforms

Post by jgriessen » Thu Mar 10, 2016 5:25 pm

mpconfigport.h
Thanks, I'll read up on that.

@dhylands I read about compiling so all the program goes in the on chip ROM, for chips that have no SD card port such as
the F401's that have 64k RAM, 128k flash. Was that you, and if so, where to find details? I am going to want to use that method along with creating a F401 platform if not done yet.

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

Re: compiling for small RAM/ROM platforms

Post by dhylands » Thu Mar 10, 2016 5:34 pm

There are several F401 boards supported already:
ESPRUINO_PICO, and STM32F401NUCLEO (soon to be renamed to NUCLEO_F401RE), and G30HDR are all 401 based boards (although these boards have 384K or 512K flash).

These all have internal flash filesystems (like the pyboard) just a bit smaller.

You can compile python source code into the firmware image using FROZEN modules. With PR #1811: https://github.com/micropython/micropython/pull/1811 you can have frozen bytecode as well.

I'd like to be able to build stmhal with no USB and no internal filesystem so we can target some of the smaller processors, but that still needs some work.

User avatar
jgriessen
Posts: 103
Joined: Mon Sep 29, 2014 4:20 pm
Contact:

Re: compiling for small RAM/ROM platforms

Post by jgriessen » Thu Mar 10, 2016 5:46 pm

I'd like to be able to build stmhal with no USB and no internal filesystem
What is a good way to load flash in those cases? SWD port?

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

Re: compiling for small RAM/ROM platforms

Post by dhylands » Thu Mar 10, 2016 8:22 pm

Yes. With the nucleo board there is no USB connected to the processor, but it has onboard SWD. You can use also the SWD on the nucleo to program other STM porocessors.

The STM32 also has onboard bootloaders that allow programming over serial, i2c, can, and spi (varies a bit depending on the MCU) in addition to the DFU mode over USB.

I've successfuly programmed a 405 using the serial bootloader:
http://blog.davehylands.com/2014/02/ser ... m32f4.html

The stm32's also have a builtin oscillator, so you can reduce parts on a custom board by not using an external oscillator, but this means yoiu need to give up USB.

Once the firmware is flashed, I use rshell to copy files into and out of the internal file system on the nucleo board.

ajie_dirgantara
Posts: 73
Joined: Fri Sep 02, 2016 9:26 am

Re: compiling for small RAM/ROM platforms

Post by ajie_dirgantara » Wed Oct 11, 2017 3:42 am

Another thing to consider is to remove unused python compile-able modules in /modules.

Post Reply