Q: Nucleo F401 with UART bootloader

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
jgriessen
Posts: 191
Joined: Mon Sep 29, 2014 4:20 pm
Contact:

Re: Q: Nucleo F401 with UART bootloader

Post by jgriessen » Sun Jun 26, 2016 4:21 pm

I found a blog about booting and compiling by cnoviello and his fork cnoviello/micropython which probably
was pulled into micropython/micropython in august 2015. Is there a good reference for loading micropython to Nucleo-F401RE,
or do I need to find it in forum posts?
John Griessen blog.kitmatic.com

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

Re: Q: Nucleo F401 with UART bootloader

Post by dhylands » Sun Jun 26, 2016 10:54 pm

I use the included stlink programmer to load code.

You can build using:

Code: Select all

make BOARD=NUCLEO_F401RE
and program using:

Code: Select all

make BOARD=NUCLEO_F401RE deploy-stlink
You should then get a UART REPL using the USB cable (/dev/ttyACM0 for me). The filesystem that you see is from the stlink processor and not the '401. You'll need to use something like rshell to copy files into the filesystem on the '401.

Code: Select all

MicroPython v1.8.1-90-gab8a5d5-dirty on 2016-06-26; NUCLEO-F401RE with STM32F401xE
Type "help()" for more information.
>>> 

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

Re: Q: Nucleo F401 with UART bootloader

Post by jgriessen » Mon Jun 27, 2016 11:19 pm

You'll need to use something like rshell to copy files into the filesystem on the '401.
I tried installing rshell and not sure it's working right. First it could not connect as user john, since the /dev/ttyACM0
did not have permissions for it: crw-rw---- 1 root dialout 166, 0 Jun 27 18:04 /dev/ttyACM0
It runs fine as root, and when I do
ls -l /flash shows wrong thing relative to /root,
so I change perms:
sudo chown john /dev/ttyACM0

and it runs as you say.

What to do about permissions of /dev/ttyACM0 that pops in and out of existence? Does this need udev rules?

Thanks, John
John Griessen blog.kitmatic.com

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

Re: Q: Nucleo F401 with UART bootloader

Post by jgriessen » Mon Jun 27, 2016 11:48 pm

I'm close, but not quite there yet:

john@ecolab3 [stmhal]make BOARD=NUCLEO_F401RE deploy-stlink
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
Writing build-NUCLEO_F401RE/firmware0.bin to the board via ST-LINK
make: st-flash: Command not found
Makefile:316: recipe for target 'deploy-stlink' failed
make: *** [deploy-stlink] Error 127

make: st-flash: Command not found --> Now how would I fix that? Hmmm?
https://github.com/texane/stlink looks like it, and there is a mention of udev rules even :-)
John Griessen blog.kitmatic.com

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

Re: Q: Nucleo F401 with UART bootloader

Post by dhylands » Tue Jun 28, 2016 2:13 am

Ahh right.

You need to install the st-flash utility.

https://startingelectronics.org/tutoria ... -in-Linux/

In order to build the stlink stuff I had to do:

Code: Select all

sudo apt-get install automake
cd stlink.git
./autogen.sh
./configure
make

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

Re: Q: Nucleo F401 with UART bootloader

Post by jgriessen » Wed Jun 29, 2016 2:04 am

I've hit a wall finding out how to compile stlink from https://github.com/texane/stlink.

The environment variables LIBUSB_LIBRARY= and LIBUSB_INCLUDE_DIR="/usr/include"
are not intuitive and changing them seems to have no effect on error message output, so debugging
grinds to a halt.

in my debian jessie installation,

there is:
/usr/local/src/stlink/include/stlink/usb.h
and there is debian package installed:
ii libusb-0.1-4:amd64 2:0.1.12-25 amd64 userspace USB programming library
ii libusb-1.0-0:amd64 2:1.0.19-1 amd64 userspace USB programming library
ii libusb-dev 2:0.1.12-25 amd64 userspace USB programming library development files

and the system is aware of:
john@ecolab3 [stlink]locate usb.h
/home/john/micropython/stmhal/usb.h
/home/john/micropython/stmhal/hal/f2/inc/stm32f2xx_ll_usb.h
/home/john/micropython/stmhal/hal/f4/inc/stm32f4xx_ll_usb.h
/home/john/micropython/stmhal/hal/f7/inc/stm32f7xx_ll_usb.h
/home/john/micropython/stmhal/hal/l4/inc/stm32l4xx_ll_usb.h
/home/john/micropython/teensy/usb.h


Any help compiling stlink appreciated.

JG
John Griessen blog.kitmatic.com

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

Re: Q: Nucleo F401 with UART bootloader

Post by dhylands » Wed Jun 29, 2016 4:30 am

Did you install libusb-dev ?

It may also be called libusb-1.0-0-dev

I usually figure out the correct name by doing something like:

Code: Select all

apt-cache search libusb | grep libusb | grep dev
I've never had to touch LIBUSB_LIBRARY (or anything else in the Makefile). If I get a build error, it almost always means that I'm missing some dependency.

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

Re: Q: Nucleo F401 with UART bootloader

Post by jgriessen » Wed Jun 29, 2016 1:46 pm

I had libusb-dev, but not libusb-1.0-0-dev as shown by the apt-cache search.
Will do that. That did it.
Now getting gtk3 installed.
Thanks, JG
John Griessen blog.kitmatic.com

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

Re: Q: Nucleo F401 with UART bootloader

Post by jgriessen » Fri Jul 01, 2016 4:10 am

I am able to rshell to my pyboard, but don't have the right settings for the nucleo-F401RE.

The serial port changed from /dev/ttyACM0 to /dev/ttyACM2 somehow.

rshell gives a message: No MicroPython boards connected - use the connect command to add one

Oh wait --- the prompt changed.
/home/john/micropython/stmhal>
It's not a remote machine though, just the current dir I ran the command in.

I figured it out:
john@ecolab3 [stmhal]export RSHELL_PORT=/dev/ttyACM2
john@ecolab3 [stmhal]rshell
Connecting to /dev/ttyACM2 ...
Welcome to rshell. Use Control-D to exit.
/home/john/micropython/stmhal> ls -l /flash
528 Jan 1 2015 README.txt
302 Jan 1 2015 boot.py
34 Jan 1 2015 main.py
2721 Jan 1 2015 pybcdc.inf
/home/john/micropython/stmhal>
John Griessen blog.kitmatic.com

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

Re: Q: Nucleo F401 with UART bootloader

Post by dhylands » Fri Jul 01, 2016 7:43 am

rshell only auto detects boards with a USB repl, so you'll need to use the connect serial command.

With the nucleo boards you're using a uart repl and the stink board is acting like a usb-to-serial adapter.

I also found that I had to drop the buffer size with rshell down to about 32 in order to transfer files. (Use --buffer-size=32 on the rshell command line).

Post Reply