Nice - thanks for posting this up!
Indeed it is poor man's SWD for free if you have the Pi. However when Pi is used also as a desktop the connection is very unreliable. I tried this or Pi 3B+ and when just moving window the opened SWD connections breaks. But when just using already opened terminal window it works fine. Maybe it is also because dynamic CPU scaling as there are some hardcoded numbers expecting specific CPU frequency in the config.
But I guess Zero as a dedicated device over e.g. serial or USB could be quite reliable in this. In fact just reliable as those <$2 STLINK clones from aliexpress are :-)
I used my (headless) Zero W with ssh terminal over WiFi. Worked like a charm. Zero W is cheaper than any of the official programmers and after programming, you'll have a fully working wireless computer to play with. All for 12 €.
Very nice, thanks for confirming this. I feared that even wireless and ssh could affect the reliability. BTW, those stlink clones are in fact generic stm32f103c8t6 boards in small usb stick like package so they are also quite versatile but Zero (W) is definitely better and far more flexible.
Can openocd run as a daemon without attaching to device immediately? Then one could run it on the Zero W automatically at boot time so one would not need to login over ssh to it since it runs as server already. And if it is not possible out of box maybe it can be proxied over inetd so it would try to start and attach each time one opens network connection to openocd port.
The ZeroW running OpenOcd should bd able to do a complete "mass erase", which a ST-link v2.x could not, I believe...
I tried to follow this tutorial but without success.
So, I'm suspicous about my soldered wires.
To test at least power wires, I was wondering if I only connect 3v3 and GND pins of my raspberry pi
3 B+ to the nRF52832 chip, I guess it should be visible from my smarphone using a BLE app (like nRF Toolbox). Could you confirm? (because currently I don't see it...)
Only if the firmware on your nrf52832 chip is set to advertise on powerup. Bare chips usually would have a factory firmware that don't do anything (at least the ones I've had).
You should connect the four wires (swd + power) and see if openocd will show the chip as a target. This setup is very sensitive to movement/interference so try to keep things as stable as possible, without any background programs running on the pi.
This setup is very sensitive to movement/interference so try to keep things as stable as possible, without any background programs running on the pi.
It might help to disable cpu frequency scaling as there is hardcoded number in openocd config specific to cpu clock. by default e.g pi zero runs at 700MHz and scales to 1GHz when cpu is more busy. For faster Pis this difference is even larger like 600 idle vs 1600 busy for Pi4 so this is probably what breaks it as some timing loops may run 3x faster when something else runs too. see e.g https://wiki.archlinux.org/index.php/CPU_frequency_scaling#Scaling_governors
Thank you for details and advices.
I checked my wires and they're well soldered. I'll keep investigating... (probably try an another Pi or chip)
Update for "rpi1.cfg" if not using the Raspi Zero like me having a Raspi3
interface bcm2835gpio # RPi Zero/v1 interface [#bcm2835gpio_peripheral_base](http://forum.espruino.com/search/?q=%23bcm2835gpio_peripheral_base) 0x20000000 [#bcm2835gpio_speed_coeffs](http://forum.espruino.com/search/?q=%23bcm2835gpio_speed_coeffs) 113714 28 # Raspi1 BCM2835: (700Mhz) [#bcm2835gpio_peripheral_base](http://forum.espruino.com/search/?q=%23bcm2835gpio_peripheral_base) 0x20000000 [#bcm2835gpio_speed_coeffs](http://forum.espruino.com/search/?q=%23bcm2835gpio_speed_coeffs) 113714 28 # Raspi2 BCM2836 (900Mhz): [#bcm2835gpio_peripheral_base](http://forum.espruino.com/search/?q=%23bcm2835gpio_peripheral_base) 0x3F000000 [#bcm2835gpio_speed_coeffs](http://forum.espruino.com/search/?q=%23bcm2835gpio_speed_coeffs) 146203 36 # Raspi3 BCM2837 (1200Mhz): bcm2835gpio_peripheral_base 0x3F000000 bcm2835gpio_speed_coeffs 194938 48
Thanks to @jaolho and @fanoush
Wow it look's horrible - preview look fine but the result after "Post reply" is ugly....
Here it is... just follow 'old conventions': make the line comment char a token by letting if follow by a blank:
# FULL ESPRUINO SCRIPT interface bcm2835gpio # RPi Zero/v1 interface # bcm2835gpio_peripheral_base 0x20000000 # bcm2835gpio_speed_coeffs 113714 28 # Raspi1 BCM2835: (700Mhz) # bcm2835gpio_peripheral_base 0x20000000 # bcm2835gpio_speed_coeffs 113714 28 # Raspi2 BCM2836 (900Mhz): # bcm2835gpio_peripheral_base 0x3F000000 # bcm2835gpio_speed_coeffs 146203 36 # Raspi3 BCM2837 (1200Mhz): bcm2835gpio_peripheral_base 0x3F000000 bcm2835gpio_speed_coeffs 194938 48 # Pins bcm2835gpio_swd_nums 25 24 bcm2835gpio_srst_num 18 reset_config srst_only srst_push_pull # Transport transport select swd # Target set WORKAREASIZE 0 set CHIPNAME nrf52832 source [find target/nrf52.cfg] reset_config srst_only srst_nogate adapter_nsrst_delay 100 adapter_nsrst_assert_width 100 # Execution init targets halt nrf52832.dap apreg 1 0x04 0x01 flash write_image espruino_2v01_nrf52832.hex reset halt targets verify_image espruino_2v01_nrf52832.hex reset run targets exit
(I assume that a # immediately followed by something is considered kind of an anchor thing for post/conversation/document internal navigation.)
so let's just upload the extended version as text file :)
The forum source parsing and rendering system is very particular when it comes to special characters and more so what the character after the special character is. Simple mark-up - avoiding a real mark-up - has a price... though pretty smart: in 'old fashioned' language syntax / tokenizing blanks after a symbol was required to keep the parsing simple... so do it here too:
Add a blank *after* the comment (
#) sign character.
(Escaping with a leading backslash works some times too... as after between single asterisks does, even within a triple-asterisks streak... ;-\ )
(IMNSHO anyway a good and gentle practice... for the - human - code reader... we may be nerds, but we are not machines after all. - If I'm not in resource constraints, I write code so I and other humans can read the code easily and grok it right away... and leave the crappy work to the machine, that's for what I have them for.)
And if you want to get rid of the 'random' syntax coloring pack the stuff into a multi-line js string , like this:
` # FULL ESPRUINO SCRIPT interface bcm2835gpio # RPi Zero/v1 interface # bcm2835gpio_peripheral_base 0x20000000 # bcm2835gpio_speed_coeffs 113714 28 # Raspi1 BCM2835: (700Mhz) # bcm2835gpio_peripheral_base 0x20000000 # bcm2835gpio_speed_coeffs 113714 28 # Raspi2 BCM2836 (900Mhz): # bcm2835gpio_peripheral_base 0x3F000000 # bcm2835gpio_speed_coeffs 146203 36 # Raspi3 BCM2837 (1200Mhz): bcm2835gpio_peripheral_base 0x3F000000 bcm2835gpio_speed_coeffs 194938 48 # Pins bcm2835gpio_swd_nums 25 24 bcm2835gpio_srst_num 18 reset_config srst_only srst_push_pull ..... ... . `
(Sorry, my bad,... it - color coding - is not random, it follows the rules... But: I wish the triple back tick - ``` - would have something to tell what semantics should be applied for what is triple back ticked... may be there is something possible, but I just don't know about; for example,
` ` ` jsor
` ` ` textas standalone line after a blank line - of course, all without blanks between the individual chars - would tell the rendering what rules to apply... and being no rules -just plain, pre-formatted text - would just be good enough. JS (js) could be default with no need to say something;
prefor 'just leave it alone' would do just great... additional attributes could be about font: fixed, size, color,... like css short specs: fixed 1.0 blue on grey. - 1.0em rather than 11px).
Does anybody knows why I am getting error while installing OpenOCD?
[submodule "tools/git2cl"] path = tools/git2cl url = http://repo.or.cz/r/git2cl.git [submodule "jimtcl"] path = jimtcl url = http://repo.or.cz/r/jimtcl.git [submodule "src/jtag/drivers/libjaylink"] path = src/jtag/drivers/libjaylink url = http://repo.or.cz/r/libjaylink.git
Faling to install all above submodules with same error
fatal: unable to access 'http://repo.or.cz/git2cl.git/': Recv failure: Connection reset by peer
Is OpenOCD still in business?
The link http://repo.or.cz/git2cl.git/ fails to load in the browser (which I'm sure was attempted) with error 'This site can’t be reached'
I did find a mirror site:
'Is OpenOCD still in business?'
Google return links seem to be dated into mid-late 2019.
For people who want to upload the NRF52 hex to the device with a Raspberry 400, see files attached.
In general there is a shorthand command for uploading hex/bin/elf file to your device, see code below:
source [find interface/raspberrypi4-native.cfg] transport select swd set CHIPNAME nrf52 source [find target/nrf52.cfg] adapter speed 100 reset_config srst_nogate adapter srst delay 100 adapter srst pulse_width 100 program /home/pi/bootloader/espruino_2v01_nrf52832.hex reset shutdown
programline is enough with the path to your file. In the attachments there is also an interface for the raspberrypi 400 that should be placed in /usr/local/shared/openocd/scripts/interfaces/raspberrypi4-native.cfg
ok, great, but why would anyone use espruino 2v01 hex file now?
I was not successful with the script, it could not remove the protection on my E-Byte board.
Maybe you need two scripts, first this one:
nrf52.dap apreg 1 0x0c 0x00000000
nrf52.dap apreg 1 0x04 0x01
I finally had success with 'nrfjprog -f NRF52 --recover', this cleared the board even with an upgraded ST-Link interface (Segger upgrade). But nrfjprog and the upgraded cable could not program any bootloader. So thank you for this tutorial which made my day happy in the end :-)
Figuring out how to get Espruino into a blank nRF52832 (ebyte E73 module from Aliexpress) took me quite a lot of time since I couldn't find a single tutorial with all the needed steps.
I 'm a total beginner in ARM programming and architecture, so words like J-TAG or SWD didn't tell me anything. After some googling I figured I need more than an USB-UART adapter to bring the chip alive. Fortunately, I had a RPi Zero W lying around and it turned out that it's all you need!
Here are the steps. In the end, the process is very simple.
1) Use RPi's command line to install openocd:
2) Create the following script file (rpi1.cfg) (uncomment the RPi v2+ part if you are using RPi v2 or later):
4) Copy the "espruino_2v01_nrf52832.hex" file into the openocd directory and make sure that the "rpi1.cfg" file is also in that directory. The hex file is from "http://www.espruino.com/binaries".
5) Connect the nRF52832 chip and the Raspberry Pi:
nRF52832 <-> RPi
6) Run this command in the openocd directory:
ps. If you want to execute the openocd commands one by one or execute other commands, comment out the execution portion of the script file. Then run the script, open another terminal and give the command:
You can now give the openocd debugger commands one by one through the telnet terminal. Telnet can be installed with
pps. This tutorial can be used to program other nRF51 and nRF52 chips with minor modifications to the script file. Also other Raspberry Pi boards can be used!
Most of this tutorial is based on these posts: