[STM32F427] Beginner interested in porting to F427

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
plunk
Posts: 11
Joined: Thu Oct 05, 2017 1:54 pm

[STM32F427] Beginner interested in porting to F427

Post by plunk » Tue Oct 10, 2017 7:11 pm

Hello,

I have a STM32F427 that I would like to get micropython running on. I am not sure how exactly to go about this - my idea is to take all of the files marked as *F429 in the /ports/stm32/boards/ directory and use those as a template, along with the datasheet for the F427, to add new files that would hopefully just work when I try to build it.

The files I've found (in /master/ports/stm32/boards/) are:

STM32F429_af.csv -> STM32F427_af.csv
STM32F429.ld -> STM32F427.ld
STM32F429DISC/mpconfigboard.h -> STM32F427/mpconfigboard.h
STM32F429DISC/mpconfigboard.mk -> STM32F427/mpconfigboard.mk
STM32F429DISC/pins.csv -> STM32F427/pins.csv

Should this work, or is porting to the F427 more complicated than that? Also, does anybody know of any existing work done to port to the F427 that I am not aware of?

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

Re: [STM32F427] Beginner interested in porting to F427

Post by dhylands » Tue Oct 10, 2017 7:22 pm

I'd check the _af.csv files. Its quite possible that you'll be able to use the same file for both MCUs.

It's also highly unlikely that you'll need a different .ld file.

Note that STM32F427 would be a poor choice for a board name. You really want a particular board, and not the generic MCU. The pins.csv is intended to be very board specific.

I know of a few '427 boards that I'd eventually like to add support for.

plunk
Posts: 11
Joined: Thu Oct 05, 2017 1:54 pm

Re: [STM32F427] Beginner interested in porting to F427

Post by plunk » Tue Oct 10, 2017 9:36 pm

Thanks for responding. This would actually be for a non-commercial, custom board. Does that make a difference in what would need to be altered from the F429 Discovery files?

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

Re: [STM32F427] Beginner interested in porting to F427

Post by dhylands » Wed Oct 11, 2017 12:34 am

Not really. I've done a bunch of board definitions for various board which you can fine over here:
https://github.com/dhylands/wiki/wiki/M ... oard-files
Your pins.csv file will be entirely dependent on your custom board. The BIOLOID_POWER board is a example of a custom board that I did. It was based on the STM32F401

The biggest thing to get right will be the crystal frequency in the stm32f4xx_hal_conf.h file.
This will be HSE_VALUE and the corresponding MICROPY_HW_CLK_PLLM, MICROPY_HW_CLK_PLLN, MICROPY_HW_CLK_PLLP and MICROPY_HW_CLK_PLLQ values from mpconfigboard.h

I normally find another board with the same MCU that has the same HSE_VALUE and use that as my starting point. For a different MCU, I'd recommend checking the data sheet and seeing if the formulas for the M, N, P, and Q values are the same. If so you can steal value from a different MCU, or calculate them using the formulas in the datasheet.

Most of the remaining differences will be pin mappings and which peripherals are enabled.

chrismas9
Posts: 152
Joined: Wed Jun 25, 2014 10:07 am

Re: [STM32F427] Beginner interested in porting to F427

Post by chrismas9 » Sun Oct 15, 2017 12:44 am

I use the STM32cube software to setup the clocks. It has a GUI editor that lets you change all the clock sources, multiplexers, multipliers and dividers and see the affect on the core, USB and peripheral clocks.

plunk
Posts: 11
Joined: Thu Oct 05, 2017 1:54 pm

Re: [STM32F427] Beginner interested in porting to F427

Post by plunk » Mon Oct 23, 2017 6:18 pm

So I've got micropython successfully running on the custom F427 board using the unmodified F429DISC build. I have access to the REPL and the board shows up as a flash drive in Windows where I can edit main.py. However I cannot toggle the LEDs on the custom board like I am able to on the discovery board, and I cannot find which file(s) I should edit to make this work. The pins.csv file for the discovery board just looks to be a mapping of each Port/Pin to itself (e.g. PD8, PD8 ; PD9, PD9 ; etc.) so I don't see why that would be any different for the F427.

The example script I'm using:

Code: Select all

import machine
led = machine.Pin("PG13")
led.high()
The custom board has leds on pins PC0, PC1, and PC2, but they do not light when using them as I use PG13 on the discovery board.

User avatar
benalb
Posts: 25
Joined: Fri May 19, 2017 1:23 pm

Re: [STM32F427] Beginner interested in porting to F427

Post by benalb » Tue Oct 24, 2017 6:54 am

plunk wrote:
Mon Oct 23, 2017 6:18 pm

The example script I'm using:

Code: Select all

import machine
led = machine.Pin("PG13")
led.high()
I think is led.on()

plunk
Posts: 11
Joined: Thu Oct 05, 2017 1:54 pm

Re: [STM32F427] Beginner interested in porting to F427

Post by plunk » Thu Oct 26, 2017 2:53 pm

I got the LED issues to work (in part by changing the LED values in mpconfig.mk, and in part by realizing that the board's LEDs are active low and thus need to call off() to turn on).

Now I am trying to get the board's UART to work. I tried replacing the pin values in mpconfig.mk from those used by the F429-Discovery to the pins used on my F427, and now when calling pyb.UART(1, 9600, timeout=0) I receive the error message "ValueError: UART(1) doesn't exist". Any ideas how to fix this?

Post Reply