STM32F429 Discovery with Micropython

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
donikuy
Posts: 14
Joined: Fri Feb 09, 2018 10:43 am

STM32F429 Discovery with Micropython

Post by donikuy » Fri Feb 09, 2018 11:00 am

Hi,

I am trying to get started with Micropython and would like to be able to load the image on a STM32F429 Discovery board.
I tried downloading the files provided on https://micropython.org/download which seems to run fine.
Even after the download the STM32F4 mini usb appears as STMicroelectronics STLink dongle and the micro USB does not appear at all, which I guess is because there is no code written for them. But how can I access the python files?

Thank you.

donikuy

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

Re: STM32F429 Discovery with Micropython

Post by dhylands » Fri Feb 09, 2018 9:14 pm

If you add a jumper from PA9 to 5V then you can use the micro-USB to both power the board and program and get the REPL.

Here's what I did (on my linux host machine):
1 - Add jumper from PA9 to 5V
2 - Add jumper from BOOT0 to VDD (these 2 pins are right next to each other) - I borrowed one of the spare jumpers on the back of the board.
3 - I powered up the board, and run dfu-util -l which showed the board:

Code: Select all

652 >dfu-util -l
dfu-util 0.8

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2014 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, alt=3, name="@Device Feature/0xFFFF0000/01*004 e", serial="395A30563133"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, alt=2, name="@OTP Memory /0x1FFF7800/01*512 e,01*016 e", serial="395A30563133"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, alt=1, name="@Option Bytes  /0x1FFFC000/01*016 e", serial="395A30563133"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, alt=0, name="@Internal Flash  /0x08000000/04*016Kg,01*064Kg,07*128Kg", serial="395A30563133"
4 - I downloaded http://micropython.org/resources/firmwa ... 6-v1.9.dfu
5 - I programmed the image using:

Code: Select all

dfu-util -a 0 -d 0483:df11 -D stm32f4disc-20170526-v1.9.dfu
6 - I removed the jumper between BOOT0 and VDD and pressed RESET
7 - I observed that each of the 4 LEDs was flashing in sequence. It seems that the image includes a main.py which does that.
8 - I connected a serial terminal to /dev/ttyACM0 and pressed Control-C to interrupt main.py and got a python prompt:

Code: Select all

Traceback (most recent call last):
  File "main.py", line 7, in <module>
KeyboardInterrupt: 
MicroPython v1.9 on 2017-05-26; F4DISC with STM32F407
Type "help()" for more information.
>>> 
If you want to remove the main.py and just get to the REPL, then you can do:

Code: Select all

>>> import os
>>> os.remove('/flash/main.py')
>>> 
Now when you press RESET it will go right into the prompt without having to use Control-C

donikuy
Posts: 14
Joined: Fri Feb 09, 2018 10:43 am

Re: STM32F429 Discovery with Micropython

Post by donikuy » Mon Feb 12, 2018 8:59 am

Hi,

Thank you very much for your reply. I appreciate your help.

I have shorted PA9 to 5V and have shorted BOOT0 to VDD next to it.
After having done this I power cycled (also used the reset button), but the STM32F429 Discovery board shows under Universal Serial Bus Devices as "STMicroelectronics STLink dongle", so I cannot use the DFU Mode.

Would you please be able to assist me at to why I get this issue?

If I were able to get the board into DFU Mode, then I can easily download the stm32f4disc-20170526-v1.9.dfu onto the device.

Kind Regards,
Ylber Doniku

donikuy
Posts: 14
Joined: Fri Feb 09, 2018 10:43 am

Re: STM32F429 Discovery with Micropython

Post by donikuy » Mon Feb 12, 2018 11:32 am

Hi,

Sorry I have managed to enter DFU mode by:
Shorting PB2 to 0V, shorting BOOT0 to VDD, hacked a USB cable and connected 5V, 0V DP and DM (PA11 and PA12).

Then I used DFuSeDemo and flashed stm32f4disc-20170526-v1.9.dfu .

Now I am struggling to access the USB files so I can start development.

I tried to remove PB2 - 0V and BOOT0 - VDD jumpers, but not success.

Thank you very much.

Kind Regards,
donikuy

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

Re: STM32F429 Discovery with Micropython

Post by dhylands » Mon Feb 12, 2018 7:26 pm

I see you're using the STM32F429 Discovery. I missed that in my original reply (sorry about that). The image from the downloads page is for the STM32F407 Discovery.

The 429 uses the high-speed USB, and the 407 uses the full-speed USB. Unfortunately, DFU is not available on the high-speed USB connector.

You'll need to build a custom image and flash it using the stlink utilities. See this page: https://github.com/micropython/micropyt ... -STM32F429 for more details about that particular board.

I was able to build and flash my STM32F429Discovery using the command:

Code: Select all

make BOARD=STM32F429DISC deploy-stlink
You can then plug a USB cable into CN6 - USB USER (the micro-USB connector closest to the LCD) and get the REPL.

donikuy
Posts: 14
Joined: Fri Feb 09, 2018 10:43 am

Re: STM32F429 Discovery with Micropython

Post by donikuy » Tue Feb 13, 2018 8:27 am

Thank you.
With the hack as described on the previous comment I have managed to upload the stm32f4disc-20170526-v1.9.dfu file but that did not work.
I then tried the stm32f4disc-20170108-v1.8.7.dfu and that has worked well, now I can see my PYFLASH and can start writing code.
Would you please be able to tell me what is the difference between these two and why the later version does not work?

Kind Regards,
donikuy

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

Re: STM32F429 Discovery with Micropython

Post by dhylands » Tue Feb 13, 2018 10:12 pm

I'm surprised either version works on the 429. If it works, its by accident and not by design since its designed for the 407 board.

The 429 boards has the LEDs connected to different pins, has the USB connected differently, etc.

Post Reply