|
> TODO: document the USB way and the serial port way
|
|
So, you wrote your driver and then compiled it: now want to run it on a STM32 microcontroller. To do this, there are several ways, depending on your board's configuration.
|
|
|
|
|
|
So, you wrote your driver and then compiled it: now want to run it on a board.
|
|
## Method 1: USB
|
|
|
|
|
|
You can start using a STM32 Discovery board: these are very
|
|
If you are using a Discover board, you can directly plug your board to your PC with a USB cable. You will need some drivers that are available one the vendor's site. Once the PC has recognized tour board, you have two options.
|
|
versatile boards that you can easily use for test porpouses. Otherwise, if you have one,
|
|
|
|
you can directly flash it on one of Skyward's Tropper/Anakin boards.
|
|
|
|
|
|
|
|
### Requirements
|
|
### 1.1 Drag and Drop
|
|
You'll need a binary file (bin, elf...) that you have built for the right board
|
|
|
|
using SBS (see [here](./Skyward-Build-Systems-(SBS))).
|
|
|
|
|
|
|
|
Then obviously you'll need a board and a USB-to-MiniUSB cable that you'll have to plug
|
|
Some boards support drag and drop: simply select your .bin file and drop it in the device.
|
|
to the corresponding port (if the board has two, it's the biggest one).
|
|
|
|
|
|
|
|
What's written here is taken from Miosix's Quick start guide: <https://miosix.org/wiki/index.php?title=Quick_start#Getting_started>.
|
|
|
|
|
|
|
|
|
|
### 1.2 ST-Link software
|
|
|
|
|
|
**Software**
|
|
If this doesn't work, you can try downloading an ST-Link utility, which is provided with a GUI. You will need to press Connect, flash your binary, verify it and then power cycle the board.
|
|
|
|
|
|
*Windows*
|
|
*Windows*
|
|
|
|
|
... | @@ -34,19 +28,24 @@ wget https://raw.githubusercontent.com/mobyfab/QStlink2/master/res/49-stlinkv2.r |
... | @@ -34,19 +28,24 @@ wget https://raw.githubusercontent.com/mobyfab/QStlink2/master/res/49-stlinkv2.r |
|
sudo mv 49-stlinkv2.rules /etc/udev/rules.d
|
|
sudo mv 49-stlinkv2.rules /etc/udev/rules.d
|
|
sudo chown root:root /etc/udev/rules.d/49-stlinkv2.rules
|
|
sudo chown root:root /etc/udev/rules.d/49-stlinkv2.rules
|
|
```
|
|
```
|
|
Or you can use `stm32flash` or `openocd` from CLI (the last one is needed to run SBS's script).
|
|
|
|
|
|
|
|
### Discovery Boards
|
|
|
|
|
|
|
|
**Flashing**
|
|
## Method 2: USART
|
|
|
|
|
|
Discovery boards are quite simple to use: plug your board via usb to your PC and then
|
|
If your board has at least a USART port accessible, you can also flash binaries through it. To do this, you'll need a USB-TTL module and you need to have access to the following pins of your STM32:
|
|
use QSTLink to flash the binary file on the board.
|
|
|
|
|
|
|
|
Or, if you prefer, you can use two scripts that you can find in the `scripts\` folder:
|
|
* BOOT0
|
|
|
|
* BOOT1
|
|
|
|
* NRST
|
|
|
|
* USART RX
|
|
|
|
* USART TX
|
|
|
|
|
|
- start_openocd.sh: starts openocd(leave it in background)
|
|
You also need `stm32flash` installed.
|
|
- openocd-flash.sh <binary_file_name>: connects to openocd using gdb and
|
|
|
|
uses it to flash the binary file into the connected board.
|
|
**Procedure**
|
|
|
|
1. Connect BOOT0 to VDD and BOOT1 to GND
|
|
|
|
2. Reset the board by pulling NRST to GND and then leave it floating
|
|
|
|
3. try `stm32flash /dev/ttyUSB0` or `ttyS0`
|
|
|
|
4. if the board information is printed, flash with `stm32flash -b <BAUDRATE> -w <BINARYNAME> /dev/ttyUSB0` or whatever device the USB-TTL is attached.
|
|
|
|
5. once finished, restore BOOT0 and BOOT1 values and reset the board.
|
|
|
|
|
|
If the program is not running, power-cycle the board and you'll see it working! |
|
|