TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Discussions related to motors other than hub motors.
This includes R/C motors, botttom bracket, roller and geared drives.
bobreece20   1 mW

1 mW
Posts: 18
Joined: Jun 19 2020 11:10am

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by bobreece20 » Jul 10 2020 3:33am

Finally got around to soldering pins onto my dongle for the STLink, my dongle is one of the blue ones (i.e. https://uk.farnell.com/nordic-semicondu ... dp/2902521) which appears to have a completely different pinout to the ones used in the schematics (can't seem to source the MDK version in the UK unless I wait for chinese shipping). It has a built in reset button but I couldn't find the RST pin exposed on the board so left that off when flashing and as a result the "NRF52 Flash and Debug" doesn't function correctly. To get it to work I have to "NRF52 Flash and Debug", wait for it to finish flashing, stop it, manually hit the reset button on the board and then run "NRF52 Debug".

casainho   10 GW

10 GW
Posts: 4496
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by casainho » Jul 10 2020 3:57am

bobreece20 wrote:
Jul 10 2020 3:33am
Finally got around to soldering pins onto my dongle for the STLink, my dongle is one of the blue ones (i.e. https://uk.farnell.com/nordic-semicondu ... dp/2902521) which appears to have a completely different pinout to the ones used in the schematics (can't seem to source the MDK version in the UK unless I wait for chinese shipping). It has a built in reset button but I couldn't find the RST pin exposed on the board so left that off when flashing and as a result the "NRF52 Flash and Debug" doesn't function correctly. To get it to work I have to "NRF52 Flash and Debug", wait for it to finish flashing, stop it, manually hit the reset button on the board and then run "NRF52 Debug".
That boards on that site, costs to me 23€ while the one from China costs to me 16€ - this including the shipping costs. So, the difference is not that much. Maybe we should make that board as an option on the wiki documentation.

And the ANT+ firmware is not working for me... it always disconnect but the Edge and SimulANT always receive 1 data package and then 7 wrong RX fail and then again a correct package. The firmware seems to not be resetting and even every data package seem to have the correct data format for what I see on the SimulANT. I need to solve this issue....
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless Ebike boar ANT+ and Bluetooth, Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation to help my developments: paypal.me/jorgecasa

bobreece20   1 mW

1 mW
Posts: 18
Joined: Jun 19 2020 11:10am

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by bobreece20 » Jul 10 2020 4:22am

casainho wrote:
Jul 10 2020 3:57am
bobreece20 wrote:
Jul 10 2020 3:33am
Finally got around to soldering pins onto my dongle for the STLink, my dongle is one of the blue ones (i.e. https://uk.farnell.com/nordic-semicondu ... dp/2902521) which appears to have a completely different pinout to the ones used in the schematics (can't seem to source the MDK version in the UK unless I wait for chinese shipping). It has a built in reset button but I couldn't find the RST pin exposed on the board so left that off when flashing and as a result the "NRF52 Flash and Debug" doesn't function correctly. To get it to work I have to "NRF52 Flash and Debug", wait for it to finish flashing, stop it, manually hit the reset button on the board and then run "NRF52 Debug".
That boards on that site, costs to me 23€ while the one from China costs to me 16€ - this including the shipping costs. So, the difference is not that much. Maybe we should make that board as an option on the wiki documentation.

And the ANT+ firmware is not working for me... it always disconnect but the Edge and SimulANT always receive 1 data package and then 7 wrong RX fail and then again a correct package. The firmware seems to not be resetting and even every data package seem to have the correct data format for what I see on the SimulANT. I need to solve this issue....
I'm fairly familiar with KiCad so when I get a spare moment I'll check out the pins and generate a new schematic for the blue dongle. Will probably also commit a footprint file for it too ready for pcb design

casainho   10 GW

10 GW
Posts: 4496
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by casainho » Jul 10 2020 4:44am

bobreece20 wrote:
Jul 10 2020 4:22am
I'm fairly familiar with KiCad so when I get a spare moment I'll check out the pins and generate a new schematic for the blue dongle. Will probably also commit a footprint file for it too ready for pcb design
I think would be better to have only one schematic with clearly indication that user could use one or the other board - or maybe this could clutter to much the schematic? - because I wish to have the most simple and clean one, so users would not be afraid when see it - we need the bare minimum schematic and with clear wiring.

I got mine BTS4140N and I need to solder and test it... But my focus is on the ANT+ LEV now...
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless Ebike boar ANT+ and Bluetooth, Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation to help my developments: paypal.me/jorgecasa

bobreece20   1 mW

1 mW
Posts: 18
Joined: Jun 19 2020 11:10am

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by bobreece20 » Jul 10 2020 5:18am

casainho wrote:
Jul 10 2020 4:44am
I think would be better to have only one schematic with clearly indication that user could use one or the other board - or maybe this could clutter to much the schematic? - because I wish to have the most simple and clean one, so users would not be afraid when see it - we need the bare minimum schematic and with clear wiring.

I got mine BTS4140N and I need to solder and test it... But my focus is on the ANT+ LEV now...
Guess it's worth doing some experimentation with labels to see if we can have alternative boards much like we have alternative motor cables and then seeing how messy the schematic is

bobreece20   1 mW

1 mW
Posts: 18
Joined: Jun 19 2020 11:10am

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by bobreece20 » Jul 10 2020 6:06am

bobreece20 wrote:
Jul 10 2020 3:33am
Finally got around to soldering pins onto my dongle for the STLink, my dongle is one of the blue ones (i.e. https://uk.farnell.com/nordic-semicondu ... dp/2902521) which appears to have a completely different pinout to the ones used in the schematics (can't seem to source the MDK version in the UK unless I wait for chinese shipping). It has a built in reset button but I couldn't find the RST pin exposed on the board so left that off when flashing and as a result the "NRF52 Flash and Debug" doesn't function correctly. To get it to work I have to "NRF52 Flash and Debug", wait for it to finish flashing, stop it, manually hit the reset button on the board and then run "NRF52 Debug".
Turns out I was actually wrong about this, can only debug if I've flashed it via nRF Connect (even hooking up RST via the button doesn't work). The debug information appears to show it flashing correctly (and verifying it also shows its correct). I also verified after using nRFConnect and both show the addresses it is checking as correct so there must be something outside the hex file that openocd is changing which break it.
Also once I've flashed with openocd and then plug in via USB it boots straight to the programming mode so something isn't quite right.

Code: Select all

Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 10000 kHz
Info : Unable to match requested speed 10000 kHz, using 4000 kHz
Info : Unable to match requested speed 10000 kHz, using 4000 kHz
Info : clock speed 4000 kHz
Info : STLINK v2 JTAG v29 API v2 SWIM v7 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.123245
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : accepting 'gdb' connection on tcp/3333
Warn : Unknown device (HWID 0x0000015b)
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000a80 msp: 0x20000400
auto erase enabled
Info : Padding image section 0 with 1280 bytes
Info : Padding image section 1 with 6336 bytes
Warn : using fast async flash loader. This is currently supported
Warn : only with ST-Link and CMSIS-DAP. If you have issues, add
Warn : "set WORKAREASIZE 0" before sourcing nrf51.cfg to disable it
target halted due to breakpoint, current mode: Thread 
xPSR: 0x61000000 pc: 0x2000001e msp: 0x20000400
wrote 225280 bytes from file /home/bob/workspace/NRF52840/TSDZ2_wireless/firmware/_build/TSDZ2_wireless_with_SD.hex in 6.423690s (34.248 KiB/s)
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000a80 msp: 0x20000400

Code: Select all

1: (232) LaunchOptions<LocalLaunchOptions xmlns='http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014'
1: (256) LaunchOptions  ExePath='/home/bob/workspace/NRF52840/TSDZ2_wireless/firmware/_build/TSDZ2_wireless.out'
1: (256) LaunchOptions  WorkingDirectory='/home/bob/workspace/NRF52840/TSDZ2_wireless/firmware'
1: (256) LaunchOptions  TargetArchitecture='arm'
1: (256) LaunchOptions  ExeArguments=''
1: (256) LaunchOptions  MIMode='gdb'
1: (256) LaunchOptions  MIDebuggerPath='gdb-multiarch'
1: (256) LaunchOptions  WaitDynamicLibLoad='false'
1: (256) LaunchOptions  MIDebuggerServerAddress='localhost:3333'
1: (257) LaunchOptions>
1: (257) LaunchOptions    <CustomLaunchSetupCommands>
1: (257) LaunchOptions        <Command IgnoreFailures='false' Description='Set remote target'>file /home/bob/workspace/NRF52840/TSDZ2_wireless/firmware/_build/TSDZ2_wireless.out</Command>
1: (257) LaunchOptions        <Command IgnoreFailures='false' Description='Set remote target'>target remote localhost:3333</Command>
1: (257) LaunchOptions        <Command IgnoreFailures='false' Description=''>monitor init</Command>
1: (257) LaunchOptions        <Command IgnoreFailures='false' Description=''>monitor reset init</Command>
1: (257) LaunchOptions        <Command IgnoreFailures='false' Description='Flash firmware'>monitor flash write_image erase /home/bob/workspace/NRF52840/TSDZ2_wireless/firmware/_build/TSDZ2_wireless_with_SD.hex</Command>
1: (258) LaunchOptions        <Command IgnoreFailures='false' Description='Start debug'>monitor reset halt</Command>
1: (258) LaunchOptions    </CustomLaunchSetupCommands>
1: (258) LaunchOptions</LocalLaunchOptions>
1: (480) Starting: "/usr/bin/gdb-multiarch" --interpreter=mi
1: (508) DebuggerPid=14779
1: (644) ->=thread-group-added,id="i1"
1: (647) ->~"GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git\n"
1: (648) ->~"Copyright (C) 2018 Free Software Foundation, Inc.\n"
1: (648) ->~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\n"
1: (649) ->~"This GDB was configured as \"x86_64-linux-gnu\".\nType \"show configuration\" for configuration details."
1: (649) ->~"\nFor bug reporting instructions, please see:\n"
1: (649) ->~"<http://www.gnu.org/software/gdb/bugs/>.\n"
1: (649) ->~"Find the GDB manual and other documentation resources online at:\n<http://www.gnu.org/software/gdb/documentation/>.\n"
1: (649) ->~"For help, type \"help\".\n"
1: (649) ->~"Type \"apropos word\" to search for commands related to \"word\".\n"
1: (650) ->(gdb)
1: (660) <-1001-gdb-set target-async on
1: (660) ->1001^done
1: (661) ->(gdb)
1: (664) 1001: elapsed time 6
1: (686) <-1002-interpreter-exec console "set pagination off"
1: (686) ->=cmd-param-changed,param="pagination",value="off"
1: (687) ->1002^done
1: (687) ->(gdb)
1: (687) 1002: elapsed time 1
1: (687) <-1003-gdb-set auto-solib-add on
1: (688) ->1003^done
1: (688) ->(gdb)
1: (688) 1003: elapsed time 0
1: (688) <-1004-gdb-set solib-search-path /home/bob/workspace/NRF52840/TSDZ2_wireless/firmware/_build:
1: (689) ->1004^done
1: (689) ->(gdb)
1: (689) 1004: elapsed time 0
1: (691) <-1005-interpreter-exec console "file /home/bob/workspace/NRF52840/TSDZ2_wireless/firmware/_build/TSDZ2_wireless.out"
1: (693) ->~"Reading symbols from /home/bob/workspace/NRF52840/TSDZ2_wireless/firmware/_build/TSDZ2_wireless.out..."
1: (701) ->~"done.\n"
1: (714) ->1005^done
1: (714) ->(gdb)
1: (714) 1005: elapsed time 22
1: (715) <-1006-interpreter-exec console "target remote localhost:3333"
1: (716) ->~"Remote debugging using localhost:3333\n"
1: (722) ->=thread-group-started,id="i1",pid="42000"
1: (723) ->=thread-created,id="1",group-id="i1"
1: (746) ->~"0x000e5aae in ?? ()\n"
1: (747) ->*stopped,frame={addr="0x000e5aae",func="??",args=[]},thread-id="1",stopped-threads="all"
1: (747) ->1006^done
1: (747) ->(gdb)
1: (755) 1006: elapsed time 40
1: (756) <-1007-thread-info 1
1: (757) ->1007^done,threads=[{id="1",target-id="Remote target",frame={level="0",addr="0x000e5aae",func="??",args=[]},state="stopped"}]
1: (757) ->(gdb)
1: (759) 1007: elapsed time 3
1: (760) <-1008-interpreter-exec console "monitor init"
1: (762) ->1008^done
1: (762) ->(gdb)
1: (767) 1008: elapsed time 6
1: (767) <-1009-interpreter-exec console "monitor reset init"
1: (817) ->@"target halted due to debug-request, current mode: Thread \n"
1: (817) ->@"xPSR: 0x01000000 pc: 0x00000a80 msp: 0x20000400\n"
1: (819) ->1009^done
1: (820) ->(gdb)
1: (820) 1009: elapsed time 52
1: (820) <-1010-interpreter-exec console "monitor flash write_image erase /home/bob/workspace/NRF52840/TSDZ2_wireless/firmware/_build/TSDZ2_wireless_with_SD.hex"
1: (822) ->@"auto erase enabled\n"
1: (865) ->@"Padding image section 0 with 1280 bytes\n"
1: (865) ->@"Padding image section 1 with 6336 bytes\n"
1: (5712) ->@"using fast async flash loader. This is currently supported\n"
1: (5712) ->@"only with ST-Link and CMSIS-DAP. If you have issues, add\n"
1: (5712) ->@"\"set WORKAREASIZE 0\" before sourcing nrf51.cfg to disable it\n"
1: (7243) ->@"target halted due to breakpoint, current mode: Thread \n"
1: (7243) ->@"xPSR: 0x61000000 pc: 0x2000001e msp: 0x20000400\n"
1: (7246) ->@"wrote 225280 bytes from file /home/bob/workspace/NRF52840/TSDZ2_wireless/firmware/_build/TSDZ2_wireless_with_SD.hex in 6.423690s (34.248 KiB/s)\n"
1: (7247) ->1010^done
1: (7247) ->(gdb)
1: (7248) 1010: elapsed time 6427
1: (7248) <-1011-interpreter-exec console "monitor reset halt"
1: (7297) ->@"target halted due to debug-request, current mode: Thread \n"
1: (7298) ->@"xPSR: 0x01000000 pc: 0x00000a80 msp: 0x20000400\n"
1: (7299) ->1011^done
1: (7299) ->(gdb)
1: (7299) 1011: elapsed time 51
1: (7317) Send Event AD7EngineCreateEvent
1: (7321) Send Event AD7ProgramCreateEvent
<--   C (setFunctionBreakpoints-3): {"command":"setFunctionBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":3}
<--   C (configurationDone-4): {"command":"configurationDone","type":"request","seq":4}
1: (7400) Send Event AD7LoadCompleteEvent
=thread-group-added,id="i1"
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
=cmd-param-changed,param="pagination",value="off"
<--   C (threads-5): {"command":"threads","type":"request","seq":5}
1: (7454) <-1012-thread-info
1: (7455) ->1012^done,threads=[{id="1",target-id="Remote target",frame={level="0",addr="0x000e5aae",func="??",args=[]},state="stopped"}],current-thread-id="1"
1: (7455) ->(gdb)
1: (7458) 1012: elapsed time 3
1: (7481) <-1013-stack-list-frames 0 1000
1: (7507) ->1013^done,stack=[frame={level="0",addr="0x000e5aae",func="??"},frame={level="1",addr="0x000e5a9c",func="??"}]
1: (7507) ->(gdb)
1: (7507) 1013: elapsed time 26
1: (7511) Send Event AD7ProcessInfoUpdatedEvent
1: (7512) Send Event AD7ThreadCreateEvent
1: (7526) <--exec-continue
1: (7527) ->^running
1: (7527) ->*running,thread-id="all"
1: (7528) ->(gdb)
<--   C (threads-6): {"command":"threads","type":"request","seq":6}
<--   C (pause-7): {"command":"pause","arguments":{"threadId":-2},"type":"request","seq":7}
1: (44854) <-1014-exec-interrupt
1: (44855) ->1014^done
1: (44856) ->(gdb)
1: (44856) 1014: elapsed time 1
1: (44996) ->~"\nProgram"
1: (44997) ->~" received signal SIGINT, Interrupt.\n"

Program received signal SIGINT, Interrupt.
1: (45012) ->~"0x000e5aae in ?? ()\n"
0x000e5aae in ?? ()
1: (45013) ->*stopped,reason="signal-received",signal-name="SIGINT",signal-meaning="Interrupt",frame={addr="0x000e5aae",func="??",args=[]},thread-id="1",stopped-threads="all"
1: (45013) <-1015-stack-list-frames 0 1000
1: (45041) ->1015^done,stack=[frame={level="0",addr="0x000e5aae",func="??"},frame={level="1",addr="0x000e5a9c",func="??"}]
1: (45042) ->(gdb)
1: (45042) 1015: elapsed time 29
1: (45043) Send Event AD7AsyncBreakCompleteEvent
Execute debugger commands using "-exec <command>", for example "-exec info registers" will list registers in use (when GDB is the debugger)
1: (45049) Send Event AD7StopCompleteEvent
<--   C (threads-8): {"command":"threads","type":"request","seq":8}
<--   C (stackTrace-9): {"command":"stackTrace","arguments":{"threadId":-2,"startFrame":0,"levels":20},"type":"request","seq":9}
1: (45095) <-1016-stack-list-arguments 0 0 0
1: (45095) ->1016^done,stack-args=[frame={level="0",args=[]}]
1: (45096) ->(gdb)
1: (45098) 1016: elapsed time 3
<--   C (stackTrace-10): {"command":"stackTrace","arguments":{"threadId":-2,"startFrame":0,"levels":20},"type":"request","seq":10}
<--   C (next-11): {"command":"next","arguments":{"threadId":-2},"type":"request","seq":11}
1: (51674) <-1017-exec-next
1: (51675) ->1017^error,msg="Cannot find bounds of current function"
1: (51675) ->(gdb)
1: (51677) 1017: elapsed time 2
1: (51688) Send Event AD7MessageEvent
ERROR: Unexpected GDB output from command "-exec-next". Cannot find bounds of current function

casainho   10 GW

10 GW
Posts: 4496
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by casainho » Jul 10 2020 8:42am

bobreece20 wrote:
Jul 10 2020 6:06am
Turns out I was actually wrong about this, can only debug if I've flashed it via nRF Connect (even hooking up RST via the button doesn't work). The debug information appears to show it flashing correctly (and verifying it also shows its correct). I also verified after using nRFConnect and both show the addresses it is checking as correct so there must be something outside the hex file that openocd is changing which break it.
Also once I've flashed with openocd and then plug in via USB it boots straight to the programming mode so something isn't quite right.
I am only using OpenOCD and it works as expected. Here my log of OpenOCD:

Code: Select all

> Executing task: openocd -f /home/cas/OpenSource-EBike-firmware/TSDZ2_wireless/firmware/tools/openocd-v0.10.0-scripts/stlink-v2.cfg -f /home/cas/OpenSource-EBike-firmware/TSDZ2_wireless/firmware/tools/openocd-v0.10.0-scripts/nrf52.cfg <

Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 10000 kHz
Info : Unable to match requested speed 10000 kHz, using 4000 kHz
Info : Unable to match requested speed 10000 kHz, using 4000 kHz
Info : clock speed 4000 kHz
Info : STLINK v2 JTAG v29 API v2 SWIM v7 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.172721
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : accepting 'gdb' connection on tcp/3333
Warn : Unknown device (HWID 0x0000015b)
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000a80 msp: 0x20000400
auto erase enabled
Info : Padding image section 0 with 1280 bytes
Info : Padding image section 1 with 6336 bytes
Warn : using fast async flash loader. This is currently supported
Warn : only with ST-Link and CMSIS-DAP. If you have issues, add
Warn : "set WORKAREASIZE 0" before sourcing nrf51.cfg to disable it
target halted due to breakpoint, current mode: Thread 
xPSR: 0x61000000 pc: 0x2000001e msp: 0x20000400
wrote 233472 bytes from file /home/cas/OpenSource-EBike-firmware/TSDZ2_wireless/firmware/_build/TSDZ2_wireless_with_SD.hex in 6.684961s (34.106 KiB/s)
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000a80 msp: 0x20000400
And the debug console log:

Code: Select all

1: (266) LaunchOptions<LocalLaunchOptions xmlns='http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014'
1: (303) LaunchOptions  ExePath='/home/cas/OpenSource-EBike-firmware/TSDZ2_wireless/firmware/_build/TSDZ2_wireless.out'
1: (303) LaunchOptions  WorkingDirectory='/home/cas/OpenSource-EBike-firmware/TSDZ2_wireless/firmware'
1: (303) LaunchOptions  TargetArchitecture='arm'
1: (303) LaunchOptions  ExeArguments=''
1: (303) LaunchOptions  MIMode='gdb'
1: (303) LaunchOptions  MIDebuggerPath='gdb-multiarch'
1: (303) LaunchOptions  WaitDynamicLibLoad='false'
1: (304) LaunchOptions  MIDebuggerServerAddress='localhost:3333'
1: (304) LaunchOptions>
1: (304) LaunchOptions    <CustomLaunchSetupCommands>
1: (304) LaunchOptions        <Command IgnoreFailures='false' Description='Set remote target'>file /home/cas/OpenSource-EBike-firmware/TSDZ2_wireless/firmware/_build/TSDZ2_wireless.out</Command>
1: (304) LaunchOptions        <Command IgnoreFailures='false' Description='Set remote target'>target remote localhost:3333</Command>
1: (304) LaunchOptions        <Command IgnoreFailures='false' Description=''>monitor init</Command>
1: (304) LaunchOptions        <Command IgnoreFailures='false' Description=''>monitor reset init</Command>
1: (304) LaunchOptions        <Command IgnoreFailures='false' Description='Flash firmware'>monitor flash write_image erase /home/cas/OpenSource-EBike-firmware/TSDZ2_wireless/firmware/_build/TSDZ2_wireless_with_SD.hex</Command>
1: (304) LaunchOptions        <Command IgnoreFailures='false' Description='Start debug'>monitor reset halt</Command>
1: (304) LaunchOptions    </CustomLaunchSetupCommands>
1: (305) LaunchOptions</LocalLaunchOptions>
1: (505) Starting: "/usr/bin/gdb-multiarch" --interpreter=mi
1: (541) DebuggerPid=17216
1: (608) ->=thread-group-added,id="i1"
1: (613) ->~"GNU gdb (Ubuntu 9.1-0ubuntu1) 9.1\n"
1: (614) ->~"Copyright (C) 2020 Free Software Foundation, Inc.\n"
1: (615) ->~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law."
1: (615) ->~"\nType \"show copying\" and \"show warranty\" for details.\n"
1: (616) ->~"This GDB was configured as \"x86_64-linux-gnu\".\n"
1: (618) ->~"Type \"show configuration\" for configuration details.\n"
1: (618) ->~"For bug reporting instructions, please see:\n"
1: (618) ->~"<http://www.gnu.org/software/gdb/bugs/>.\n"
1: (618) ->~"Find the GDB manual and other documentation resources online at:\n    <http://www.gnu.org/software/gdb/documentation/>."
1: (618) ->~"\n\n"
1: (618) ->~"For help, type \"help\".\n"
1: (618) ->~"Type \"apropos word\" to search for commands related to \"word\".\n"
1: (618) ->(gdb)
1: (626) <-1001-gdb-set target-async on
1: (628) ->1001^done
1: (628) ->(gdb)
1: (631) 1001: elapsed time 6
1: (642) <-1002-interpreter-exec console "set pagination off"
1: (643) ->=cmd-param-changed,param="pagination",value="off"
1: (644) ->1002^done
1: (644) ->(gdb)
1: (645) 1002: elapsed time 2
1: (645) <-1003-gdb-set auto-solib-add on
1: (646) ->1003^done
1: (646) ->(gdb)
1: (646) 1003: elapsed time 0
1: (647) <-1004-gdb-set solib-search-path /home/cas/OpenSource-EBike-firmware/TSDZ2_wireless/firmware/_build:
1: (648) ->1004^done
1: (648) ->(gdb)
1: (648) 1004: elapsed time 1
1: (651) <-1005-interpreter-exec console "file /home/cas/OpenSource-EBike-firmware/TSDZ2_wireless/firmware/_build/TSDZ2_wireless.out"
1: (652) ->~"Reading symbols from /home/cas/OpenSource-EBike-firmware/TSDZ2_wireless/firmware/_build/TSDZ2_wireless.out...\n"
1: (712) ->1005^done
1: (712) ->(gdb)
1: (713) 1005: elapsed time 62
1: (714) <-1006-interpreter-exec console "target remote localhost:3333"
1: (714) ->~"Remote debugging using localhost:3333\n"
1: (717) ->=thread-group-started,id="i1",pid="42000"
1: (717) ->=thread-created,id="1",group-id="i1"
1: (726) ->~"0x000368c6 in main () at ./main.c:150\n"
1: (726) ->~"150\t        cnt_2++;\n"
1: (726) ->*stopped,frame={addr="0x000368c6",func="main",args=[],file="./main.c",fullname="/home/cas/OpenSource-EBike-firmware/TSDZ2_wireless/firmware/main.c",line="150",arch="armv7e-m"},thread-id="1",stopped-threads="all"
1: (726) ->1006^done
1: (726) ->(gdb)
1: (739) 1006: elapsed time 25
1: (739) <-1007-thread-info 1
1: (740) ->1007^done,threads=[{id="1",target-id="Remote target",frame={level="0",addr="0x000368c6",func="main",args=[],file="./main.c",fullname="/home/cas/OpenSource-EBike-firmware/TSDZ2_wireless/firmware/main.c",line="150",arch="armv7e-m"},state="stopped"}]
1: (740) ->(gdb)
1: (741) 1007: elapsed time 2
1: (742) <-1008-interpreter-exec console "monitor init"
1: (743) ->1008^done
1: (743) ->(gdb)
1: (745) 1008: elapsed time 3
1: (746) <-1009-interpreter-exec console "monitor reset init"
1: (769) ->@"target halted due to debug-request, current mode: Thread \n"
1: (769) ->@"xPSR: 0x01000000 pc: 0x00000a80 msp: 0x20000400\n"
1: (770) ->1009^done
1: (770) ->(gdb)
1: (770) 1009: elapsed time 24
1: (770) <-1010-interpreter-exec console "monitor flash write_image erase /home/cas/OpenSource-EBike-firmware/TSDZ2_wireless/firmware/_build/TSDZ2_wireless_with_SD.hex"
1: (771) ->@"auto erase enabled\n"
1: (804) ->@"Padding image section 0 with 1280 bytes\n"
1: (805) ->@"Padding image section 1 with 6336 bytes\n"
1: (5818) ->@"using fast async flash loader. This is currently supported\n"
1: (5821) ->@"only with ST-Link and CMSIS-DAP. If you have issues, add\n"
1: (5821) ->@"\"set WORKAREASIZE 0\" before sourcing nrf51.cfg to disable it\n"
1: (7458) ->@"target halted due to breakpoint, current mode: Thread \n"
1: (7460) ->@"xPSR: 0x61000000 pc: 0x2000001e msp: 0x20000400\n"
1: (7461) ->@"wrote 233472 bytes from file /home/cas/OpenSource-EBike-firmware/TSDZ2_wireless/firmware/_build/TSDZ2_wireless_with_SD.hex in 6.684961s (34.106 KiB/s)\n"
1: (7461) ->1010^done
1: (7462) ->(gdb)
1: (7463) 1010: elapsed time 6692
1: (7463) <-1011-interpreter-exec console "monitor reset halt"
1: (7504) ->@"target halted due to debug-request, current mode: Thread \n"
1: (7505) ->@"xPSR: 0x01000000 pc: 0x00000a80 msp: 0x20000400\n"
1: (7506) ->1011^done
1: (7507) 1011: elapsed time 43
1: (7512) ->(gdb)
1: (7556) Send Event AD7EngineCreateEvent
1: (7574) Send Event AD7ProgramCreateEvent
<--   C (setBreakpoints-3): {"command":"setBreakpoints","arguments":{"source":{"name":"main.c","path":"/home/cas/OpenSource-EBike-firmware/TSDZ2_wireless/firmware/main.c"},"lines":[145],"breakpoints":[{"line":145}],"sourceModified":false},"type":"request","seq":3}
1: (7750) <-1012-break-insert -f main.c:145
1: (7752) ->1012^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x000368b4",func="main",file="./main.c",fullname="/home/cas/OpenSource-EBike-firmware/TSDZ2_wireless/firmware/main.c",line="145",thread-groups=["i1"],times="0",original-location="main.c:145"}
1: (7753) ->(gdb)
1: (7753) 1012: elapsed time 2
1: (7765) <-1013-symbol-list-lines /home/cas/OpenSource-EBike-firmware/TSDZ2_wireless/firmware/main.c
1: (7766) ->1013^done,lines=[{pc="0x0003663c",line="52"},{pc="0x00036648",line="53"},{pc="0x0003664c",line="55"},{pc="0x000367a8",line="91"},{pc="0x000367aa",line="93"},{pc="0x000367b2",line="0"},{pc="0x000367b4",line="96"},{pc="0x000367ba",line="99"},{pc="0x000367c6",line="102"},{pc="0x000367d6",line="105"},{pc="0x000367e6",line="109"},{pc="0x000367f4",line="113"},{pc="0x000367fc",line="114"},{pc="0x0003680c",line="115"},{pc="0x00036828",line="0"},{pc="0x00036828",line="118"},{pc="0x0003682e",line="119"},{pc="0x00036834",line="120"},{pc="0x00036844",line="124"},{pc="0x0003684a",line="125"},{pc="0x0003685a",line="127"},{pc="0x00036862",line="128"},{pc="0x00036872",line="129"},{pc="0x0003687a",line="0"},{pc="0x0003687a",line="132"},{pc="0x00036880",line="133"},{pc="0x0003688c",line="134"},{pc="0x0003689c",line="136"},{pc="0x000368a0",line="137"},{pc="0x000368a8",line="0"},{pc="0x000368a8",line="140"},{pc="0x000368ac",line="143"},{pc="0x000368b0",line="144"},{pc="0x000368b4",line="145"},{pc="0x000368b8",line="149"},{pc="0x000368c4",line="150"},{pc="0x000368d0",line="151"},{pc="0x000368d2",line="153"},{pc="0x000368de",line="149"},{pc="0x000368e8",line="0"}]
1: (7766) ->(gdb)
1: (7767) 1013: elapsed time 2
1: (7772) Send Event AD7BreakpointBoundEvent
<--   C (setFunctionBreakpoints-4): {"command":"setFunctionBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":4}
<--   C (configurationDone-5): {"command":"configurationDone","type":"request","seq":5}
1: (7919) Send Event AD7LoadCompleteEvent
=thread-group-added,id="i1"
GNU gdb (Ubuntu 9.1-0ubuntu1) 9.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
=cmd-param-changed,param="pagination",value="off"
<--   C (threads-6): {"command":"threads","type":"request","seq":6}
1: (7960) <-1014-thread-info
1: (7961) ->1014^done,threads=[{id="1",target-id="Remote target",frame={level="0",addr="0x000368c6",func="main",args=[],file="./main.c",fullname="/home/cas/OpenSource-EBike-firmware/TSDZ2_wireless/firmware/main.c",line="150",arch="armv7e-m"},state="stopped"}],current-thread-id="1"
1: (7961) ->(gdb)
1: (7968) 1014: elapsed time 8
1: (7986) <-1015-stack-list-frames 0 1000
1: (7986) ->1015^done,stack=[frame={level="0",addr="0x000368c6",func="main",file="./main.c",fullname="/home/cas/OpenSource-EBike-firmware/TSDZ2_wireless/firmware/main.c",line="150",arch="armv7e-m"}]
1: (7986) ->(gdb)
1: (7989) 1015: elapsed time 3
1: (7996) Send Event AD7ProcessInfoUpdatedEvent
1: (7997) Send Event AD7ThreadCreateEvent
1: (8021) <--exec-continue
1: (8021) ->^running
1: (8021) ->*running,thread-id="all"
1: (8021) ->~"Note: automatically using hardware breakpoints for read-only addresses.\n"
Note: automatically using hardware breakpoints for read-only addresses.
1: (8023) ->(gdb)
<--   C (threads-7): {"command":"threads","type":"request","seq":7}
1: (8949) ->=breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x000368b4",func="main",file="./main.c",fullname="/home/cas/OpenSource-EBike-firmware/TSDZ2_wireless/firmware/main.c",line="145",thread-groups=["i1"],times="1",original-location="main.c:145"}
1: (8955) ->~"\n"

1: (8955) ->~"Breakpoint 1, main () at ./main.c:145\n"
1: (8955) ->~"145\t    profile_setup();\n"
Breakpoint 1, main () at ./main.c:145
145	    profile_setup();
1: (8955) ->*stopped,reason="breakpoint-hit",disp="keep",bkptno="1",frame={addr="0x000368b4",func="main",args=[],file="./main.c",fullname="/home/cas/OpenSource-EBike-firmware/TSDZ2_wireless/firmware/main.c",line="145",arch="armv7e-m"},thread-id="1",stopped-threads="all"
1: (8956) <-1016-stack-list-frames 0 1000
1: (8957) ->1016^done,stack=[frame={level="0",addr="0x000368b4",func="main",file="./main.c",fullname="/home/cas/OpenSource-EBike-firmware/TSDZ2_wireless/firmware/main.c",line="145",arch="armv7e-m"}]
1: (8957) ->(gdb)
1: (8958) 1016: elapsed time 1
1: (8966) Send Event AD7BreakpointEvent
Execute debugger commands using "-exec <command>", for example "-exec info registers" will list registers in use (when GDB is the debugger)
<--   C (threads-8): {"command":"threads","type":"request","seq":8}
<--   C (stackTrace-9): {"command":"stackTrace","arguments":{"threadId":-2,"startFrame":0,"levels":20},"type":"request","seq":9}
1: (9274) <-1017-stack-list-arguments 0 0 0
1: (9275) ->1017^done,stack-args=[frame={level="0",args=[]}]
1: (9276) ->(gdb)
1: (9278) 1017: elapsed time 4
<--   C (stackTrace-10): {"command":"stackTrace","arguments":{"threadId":-2,"startFrame":0,"levels":20},"type":"request","seq":10}
<--   C (evaluate-11): {"command":"evaluate","arguments":{"expression":"m_ant_lev","frameId":1000,"context":"watch"},"type":"request","seq":11}
1: (9586) <-1018-var-create - * "m_ant_lev"
1: (9587) ->1018^done,name="var1",numchild="13",value="{...}",type="ant_lev_profile_t",has_more="0"
1: (9587) ->(gdb)
1: (9587) 1018: elapsed time 0
<--   C (scopes-12): {"command":"scopes","arguments":{"frameId":1000},"type":"request","seq":12}
1: (9939) <-1019-stack-list-variables 0
1: (9940) ->1019^done,variables=[{name="cnt_2"}]
1: (9940) ->(gdb)
1: (9943) 1019: elapsed time 3
1: (9946) <-1020-var-create - * "cnt_2"
1: (9948) ->1020^done,name="var2",numchild="0",value="0",type="uint16_t",has_more="0"
1: (9949) ->(gdb)
1: (9950) 1020: elapsed time 3
<--   C (variables-13): {"command":"variables","arguments":{"variablesReference":1001},"type":"request","seq":13}
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless Ebike boar ANT+ and Bluetooth, Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation to help my developments: paypal.me/jorgecasa

casainho   10 GW

10 GW
Posts: 4496
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by casainho » Jul 10 2020 11:20am

Finally the ANT+ LEV firmware works!! the issue was the configuration LEV_MSG_PERIOD_4Hz 0x2000u // decimal 8192 (4.00 Hz). that was slightly different.

Here a picture of both GPS Edge 830 and Forerunner 245 watch connecting and showing information about the ebike. The watch is running a demo app that shows the ebike information / properties. The GPS on the other hand, show the information and let us change the assist level:

Image


And here a breakpoint while in debug mode, on the firmware code that runs when I did change the assist level on the GPS display:

Image
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless Ebike boar ANT+ and Bluetooth, Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation to help my developments: paypal.me/jorgecasa

bobreece20   1 mW

1 mW
Posts: 18
Joined: Jun 19 2020 11:10am

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by bobreece20 » Jul 10 2020 12:18pm

Very nice! I'm still hunting down the issues with trying to program my dongle. I've found that the application flash content is correct after a flash and flashing using openocd works if I flash the same hex as what I programmed via nRF Connect as a result it has to be the bootloader which is preventing the code from launching. Looks like it's doing a CRC check and refusing the software (https://infocenter.nordicsemi.com/index ... ocess.html), not sure why your dongle isn't doing that, did you remove the DFU Bootloader (or I wonder if it is an old one that doesn't perform the check)

casainho   10 GW

10 GW
Posts: 4496
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by casainho » Jul 10 2020 1:19pm

bobreece20 wrote:
Jul 10 2020 12:18pm
Very nice! I'm still hunting down the issues with trying to program my dongle. I've found that the application flash content is correct after a flash and flashing using openocd works if I flash the same hex as what I programmed via nRF Connect as a result it has to be the bootloader which is preventing the code from launching. Looks like it's doing a CRC check and refusing the software (https://infocenter.nordicsemi.com/index ... ocess.html), not sure why your dongle isn't doing that, did you remove the DFU Bootloader (or I wonder if it is an old one that doesn't perform the check)
After flashing, try to hit stop and run a few times, maybe it will work.

As the command for write the firmware file say autoerase, I hope it will erase before flashing so I do not expect to have any bootloader anymore.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless Ebike boar ANT+ and Bluetooth, Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation to help my developments: paypal.me/jorgecasa

casainho   10 GW

10 GW
Posts: 4496
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by casainho » Jul 10 2020 1:35pm

I got the motor voltage / power being turned on and off, this is the board:

Image

The BTS4140N, I added a small mosfet with a 150K resistor otherwise it would not turn off. Maybe next I should try remove that mosfet and resistor and instead of change the microcontroller pin to 0 or 3.3V, I should change to 0V or as high impedance ? input -- will it work??

And a video showing this working -- changing assist level on the display and when value is zero it disable the motor voltage (turning off the motor) and enable the motor voltage when assist level higher than zero:

- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless Ebike boar ANT+ and Bluetooth, Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation to help my developments: paypal.me/jorgecasa

bobreece20   1 mW

1 mW
Posts: 18
Joined: Jun 19 2020 11:10am

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by bobreece20 » Jul 10 2020 2:58pm

casainho wrote:
Jul 10 2020 1:19pm
After flashing, try to hit stop and run a few times, maybe it will work.

As the command for write the firmware file say autoerase, I hope it will erase before flashing so I do not expect to have any bootloader anymore.
I was correct the issue was the bootloader checking application CRC and it not matching with the CRC it had stored. For now I've got around it by merging in the hex generated from `nrfutil settings generate --family NRF52840 --bootloader-version 0 --bl-settings-version 1 --application $(OUTPUT_DIRECTORY)/TSDZ2_wireless.hex --application-version 4294967295 $(OUTPUT_DIRECTORY)/settings.hex` (nrfutil is a python program from nordic) but want to find a way to just disable it altogether.

Update: Flashing the more permissive dfu/open_bootloader/pca100059_usb_debug bootloader disables crc checking, by far the easiest way around the issues I've been having. I've pushed some documentation on this to the repo.

bobreece20   1 mW

1 mW
Posts: 18
Joined: Jun 19 2020 11:10am

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by bobreece20 » Jul 10 2020 4:30pm

bobreece20 wrote:
Jul 10 2020 5:18am
Guess it's worth doing some experimentation with labels to see if we can have alternative boards much like we have alternative motor cables and then seeing how messy the schematic is
The pins used by these two different dongles are quite different. The only common exposed pins they share are the debugging pins and: 0.20, 0.09, 0.10, 0.02, 0.04(on the bottom of board, would be pita to use). Worse is that this dongle has LEDs on 0.06 which is being used for motor comms so will have to be careful not to enable the LED service and 0.19 is tied to the reset pin. Looks like to support the board we'll need a separate pin map in code and schematic.

e3s   10 W

10 W
Posts: 79
Joined: Jan 08 2018 12:40pm

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by e3s » Jul 10 2020 5:48pm

for reference only this devices has also lev
Garmin
edge 520 plus
edge 530
edge 820
edge 830
edge 1030
edge 1030 plus
edge explore
edge explore 1000
edge touring plus

o-synce
usee
coachsmart lev

Selfloops Android ANT+

sigma sport rox 12.0 sport
wahoo elemnt roam

Headless   10 mW

10 mW
Posts: 29
Joined: Jun 02 2020 5:23am

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by Headless » Jul 10 2020 11:57pm

casainho wrote:
Jul 10 2020 1:35pm
change to 0V or as high impedance ? input -- will it work??
That is correct.

BTS4140N Input pin floating = OFF
BTS4140N Input pin grounded = ON

If all the nRF pins are high-impedance on start-up this should be safe. Nice work!

casainho   10 GW

10 GW
Posts: 4496
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by casainho » Jul 11 2020 3:51am

Headless wrote:
Jul 10 2020 11:57pm
casainho wrote:
Jul 10 2020 1:35pm
change to 0V or as high impedance ? input -- will it work??
That is correct.

BTS4140N Input pin floating = OFF
BTS4140N Input pin grounded = ON

If all the nRF pins are high-impedance on start-up this should be safe. Nice work!
That did not work. I removed the small MOSFET and changed the firmware for pin floating. Even with the 150K resistor in series with the in pin of BTS4140N, the voltage at NRF pin is "floating" at about 4V and so it does not work, with or without the resistor. The in pin has the battery voltage if we left it floating... So, I think the internal diodes of NRF get active as you said.

So, the minimum circuit is the BTS4140N + 150K resistor (other big may work as well) and the small n channel MOSFET. Can you please update the schematic?

And the schematic was updated by Bob, with the latest pull request, to add as optimal the NRF blue board.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless Ebike boar ANT+ and Bluetooth, Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation to help my developments: paypal.me/jorgecasa

Headless   10 mW

10 mW
Posts: 29
Joined: Jun 02 2020 5:23am

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by Headless » Jul 11 2020 4:41am

casainho wrote:
Jul 11 2020 3:51am
the minimum circuit is the BTS4140N + 150K resistor
Please can you confirm where the 150K resistor is connected? The datasheet is as below:-
BTS4140N.png
BTS4140N.png (3.29 KiB) Viewed 191 times

casainho   10 GW

10 GW
Posts: 4496
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by casainho » Jul 11 2020 6:58am

Headless wrote:
Jul 11 2020 4:41am
casainho wrote:
Jul 11 2020 3:51am
the minimum circuit is the BTS4140N + 150K resistor
Please can you confirm where the 150K resistor is connected? The datasheet is as below:-
BTS4140N.png
Well, it is now in series with small MOSFET ouptut and input of the BTS4140N. But I will try to remove the resistor and see if it keeps working, it should. I will give feedback in 2 or 3 hours.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless Ebike boar ANT+ and Bluetooth, Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation to help my developments: paypal.me/jorgecasa

casainho   10 GW

10 GW
Posts: 4496
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by casainho » Jul 11 2020 9:49am

casainho wrote:
Jul 11 2020 6:58am
Headless wrote:
Jul 11 2020 4:41am
casainho wrote:
Jul 11 2020 3:51am
the minimum circuit is the BTS4140N + 150K resistor
Please can you confirm where the 150K resistor is connected? The datasheet is as below:-
BTS4140N.png
Well, it is now in series with small MOSFET ouptut and input of the BTS4140N. But I will try to remove the resistor and see if it keeps working, it should. I will give feedback in 2 or 3 hours.
I confirm that resistor is needed, at least with the small mosfet I used: FDV301N. That resistor of 15K, there is 0.4mA crossing when the mosfet is turn on and enabling the BTS4140N.

Can you please update the schematic and the main page README?

My next step is to connect the board to a real TSDZ2 motor controller and prepare the firmware to communicate with it, then if the UART tx and rx pins work as expected, then the board is final!!

Another thing: on the main page says: For convenience it is advised that you permanently wire in a connector to allow programming the nRF52840, to allow for future Firmware updates

In future we need to build and test the Bluetooth bootloader from Nordic - since I remember, it can be activated at boot while pressing the button on the board. Is also possible to develop the firmware with a feature to enable the bootloader for next boot and reset the system, so, is like having a command to initiate the bootloader. And even possible to have bootloader ALSO running in the firmware, so, we could update the firmware after pressing the button at boot or simple by starting flash the firmware even when our firmware is running, so, user should solder that wires only once to install our bootloader and then everything should be done by wireless Bluetooth -- Nordic provides an Android app on play store specific to flash the firmware if we are using their bootloader, which we should (just like we do on SW102 display).
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless Ebike boar ANT+ and Bluetooth, Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation to help my developments: paypal.me/jorgecasa

Waynemarlow   1 kW

1 kW
Posts: 430
Joined: Jul 09 2016 7:22am
Location: Bucks, England

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by Waynemarlow » Jul 11 2020 10:24am

What about all the guys using Apple phones, still a big lot of us ( but getting smaller by the day :D ) we will still need the direct wired connection to the ST Link ?

Headless   10 mW

10 mW
Posts: 29
Joined: Jun 02 2020 5:23am

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by Headless » Jul 11 2020 12:22pm

casainho wrote:
Jul 11 2020 9:49am
I confirm that resistor is needed, at least with the small mosfet I used: FDV301N.
Obviously it works, but the datasheet describes this as a logic-level device that can work directly with 3V devices? Mosfets (other than logic-level mosfets?) so far as I remember are voltage devices and don't need current-limiting resistors on the inputs like transistors, but beyond that...

One thing that does worry me a bit is that the FDV301N Drain-Source breakdown voltage is only 25V. If the Drain is pulled up to battery-voltage by the BTS4140N when the mosfet is off, it could be more than double that. Maybe this is why a resistor is needed? If any electronics experts can help, please announce yourselves!

casainho   10 GW

10 GW
Posts: 4496
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by casainho » Jul 11 2020 1:01pm

Headless wrote:
Jul 11 2020 12:22pm
casainho wrote:
Jul 11 2020 9:49am
I confirm that resistor is needed, at least with the small mosfet I used: FDV301N.
Obviously it works, but the datasheet describes this as a logic-level device that can work directly with 3V devices? Mosfets (other than logic-level mosfets?) so far as I remember are voltage devices and don't need current-limiting resistors on the inputs like transistors, but beyond that...

One thing that does worry me a bit is that the FDV301N Drain-Source breakdown voltage is only 25V. If the Drain is pulled up to battery-voltage by the BTS4140N when the mosfet is off, it could be more than double that. Maybe this is why a resistor is needed? If any electronics experts can help, please announce yourselves!
I used FDV301N because was the only one small MOSFET I had with me.

Now I was looking to buy the BSS100 but seems it is kind of expensive and a bit hard to find. Maybe there are other popular options? I would like to find something cheap on ebay. BSS100 on Darnell, for instance, I could find to buy only 100 units which is to much for each user to buy as DIY, to build 1 or 2 units of the wireless board. Do you know any other popular alternative?
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless Ebike boar ANT+ and Bluetooth, Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation to help my developments: paypal.me/jorgecasa

casainho   10 GW

10 GW
Posts: 4496
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by casainho » Jul 11 2020 1:08pm

Ok, found the BSS123 that seems similar and I can find easily on ebay. Can you please check if this can work and then you can use it instead?
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless Ebike boar ANT+ and Bluetooth, Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation to help my developments: paypal.me/jorgecasa

Headless   10 mW

10 mW
Posts: 29
Joined: Jun 02 2020 5:23am

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by Headless » Jul 11 2020 1:26pm

casainho wrote:
Jul 11 2020 1:08pm
found the BSS123 that seems similar
Good choice! It looks as though it's the replacement for the BSS100, same spec just not available in the old TO92 package. There are some projects that use it for switching LEDs, with the Gate input being 3.3V logic, so it should be fine - and with 100V Drain/Source breakdown battery voltage is not a problem!

I'll update the schematics tomorrow.

Zelenaar   100 mW

100 mW
Posts: 35
Joined: Apr 11 2019 5:52am

Re: TSDZ2 wireless mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware

Post by Zelenaar » Jul 13 2020 9:13am

e3s wrote:
Jul 10 2020 5:48pm
for reference only this devices has also lev
wahoo elemnt roam
According to the docs also the wahoo elemnt bolt is supporting LEV (with firmware upgrade)

Post Reply