stm32l4 port and cmake

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
stiege
Posts: 10
Joined: Sat Feb 04, 2017 6:22 am

stm32l4 port and cmake

Postby stiege » Sat Feb 04, 2017 7:38 am

Hi all,

Have just started using micropython and very keen to work on a port for the STM32Lxxx series (the low power range for ST). Any ideas about why this would be a bad idea or things to watch out for?

I created a cmake build of the pyboard v11 at https://github.com/stiege/cmake_micropython ; it still uses the makefiles for the code generation parts that relate to the pyboard.

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

Re: stm32l4 port and cmake

Postby dhylands » Sat Feb 04, 2017 6:47 pm

There is a board definition file for the STM32L476 already in the repository.

The L series have different sized flash blocks. Most of the differences are abstracted by the HAL.

stiege
Posts: 10
Joined: Sat Feb 04, 2017 6:22 am

Re: stm32l4 port and cmake

Postby stiege » Sun Feb 05, 2017 7:43 am

Oops!

Thanks for pointing that out!

shaoziyang
Posts: 121
Joined: Sun Apr 17, 2016 1:55 pm

Re: stm32l4 port and cmake

Postby shaoziyang » Sun Feb 05, 2017 8:54 am

stiege wrote:Hi all,

Have just started using micropython and very keen to work on a port for the STM32Lxxx series (the low power range for ST). Any ideas about why this would be a bad idea or things to watch out for?

I created a cmake build of the pyboard v11 at https://github.com/stiege/cmake_micropython ; it still uses the makefiles for the code generation parts that relate to the pyboard.


I have port micropython to ST's SensorTile kit, it using STM32L476JG mcu.

stiege
Posts: 10
Joined: Sat Feb 04, 2017 6:22 am

Re: stm32l4 port and cmake

Postby stiege » Tue Feb 07, 2017 11:44 pm

Hi @shaoziyang,

I just tried uploading a port to the STM32L476 discovery board that I ordered and it almost seems to work - unfortunately Windows is having a problem with the USB device (Invalid Device Desciptor, Code 43). I can't see immediately why this would have any problems while the pyboard works fine. Your SensorTile port isn't yet in the master branch from what I can see?

stiege
Posts: 10
Joined: Sat Feb 04, 2017 6:22 am

Re: stm32l4 port and cmake

Postby stiege » Tue Feb 07, 2017 11:53 pm

I think my issue may be:

In order to connect the OTG_FS_VBUS and OTG_FS_ID signals from the connector CN7 to
the OTG FS hardware IP of STM32L476VGT6, remove the LCD from its socket U5, and
close SB24 and SB25.

Unsure though.

I managed to connect via the ST link USB instead. I get a serial port with a REPL at least but no file system access. Also a bit of work for me to do on the port I think...

MicroPython v1.8.7 on 2017-02-08; L476-DISCO with STM32L476
Type "help()" for more information.
>>> dir()
[
FATAL ERROR:
HardFault


Any attempt at tab completion results in the same.

_______

My issue was not erasing on first flash to force the initialisation of the file system.

https://github.com/micropython/micropython/issues/2852

shaoziyang
Posts: 121
Joined: Sun Apr 17, 2016 1:55 pm

Re: stm32l4 port and cmake

Postby shaoziyang » Wed Feb 08, 2017 6:21 am

stiege wrote:Hi @shaoziyang,

I just tried uploading a port to the STM32L476 discovery board that I ordered and it almost seems to work - unfortunately Windows is having a problem with the USB device (Invalid Device Desciptor, Code 43). I can't see immediately why this would have any problems while the pyboard works fine. Your SensorTile port isn't yet in the master branch from what I can see?


You may find my SensorTile kit port at:
https://github.com/shaoziyang/MicroPython_firmware/tree/master/SensorTile

It work fine, and I am working on the sensor in the board now, it almost finished.

stiege
Posts: 10
Joined: Sat Feb 04, 2017 6:22 am

Re: stm32l4 port and cmake

Postby stiege » Thu Feb 09, 2017 10:22 pm

Thanks for that.

I still have some problems with the stm32l4 port.

If I use `dfu-util -a 0 -s :mass-erase:force -D firmware.dfu` then I no longer get the dir() hard fault. I can also see that on first boot the LEDs stay on for longer (presumably initialising the file system). Unfortunately though Windows still has problems recognising the filesystem.

If I use the STM32 ST-LINK utility and perform the erase/program this way then there's no problem.

Any ideas on what's going wrong with my dfu-util command?

______

I suspect maybe the mass erase is not working on the MCU, modifying the firmware.dfu objcopy makefile instructions to include "--gap-fill 0xFF --pad-to 0x8004000" (bin0) and "--gap-fill 0xFF --pad-to 0x8100000" (bin1) fixed the issue - albeit takes a lot longer to program now.

shaoziyang
Posts: 121
Joined: Sun Apr 17, 2016 1:55 pm

Re: stm32l4 port and cmake

Postby shaoziyang » Fri Feb 10, 2017 4:26 am

stiege wrote:Thanks for that.

I still have some problems with the stm32l4 port.

If I use `dfu-util -a 0 -s :mass-erase:force -D firmware.dfu` then I no longer get the dir() hard fault. I can also see that on first boot the LEDs stay on for longer (presumably initialising the file system). Unfortunately though Windows still has problems recognising the filesystem.

If I use the STM32 ST-LINK utility and perform the erase/program this way then there's no problem.

Any ideas on what's going wrong with my dfu-util command?

______

I suspect maybe the mass erase is not working on the MCU, modifying the firmware.dfu objcopy makefile instructions to include "--gap-fill 0xFF --pad-to 0x8004000" (bin0) and "--gap-fill 0xFF --pad-to 0x8100000" (bin1) fixed the issue - albeit takes a lot longer to program now.


dfu-util has bug on STML4 mcu, so you can only using STM32 ST-LINK utility now.

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

Re: stm32l4 port and cmake

Postby dhylands » Fri Feb 10, 2017 6:52 am

Does pydfu.py work any better? (found in the micropython/tools directory)


Return to “Development of MicroPython”

Who is online

Users browsing this forum: No registered users and 1 guest