STM32F3 ports

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.
romeo
Posts: 23
Joined: Mon Jan 28, 2019 5:57 pm

Re: STM32F3 ports

Post by romeo » Fri Feb 08, 2019 8:35 pm

Hi,

Ok the error now is that the MCU is unsupported!
Got into the mpconfigboard_common.h and I saw that mine is not supported.

These variables are missing:

Code: Select all

MP_HAL_UNIQUE_ID_ADDRESS
PYB_EXTI_NUM_VECTORS
MICROPY_HW_MAX_TIMER
MICROPY_HW_MAX_UART
Any hints?

Thanks,
Romeo

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

Re: STM32F3 ports

Post by dhylands » Sat Feb 09, 2019 4:48 am

Those should all be available from the data sheet and/or reference manual.

romeo
Posts: 23
Joined: Mon Jan 28, 2019 5:57 pm

Re: STM32F3 ports

Post by romeo » Sat Feb 09, 2019 8:59 am

Hi!

I have updated the mpconfigboard_common.h with the data found in the reference manual.

Now I got stuck here:
20190209.PNG
20190209.PNG (23.05 KiB) Viewed 170 times
Thanks,
Romeo

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

Re: STM32F3 ports

Post by dhylands » Sat Feb 09, 2019 3:34 pm

The problem in main.c is that the code wants a way to interact with the user for doing the various resets.

MICROPY_HS_HAS_SWITCH is defined, however it seems that neither MICROPY_HW_LED2 nor MICROPY_HW_LED1 is defined.

Looking at the mpconfigboard.h file I see lots of LEDs defined. I'm assuming that you chose LED numbers that match what's on the board. The micropython code wants LED1 thru N. I'd probably create definitions for 1 and 2 which map onto 2 of the other LEDs.

The other problem appears to be a bug in the make-pins.py script. As a temporary workaround, you can comment out these 2 lines:
https://github.com/sfynxu/stm32f3discov ... ins.py#L20
https://github.com/sfynxu/stm32f3discov ... ins.py#L30

I'll see what needs to be changed so that make-pins.py works for the F3.

romeo
Posts: 23
Joined: Mon Jan 28, 2019 5:57 pm

Re: STM32F3 ports

Post by romeo » Sat Feb 09, 2019 4:05 pm

Hi,
Thank you. I came around with CAN by naming it CAN1 (since is the only one).
For LED I doubled the LED3 and named it LED2.
On the board LED1 and 2 are attached to ST-LINK programmer.

Now seems to be and error of dma, flash, ... and I stoped the script to get the screenshot.
I updated the repository also.
20190209_02.PNG
20190209_02.PNG (4.87 KiB) Viewed 159 times
Thanks,
Romeo

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

Re: STM32F3 ports

Post by dhylands » Sat Feb 09, 2019 4:24 pm

The following change will fix make-pins.py to work properly with the F3. Change the function condition_var (line 58) from this:

Code: Select all

def conditional_var(name_num):
    # Try the specific instance first. For example, if name_num is UART4_RX
    # then try UART4 first, and then try UART second.
    name, num = split_name_num(name_num)
    var = []
    if name in CONDITIONAL_VAR:
        var.append(CONDITIONAL_VAR[name].format(num=num))
    if name_num in CONDITIONAL_VAR:
        var.append(CONDITIONAL_VAR[name_num])
    return var
to this:

Code: Select all

def conditional_var(name_num):
    # Try the specific instance first. For example, if name_num is UART4_RX
    # then try UART4 first, and then try UART second.
    name, num = split_name_num(name_num)
    var = []
    if num is None:
        # Covers the case where name_num is CAN instead of CAN1
        if name in CONDITIONAL_VAR:
            var.append(CONDITIONAL_VAR[name].format(num=''))
    else:
        if name in CONDITIONAL_VAR:
            var.append(CONDITIONAL_VAR[name].format(num=num))
        if name_num in CONDITIONAL_VAR:
            var.append(CONDITIONAL_VAR[name_num])
    return var
The issue is that the F3 only has a single CAN peripheral, so the pins are named CAN_TX but the script was expecting CAN1_TX.

romeo
Posts: 23
Joined: Mon Jan 28, 2019 5:57 pm

Re: STM32F3 ports

Post by romeo » Sat Feb 09, 2019 4:38 pm

Ok. Applied patch. Returned to old _af csv (with CAN, not CAN1).
Updated repository.
Can't figure out if F3 has DMA_Stream or DMA_Channel ...

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

Re: STM32F3 ports

Post by dhylands » Sat Feb 09, 2019 4:44 pm

A quick grep in the HAL directory shows lots of references to DMA_Channel_TypeDef and none to DMA_StreamTypeDef

romeo
Posts: 23
Joined: Mon Jan 28, 2019 5:57 pm

Re: STM32F3 ports

Post by romeo » Sat Feb 09, 2019 4:50 pm

Ok. It seems legit.

I try this with the flash.c flashdev.c ... also

Thanks for the tip,
Romeo

romeo
Posts: 23
Joined: Mon Jan 28, 2019 5:57 pm

Re: STM32F3 ports

Post by romeo » Sun Feb 10, 2019 8:04 pm

Hi!
Just finished the dac and adc!
The only thing I cannot figure out where to set the cache and how big should be ...

The rest is updated on github.

Any suggestion for the cache?

Thanks,
Romeo

Post Reply