Alrighty, you already know how to flash the Bluetooth module firmware with
J-Link. But that thing is very expensive. So today I am going to show you how you can flash your INNOTRACE M620 CAN motor controller Bluetooth module NRF chip with a cheap ST-Link V2 USB dongle.
Here is the tools list you need (the same tools you need to flash the STM32 chip of the motor controller):
1) Obtain an ST-Link V2 dongle (ST-Link V2 dongles can be purchased here for example
https://www.amazon.com/dp/B0B2D6HZR6?th=1)
2) Obtain a Tag-Connect cable TC2030-MCP-NL (This cable and all further items below are to connect the ST-Link V2 dongle to the controller. This cable and all items below are optional, you can solder wires to the pads and connect them to ST-Link dongle, however you want to make it happens. The cable can be purchased here
https://www.digikey.com/en/products/detail/tag-connect-llc/TC2030-MCP-NL/2666489)
3) If you want to use the Tag-Connect cable I mentioned above then you also might want to obtain a TC2030-CLIP (This clip fastens the Tag-Connect cable to the controller board. This part is obsolete and hard to find. But you can use TC2050-CLIP and re-solder one receptacle to match the TC2030-MCP-NL cable interface. This clip can be purchased here
https://www.digikey.com/en/products/detail/tag-connect-llc/TC2050-CLIP-3PACK/12318009 )
This clip can hold the Tag-Connect cable connected
4) Obtain an RJ11 to pins adapter ST-RJ11-R-BB if you want to use the Tag-Connect cable I mentioned above (This adapter is to connect Tag-Connect cable plug and have convenient access to the pins. The adapter can be purchased here
https://www.digikey.com/en/products/detail/schmalztech-llc/ST-RJ11-R-BB/23307380 )
5) You also might need to obtain some jumper wires for wiring between the ST-Link V2 and the ST-RJ11-R-BB adapter (To connect the ST-Link dongle to ST-RJ11-R-BB. Bulk of such wires can be purchased here
https://www.digikey.com/en/products/detail/digikey/DKS-20FF-20/17038802 )
I recommend you to install Bluetooth firmware first before flashing the motor controller firmware. Here are the Bluetooth flashing instructions:
1) Download and unzip the OpenOCD Windows Programmer files (latest version should probably work the best):
Download OpenOCD for Windows
2) Open Notepad application and type the following text and save it as openocd.cfg file into the OpenOCD “bin” directory (same dir as openocd.exe):
# nRF51822 Target
source [find interface/stlink-v2.cfg]
transport select swd
set WORKAREASIZE 0x4000
source [find target/nrf51.cfg]
# use hardware reset, connect under reset
#reset_config srst_only srst_nogate
3) Copy the Bluetooth firmware hex file from the shared KiCAD files controller archive "\M620 CAN VESC controller_BRAIN\Firmware" folder to the OpenOCD “bin” directory (same dir as openocd.exe). Name that copied firmware file to Bluetooth_Firmware_nRF51822.hex
4) Make sure ST-Link V2 drivers are installed. ST Link V2 drivers can be downloaded here
https://www.st.com/en/development-tools/stsw-link009.html
5) Connect St-Link V2 to the BRAIN board PCB (3.3V to 3.3V, GND to GND, SWDIO to SWDIO, SWCLK to SWCLK) using the P8(NRF) interface (Tag-Connect). Pinout of the P8(NRF) interface can be found in the BRAIN board KiCAD files.
6) Type cmd.exe into the address bar of Windows Explorer while you are in OpenOCD “bin” directory (same dir as openocd.exe) and press Enter
7) Paste this command and press Enter on the keyboard
openocd -f openocd.cfg -c "init" -c "halt" -c "nrf51 mass_erase" -c "program Bluetooth_Firmware_nRF51822.hex verify reset exit"
8) Wait until the program finished flashing the Bluetooth module, then you can disconnect the ST-Link V2. The last lines of the report of the OpenOCD program in case of properly flashed firmware should look like this:
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **
shutdown command invoked
Now the Bluetooth module is flashed!
After this you can flash the STM32 with the controller firmware the regular way with the same ST-Link V2 with the same Tag- Connect cable with STM32 ST-LINK Utility application. You need to connect the Tab-Connect cable to the P7(STM32) Tag-Connect interface. That interface has the same pinout as the P8(NRF) interface for the Bluetooth module (plus NRST pin) so you can use the same cable to flash the firmware files for both, Bluetooth and STM32 without changing the pins. Here are the instructions
It looks like we need instructions about how to flash the STM32 chip of the motor controller with the bin firmware file. When you have a blank controller STM32 chip with blank Bluetooth module NRF chip and want Bluetooth working then flash the Bluetooth module NRF chip first before flashing the...
endless-sphere.com
After flashing the controller firmware on the blank STM32 the green LED should light up and you also should be able to connect the controller to VESC Tool application using Bluetooth.
