Step 6: Prepare your hardware; connect Raspberry Pi & Embedded Pi as below
- Setup the Embedded Pi in ST-Adapter mode - connect JP2, JP3 connection.
- Connect the Embedded Pi and Raspberry Pi using 26 pin ribbon cable.
- Connect Raspberry Pi and Embedded Pi UART communication port as shown in "Yellow Lines" below:
Step 7: STM32 loader ISP tool requires Raspberry Pi UART port, but the Raspberry Pi UART interface is by default occupied by Raspberry Pi OS to output kernel information. So we need to configure the Raspberry Pi UART0 before we can use it for STM32 loader ISP tool to download the program into Embedded Pi. Please follow the below steps to configure Raspberry Pi UART port:
Note: It's better to backup the /boot/cmdline.txt file before you edit, just in case if something goes wrong ( $sudo cp /boot/cmdline.txt /boot/cmdline_backup.txt)
Edit the file as below:
$
sudo vi /boot/cmdline.txt
The file contained the following:
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
Delete any parameters involving the serial port "
ttyAMA0", which in this example is:
console=ttyAMA0,115200 kgdboc=ttyAMA0,115200
Which gives:
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
Press ESC to return to the vi command mode and then type "
:wq" (without the quotation marks) to save and exit (even if it appears vi is still in editing mode just type the "
:wq" command). If you need to exit without saving type "
:q".
You also need to edit this file:
$
sudo vi /etc/inittab
Search
/ttyAMA0/ for the serial port usage by typing:
This should find the line of the file specifying the serial port (if there is one), move the cursor to the start of the line and press "i" to select insert and then press "#" to comment out the line. Now press ESC and enter ":wq" to save and exit.
Enter "sudo reboot" to restart the Raspberry Pi and now the UART will be available to use in another process.
Step 8: Download the "
led.bin" file into the Embedded Pi using STM32 loader ISP tool.
1. Copy the “
stm32loader.py” file from “
/home/pi/EmbeddedPi/tools” directory to “
/home/pi/LED_linky” project directory.
2. Setup the Embedded Pi STM32 in serial download mode - first press the Embedded Pi
BOOT0 key (HIGH) and without releasing press the
RESET button. After pressing
RESET button, release the
BOOT0 key.
3. Now use the below command to download the generated binary "
led.bin" file
(in Step 5) into the Embedded Pi flash memory:
pi@raspberrypi ~ / LED_Blinky $
sudo python stm32loader.py -e -w -v led.bin
Possible Outcomes:
a. If prompted with "NONE" on screen, please re-run the above Steps 8.2 [hold boot0, reset MCU].
b. If prompted with “NACK” on screen, please re-download the
.bin file (Step 8.3).
c. If prompted with “Verification OK” on screen, indicates a successful download.
a.Ifpromptedwith"NONE"onscreen,pleasere-runtheaboveSteps8.2[holdboot0,resetMCU].
b.Ifpromptedwith“NACK”onscreen,pleasere-downloadthe
.binfile(Step8.3).
c.Ifpromptedwith“VerificationOK”onscreen,indicatesasuccessfuldownload.
Now restart the Embedded Pi, the program should execute and LED will start blinking.
`