diff --git a/README.md b/README.md new file mode 100644 index 0000000..51d2315 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# + +## Requirements + +``` +sudo apt install python3-pip openocd +sudo pip3 install pyserial platformio saleae +sudo pip3 uninstall enum34 +``` diff --git a/templates/bluepill/openocd.cfg b/templates/bluepill/openocd.cfg new file mode 100644 index 0000000..dfa1d72 --- /dev/null +++ b/templates/bluepill/openocd.cfg @@ -0,0 +1,25 @@ +interface ftdi +transport select jtag + +ftdi_device_desc "FT2232H MiniModule" +ftdi_vid_pid 0x0403 0x6010 + +# The other channel is used for UART +ftdi_channel 1 +ftdi_layout_init 0x0018 0x05fb + +# BDBUS4 is connected to JTAG TRST +ftdi_layout_signal nTRST -data 0x0010 + +# BDBUS5 is connected to System Reset +ftdi_layout_signal nSRST -data 0x0020 + + +set WORKAREASIZE 0x2000 +source [find target/stm32f1x.cfg] + +#tpiu config internal swodump.stm32f103-generic.log uart off 72000000 + +#reset_config srst_only srst_push_pull srst_nogate connect_assert_srst +reset_config none srst_push_pull srst_nogate + diff --git a/templates/bluepill/test b/templates/bluepill/test index bc8087f..7550a6e 100755 --- a/templates/bluepill/test +++ b/templates/bluepill/test @@ -15,31 +15,20 @@ def eprint(*args, **kargs): def flash(): pipe = subprocess.PIPE - cmd = ['platformio', 'run', '-e', 'bluepill_f103c8', '--target', 'upload'] + cmd = ['openocd', '-f', 'openocd.cfg', '-c' 'program ' + + '.pio/build/bluepill_f103c8/firmware.elf verify reset exit'] p = subprocess.Popen(cmd, - stdout=sys.stderr, stdin=pipe) - stdout, stderr = p.communicate("") - - -def popen_jlink(): - pipe = subprocess.PIPE - cmd = ['JLinkExe'] - cmd.extend(['-autoconnect', '1']) - cmd.extend(['-device', 'STM32F103C8']) - cmd.extend(['-if', 'swd']) - cmd.extend(['-speed', '4000']) - return subprocess.Popen(cmd, stdout=sys.stderr, stdin=pipe) + stdout=sys.stderr, stdin=sys.stdout) + stdout, stderr = p.communicate("") def fill_ram(): - p = popen_jlink() - return p.communicate((""" -h -loadbin empty_ram.bin 0x20000000 -r -g -exit - """).encode('ascii')) + pipe = subprocess.PIPE + cmd = ['openocd', '-f', 'openocd.cfg', '-c' 'program ' + + 'empty_ram.bin reset exit 0x20000000'] + p = subprocess.Popen(cmd, + stdout=sys.stderr, stdin=sys.stdout) + stdout, stderr = p.communicate("") def get_serial():