|
|
Prerequisites for this guide is having installed Git, Python3, the [Miosix toolchain](https://miosix.org/wiki/index.php?title=Quick_start) and the STM32 ST-Link software.
|
|
|
Prerequisites for this guide is having installed Git, CMake, the [Miosix toolchain](https://miosix.org/wiki/index.php?title=Quick_start) and the STM32 ST-Link software.
|
|
|
Also a compatible board is needed: all the examples are made with a STM32F407VG Discovery.
|
|
|
|
|
|
This tutorial is a simple led blink test: it will teach you how to clone the boardcore repository, create your own entrypoint (_i.e. Main_) and flash the compiled binary in the target board.
|
... | ... | @@ -8,9 +8,8 @@ This tutorial is a simple led blink test: it will teach you how to clone the boa |
|
|
Open the git console inside a folder and clone the boardcore repository:
|
|
|
|
|
|
```sh
|
|
|
git clone --recurse-submodules https://git.skywarder.eu/scs/skyward-boardcore.git
|
|
|
git clone --recurse-submodules https://git.skywarder.eu/scs/skyward-boardcore.git
|
|
|
cd skyward-boardcore
|
|
|
./sbs -v # build all the entrypoint (with verbose output)
|
|
|
```
|
|
|
|
|
|
If all was built without errors you're good to start.
|
... | ... | @@ -23,7 +22,7 @@ git submodule update --init --recursive --remote |
|
|
|
|
|
## Create your branch
|
|
|
|
|
|
First of all, create a new working branch off from testing ( [why?](Git-Workflow) ):
|
|
|
First of all, create a new working branch off from testing ([why?](Git-Workflow)):
|
|
|
|
|
|
```
|
|
|
git checkout testing
|
... | ... | @@ -43,7 +42,7 @@ using namespace miosix; |
|
|
|
|
|
int main()
|
|
|
{
|
|
|
while(1)
|
|
|
while (true)
|
|
|
{
|
|
|
ledOn();
|
|
|
miosix::Thread::sleep(200);
|
... | ... | @@ -55,40 +54,41 @@ int main() |
|
|
}
|
|
|
```
|
|
|
|
|
|
By calling _ledOn()_ and _ledOff()_ Miosix automatically sets high or low the [GPIO](GPIO-Usage-&-Used-Pins.md) associated to the default board LED (called `_led` and specified in `libs/miosix-kernel/arch/<your-arch>/<your-board>/interfaces-impl/bsp_impl.h`).
|
|
|
By calling `ledOn()` and `ledOff()` Miosix automatically sets high or low the [GPIO](GPIO-Usage-&-Used-Pins.md) associated to the default board LED (called `_led` and specified in `libs/miosix-kernel/arch/<your-arch>/<your-board>/interfaces-impl/bsp_impl.h`).
|
|
|
|
|
|
## Compile with SBS
|
|
|
|
|
|
To compile your entrypoint you must add it to the build system (called [SBS](Skyward-Build-System-(SBS))): open `sbs.conf` (in the top folder), go to the end of the file and write:
|
|
|
To compile your entrypoint you must add it to the build system (called [SBS](Skyward-Build-System-(SBS))): open `CMakeLists.txt` (in the top folder), go to the end of the file and write:
|
|
|
|
|
|
```
|
|
|
[led-blink]
|
|
|
Type: board
|
|
|
BoardId: stm32f407vg_stm32f4discovery
|
|
|
BinName: led-blink
|
|
|
Include:
|
|
|
Defines:
|
|
|
Main: led-blink
|
|
|
```cmake
|
|
|
add_executable(led-blink src/entrypoints/led-blink.cpp)
|
|
|
sbs_target(led-blink stm32f407vg_stm32f4discovery)
|
|
|
```
|
|
|
|
|
|
Now compile:
|
|
|
|
|
|
```
|
|
|
./sbs -b led-blink -v
|
|
|
./sbs -b led-blink
|
|
|
```
|
|
|
> :warning: **WARNING: In this and the following examples we are assuming that you will run the code on an STM32F407VG Discovery board: if that is not the case, you should change the `BoardId` field in the `sbs.conf` file. The possible board IDs are defined at the beginning of the file.**
|
|
|
> :warning: **WARNING: In this and the following examples we are assuming that you will run the code on an STM32F407VG Discovery board: if that is not the case, you should change the value of the argument of `sbs_target` in the `CMakeLists.txt` file. You can see a list of the possible board IDs using the SBS script: `./sbs -r`.**
|
|
|
|
|
|
## Flash on a board
|
|
|
|
|
|
Now the program is ready to be executed on the target you chose. To do that, you need to:
|
|
|
Now the program is ready to be executed on the target you chose. To do that, you need to:
|
|
|
|
|
|
* Plug the board to your PC (may need drivers to be recognized)
|
|
|
* Open the STM32 utility software
|
|
|
* Target > Connect
|
|
|
* Target > Program and choose `bin/led-blink/led-blink.elf`
|
|
|
* Target > Program and choose `build/led-blink.elf`
|
|
|
* Program
|
|
|
|
|
|
Restart the board and look at the led blinking.
|
|
|
Or using the SBS script:
|
|
|
|
|
|
```sh
|
|
|
./sbs -f led-blink
|
|
|
```
|
|
|
|
|
|
Restart the board and look at the led blinking.
|
|
|
|
|
|
If something went wrong, try looking at [how to flash on a target board](Flashing-on-a-Target-Board).
|
|
|
|
... | ... | |