flo199213 / Hoverboard-Firmware-Hack-Gen2

Hoverboard Hack Firmware Generation 2 for the Hoverboard with the two Mainboards instead of the Sensorboards (See Readme.md).
GNU General Public License v3.0
143 stars 112 forks source link

Split Board "Jiaan" with GD32F130C6 #13

Closed t-oster closed 4 years ago

t-oster commented 4 years ago

Hi,

I have a Hoverboard with two almost identical boards labeled "Jiaan". I am trying to get this to work, however I am not experienced with ARMs so far (only AVRs) and not so used to reverse engineering. I already found out it uses a GD32F130C6 instead of GD32F130C8 (32kb instead of 64kb flash etc). I unlocked both controllers and I can flash files, which can successfully be read after that, so I think flashing is fine. I guess the basics are similar to the boards this firmware is written for, but there must be differences (e.g. other PINs used?). I'd like to provide a patch for this firmware to also work with those boards, but I'm stuck.

I am trying to get some answer from the board, I tried to send something on both USARTs or blink some Pin I think is connected to an LED but nothing so far.

Has anybody already seen this board an can help me out?

MVIMG_20200426_232139 MVIMG_20200426_232151

t-oster commented 4 years ago

At least the Master/Slave UART seems to be on the correct PINs. I can communicate with the controller now. Any Idea how I can find out the pin-assignments without destructing the board? It's not easy for me to follow the tracks on the board, but I guess I should not just set all pins as output and set/reset them in order to look for which LED is blinking or if the motor does something, because if there is an output from another IC connected I might short circuit it...

t-oster commented 4 years ago

OK, now I know the Pins for the Light-Barriers, the Buzzer, the hall sensor, power button and power-latch. Now I only need to find the pins for the 6 channels for the motor. Any idea how I can easily trace them? I guess if I accidentally switch the same channel high and low at the same time I would get a short circuit? Are the outputs usually pulled up or down externally?

t-oster commented 4 years ago

Nevermind, I got it to work basically. The motors are on the same pin as on your board. The biggest problem with mine is that the second UART is not broken out, so I have to use the TX for the slave and the RX for the arduino.... maybe I will send a PR after cleaning a bit. However here are my PINs so far:


#ifndef DEFINES_H
#define DEFINES_H

#include "gd32f1x0.h"
#include "../Inc/config.h"

// LED defines

#define UPPER_LED_PIN GPIO_PIN_5
#define UPPER_LED_PORT GPIOB
#define LOWER_LED_PIN GPIO_PIN_8
#define LOWER_LED_PORT GPIOB

// Brushless Control DC (BLDC) defines
// Channel G
#define RCU_TIMER_BLDC RCU_TIMER0
#define TIMER_BLDC TIMER0
#define TIMER_BLDC_CHANNEL_G TIMER_CH_2
#define TIMER_BLDC_GH_PIN GPIO_PIN_10
#define TIMER_BLDC_GH_PORT GPIOA
#define TIMER_BLDC_GL_PIN GPIO_PIN_15
#define TIMER_BLDC_GL_PORT GPIOB
// Channel B
#define TIMER_BLDC_CHANNEL_B TIMER_CH_1
#define TIMER_BLDC_BH_PIN GPIO_PIN_9
#define TIMER_BLDC_BH_PORT GPIOA
#define TIMER_BLDC_BL_PIN GPIO_PIN_14
#define TIMER_BLDC_BL_PORT GPIOB
// Channel Y
#define TIMER_BLDC_CHANNEL_Y TIMER_CH_0
#define TIMER_BLDC_YH_PIN GPIO_PIN_8
#define TIMER_BLDC_YH_PORT GPIOA
#define TIMER_BLDC_YL_PIN GPIO_PIN_13
#define TIMER_BLDC_YL_PORT GPIOB

// Timer BLDC short circuit emergency shutoff define
#define TIMER_BLDC_EMERGENCY_SHUTDOWN_PIN GPIO_PIN_12
#define TIMER_BLDC_EMERGENCY_SHUTDOWN_PORT GPIOB

// Hall sensor defines
#define HALL_A_PIN GPIO_PIN_0
#define HALL_A_PORT GPIOA
#define HALL_C_PIN GPIO_PIN_11
#define HALL_C_PORT GPIOB
#define HALL_B_PIN GPIO_PIN_1
#define HALL_B_PORT GPIOA

// Usart master slave defines
#define USART_MASTERSLAVE USART1
#define USART_MASTERSLAVE_TX_PIN GPIO_PIN_2
#define USART_MASTERSLAVE_TX_PORT GPIOA
#define USART_MASTERSLAVE_RX_PIN GPIO_PIN_3
#define USART_MASTERSLAVE_RX_PORT GPIOA

// ADC defines
#define VBATT_PIN   GPIO_PIN_4
#define VBATT_PORT GPIOA
#define VBATT_CHANNEL ADC_CHANNEL_4
#define CURRENT_DC_PIN  GPIO_PIN_6
#define CURRENT_DC_PORT GPIOA
#define CURRENT_DC_CHANNEL ADC_CHANNEL_6

// Self hold defines
#define SELF_HOLD_PIN GPIO_PIN_2
#define SELF_HOLD_PORT GPIOB

// Button defines
#define BUTTON_PIN GPIO_PIN_5
#define BUTTON_PORT GPIOA

// Buzzer defins
#define BUZZER_PIN GPIO_PIN_9
#define BUZZER_PORT GPIOB

// Charge state defines
#define CHARGE_STATE_PIN GPIO_PIN_15
#define CHARGE_STATE_PORT GPIOC