I know Elco wrote a great tutorial but i decided to create a Mac version that i personally tested.
This makes it easy for me to assist the community for something that i myself wrote and use
Pre-requisite
DFU-util
$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Once homebrew is installed, we will install DFU-util
$ brew install dfu-util
st-util [to write a tutorial soon]
$ git clone https://github.com/texane/stlink.git st-util
$ cd st-util
$ ./autogen.sh
$ ./configure
$ make
GNU Tools for ARM Embedded Processors
Download from : https://launchpad.net/gcc-arm-embedded and place it in a PATH accessible
Place the binary in /usr/bin
or somewhere in PATH for the command-line```
.
.
.
.
.
Download Netbeans IDE
https://netbeans.org/downloads/
Use the C/C++ version
.
.
.
.
.
Install the GDBserver plugin
- Press on Available plugins tab
- search for gdbserver
- hit install on the bottom left
.
.
.
.
.
Add our toolchain
- Open the tools page
- Add our tool and specify the path to file it, name it ARM Embedded
- Modify the debugger command
.
.
.
.
.
Create a new project
- C/C++ project with Existing Sources
- Next
- Choose the toolchain we added [ARM embedded] and browse to root directory of the firmware
.
.
.
.
.
Close Netbeans and launch from terminal
$ open -a "/Applications/Netbeans/Netbeans 8.0.2.app"
Due to the requirement of /usr
path for the toolchain, we need to launch the App via terminal or the path will not be found
.
.
.
.
.
Add USE_SWD_JTAG flag to compiler
- Right-click on the main folder and click on properties
- Add in the line USE_SWD_JTAG=y at the end for Build
.
.
.
.
.
Try compiling!
- Hit on the Clean and build project button
- You should see a green message
- Copy the build result path and we will paste it in the Build --> Make --> Build Result
.
.
.
.
.
Flash code via STlinkV2 and turn on GDB server
- create a
gdb-run.sh
andgdbcommand.txt
file - Be sure to change the path for your app in
gdb-run.sh
- Run the command
./gdb-run.sh
in the gdb folder - This will flash code and also turn on the GDB server!
Create a gdb-run.sh
file with:
#!/bin/sh
set -m
st-util -p 9025 2>&1 &
sleep 5
arm-none-eabi-gdb ../build/target/main/platform-0/applications/UPDATETHISPATH/xxx.elf -x /PATHWHEREFILEISPLACE/gdbcommand.txt
st-util -p 9025
Create a gdbcommand.txt
file with:
# connect remote gdbserver on port 9025 (started with st-util -p 9025)
target remote localhost:9025
# reset core and hold in reset
monitor reset halt
# program core with supplied .elf file
load
# remove all breakpoints
delete
# disconnect from remote. This pauses execution. Detach is not supported.
disconnect
quit
.
.
.
.
.
.
Attaching the debugger
-Once code is flashed, a only a simple step is required to attach the debugger!
- Be sure the target is
remote localhost:9025