Making firmware hacking easier


#21

> Let me know if this works

I’d rather let someone else test it if possible, I don’t have all the software installed… sorry :-/


#22

I’m not asking you to test the vagrant environment, but the new makefile / openocd scripts!


#23

Oh sorry, ok! I’ll try that tomorrow.


#24

Did a quick upload with PGM_INTERFACE=arm-usb-tiny-h in VM, seems to have worked without issues.


#25

Yep, I can confirm, communication with my st-link-v2 works fine.


#26

Ok, I guess I have a VM issue since this is what I get when trying to program via the VM:

Error: The specified debug interface was not found (hla)
The following debug interfaces are available:
1: ft2232
2: ftdi
Runtime Error: stmlib/programming/jtag/interface_stlink-v2.cfg:28:
in procedure 'script’
at file “embedded:startup.tcl”, line 58
in procedure ‘interface’ called at file “stmlib/programming/jtag/interface_stlink-v2.cfg”, line 28
Open On-Chip Debugger 0.7.0 (2015-09-03-11:04)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.sourceforge.net/doc/doxygen/bugs.html
Error: The specified debug interface was not found (hla)
The following debug interfaces are available:
1: ft2232
2: ftdi
Runtime Error: stmlib/programming/jtag/interface_stlink-v2.cfg:28:
in procedure 'script’
at file “embedded:startup.tcl”, line 58
in procedure ‘interface’ called at file “stmlib/programming/jtag/interface_stlink-v2.cfg”, line 28
make: ***** [upload_combo_jtag] Error 1

I cloned the contents of the stmlib directory, changed the programmer the st-link and interface to hla

Also added a filter for the stlink since the one in the virtualbox list was listed as “inactive” and there was a different entry available for the stlinkv2


#27

Let me check… maybe openocd needs to be built with special flags to support stlink.


#28

altitude: 1/ rebuild a VM with the file I have just committed. It compiles openOCD with STLINK support.

2/ Try it! The OpenOCD config files appear to work for Mqtthiqs, but I get errors here. Try removing some stuff in stm32f4xx_hla.cfg and stm32f10x_hla.cfg:

  • The arguments -irlen 4 -ircapture 0x1 -irmask 0xf
  • The line jtag_ntrst_delay 100

From that point I can’t do any further test because I don’t have any STLink board!


#29

Will do. I’ll report back later when I’m back at the lab


#30

Nice idea, though I’m not sure if it should be that specific to Virtualbox/Vagrant. Actually it’s pretty easy - at least with Linux - to use KVM/Qemu with libvirt/virt-manager instead, so I think a more generic bootstrap-script (without the Virtualbox/Vagrant stuff) which could be run after a fresh installation (doesn’t even need to be a virtual machine) could be also much of use. But then again, a preseed file for the Debian/Ubuntu Installer could also be sufficient.

Anyways, I guess >99% of MI users will be just happy with Virtualbox/Vagrant, and all others are happy to read such a script instead of searching through forum postings.


#31

still no dice. I tried it as is and with the changes

jtag
adapter speed: 1000 kHz
adapter_nsrst_delay: 200
trst_and_srst separate srst_gates_jtag trst_push_pull srst_open_drain connect_deassert_srst
Runtime Error: embedded:startup.tcl:20: Unknown param: -irlen, try one of: or -expected-id
in procedure 'script’
at file “embedded:startup.tcl”, line 58
in procedure ‘hla’ called at file “stmlib/programming/jtag/stm32f10x_hla.cfg”, line 64
in procedure 'ocd_bouncer’
at file “embedded:startup.tcl”, line 20
Open On-Chip Debugger 0.8.0 (2015-09-03-22:25)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.sourceforge.net/doc/doxygen/bugs.html
jtag
adapter speed: 1000 kHz
adapter_nsrst_delay: 200
trst_and_srst separate srst_gates_jtag trst_push_pull srst_open_drain connect_deassert_srst
Runtime Error: embedded:startup.tcl:20: Unknown param: -irlen, try one of: or -expected-id
in procedure 'script’
at file “embedded:startup.tcl”, line 58
in procedure ‘hla’ called at file “stmlib/programming/jtag/stm32f10x_hla.cfg”, line 64
in procedure 'ocd_bouncer’
at file “embedded:startup.tcl”, line 20
make: ***** [upload_combo_jtag] Error 1
vagrant@vagrant-ubuntu-trusty-64:/vagrant/eurorack-modules$


#32

ok, there was an -irlen 5 argument as well so I ditched that and now I have some blinky going on on the programmer but and this is the output

jtag
adapter speed: 1000 kHz
adapter_nsrst_delay: 200
trst_and_srst separate srst_gates_jtag trst_push_pull srst_open_drain connect_deassert_srst
Info : This adapter doesn’t support configurable speed
Info : STLINK v2 JTAG v23 API v2 SWIM v4 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.247895
Warn : Invalid ACK 0 in JTAG-DP transaction
Error: Target not examined yet
Runtime Error: stmlib/programming/jtag/prelude_f10x.cfg:25:
in procedure 'script’
at file “embedded:startup.tcl”, line 58
in procedure ‘halt’ called at file “stmlib/programming/jtag/prelude_f10x.cfg”, line 25
make: ***** [upload_combo_jtag] Error 1
vagrant@vagrant-ubuntu-trusty-64:/vagrant/eurorack-modules$


#33

mqtthiqs: did you have to remove the irlen arguments to make the makefile work? If not, which version of openocd are you using?

If we can’t get it working this way, I’ll add a rule that I’ll use st-flash.

altitude: can you check that this command does the right thing?

st-flash write build/braids/braids_bootloader_combo.bin 0x08000000


#34

Hi. No, didn’t have to remove the irlen argments, it worked out of the box (setting the variables PGM_INTERFACE and PGM_INTERFACE_TYPE). I’m using OpenOCD 0.9.0 as packaged by Macports on OSX. There is among others an “st-link” port variant, which means that there is probably a build option for it. My OpenOCD uses only the default port variants.


#35

Will try to upgrade openocd to 0.9.


#36

I’m working with a tides btw, but I dont think that matters

vagrant@vagrant-ubuntu-trusty-64:/vagrant/eurorack-modules$ st-flash write braids/braids_bootloader_combo.bin 0x08000000
2015-09-04T11:09:58 INFO src/stlink-common.c: Loading device parameters…
2015-09-04T11:09:58 INFO src/stlink-common.c: Device connected is: F1 Medium-density device, id 0x20036410
2015-09-04T11:09:58 INFO src/stlink-common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x20000 bytes (128 KiB) in pages of 1024 bytes
open(braids/braids_bootloader_combo.bin) -1
2015-09-04T11:09:58 ERROR src/stlink-common.c: map_file() -1
stlink_fwrite_flash() == -1


#37

build/braids/braids_bootloader_combo.bin?


#38

I tried this again with the right file and path. I think you’re almost there, I get activity on the programmer.

For your reference, I have the STlink2 running the the latest firmware (V2.J23.S4)

vagrant@vagrant-ubuntu-trusty-64:/vagrant/eurorack-modules$ st-flash write build/tides/tides_bootloader_combo.bin 0x08000000
2015-09-04T11:35:19 INFO src/stlink-common.c: Loading device parameters…
2015-09-04T11:35:19 INFO src/stlink-common.c: Device connected is: F1 Medium-density device, id 0x20036410
2015-09-04T11:35:19 INFO src/stlink-common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x20000 bytes (128 KiB) in pages of 1024 bytes
2015-09-04T11:35:19 INFO src/stlink-common.c: Attempting to write 121064 (0x1d8e8) bytes to stm32 address: 134217728 (0x8000000)
2015-09-04T11:35:19 WARN src/stlink-common.c: unknown coreid 3ba00477, page erase failed
2015-09-04T11:35:19 ERROR src/stlink-common.c: Failed to erase_flash_page(0x8000000) -1
stlink_fwrite_flash() -1


#39

(deleted silly messages because I realized you were trying stlink directly, not openocd)

And yeah, pld is right, the path to the bin file is wrong!


#40

Maybe you have to use another command before to erase the chip?