File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ USE_PYDFU ?= 1
2929PYDFU ?= ../tools/pydfu.py
3030DFU_UTIL ?= dfu-util
3131DEVICE =0483:df11
32+ STFLASH ?= st-flash
3233
3334CROSS_COMPILE = arm-none-eabi-
3435
@@ -286,6 +287,12 @@ else
286287 $(Q)$(DFU_UTIL) -a 0 -d $(DEVICE) -D $<
287288endif
288289
290+ deploy-stlink : $(BUILD ) /firmware.dfu
291+ $(ECHO ) " Writing $( BUILD) /firmware0.bin to the board via ST-LINK"
292+ $(Q )$(STFLASH ) write $(BUILD ) /firmware0.bin 0x08000000
293+ $(ECHO ) " Writing $( BUILD) /firmware1.bin to the board via ST-LINK"
294+ $(Q )$(STFLASH ) --reset write $(BUILD ) /firmware1.bin 0x08020000
295+
289296$(BUILD ) /firmware.dfu : $(BUILD ) /firmware.elf
290297 $(ECHO ) " Create $@ "
291298 $(Q )$(OBJCOPY ) -O binary -j .isr_vector $^ $(BUILD ) /firmware0.bin
Original file line number Diff line number Diff line change @@ -57,6 +57,31 @@ Or using `dfu-util` directly:
5757
5858 $ sudo dfu-util -a 0 -d 0483:df11 -D build-PYBV11/firmware.dfu
5959
60+
61+ ### Flashing the Firmware with stlink
62+
63+ ST Discovery or Nucleo boards have a builtin programmer called ST-LINK. With
64+ these boards and using Linux or OS X, you have the option to upload the
65+ ` stmhal ` firmware using the ` st-flash ` utility from the
66+ [ stlink] ( https://github.com/texane/stlink ) project. To do so, connect the board
67+ with a mini USB cable to its ST-LINK USB port and then use the make target
68+ ` deploy-stlink ` . For example, if you have the STM32F4DISCOVERY board, you can
69+ run:
70+
71+ $ make BOARD=STM32F4DISC deploy-stlink
72+
73+ The ` st-flash ` program should detect the USB connection to the board
74+ automatically. If not, run ` lsusb ` to determine its USB bus and device number
75+ and set the ` STLINK_DEVICE ` environment variable accordingly, using the format
76+ ` <USB_BUS>:<USB_ADDR> ` . Example:
77+
78+ $ lsusb
79+ [...]
80+ Bus 002 Device 035: ID 0483:3748 STMicroelectronics ST-LINK/V2
81+ $ export STLINK_DEVICE="002:0035"
82+ $ make BOARD=STM32F4DISC deploy-stlink
83+
84+
6085Accessing the board
6186-------------------
6287
You can’t perform that action at this time.
0 commit comments