EasyDIY OpenSource display for EVs: TSDZ2 and Bafang M500/M600 EBike motors

martinn27 said:
Hello everyone, I need your help. I studied in detail the instructions on how to build this display, but I can't flash the bootloader with stlink v2 (V2.J40.S7)
I suspect that I can't get in because "Warn : target nrf52.cpu examination failed"
nrf52840 (PCA10059 , 2.1.0 , 2022.9)
I also don't know how to proceed with telnet communication and whether stlink v2 needs to be modified or is it enough if I have stock firmware
Hi Martin.

The good news is that OpenOCD seems is working well, connecting as expected to NRF52.

On Linux, I do on a terminal:

telnet localhost 4444

Then I get inside telnet and I can run OpenOCD commands. You can do "help" to get help from OpenOCD commands. Then you will see the commands for flash, erase, etc. You can also search on google but you will figure out what are the commands and parameters.

Are you building the display for TSDZ2 or Bafang?

I am developing a new version of the display, but I will only test / develop for my Bafang M500. The most important change is that it runs Pyhton firmware and uses the ESP32-S2 (first programming is done with a USBC cable, then it is wireless). It is also programmed by wireless, I can edit the Pyhton firmware file directly with my phone!! More details:

The schematic is so simple!! Only 11 wires to solder:



I already tested and it works. Early tests showing the state of POWER, UP and DOWN buttons:



Details of the build.
One connector is the display connector to the original Bafang M500 harness cable. The other round connector is to connect to the 860C display remote keypad I bought on Aliexpress:




Very clean and simple:


And now there are two wireless devices connected to my home wifi router, one device is the ESP32-S3 from the EBike board and other device is the ESP32-S2 from this display. I can select which one I want to edit the Pyhton firmware or simple open a second window to select the other board and so have access to both Python firmwares at the same time -- that screenshot is from my phone! I am really amazed to have such advanced technology!!



In the same spirit of the DIY display, I am building a DIY EBike electronics. The motor controller is the popular, high performance and OpenSource VESC. Then I add a ESP32-S3 board to run the EBike application, that is also Pyhton code. Again, I can also program the EBike board using wireless, with my phone or PC.

Here is an example of a small VESC that will be installed inside my motor + the EBike board:

Luckily, the ESP32-S3 board I use, can be placed on top of this VESC and the VESC connectors will still be accessible:


And also, all this are ok to go inside - I just hope wifi will still working with board on that place:
 
Hi y'all,
today I attempted to make Casainho's open source display for the second time (the last one released magic smoke due to sloppy probing around DC-DC converter), after flashing the bootloader I wanted to DFU flash "firmware_ota-TSDZ2-OLED_0.96_I2C-0.20.0.zip" from the NRF connect app, however I didn't get the confirmation or the upload graph like in the case of the last attempt. I tried to connect multiple times to initiate DFU flash again but NRF connect couldn't find my NRF52. I also wanted to flash a fresh bootloader just in case, but openocd couldn't connect to the target, wanting to move on I thought that maybe the firmware was flashed successfully nevertheless.

However after I finished assembly I powered the board up from 12V 1A power supply (In place of Battery_VIN), I was met with black screen and no sign of life from the NRF52 (none that I could measure). Later I tried to power on the NRF52 only, to try to flash a new bootloader but without success.

I think that the initial failure to finish DFU flash was due to my previous power supply which consisted of 2x 9V batteries in series (I thought that for a quick test and flash it will be fine), and they couldn't supply enough current. Or maybe my cheap 0,96" OLED has some weird driver (I already ordered, a 1.3" OLED to test).

I searched for some answers on other forums, but couldn't find anything relevant enough, I will dig some more tho.

I will be very thankful for any suggestions.
 
martinn27 said:
Hello everyone, I need your help. I studied in detail the instructions on how to build this display, but I can't flash the bootloader with stlink v2 (V2.J40.S7)
I suspect that I can't get in because "Warn : target nrf52.cpu examination failed"
nrf52840 (PCA10059 , 2.1.0 , 2022.9)
I also don't know how to proceed with telnet communication and whether stlink v2 needs to be modified or is it enough if I have stock firmware

Hey Martin27,
I don't know if I will be of much help, because I faced a similar issue like you, both on linux and windows, however I finally resolved it on linux. In case it is useful to somebody I will list what helped me:

Linux Mint 20
Don't install openocd from apt (at least on linuxmint) it is a version from 2017.
-instead pull the most recent one from github in to the exp. "~/" directory
-go into the newly created directory in terminal: "cd /openocd"
-"./bootstrap"
-"./configure --prefix=/Your-path/openocd-git_install --enable-aice --enable-amtjtagaccel --enable-armjtagew --enable-cmsis-dap --enable-dummy --enable-ftdi --enable-gw16012 --enable-jlink --enable-jtag_vpi --enable-opendous --enable-openjtag_ftdi --enable-osbdm --enable-legacy-ft2232_libftdi --enable-parport --disable-parport-ppdev --enable-parport-giveio --enable-presto_libftdi --enable-remote-bitbang --enable-rlink --enable-stlink --enable-ti-icdi --enable-ulink --enable-usb-blaster-2 --enable-usb_blaster_libftdi --enable-usbprog --enable-vsllink"
-"make"
-"make install"
-if you encounter any errors like: "configure: error: libjaylink-0.2 is required for the SEGGER J-Link Programmer" or "configure: error: hidapi is required for the CMSIS-DAP Compliant Debugger"
-clone them as well: "git clone https://gitlab.zapb.de/libjaylink/libjaylink.git", "sudo apt install libhidapi-dev",
-libjaylink: "cd" (go to home directory), "cd libjaylink/" (go into newly created libjaylink directory), "./autogen.sh", "./configure", "make", "make install"
-hidapi: sudo apt install libhidapi-dev

Congratulations!!! you just installed the newest openocd version! Now of to the flashing the board.

-go to the home directory "cd"
-go to the openocd directory "cd /openocd"
-sudo openocd -f tcl/interface/stlink-dap.cfg -f tcl/target/nrf52.cfg
-You are connected if you get something like this:
Code:
Open On-Chip Debugger 0.12.0+dev-00040-gcda39f929 (2023-01-16-15:51)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "dapdirect_swd". To override use 'transport select <transport>'.
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : STLINK V2J29S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 2.490828
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Info : stlink_dap_op_connect(connect)
Info : SWD DPIDR 0x2ba01477

-now open new terminal window (ctrl+alt+t) and type:
-"sudo telnet localhost 4444"
-"reset init"
-"nrf52_recover"
-"halt"
-"nrf52.dap apreg 1 0x04 0x01"
-"nrf5 mass_erase"
-"program replace_with_directory_to/bootloader.hex verify"
-"reset exit"
-"exit"

Example of bootloader location: "Downloads/bootloader.hex"
Link to bootloader.hex: https://github.com/OpenSourceEBike/ev_display_bluetooth_ant/releases (scroll down and open oldest release)
Congratulations!!! Now you should be a proud owner of freshly flashed NRF52, of to soldering...

Take these tips with a huge grain of salt, what I just wrote is just a compilation of many forum post all around the internet and an effect of 4hrs of work of an maniac high on solder fumes. Also please excuse any errors and form I wrote, make yourself welcome to correct any of my inaccuracies and mistakes.

That being said I hope that I could at least steer somebody to solution that they need,
Cheers!
 
Hi all!

I recently built this display using a 1.3'' SPI display with SHH1106 chip and the latest firmware doesn't work, just black screen.

I then tried the v0.10.0, which worked fine, except for the 2 pixel shift. After much trial and error I managed to compile new version that had the correct byte changed from 0 to 2 to fix the pixel shift.

Just letting you know that v0.20.0 doesn't work with SHH1106 chips.
I had the same issue. Today I finally had a chance to sit down on it, and found the cause.
The cause of blank screen on 0.20.0 version for TSDZ2 (1.3 inch SPI) is that the RS pin has been changed. On the schematics and in version 0.10.0 it is on P1.15, but in version 0.20.0 it is on the P0.10.

I tried to fix this by adding #ifdef in pins.h file, but it looks like TSDZ2 is not defined when the TSDZ2 motor is selected!
It looks like more serious problem with the code. I suppose TSDZ2 with version 0.20.0 will not work at all at this stage.

@casainho I think you shouldn't have released a software version for the same project, that is not compatible with the old hardware. Or you should have mentioned it clearly along with the download files. But the best would have been to release version 0.10.1 that just fixes the 2-pixel offset. Because now there is not a single official release that works fine on TSDZ2 with the 1.3 inch SPI display.

Also I can see the repository is now archived. Does that mean there won't be further updates? It's very sad this project died without even one fully working software.

EDIT: I probably managed to fix the blank display and missing "TSDZ2" define issues in the 0.20.0, but I'm not able to test it yet (I will in a week or so). I pushed the changes to my fork of the repo. I will post the link to it if @casainho doesn't mind.
 
Last edited:
I finally assembled the display and installed it on my TSDZ2 ebike. It seems to work fine, but I haven't got it outside yet.

@casainho, I have some questions about the display configuration. I tried some button combination that didn't work. Then I found out that I need an app, so I found the EBike wireless Android app (it wasn't easy to find, perhaps you should mention it with links on the display manual pages). Now I'm trying to connect to the display using the app, but it won't find the display (the display is powered on of course). Am I doing this right? Is the app supposed to connect to the DIY display? The display does not even show in my phone's BT devices (bootloader does, and I can DFU without problems, so the BT is fine).

Is there anyone else who built the display and could hint me on how to configure the thing?
 
@casainho I looked at the code, and I can see the ble_init function, that has almost everything disabled. The only enabled line is ble_stack_init, which also has almostall of it disabled. Does BT actually work in this software? I am using EV_Display_Bluetooth_Ant repository, which is now archived. The link in readme points to EBike_EScooter_modular_DIY, but I couldn't find the software for nRF board there. I guess it's not for the same display hardware?

Is there any software version for the display and TSDZ2, that actually works with BT?
I can see the version 0.10.0 has the BLE code enabled. Does BT work with version 0.10.0? Are there important changes between 0.20.0 and 0.10.0 that make using 0.10.0 for riding not recommended?
 
Hey Martin27,
I don't know if I will be of much help, because I faced a similar issue like you, both on linux and windows, however I finally resolved it on linux. In case it is useful to somebody I will list what helped me:

Linux Mint 20
Don't install openocd from apt (at least on linuxmint) it is a version from 2017.
-instead pull the most recent one from github in to the exp. "~/" directory
-go into the newly created directory in terminal: "cd /openocd"
-"./bootstrap"
-"./configure --prefix=/Your-path/openocd-git_install --enable-aice --enable-amtjtagaccel --enable-armjtagew --enable-cmsis-dap --enable-dummy --enable-ftdi --enable-gw16012 --enable-jlink --enable-jtag_vpi --enable-opendous --enable-openjtag_ftdi --enable-osbdm --enable-legacy-ft2232_libftdi --enable-parport --disable-parport-ppdev --enable-parport-giveio --enable-presto_libftdi --enable-remote-bitbang --enable-rlink --enable-stlink --enable-ti-icdi --enable-ulink --enable-usb-blaster-2 --enable-usb_blaster_libftdi --enable-usbprog --enable-vsllink"
-"make"
-"make install"
-if you encounter any errors like: "configure: error: libjaylink-0.2 is required for the SEGGER J-Link Programmer" or "configure: error: hidapi is required for the CMSIS-DAP Compliant Debugger"
-clone them as well: "git clone libjaylink / libjaylink · GitLab", "sudo apt install libhidapi-dev",
-libjaylink: "cd" (go to home directory), "cd libjaylink/" (go into newly created libjaylink directory), "./autogen.sh", "./configure", "make", "make install"
-hidapi: sudo apt install libhidapi-dev

Congratulations!!! you just installed the newest openocd version! Now of to the flashing the board.

-go to the home directory "cd"
-go to the openocd directory "cd /openocd"
-sudo openocd -f tcl/interface/stlink-dap.cfg -f tcl/target/nrf52.cfg
-You are connected if you get something like this:
Code:
Open On-Chip Debugger 0.12.0+dev-00040-gcda39f929 (2023-01-16-15:51)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "dapdirect_swd". To override use 'transport select <transport>'.
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : STLINK V2J29S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 2.490828
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Info : stlink_dap_op_connect(connect)
Info : SWD DPIDR 0x2ba01477

-now open new terminal window (ctrl+alt+t) and type:
-"sudo telnet localhost 4444"
-"reset init"
-"nrf52_recover"
-"halt"
-"nrf52.dap apreg 1 0x04 0x01"
-"nrf5 mass_erase"
-"program replace_with_directory_to/bootloader.hex verify"
-"reset exit"
-"exit"

Example of bootloader location: "Downloads/bootloader.hex"
Link to bootloader.hex: Releases · OpenSourceEBike/EV_Display_Bluetooth_Ant (scroll down and open oldest release)
Congratulations!!! Now you should be a proud owner of freshly flashed NRF52, of to soldering...

Take these tips with a huge grain of salt, what I just wrote is just a compilation of many forum post all around the internet and an effect of 4hrs of work of an maniac high on solder fumes. Also please excuse any errors and form I wrote, make yourself welcome to correct any of my inaccuracies and mistakes.

That being said I hope that I could at least steer somebody to solution that they need,
Cheers!
Hey Martin27,
I don't know if I will be of much help, because I faced a similar issue like you, both on linux and windows, however I finally resolved it on linux. In case it is useful to somebody I will list what helped me:

Linux Mint 20
Don't install openocd from apt (at least on linuxmint) it is a version from 2017.
-instead pull the most recent one from github in to the exp. "~/" directory
-go into the newly created directory in terminal: "cd /openocd"
-"./bootstrap"
-"./configure --prefix=/Your-path/openocd-git_install --enable-aice --enable-amtjtagaccel --enable-armjtagew --enable-cmsis-dap --enable-dummy --enable-ftdi --enable-gw16012 --enable-jlink --enable-jtag_vpi --enable-opendous --enable-openjtag_ftdi --enable-osbdm --enable-legacy-ft2232_libftdi --enable-parport --disable-parport-ppdev --enable-parport-giveio --enable-presto_libftdi --enable-remote-bitbang --enable-rlink --enable-stlink --enable-ti-icdi --enable-ulink --enable-usb-blaster-2 --enable-usb_blaster_libftdi --enable-usbprog --enable-vsllink"
-"make"
-"make install"
-if you encounter any errors like: "configure: error: libjaylink-0.2 is required for the SEGGER J-Link Programmer" or "configure: error: hidapi is required for the CMSIS-DAP Compliant Debugger"
-clone them as well: "git clone libjaylink / libjaylink · GitLab", "sudo apt install libhidapi-dev",
-libjaylink: "cd" (go to home directory), "cd libjaylink/" (go into newly created libjaylink directory), "./autogen.sh", "./configure", "make", "make install"
-hidapi: sudo apt install libhidapi-dev

Congratulations!!! you just installed the newest openocd version! Now of to the flashing the board.

-go to the home directory "cd"
-go to the openocd directory "cd /openocd"
-sudo openocd -f tcl/interface/stlink-dap.cfg -f tcl/target/nrf52.cfg
-You are connected if you get something like this:
Code:
Open On-Chip Debugger 0.12.0+dev-00040-gcda39f929 (2023-01-16-15:51)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "dapdirect_swd". To override use 'transport select <transport>'.
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : STLINK V2J29S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 2.490828
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Info : stlink_dap_op_connect(connect)
Info : SWD DPIDR 0x2ba01477

-now open new terminal window (ctrl+alt+t) and type:
-"sudo telnet localhost 4444"
-"reset init"
-"nrf52_recover"
-"halt"
-"nrf52.dap apreg 1 0x04 0x01"
-"nrf5 mass_erase"
-"program replace_with_directory_to/bootloader.hex verify"
-"reset exit"
-"exit"

Example of bootloader location: "Downloads/bootloader.hex"
Link to bootloader.hex: Releases · OpenSourceEBike/EV_Display_Bluetooth_Ant (scroll down and open oldest release)
Congratulations!!! Now you should be a proud owner of freshly flashed NRF52, of to soldering...

Take these tips with a huge grain of salt, what I just wrote is just a compilation of many forum post all around the internet and an effect of 4hrs of work of an maniac high on solder fumes. Also please excuse any errors and form I wrote, make yourself welcome to correct any of my inaccuracies and mistakes.

That being said I hope that I could at least steer somebody to solution that they need,
Cheers!
I've got many problems with flashing nrf52 with st link, I used jlink edu mini and cabel tc2050 10 pin, I used nrf programmer, just turn on mcu mode ad its working fine even in versions with approtect. Te easiest way to flash and ddownloadfiles
 
Hi y'all,
today I attempted to make Casainho's open source display for the second time (the last one released magic smoke due to sloppy probing around DC-DC converter), after flashing the bootloader I wanted to DFU flash "firmware_ota-TSDZ2-OLED_0.96_I2C-0.20.0.zip" from the NRF connect app, however I didn't get the confirmation or the upload graph like in the case of the last attempt. I tried to connect multiple times to initiate DFU flash again but NRF connect couldn't find my NRF52. I also wanted to flash a fresh bootloader just in case, but openocd couldn't connect to the target, wanting to move on I thought that maybe the firmware was flashed successfully nevertheless.

However after I finished assembly I powered the board up from 12V 1A power supply (In place of Battery_VIN), I was met with black screen and no sign of life from the NRF52 (none that I could measure). Later I tried to power on the NRF52 only, to try to flash a new bootloader but without success.

I think that the initial failure to finish DFU flash was due to my previous power supply which consisted of 2x 9V batteries in series (I thought that for a quick test and flash it will be fine), and they couldn't supply enough current. Or maybe my cheap 0,96" OLED has some weird driver (I already ordered, a 1.3" OLED to test).

I searched for some answers on other forums, but couldn't find anything relevant enough, I will dig some more tho.

I will be very thankful for any suggestions.
I had a similar problem, check it with an electric meter whether, maybe you have a break somewhere between the pins on nrf52840 and/or on the board. I had a minor puncture, when I corrected it everything started working. Alternatively, try uploading the files again and starting the dfu procedure again. It also didn't work on one phone and on the other it did.
 
Back
Top