STM32 F4 Discovery ...

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.
User avatar
dhylands
Posts: 2097
Joined: Mon Jan 06, 2014 6:08 pm
Location: Shuswap, BC, Canada
Contact:

Re: STM32 F4 Discovery ...

Postby dhylands » Tue May 10, 2016 12:36 am

I'm not sure what the Windows program is capable of handling (so maybe it deals with .hex files where the command line st-flash doesn't).

I tried a .hex file with the st-flash command line tool and it filled my flash with the literal contents of the .hex.

Code: Select all

538> st-flash write firmware.hex 0x08000000
...output omitted...
539 >st-flash read foo-hex.bin 0x08000000 0x100
...output omitted...
540 >od -t x1z foo-hex.bin
0000000 3a 30 32 30 30 30 30 30 34 30 38 30 30 46 32 0d  >:020000040800F2.<
0000020 0a 3a 31 30 30 30 30 30 30 30 30 30 30 30 30 32  >.:10000000000002<
0000040 32 30 33 44 38 41 30 34 30 38 39 31 30 41 30 34  >203D8A0408910A04<
0000060 30 38                                            >08<
versus:

Code: Select all

542 >st-flash write firmware.bin 0x08000000
...output omitted...
542 >st-flash read foo-bin.bin 0x08000000 32
...output omitted...
543 >od -t x1z foo-bin.bin
0000000 00 00 02 20 3d 8a 04 08 91 0a 04 08 81 0a 04 08  >... =...........<
0000020 95 0a 04 08 a5 0a 04 08 b5 0a 04 08 00 00 00 00  >................<
0000040 00 00 00 00 00 00 00 00 00 00 00 00 c5 0a 04 08  >................<
0000060 c7 0a                                            >..<


If you saw the red and green LED come on for a short time and then go out after flashing, then that probably means that everything was flashed properly.

The VID:PID od f055:9800 is common for all of the stmhal variants of MicroPython, regardless of the board.

I know that accessing USB ports from within a VM can be tricky.

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

Re: STM32 F4 Discovery ...

Postby dhylands » Tue May 10, 2016 12:38 am

Is this a native linux machine? Or a linux VM?

SpotlightKid
Posts: 131
Joined: Wed Apr 08, 2015 5:19 am

Re: STM32 F4 Discovery ...

Postby SpotlightKid » Tue May 10, 2016 1:07 am

Just a question to be sure (without re-reading the whole thread): you do have your board connected from the bottom USB-OTG connector (CN5, micro-USB socket) to your computer? The top USB connector (mini-USB socket) is just for programming and power, the USB serial connection works only with the USB-OTG connector.

Rando
Posts: 19
Joined: Thu Apr 28, 2016 1:00 pm

Re: STM32 F4 Discovery ...

Postby Rando » Tue May 10, 2016 1:56 am

I'm working on a native linux machine, Ubuntu 15.04. Just a spare machine, from several years ago, numerous issues, but good enough for most tasks, and until I get time to rebuild my serious machine. I wasn't nearly clear about that at the onset of describing my problem, sorry for the confusion.

And, yes, I am plugged into the bottom micro-USB, OTG connector, the top usb port is for the hardware st-link.

Rando
Posts: 19
Joined: Thu Apr 28, 2016 1:00 pm

Re: STM32 F4 Discovery ...

Postby Rando » Tue May 10, 2016 2:08 am

OK, I guess this gray hair is good for something. Suspecting a hw issue, I unplugged the bottom usb cable from the hub in the front of my PC, ponderously walked around my desk cable in hand, and plugged into the lone free USB port on my somewhat obsolescent mother board. Wham!

The PYBFLASH hard drive instance came up, and here's the report from lsusb ...

Code: Select all

rasyoung@vic2016:~/Desktop/MicroPython ESP8266/Official micropython master GITHUB 28 APR 2106/micropython-master/stmhal$ lsusb
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 021: ID 13fd:1040 Initio Corporation
Bus 002 Device 003: ID 0bda:0181 Realtek Semiconductor Corp.
Bus 002 Device 002: ID 058f:6254 Alcor Micro Corp. USB Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 024: ID 148f:2573 Ralink Technology, Corp. RT2501/RT2573 Wireless Adapter
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 003: ID 0461:4d0f Primax Electronics, Ltd HP Optical Mouse
Bus 004 Device 004: ID f055:9800 
Bus 004 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 033: ID 0483:374b STMicroelectronics
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub


Bus 004 Device 004: ID f055:9800 is evident.

I'm not seeing the serial port yet, am I missing a simple step?
Last edited by Rando on Tue May 10, 2016 3:00 am, edited 1 time in total.

Rando
Posts: 19
Joined: Thu Apr 28, 2016 1:00 pm

Re: STM32 F4 Discovery ...

Postby Rando » Tue May 10, 2016 2:25 am

Final step ... hurrah!

applied the clear instructions here for an appropriate udev rule:

http://wiki.micropython.org/Installation

"copy the following text to /etc/udev/rules.d/49-micropython.rules"

f055:9800 - MicroPython board
ATTRS{idVendor}=="f055", ATTRS{idProduct}=="9800", ENV{ID_MM_DEVICE_IGNORE}="1"
ATTRS{idVendor}=="f055", ATTRS{idProduct}=="9800", ENV{MTP_NO_PROBE}="1"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="f055", ATTRS{idProduct}=="9800", MODE:="0666"
KERNEL=="ttyACM*", ATTRS{idVendor}=="f055", ATTRS{idProduct}=="9800", MODE:="0666"


sudo udevadm control --reload-rules

search for the new serial port, and fire up a terminal session when I know where...

Code: Select all

dmesg | grep tty
[821851.742905] cdc_acm 4-2:1.1: ttyACM4: USB ACM device


screen /dev/ttyACM4

MicroPython v1.7 on 2016-05-09; F4DISC with STM32F407
Type "help()" for more information.
>>>


This is an awesome system, thanks for your help and hard work in support! Let's hope fortune smiles on reading the accelerometer. This might be a good interim strategy for educators that want to work with the best language for coding the Micro:Bit, that is MicroPython. I will share the links to my hardware setup tomorrow.

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

Re: STM32 F4 Discovery ...

Postby dhylands » Tue May 10, 2016 4:28 am

If you're running under linux, you may wish to try one or both of these:

https://github.com/dhylands/usb-ser-mon - this is a serial terminal emulator and you can provide filters to find the correct serial port.
For example: usb-ser-mon.py -n MicroPython will connect to a MicroPython board, and it automatically closes and reopens the serial port if it goes away (say because the pyboard was rebooted).

There is also rshell: https://github.com/dhylands/rshell

Rando
Posts: 19
Joined: Thu Apr 28, 2016 1:00 pm

Re: STM32 F4 Discovery ...

Postby Rando » Tue May 10, 2016 3:05 pm

Thanks for the reference to rshell, looks like a great facility. Usb-ser-mon works perfectly my install.

Code: Select all

rasyoung@vic2016:~/Reserve/ARM/uPy/usb-ser-mon-master$ python usb-ser-mon.py

USB Serial device with vendor 'STMicroelectronics' serial '0670FF565349896767105251' connected @/dev/ttyACM3
Use Control-X to exit.

As I investigate further, there are postings with issues on the MicroPython forum, on both the accelerometer, and I2C communications, and they may be related I'm wondering? They may apply to the old version of the STM32F407 discovery board, or the new, both, or possibly neither - have to test myself to confirm.
___
Here's the links I used to locate my hw, for the latest STM32F407 discovery (STM32F407G-DISC1) the current upgrade, that supports mass storage drag and drop programming. There may be some subtle differences between the old tested version, and the new.

http://www.mouser.com/ProductDetail/STM ... gqeMpN8%3d

and for a generic carrier board ...

http://www.mouser.com/ProductDetail/Mik ... yb8Q%3d%3d

There are literally hundreds of Click boards, and I thought it might serve as a good test/dev bed to evaluate uPy and/with a diverse spectrum of peripheral devices.

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

Re: STM32 F4 Discovery ...

Postby jgriessen » Sun Jun 26, 2016 4:05 pm

Is there a good reference on porting to new platforms? I am wanting to use the STM32F401 on a custom board similar to the nucleo-F401RE right away, and later the STM32F030 with just 32k 256k of memory.

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

Re: STM32 F4 Discovery ...

Postby jgriessen » Sun Jun 26, 2016 6:42 pm

rshell and usb-ser-mon.py both seem to be able to flash a new binary. Is rshell the latest-greatest, or is usb-ser-mon.py
still useful for boards with a filesystem where you don't need to reflash to update and run new code?


Return to “Other Boards”

Who is online

Users browsing this forum: No registered users and 4 guests