Posts: 18
Joined: Mon May 27, 2013 9:45 am

How to program the Embedded Pi with Raspberry Pi

Thu Jul 11, 2013 1:51 am

Since the release of Embedded Pi there are complaints about not being able to use the Raspberry Pi itself to program the STM32 on Embedded Pi, as CoIDE is currently Windows specific. We value feedback of every customer and had been searching for a solution for this. Good news is that now this issue is addressed by using an open source ISP tool on the Raspberry Pi. This article introduces how to install and use the ISP tool on the Raspberry Pi.

First, download the ISP tool STM32Loader from This tool, original version by Ivan A-R , is written in Python script which will talk to the STM32 bootloader to upload and download firmware. It’s recommended of you to use Python 2.6 or 2.7, and the installation details won’t be described here.

Usage of STM32Loader:

./ [-hqVewvr] [-l length] [-p port] [-b baud] [-a addr] [file.bin]

-h This help

-q Quiet

-V Verbose

-e Erase

-w Write

-v Verify

-r Read

-l length Length of read

-p port Serial port (default: /dev/tty.usbserial-ftCYPMYJ)

-b baud Baud speed (default: 115200)

-a addr Target address

The Raspberry Pi can program the STM32 via the serial port (JP7-TX1 and JP7-RX1) when the Embedded Pi is in ISP mode, refer to section 3.6.1 in Embedded Pi User Manual.

To use this mode, you need to follow the steps below:

1、Set BOOT0 to 1 (high level), and BOOT1 to 0 (low level) – which has been done on hardware. In this case, you only need to press the BOOT0 button to enter this mode when Embedded Pi is powered on.
2、Connect the UART interface on Raspberry Pi to the UART1 interface on Embedded Pi with wires (connect Embedded Pi JP7-TX1 with Raspberry Pi P1-D10, JP7-RX1 with P1-D8), as shown in the figure below.
3、Open a Terminal session, 'cd' to wherever you downloaded the STM32Loader and then issue the following command to download bin file to the Embedded Pi

Code: Select all

sudo python -e -w -v Test.bin
An error prompt will appear if your Raspberry Pi has no PySerial library installed. Next part introduces the installation of the PySerial library.

Install PySerial
Whatever your operating system is, download the .tar.gz installation package for PySerial 2.6, i.e. pyserial-2.6.tar.gz, from
If you are using Windows system, you need to decompress the file into a folder. It is not a normal zip file, so you may need to use a tool such as 7-zip (
If you are using a Mac or Linux computer, then open a Terminal session, 'cd' to wherever you downloaded the pyserial-2.6.tar.gz and then issue the following command to unpack the installation folder

Code: Select all

$ tar -xzf pyserial-2.6.tar.gz
The rest of the procedure is the same whatever your operating system is. Use you Command Prompt / Terminal session and “cd” into the pyserial-2.6 folder, and then run the command:

Code: Select all

sudo python install
When the installation is finished, issue the following command to download bin file to the Embedded Pi

Code: Select all

sudo python -e -w -v Test.bin
This will pre-erase flash, program Test.bin to the flash on the device, and then perform verification after the programming is finished.
A prompt of “Verification OK” will appear after successful programming, as shown in the figure below:

Reset the STM32 and the LED on the Embedded Pi will blink.

If the program is not downloaded successfully, react according to the prompt appears in the Command Prompt / Terminal session:

If a prompt of “None” always appears, redo step 1 (press BOOT0 to reset the STM32).
If an error prompt like “NACK” appears, retry the download command.

Hope you all enjoy playing with the Embedded Pi. Please feel free to post a question or share your story with the Embedded Pi on our Embedded Pi Forum. Come join us to make the Pi better!

Posts: 5
Joined: Wed Dec 11, 2013 10:30 pm

Re: How to program the Embedded Pi with Raspberry Pi

Sun Dec 22, 2013 10:09 pm

Hi, I'm stuck.
I've read that link P9_0(rx) to tx1(P7) and P9_1(tx) to rx1(P7) should connect the rpi's spi to spi of stm32. so I use the 26pin cable and 2 wire to achieve the first point.

I've disabled the console logging on my pi, compile a test with MAPLE because I couln't do otherwise (gcc cross compiling was driving crazy).
But still return NONE NONE NONE.
(yes I pushed boot0 while reset 1s and vice versa to be sure)
1: should I load a SPI kernel module? lsmod helped me to see that nothing similar was loaded
2:my R and S jumper on: it's adaptor mode. Is it good?
3:what's the cause of error on this "gcc -mcpu=ANY -c truc.c -o truc.o" (with as errors -mcpu not found as ALL the gcc options options return no file)
4: could it be a ground problem between rpi and stm in spi connection? I notice I did't add wire for this but the card should share it.
edit: a test of SPI shortcircuited showed than it works. but I get no ACK from epi

Posts: 1
Joined: Fri Sep 19, 2014 4:05 pm

Re: How to program the Embedded Pi with Raspberry Pi

Fri Sep 19, 2014 4:09 pm

Having the same issue: I can't upload, I get "none" all the time.
No matter wether I press boot0 or boot0+reset, boot0 and let it go...
Any Ideas?

Posts: 4
Joined: Sat Oct 04, 2014 2:11 pm

Re: How to program the Embedded Pi with Raspberry Pi

Sat Oct 04, 2014 2:21 pm

You need to disable the serial Linux console on the Raspberry Pi, or else it will interfer with programming. More complete instructions (see Step 7):

Edit: Also, don't use There is a much more mature program called stm32flash. Or use JTAG. Here is my writeup about that:

Return to “HATs and other add-ons”