# Flash STM32 code to Rpi Installation written by 周文荏 contact: justinimbus.c@nycu.edu.tw --- ### Installation Requirements ``` $ sudo apt-get install gcc build-essential cmake libusb-1.0 libusb-1.0-0-dev ``` optional: ``` $ sudo apt-get install libgtk-3-dev pandoc ``` --- ### Installation #### 1. Create shell script named "stlink_flash.sh" ```bash= #!/bin/bash # Create a directory and navigate to it mkdir STM32_tools cd STM32_tools # Clone the git repository git clone https://github.com/stlink-org/stlink.git # Navigate to the stlink directory cd stlink # Clean and build stlink make clean make release sudo make install sudo ldconfig # Navigate back to the main directory cd ../../ # Remove the created directory rm -rf STM32_tools ``` #### 2. Add execution permission to script file ```typescript $ chmod +x stlink_setup.sh ``` #### 3. Execute script file ``` $ sudo ./stlink_setup.sh ``` #### 4. Validate Installation ``` $ st-flash ``` Successful Installation output: ``` invalid command line command line: ./st-flash [--debug] [--reset] [--connect-under-reset] [--hot-plug] [--opt] [--serial <serial>] [--format <format>] [--flash=<fsize>] [--freq=<kHz>] [--area=<area>] {read|write} [path] [addr] [size] command line: ./st-flash [--debug] [--connect-under-reset] [--hot-plug] [--freq=<kHz>] [--serial <serial>] erase [addr] [size] command line: ./st-flash [--debug] [--freq=<kHz>] [--serial <serial>] reset ...... ``` Failed Installation output: ``` bash: /usr/local/bin/st-flash: No such file or directory ``` --- ### Usage ``` $ mkdir ~/stm32_ws $ cd ~/stm32_ws ``` #### 1. Create a file named "Makefile" ```cmake # in Makefile flash: st-flash --reset write SAUVC2022.bin 0x08000000 reset: st-flash reset ``` #### 2. Copy binary(.bin) file to Rpi - run in local (in root of STM32 workspace) - change the IP below to Rpi IP (check with ifconfig) ``` $ scp build/SAUVC2022.bin pi@192.168.0.124:~/stm32_ws ``` #### 3. Flash to STM32 ``` $ make flash ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up