Flash using Raspberry Pi 3 - GUIDE UPDATED (Incl. clone)

Donnydingel
Posts: 11
Joined: Fri Apr 12, 2019 7:02 pm

Flash using Raspberry Pi 3 - GUIDE UPDATED (Incl. clone)

Postby Donnydingel Sun Jun 02, 2019 8:22 pm

This guide will not cover how to set up a raspberry pi (RPi) and enable ssh, there are plenty of those on the interwebz
(this guide can work with other boards and/or linux distros with some minor modifications. Might even work with some arduino things)
Pre-req:
  • Terminal access to the RPi and Internet access (for downloading first time, not required later on).
After you logged in to the RPi (either through ssh or hooking up the pi to a monitor)
run these commands in following order:

Update your packet list:

Code: Select all

sudo apt-get update
Install various tools:

Code: Select all

sudo apt-get install git autoconf libtool make pkg-config libusb-1.0-0 libusb-1.0-0-dev
Download the latest version of OpenOCD:

Code: Select all

git clone http://openocd.zylin.com/openocd
Go into the folder:

Code: Select all

cd openocd-code
And run a bootstrapper script:

Code: Select all

./bootstrap
Configure OpenOCD to use RPi GPIO:

Code: Select all

./configure --enable-sysfsgpio --enable-bcm2835gpio
Compile:

Code: Select all

Run make
Install your compiled code:

Code: Select all

sudo make install
You should have a working OpenOCD installed now.

Go back to your home directory:

Code: Select all

cd ~
Create a new folder:

Code: Select all

mkdir scooterflash
And go into that folder:

Code: Select all

cd bootloader
Now create a config file for OpenOCD:

Code: Select all

nano openocd.cfg
Copy and paste the following code:

Code: Select all

source [find interface/raspberrypi2-native.cfg] bcm2835gpio_swd_nums 25 24 transport select swd # target set WORKAREASIZE 0 set CHIPNAME nrf51802 source [find target/nrf51.cfg] init targets
Press CTRL+O and ENTER to save the file. Then CTRL+X to exit.

Notice the CHIPNAME, this is is the number you'll find on the chip if you look closely.

Now download the full_BLE.bin file that you will flash onto the dashboard:

Code: Select all

wget https://files.scooterhacking.org/esx/fw/ble/full_BLE.bin
You are now all set on the software side!

Hardware vise it's just like with the ST-Link v2, removing the C15 resistor and just hooking up cables:

RPi:
Image

Dashboard:
Image

Im using cable clamps so I dont have to solder, and just pressing the 3.3V cable onto the T6 square:

Image
Image
Image

Open up another terminal on the RPi (same way as you connected to it or open another terminal if using a monitor).

When cables are hoocked upp / soldered (dont forget the 3.3v cable), you should now run OpenOCD and flash.

In the first terminal, run OpenOCD (it will start with your config automagically

Code: Select all

openocd
It should start a telnet service, if not. Check your cables and/or run OpenOCD with the specific config

Code: Select all

openocd -f openocd.cfg
If you see something like "telnet 172.0.0.1 4444" you are all good to go!

Open up the other terminal and telnet to your OpenOCD telnet service:

Code: Select all

telnet localhost 4444
(I'm typing localhost since it more convenient then 127.0.0.1)

You should now be connected. If not, check your cables again! Cable connection is E V E R Y T H I N G!


- TO FLASH CLONE -
to flash a clone dashboard add these steps

Open Telnet using this command in this new window: telnet 127.0.0.1 4444
type

init
reset halt
nrf51 mass_erase
program full_ble.bin


and done
Now flash your dashboard:

Code: Select all

program full_BLE.bin
You should have a output that looks something like this:

Code: Select all

> program full_BLE.bin target halted due to debug-request, current mode: Thread xPSR: 0xc1000000 pc: 0x000006d0 msp: 0x000007c0 Programming Started Unknown device (HWID 0x00000114) not enough working area available(requested 32) no working area available, falling back to slow memory writes Programming Finished
Thats it! Rervert your disassembly, and flash your scooter through Es_DownG or whatever you use.

IF YOU GET SOMETHING LIKE THIS, CHECK YOUR SOLDERING / CABLE CONNECTIONS

Code: Select all

> program full_BLE.bin target halted due to debug-request, current mode: Thread xPSR: 0xc1000000 pc: 0x000006d0 msp: 0x000007c0 Programming Started Unknown device (HWID 0x00000114) not enough working area available(requested 32) no working area available, falling back to slow memory writes SWD DPIDR 0x0bb11477 Failed to read memory at 0x00022fd0 Couldn't read NVMC_READY register Failed to write to nrf5 flash error writing to flash at address 0x00000000 at offset 0x00000000 embedded:startup.tcl:449: Error: Programming Failed in procedure 'program' in procedure 'program_error' called at file "embedded:startup.tcl", line 508 at file "embedded:startup.tcl", line 449
Some credits to adafruit:
https://learn.adafruit.com/programming- ... ng-openocd
Last edited by Donnydingel on Mon Jun 10, 2019 10:27 am, edited 8 times in total.
Colmar
Posts: 5
Joined: Tue Jun 04, 2019 10:39 pm

Re: Flash using Raspberry Pi 3 - Now working

Postby Colmar Tue Jun 04, 2019 10:44 pm

Could you elaborate the exact steps you did. I’m new to rasberry pi.
Donnydingel
Posts: 11
Joined: Fri Apr 12, 2019 7:02 pm

Re: Flash using Raspberry Pi 3 - Now working

Postby Donnydingel Wed Jun 05, 2019 7:34 am

Could you elaborate the exact steps you did. I’m new to rasberry pi.
Sure thing! Will do it as soon as I have some spare time.
Donnydingel
Posts: 11
Joined: Fri Apr 12, 2019 7:02 pm

Re: Flash using Raspberry Pi 3 - Now working

Postby Donnydingel Sat Jun 08, 2019 6:15 pm

Could you elaborate the exact steps you did. I’m new to rasberry pi.
Hope this will do! Look at first post.
Brix
Posts: 3
Joined: Fri Jun 07, 2019 1:10 pm

Re: Flash using Raspberry Pi 3 - GUIDE UPDATED

Postby Brix Sat Jun 08, 2019 6:31 pm

here you go.

to flash a clone dashboard add these steps

Open Telnet using this command in this new window: telnet 127.0.0.1 4444
type

init
reset halt
nrf51 mass_erase
program full_ble.bin


and done
Colmar
Posts: 5
Joined: Tue Jun 04, 2019 10:39 pm

Re: Flash using Raspberry Pi 3 - GUIDE UPDATED (Incl. clone)

Postby Colmar Tue Jun 11, 2019 5:35 am

This is awesome, thanks for writing it up. I'm going to try it out shortly!
GabrielB
Posts: 5
Joined: Wed Jun 12, 2019 8:14 pm

Re: Flash using Raspberry Pi 3 - GUIDE UPDATED (Incl. clone)

Postby GabrielB Wed Jun 12, 2019 8:34 pm

First of all: great guide!

HW:
- RPi 3 B+
- OEM Dashboard with nrf51802
Wiring:
- GPIO 24 <-> SDW_IO
- GPIO 25 <-> SDW_CLK
- 3.3V and Ground-Rail <-> 3.3V ...
SW:
- OpenOCD
- full_BLE.bin

I did follow your guide, but always run into the following error message when trying to flash it:

Code: Select all

> program full_BLE.bin target halted due to debug-request, current mode: Thread xPSR: 0xc1000000 pc: 0x000006d0 msp: 0x000007c0 ** Programming Started ** SWD DPIDR 0x0bb11477 Failed to read memory at 0x4001e400 Couldn't read NVMC_READY register Failed to erase reg: 0x4001e508 val: 0x0002b000 failed erasing sectors 0 to 255 embedded:startup.tcl:449: Error: ** Programming Failed ** in procedure 'program' in procedure 'program_error' called at file "embedded:startup.tcl", line 508 at file "embedded:startup.tcl", line 449
I even tried to convert the full_BLE.bin (Binary) to a Hex-Version. This just gave me the same error, although the "Failed to read memory at..."-Number was higher. The wiring is 100% correct and was checked with a multimeter. I also ran the Erase-commands for cloned Dashboards and checked the Status.

Code: Select all

> flash erase_check 0 not enough working area available(requested 36) Running slow fallback erase check - add working memory SWD DPIDR 0x0bb11477 Failed to read memory at 0x00025d1c embedded:startup.tcl:449: Error: unknown error when checking erase state of flash bank #0 at 0x00000000 #152: 0x00026000 (0x400 1kB) not erased #153: 0x00026400 (0x400 1kB) not erased ... #255: 0x0003fc00 (0x400 1kB) not erased in procedure 'program' in procedure 'program_error' called at file "embedded:startup.tcl", line 508 at file "embedded:startup.tcl", line 449 > flash erase_check 1 not enough working area available(requested 36) Running slow fallback erase check - add working memory successfully checked erase state Bank is erased > flash info 0 #0 : nrf51 at 0x00000000, size 0x00040000, buswidth 1, chipwidth 1 # 0: 0x00000000 (0x400 1kB) not protected ...
I'm dying to solve this problem and would appreciate any help from you guys.
Donnydingel
Posts: 11
Joined: Fri Apr 12, 2019 7:02 pm

Re: Flash using Raspberry Pi 3 - GUIDE UPDATED (Incl. clone)

Postby Donnydingel Thu Jun 13, 2019 10:15 am

First of all: great guide!

Lots of text...
All errors I got while trying to get it to work was related to bad connections. Did you solder or did you use clamps?
GabrielB
Posts: 5
Joined: Wed Jun 12, 2019 8:14 pm

Re: Flash using Raspberry Pi 3 - GUIDE UPDATED (Incl. clone)

Postby GabrielB Thu Jun 13, 2019 3:46 pm

I did solder all the connections and tested the traces from the RPi-GPIO to the microcontroller nRF51802 Pin-Outs with the continuity-check on my Multimeter.
GabrielB
Posts: 5
Joined: Wed Jun 12, 2019 8:14 pm

Re: Flash using Raspberry Pi 3 - GUIDE UPDATED (Incl. clone)

Postby GabrielB Thu Jun 13, 2019 7:08 pm

I did try it with a RPi 1 instead of 3 and it worked!!!

Return to “Ninebot ES and E-series”

Who is online

Users browsing this forum: No registered users and 57 guests