diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/debug | 14 | ||||
-rwxr-xr-x | bin/dfu | 16 | ||||
-rwxr-xr-x | bin/flash-target | 6 | ||||
-rwxr-xr-x | bin/reset | 6 |
4 files changed, 30 insertions, 12 deletions
@@ -6,11 +6,21 @@ OPENOCD=openocd OPENOCD_BOARD_DIR=/usr/share/openocd/scripts/board OPENOCD_PROC_FILE=stm32f4discovery.cfg if [ "x`lsusb -d 0483:374b`" != "x" ]; then - OPENOCD_PROC_FILE=st_nucleo_f4.cfg + for fn in st_nucleo_f4.cfg st_nucleo_f401re.cfg; do + if [ -f "$OPENOCD_BOARD_DIR/$fn" ]; then + OPENOCD_PROC_FILE="$fn" + fi + done fi $OPENOCD -f $OPENOCD_BOARD_DIR/$OPENOCD_PROC_FILE & -GDB=arm-none-eabi-gdb +for gdb in gdb-multiarch arm-none-eabi-gdb; do + if command -v $gdb &>/dev/null; then + GDB=$gdb + break + fi +done + $GDB -ex "target remote localhost:3333" -ex "set remote hardware-breakpoint-limit 6" -ex "set remote hardware-watchpoint-limit 4" $PROJ.elf kill -9 $(pidof $OPENOCD) @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # # Copyright (c) 2016, NORDUnet A/S All rights reserved. # @@ -43,7 +43,7 @@ import struct import serial import argparse -from binascii import crc32 +from binascii import crc32, hexlify CHUNK_SIZE = 4096 @@ -77,23 +77,23 @@ def parse_args(): def _write(dst, data): for i in range(len(data)): - dst.write(data[i]) + dst.write(data[i:i+1]) time.sleep(0.1) if len(data) == 4: - print("Wrote 0x{:02x}{:02x}{:02x}{:02x}".format(ord(data[0]), ord(data[1]), ord(data[2]), ord(data[3]))) + print("Wrote 0x{}".format(hexlify(data).decode("ascii"))) else: print("Wrote {!r}".format(data)) def _read(dst, verbose=False): - res = '' + res = b'' while True: x = dst.read(1) if not x: break res += x if res and verbose: - print ("Read {!r}".format(res)) + print("Read {!r}".format(res)) return res @@ -111,7 +111,7 @@ def send_file(filename, args): except serial.SerialException: time.sleep(0.2) continue - dst.write('\r') + dst.write(b'\r') response = _read(dst, args.verbose) if 'OK' in response: dst.timeout=2 @@ -137,7 +137,7 @@ def send_file(filename, args): if len(ack_bytes) == 4: break print('ERROR: Did not receive an ACK, got {!r}'.format(ack_bytes)) - dst.write('\r') # eventually get back to the CLI prompt + dst.write(b'\r') # eventually get back to the CLI prompt ack = struct.unpack('<I', ack_bytes)[0] if ack != counter + 1: print('ERROR: Did not receive the expected counter as ACK (got {!r}/{!r}, not {!r})'.format(ack, ack_bytes, counter)) diff --git a/bin/flash-target b/bin/flash-target index 0d60c85..336bae1 100755 --- a/bin/flash-target +++ b/bin/flash-target @@ -22,7 +22,11 @@ OPENOCD_BOARD_DIR=/usr/share/openocd/scripts/board # OPENOCD_PROC_FILE=stm32f4discovery.cfg if [ "x`lsusb -d 0483:374b`" != "x" ]; then - OPENOCD_PROC_FILE=st_nucleo_f4.cfg + for fn in st_nucleo_f4.cfg st_nucleo_f401re.cfg; do + if [ -f "$OPENOCD_BOARD_DIR/$fn" ]; then + OPENOCD_PROC_FILE="$fn" + fi + done fi $OPENOCD -f $OPENOCD_BOARD_DIR/$OPENOCD_PROC_FILE -c "program $PROJ.elf verify reset exit" @@ -21,7 +21,11 @@ OPENOCD_BOARD_DIR=/usr/share/openocd/scripts/board # OPENOCD_PROC_FILE=stm32f4discovery.cfg if [ "x`lsusb -d 0483:374b`" != "x" ]; then - OPENOCD_PROC_FILE=st_nucleo_f4.cfg + for fn in st_nucleo_f4.cfg st_nucleo_f401re.cfg; do + if [ -f "$OPENOCD_BOARD_DIR/$fn" ]; then + OPENOCD_PROC_FILE="$fn" + fi + done fi $OPENOCD -f $OPENOCD_BOARD_DIR/$OPENOCD_PROC_FILE -c "init" -c "reset run" -c "exit" |