Accessing the STM32L412KB Serial Wire Debugger (SWD) Connections (Novice User)
You need stlink flash utility - otherwise you will need to manually send the gdb commands.

How to make the stlink flasher:

sudo apt-get install libusb-1.0-0-dev git
git clone https://github.com/texane/stlink stlink.git
cd stlink.git
make
cd flash
sudo cp st-flash /usr/bin
cd ..
sudo cp *.rules /etc/udev/rules.d
sudo restart udev


and then you can flash your nucleo board:

st-flash write yourfile.bin 0x8000000


or using the openocd

 openocd -f board/stm32&lt;yourboard&gt;.cfg -c "yourfile.bin exit 0x08000000"