Is there a preferred way to flash STM32 Nucleo board with stlink? #1546
Replies: 2 comments 3 replies
-
We use labgrid with boards running Linux, so we have tools like Perhaps the Driver for So to support these boards/MCUs in labgrid, you'd have to write corresponding Driver and Resource classes. |
Beta Was this translation helpful? Give feedback.
-
Hi, I am a little late to the party, but on my end I managed to flash stm32 device through openocd Here is what I have in my environment file: tools:
openocd: '/opt/zephyr-sdk-0.16.8/sysroots/x86_64-pokysdk-linux/usr/bin/openocd'
targets:
main:
resources:
- RawSerialPort:
name: shell_zephyr
port: /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTAD1ABG-if00-port0
- USBDebugger:
match:
ID_PATH: pci-0000:08:00.0-usb-0:1.2
drivers:
- SerialDriver:
name: shell_zephyr_driver
txdelay: 0.001
bindings:
port: shell_zephyr
- OpenOCDDriver:
config: 'boards/vossloh/pmdb/support/openocd.cfg'
search: 'boards/vossloh/pmdb/support'
load_commands:
- 'init'
- 'targets'
- 'reset init'
- 'flash write_image erase {filename}'
- 'reset run'
- 'shutdown' And I have the following class to manage flashing my device: """LabGrid helper to manage OpenOCDDriver."""
import os
import labgrid
class OpenOCD:
"""Object to manipulate OpenOCDDriver Instance from LabGrid."""
def __init__(self, target: labgrid.Target) -> None:
self.target = target
self.openocddriver = self.target.get_driver('OpenOCDDriver')
def load(self, filename: str) -> None:
"""Load firmware on target."""
assert os.path.isfile(filename), f"Firmware {filename} not found"
self.openocddriver.load(filename)
def reset(self) -> None:
"""Reset Target."""
reset_cmds = []
reset_cmds.append("init")
reset_cmds.append("targets")
reset_cmds.append("reset init")
reset_cmds.append("reset run")
reset_cmds.append("shutdown")
self.openocddriver.execute(reset_cmds) |
Beta Was this translation helpful? Give feedback.
-
Hi guys, I'm still wrapping my head around the
labgrid
. For this I'm setting up my small "device farm" to try the idea of remote access to MCU boards. My farm is an old laptop with some boards attached to it via usb cables. Some boards arearduino nano
, someSTM32Nucleo
and aRaspberry Pi
.Unfortunately I can't find an example of using labgrid to flash a
*.bin
file to aSTM32 Nucleo
board either usingstlink
or theSTM32Cube Programmer
.Same goes for flashing arduino board with prepared
*.hex
file usingavrdude
I have found the
FlashScriptDriver
, but I still am not sure how to use it.Any advice on how to approach such a task? If I've missed some place in documentation or example that explains this please point me to the right place :-)
Beta Was this translation helpful? Give feedback.
All reactions