#!/usr/bin/python import os import sys import time import struct import serial from binascii import crc32 def _write(dst, data): for i in range(len(data)): dst.write(data[i]) 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]))) else: print("Wrote {!r}".format(data)) def _read(dst): res = '' while True: x = dst.read(1) if not x: break res += x print ("Read {!r}".format(res)) return res def _execute(dst, cmd): _write(dst, '\r') prompt = _read(dst) if prompt.endswith('Username: '): _write(dst, 'ct\r') prompt = _read(dst) if prompt.endswith('Password: '): _write(dst, 'ct\r') prompt = _read(dst) if not prompt.endswith('> '): sys.stderr.write('Device does not seem to be ready for a file transfer (got {!r})\n'.format(prompt)) return False _write(dst, cmd + '\r') response = _read(dst) return response def send_file(filename, device='/dev/ttyUSB0', initiate=True): s = os.stat(filename) size = s.st_size src = open(filename, 'rb') dst = serial.Serial(device, 921600, timeout=1) if initiate: response = _execute(dst, 'filetransfer') if 'OK' not in response: sys.stderr.write('Device did not accept the filetransfer command (got {!r})\n'.format(response)) return False # 1. Write size of file (4 bytes) _write(dst, struct.pack('
path: root/bin/debug
blob: 9309e66808c68070aaa58ad6038020b0026ee7f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/sh

PROJ="${1?'project'}"

OPENOCD=openocd
OPENOCD_BOARD_DIR=/usr/share/openocd/scripts/board
OPENOCD_PROC_FILE=stm32f4discovery.cfg
#OPENOCD_PROC_FILE=st_nucleo_f4.cfg
$OPENOCD -f $OPENOCD_BOARD_DIR/$OPENOCD_PROC_FILE &

GDB=arm-none-eabi-gdb
$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)