FULL tutorial for flashing Espruino into nRF52832 with Raspberry Pi (Zero) using OpenOCD and SWD (two wires) #1235
Replies: 20 comments
-
Posted at 2019-07-01 by @gfwilliams Nice - thanks for posting this up! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-07-01 by @fanoush 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 :-) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-07-01 by jaolho 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 €. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-07-02 by @fanoush 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. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-11-06 by Rando2 The ZeroW running OpenOcd should bd able to do a complete "mass erase", which a ST-link v2.x could not, I believe... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-19 by user106587 Hi, I tried to follow this tutorial but without success. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-19 by parasquid 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. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-19 by @fanoush
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 |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-20 by user106587 Thank you for details and advices. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-12 by @MaBecker Update for "rpi1.cfg" if not using the Raspi Zero like me having a Raspi3
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-12 by @MaBecker Wow it look's horrible - preview look fine but the result after "Post reply" is ugly.... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-12 by @allObjects Here it is... just follow 'old conventions': make the line comment char a token by letting if follow by a blank:
(I assume that a # immediately followed by something is considered kind of an anchor thing for post/conversation/document internal navigation.) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-12 by @MaBecker so let's just upload the extended version as text file :)Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-12 by @allObjects 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 ( (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:
(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, |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-31 by Abhigkar Does anybody knows why I am getting error while installing OpenOCD?
Faling to install all above submodules with same error
Is OpenOCD still in business? //Abhinav |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-02-01 by Robin Sat 2020.02.01 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:
Google return links seem to be dated into mid-late 2019. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-02-02 by Abhigkar @robin, Thanks for your suggestion, but i tries that also. Unfortunately this repo has the same .gitmodules files to load the sub modules from the repo.or.cz. Sadly this site is still down and google web cache gave me that it was last cached on 30 Jan 2020. :( |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-12 by user125226 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:
The Good luckAttachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-12 by @fanoush ok, great, but why would anyone use espruino 2v01 hex file now? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-28 by user125730 I was not successful with the script, it could not remove the protection on my E-Byte board. nrf52.dap apreg 1 0x0c 0x00000000 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 :-) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-06-30 by jaolho
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.
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 "www.espruino.com/binaries".
Connect the nRF52832 chip and the Raspberry Pi:
nRF52832 <-> RPi
That's it. You should now be able to upload javascript into the nRF52832 with the Espruiono Web UI!
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:
https://iosoft.blog/2019/01/28/raspberry-pi-openocd/
https://devzone.nordicsemi.com/f/nordic-q-a/21650/flashing-nrf51-with-openocd-on-raspberry-pi
Attachments:
Beta Was this translation helpful? Give feedback.
All reactions