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:
sudo apt-get update
sudo apt-get install git autoconf libtool make pkg-config libusb-1.0-0 libusb-1.0-0-dev
git clone "http://openocd.zylin.com/openocd"
./configure --enable-sysfsgpio --enable-bcm2835gpio
sudo make install
2) Create the following script file (rpi1.cfg) (uncomment the RPi v2+ part if you are using RPi v2 or later):
# FULL ESPRUINO SCRIPT
# RPi Zero/v1 interface
bcm2835gpio_speed_coeffs 113714 28
# RPi v2+ interface
# bcm2835gpio_peripheral_base 0x3F000000
# bcm2835gpio_speed_coeffs 146203 36
bcm2835gpio_swd_nums 25 24
reset_config srst_only srst_push_pull
transport select swd
set WORKAREASIZE 0
set CHIPNAME nrf52832
source [find target/nrf52.cfg]
reset_config srst_only srst_nogate
nrf52832.dap apreg 1 0x04 0x01
flash write_image espruino_2v01_nrf52832.hex
# END OF SCRIPT
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
- VCC <-> VCC (3.3V)
- GND <-> GND
- SWDIO <-> GPIO 24 (pin header #22)
- SWDCLK <-> GPIO 25 (pin header #18)
6) Run this command in the openocd directory:
sudo openocd -f "rpi1.cfg"
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:
telnet localhost 4444
You can now give the openocd debugger commands one by one through the telnet terminal. Telnet can be installed with
sudo apt-get install telnet
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: