stancecoke
Minor legend
In the last weeks I've ported the EBiCS firmware for the Lishuis to this Bafang hub motor controller:

The processor is a GD32F303RCT6, that is mainly a clone of the STM32F103, but is much faster and has a floating point unit (ARM Cortex M4 instead of M3). The firmware uses the original GD standard periheral libraries. GD provides code examples for many typical applications, so it was quite easy to set up timers, ADC, CAN, Clock etc. without having a graphical tool like MXCube.
As I don't know, how the Bafang Bootloader works, it is necessary to open the housing to connect the STLinkV2 (yes, you can flash the GD processor with the STM programmer
) directly to the PCB at the moment.
Most pin functions are identified, just the quadrature PAS input and the light output is missing.

The motor is running by throttle with FOC at the moment. In the video the controller drives a Shengyi middrive motor, the load is a BionX direct drive in generator mode.
The CAN bus is only used for debug messages at the moment, but implementing the BAFANG CAN display protocol is just simple diligent work.
A little a way to go for having torquesensor based riding modes, but no witchwork.
The biggest hurdle for a widely use of this firmware is the bootloader. Pressing the PCB out of the housing and removing the potting to get access to the SWD port will deter most potential users...
I wonder if this processor is used in some newer BAFANG middrive controllers.
github.com

The processor is a GD32F303RCT6, that is mainly a clone of the STM32F103, but is much faster and has a floating point unit (ARM Cortex M4 instead of M3). The firmware uses the original GD standard periheral libraries. GD provides code examples for many typical applications, so it was quite easy to set up timers, ADC, CAN, Clock etc. without having a graphical tool like MXCube.
As I don't know, how the Bafang Bootloader works, it is necessary to open the housing to connect the STLinkV2 (yes, you can flash the GD processor with the STM programmer
Most pin functions are identified, just the quadrature PAS input and the light output is missing.

The motor is running by throttle with FOC at the moment. In the video the controller drives a Shengyi middrive motor, the load is a BionX direct drive in generator mode.
The CAN bus is only used for debug messages at the moment, but implementing the BAFANG CAN display protocol is just simple diligent work.
A little a way to go for having torquesensor based riding modes, but no witchwork.
The biggest hurdle for a widely use of this firmware is the bootloader. Pressing the PCB out of the housing and removing the potting to get access to the SWD port will deter most potential users...
I wonder if this processor is used in some newer BAFANG middrive controllers.
Home
Firmware for Bafang E-Bike controllers with GD32F303 processors - EBiCS/BAFANG_GD32F303RCT6
Last edited:







