cancel
Showing results for 
Search instead for 
Did you mean: 

debugging a hoverboard motor controller

iamrobot
Associate II

i have a hoverboard motor controller in which there is STM32F103RCT6.
i have hacked the firmware but it was not working due to some reason; some MOSFET got burned.
i tried to check communication with Arduino.

 

 
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.c
* @brief : Main program body
******************************************************************************
*/
/* USER CODE END Header */

#include "main.h"

/* USER CODE BEGIN Includes */
#include <string.h>
/* USER CODE END Includes */

/* Private variables ---------------------------------------------------------*/
UART_HandleTypeDef huart3;

/* USER CODE BEGIN PV */
char msg[] = "STM32 UART TEST\r\n";
/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART3_UART_Init(void);

int main(void)
{
HAL_Init();

SystemClock_Config();

MX_GPIO_Init();
MX_USART3_UART_Init();

/* USER CODE BEGIN 2 */
HAL_UART_Transmit(&huart3, (uint8_t*)msg, strlen(msg), 100);
/* USER CODE END 2 */

while (1)
{
/* USER CODE BEGIN 3 */
HAL_UART_Transmit(&huart3, (uint8_t*)msg, strlen(msg), 100);
HAL_Delay(500);
/* USER CODE END 3 */
}
}

/* Clock config (unchanged CubeMX generated) */
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;

HAL_RCC_OscConfig(&RCC_OscInitStruct);

RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;

RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0);
}

/* USART3 Init (PB10 TX, PB11 RX) */
static void MX_USART3_UART_Init(void)
{
huart3.Instance = USART3;
huart3.Init.BaudRate = 115200;
huart3.Init.WordLength = UART_WORDLENGTH_8B;
huart3.Init.StopBits = UART_STOPBITS_1;
huart3.Init.Parity = UART_PARITY_NONE;
huart3.Init.Mode = UART_MODE_TX_RX;
huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart3.Init.OverSampling = UART_OVERSAMPLING_16;

HAL_UART_Init(&huart3);
}

/* GPIO Init */
static void MX_GPIO_Init(void)
{
__HAL_RCC_GPIOB_CLK_ENABLE();
}

/* Error handler */
void Error_Handler(void)
{
__disable_irq();
while (1)
{
}
}

when I flash it, my STM is not being detected by ST-Link. I am trying to check whether the issue is with the STM or the firmware. I also flashed it into another board, but the same issue happened, so I guess the problem is in the firmware.

the power is good; I checked between all VDD and VSS and it is good (3.27V).
there is BOOT0, BOOT1, and NRST.
BOOT0 and BOOT1 are low and NRST is high.
when I short BOOT0 with VDD, the ST-Link turns off.

I am completely lost.

the screen shot is after and before firmware 

15 REPLIES 15
Andrew Neil
Super User

welcome to the forum

Please see How to write your question to maximize your chances to find a solution for best results.

 


@iamrobot wrote:

i have a hoverboard motor controller in which there is STM32F103RCT6.


Please give full details - is this your own design? a commercial design?

Note that STM32F103RCT6 are widely faked/cloned - are you sure you have a genuine one?

 


@iamrobot wrote:

when I flash it, my STM is not being detected by ST-Link.  


What ST-Link are you using?

Again, there are many clones: How to recognize a genuine ST-LINK/V2 versus a cloned one

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
iamrobot
Associate II

thanks

mainboard_pinout.png

l am using this board (hoverboard contoller) it was working before the problem is i flashed the firmware which by some reason made the stm not loading by stlink 
how can i completely reset the chip so the stlink debugger can work i have now working code
attached the schematic i found online

So that is a commercial product, then ?

If so, you really need to go to the manufacturer/supplier for support with it.

Maybe there is a user group/forum for it?

 


@iamrobot wrote:

how can i completely reset the chip 


Use STM32CubeProgrammer or similar to do a full-chip erase.

But, again, note that ST tool are not supported to work properly (or even at all) with non-ST chips.

And this, of course, won't help if the chip is damaged, and/or the problem is due to some other fault on the board.

 

PS:

In that schematic, the BOOT0 pin is left open:

AndrewNeil_0-1779795525983.png

That's bad - it should be tied to the required level.

I also note:

AndrewNeil_1-1779795624690.png

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

If this is a commercial product, it is probably safe to assume that RDP is enabled.

> how can i completely reset the chip so the stlink debugger can work ...

If, as you reported, a high-power MOSFET is blown, there is a good chance the MCU is damaged as well.
Do your due diligence and check current consumption and voltage levels on at least all supply pins.

> there is BOOT0, BOOT1, and NRST.
> BOOT0 and BOOT1 are low and NRST is high.
> when I short BOOT0 with VDD, the ST-Link turns off.

The BOOTx pins will get you into system mode, i.e. booting from system ROM.
In that case, you need to use a serial adapter on a supported UART port, and a host software like CubeProgrammer that supports ST's system bootloader protocol.

If RDP is enabled, AFAIK the only thing you can do is a mass erase.
Afterwards you would be able to flash the MCU with the ST-Link.
But the ST-Link does not support the system boot protocol.

Thanks, I really appreciate it. I am actually a programming and AI student, and I am trying very hard to understand this. As far as I know, if I need to connect to the bootloader through UART or debugging pins, I need to make BOOT0 high. But after spending a lot of time on it, I found that BOOT0 is shorted to ground through a resistor. The resistor looks fine when I check continuity. Do I need to remove it or do something else?
thanks you 
boot0.png


@iamrobo wrote:

I am actually a programming and AI student


Then you should really be talking to your tutor/teacher about this.

If the equipment supplied isn't working, then it shouldn't be your job to debug it.

 

When you say "programming" - what, exactly, do you mean by that?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
iamrobot
Associate II

i am interested in learning about hardware and its my hobby project i started working on this 
is it possible in stm that boot0 can be directly connted to ground or the hardware is faulty

 

Just don't let it interfere with your studies!

If this side-track prevents you from finishing the assignment, you might lose marks unnecessarily...

 


@iamrobot wrote:
AndrewNeil_0-1779817127211.png

That doesn't match the PDF you posted earlier - which one matches the board that you actually have?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
iamrobot
Associate II

There is no official documentation. In the schematic above, BOOT0 was not defined. The recent image is from my findings. I am currently following embedded systems and have gained experience in Arduino, ESP, ROS, and robotics. I find STM quite complex.