Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gen2.2.3 - New board SMART-L-V2.1, two controller boards equipped with STM32F103C8T6) #84

Open
zimmii91 opened this issue May 20, 2024 · 40 comments

Comments

@zimmii91
Copy link

i have found 3 sets of these boards, but unfortunately no firmware as far as i understand it. found this issue a while ago, but still no sollution. EFeru/hoverboard-firmware-hack-FOC#218

132528806-b312e35e-14bf-4f8d-aaf5-7c76c181ccc4

@RoboDurden
Copy link
Owner

Watch my autodetect YouTube videos and run the gd32f103/stm32f103 autodetect binary.. with a 2A constant current power supply or the charger without any battery connected.
https://youtu.be/X7bpMX8tCE8

@zimmii91
Copy link
Author

thank you! i will try that

@RoboDurden
Copy link
Owner

My firmwares can be compiled for the GD32F103 and i think that this mcu is compatible to the STM32F103. But noone ever tested my F103 binaries :-(
I have 2.2.1 boards here and a test setup ready for such a board to install. But no happiness to do it.
I will assign 2.2.3 to your layout. Please upload photos from backside and master / slave

@RoboDurden RoboDurden changed the title New board SMART-L-V2.1, two controller boards equipped with STM32F103C8T6) Gen2.2.3 - New board SMART-L-V2.1, two controller boards equipped with STM32F103C8T6) May 20, 2024
@zimmii91
Copy link
Author

Sounds great! here are some pictures. i can gladly try, however i am a bit unsure of the ST-link connections. i have seen in the link i provided that the pins where soldered, and i have done the same, but i want to be sure before connecting. do you have any good suggestion to fint this out?

IMG_1534
IMG_1532
IMG_1531
IMG_1527
IMG_1520

@RoboDurden
Copy link
Owner

check with a multimeter which of the 4 pins is GND and which is 3.3V. Then there are only two options for SWCLK and SWDIO

@I-hate-2FA
Copy link

My firmwares can be compiled for the GD32F103 and i think that this mcu is compatible to the STM32F103. But noone ever tested my F103 binaries :-( I have 2.2.1 boards here and a test setup ready for such a board to install. But no happiness to do it. I will assign 2.2.3 to your layout. Please upload photos from backside and master / slave

no your firmware does not work on f103 i have tested it, and it do not need a test to know

@RoboDurden
Copy link
Owner

And you feel no need to explain :-(

@I-hate-2FA
Copy link

image
target is f103, processor f130 is selected, i dont think any explaination is needed

@I-hate-2FA
Copy link

back in #77 you already asked me to not use your firmware, theres no reason gen2 cannot work on gen1, additional motor will just be ignored, and itll work without issue if the correct set of hall sensor is detected

@RoboDurden
Copy link
Owner

Ah thanks for the info. I may have corrected that:
grafik

Now i get 44 errors to be fixed :-)
Starting with

compiling bldc.c...
Src/setup.c(37): error: call to undeclared function 'gpio_mode_set'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        gpio_mode_set(pin&0xffffff00U, mode, GPIO_PUPD_NONE,BIT(pin&0xfU) );
        ^
Src/setup.c(37): note: did you mean 'gpio_bit_set'?
C:/Users/PAN CF-LX6/AppData/Local/Arm/Packs/GigaDevice/GD32F10x_DFP/2.0.3/Device/Firmware/Peripherals/inc\gd32f10x_gpio.h(460): note: 'gpio_bit_set' declared here
void gpio_bit_set(uint32_t gpio_periph, uint32_t pin);
     ^
Src/setup.c(37): error: use of undeclared identifier 'GPIO_PUPD_NONE'
        gpio_mode_set(pin&0xffffff00U, mode, GPIO_PUPD_NONE,BIT(pin&0xfU) );
                                             ^
Src/setup.c(38): error: call to undeclared function 'gpio_output_options_set'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        gpio_output_options_set(pin&0xffffff00U, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, BIT(pin&0xfU));
        ^                                           ^

Maybe i can fix it.

Yes, EferuFOC should work on these Gen2.2 boards. If the pin get traced manually.
I would prefer my autodetect :-)

@I-hate-2FA
Copy link

Now i get 44 errors to be fixed :-) Starting with

good luck, i have already gave up, supporting gd32f130 on my firmware is easier then supporting mm32f103 beause it is core m3

Yes, EferuFOC should work on these Gen2.2 boards. If the pin get traced manually. I would prefer my autodetect :-)

#77 all pins is traced manually without error, but i still does not work, gen1 code is a nightmare to work with, anyone should not attempt to support none standard hardware, it is a complete waste of time and effort, and terrible customer support in the issue, working with you is much better

@RoboDurden
Copy link
Owner

If it is a 64kB mcu, my SimpleFOC should run. I tested it with a Gen1 board.

@I-hate-2FA
Copy link

it is 128 or 256k mcu
i am not familiar with the simplefoc version, but it is written by oop fan it should be understandable unlike the gen1

@RoboDurden
Copy link
Owner

25 errors :-/
Problem is that the GD32F10x_StdPeripherals are version 2.0.2 and not compatible to the v3 of GD32F1x0.
Main problem is to understand how the AF AlternateFunctions did word in those old days..

    \brief      configure GPIO pin remap
    \param[in]  gpio_remap: select the pin to remap
      \arg        GPIO_SPI0_REMAP: SPI0 remapping
      \arg        GPIO_I2C0_REMAP: I2C0 remapping
      \arg        GPIO_USART0_REMAP: USART0 remapping
      \arg        GPIO_USART1_REMAP: USART1 remapping
      \arg        GPIO_USART2_PARTIAL_REMAP: USART2 partial remapping
      \arg        GPIO_USART2_FULL_REMAP: USART2 full remapping
      \arg        GPIO_TIMER0_PARTIAL_REMAP: TIMER0 partial remapping 
      \arg        GPIO_TIMER0_FULL_REMAP: TIMER0 full remapping
      \arg        GPIO_TIMER1_PARTIAL_REMAP1: TIMER1 partial remapping
      \arg        GPIO_TIMER1_PARTIAL_REMAP2: TIMER1 partial remapping
      \arg        GPIO_TIMER1_FULL_REMAP: TIMER1 full remapping
      \arg        GPIO_TIMER2_PARTIAL_REMAP: TIMER2 partial remapping
      \arg        GPIO_TIMER2_FULL_REMAP: TIMER2 full remapping
      \arg        GPIO_TIMER3_REMAP: TIMER3 remapping
      \arg        GPIO_CAN_PARTIAL_REMAP: CAN partial remapping(only for GD32F10X_MD, GD32F10X_HD devices and GD32F10X_XD devices)
      \arg        GPIO_CAN_FULL_REMAP: CAN full remapping(only for GD32F10X_MD, GD32F10X_HD devices and GD32F10X_XD devices)
      \arg        GPIO_CAN0_PARTIAL_REMAP: CAN0 partial remapping(only for GD32F10X_CL devices)
      \arg        GPIO_CAN0_FULL_REMAP: CAN0 full remapping(only for GD32F10X_CL devices)
      \arg        GPIO_PD01_REMAP: PD01 remapping
      \arg        GPIO_TIMER4CH3_IREMAP: TIMER4 channel3 internal remapping(only for GD32F10X_CL devices and GD32F10X_HD devices)
      \arg        GPIO_ADC0_ETRGINS_REMAP: ADC0 external trigger inserted conversion remapping(only for GD32F10X_MD, GD32F10X_HD devices and GD32F10X_XD devices)
      \arg        GPIO_ADC0_ETRGREG_REMAP: ADC0 external trigger regular conversion remapping(only for GD32F10X_MD, GD32F10X_HD devices and GD32F10X_XD devices)
      \arg        GPIO_ADC1_ETRGINS_REMAP: ADC1 external trigger inserted conversion remapping(only for GD32F10X_MD, GD32F10X_HD devices and GD32F10X_XD devices)
      \arg        GPIO_ADC1_ETRGREG_REMAP: ADC1 external trigger regular conversion remapping(only for GD32F10X_MD, GD32F10X_HD devices and GD32F10X_XD devices)
      \arg        GPIO_ENET_REMAP: ENET remapping(only for GD32F10X_CL devices) 
      \arg        GPIO_CAN1_REMAP: CAN1 remapping(only for GD32F10X_CL devices)
      \arg        GPIO_SWJ_NONJTRST_REMAP: full SWJ(JTAG-DP + SW-DP),but without NJTRST
      \arg        GPIO_SWJ_SWDPENABLE_REMAP: JTAG-DP disabled and SW-DP enabled
      \arg        GPIO_SWJ_DISABLE_REMAP: JTAG-DP disabled and SW-DP disabled
      \arg        GPIO_SPI2_REMAP: SPI2 remapping(only for GD32F10X_CL, GD32F10X_HD and GD32F10X_XD devices) 
      \arg        GPIO_TIMER1ITI1_REMAP: TIMER1 internal trigger 1 remapping(only for GD32F10X_CL devices) 
      \arg        GPIO_PTP_PPS_REMAP: ethernet PTP PPS remapping(only for GD32F10X_CL devices) 
      \arg        GPIO_TIMER8_REMAP: TIMER8 remapping
      \arg        GPIO_TIMER9_REMAP: TIMER9 remapping
      \arg        GPIO_TIMER10_REMAP: TIMER10 remapping
      \arg        GPIO_TIMER12_REMAP: TIMER12 remapping
      \arg        GPIO_TIMER13_REMAP: TIMER13 remapping
      \arg        GPIO_EXMC_NADV_REMAP: EXMC_NADV connect/disconnect
    \param[in]  newvalue: ENABLE or DISABLE
    \param[out] none
    \retval     none
*/
void gpio_pin_remap_config(uint32_t remap, ControlStatus newvalue)

gpio_pin_remap_config timer0 leads me there but i can not speak Chinese..
https://blog.csdn.net/weixin_42550185/article/details/132080826

@I-hate-2FA
Copy link

do not use CSDN website, it is complete trash, a android system developer copied code from there and caused a huge bug that involve infinite loop

core m3 do not have pinmodeAF, thats why i gave up

@RoboDurden
Copy link
Owner

It might be better to start with https://github.com/Candas1/Split_Hoverboard_SimpleFOC
my fork adds aditional hoverboard classes which makes the OO structure more complex.. The Candas1 repo was the repo where we made the motor running..

@I-hate-2FA
Copy link

do not use CSDN website

https://youtu.be/kE9tUAPU-0c

@RoboDurden
Copy link
Owner

searching for GPIO_TIMER0_FULL_REMAP or GPIO_TIMER0_PARTIAL_REMAP only give me Chinese webseites :-/ GD is from China of course.
If i would find some other code, i might be able to copy and paste..

@RoboDurden
Copy link
Owner

There is a gd32F103 Gen2 repo that seems to have done the port: https://github.com/JohMah/Hoverboard-JC2015.7.31.V2.0-Hack/blob/main/HoverBoardGD32F10x/Src/setup.c
But i can not yet get it compiled:


Build target 'Target 1'
Error instantiating RTE components
Error #544: Required Software Pack 'GigaDevice.GD32F1x0_DFP.3.1.0' is not installed

Good night from Germany.

@RoboDurden
Copy link
Owner

Now this other repo comiles with

gd32f10x_misc.c : NVIC->IP -> NVIC->IPR
NVIC->IPR[nvic_irq] = (uint8_t)temp_priority;

main.c: //#include "arm_math.h" - will this affect code speed ?

And a gd32f1x0_3.03 software pack had to be deselected in
grafik

This Hoverboard-JC2015.7.31.V2.0 is Gen2.2.1 by the way, so i should be able to test it myself.
But there might be a difference between GD32F103 and STM32F103:

your bldc driver is different than gd32 board. its original stm32f103c8t6. the difference for gd32f103c have timer0=timer1 at stm32 etc.
JohMah/Hoverboard-JC2015.7.31.V2.0-Hack#3

@I-hate-2FA
Copy link

gpio_pin_remap_config timer0 leads me there but i can not speak Chinese..

i have read it anyways, but it do not explain complementary pwm, so it is not useful anyways
most people use stm32f103 library, because it is fully compatible with gd32f103(mm32f103 is not quite fully compatible)

There is a gd32F103 Gen2 repo that seems to have done the port: https://github.com/JohMah/Hoverboard-JC2015.7.31.V2.0-Hack/blob/main/HoverBoardGD32F10x/Src/setup.c

the repo owner didnt invest time in the readme, i doubt it have nice code structure that allow you to change all the pins, so it would be just like gen1 very hard to modify, i would be happy if it wasnt the case but well im not holding my breath

@I-hate-2FA
Copy link

i have checked, it is not as bad as i thought, the adc channel is editable in defines.h unlike gen1

@RoboDurden
Copy link
Owner

According to the three issues, that firmware did actually work for some users. And take a look at the eagle/ folder!

My approach in Gen2.x is to provide wrapper defines/functions in target.h. This is sufficient to remove all errors from it.c

#elif defined GD32F103
	#include "gd32f10x.h"
...
	// it.c
	#define TIMER0_BRK_UP_TRG_COM_IRQHandler TIMER0_UP_IRQHandler
	#define adc_software_trigger_enable(a) adc_software_trigger_enable(ADC0,a)
	#define dma_interrupt_flag_get(a,b)	dma_interrupt_flag_get(DMA0,a,b)
	#define dma_interrupt_flag_clear(a,b)	dma_interrupt_flag_clear(DMA0,a,b)

But i guess it would be better to add a setup_gd32f103.c because of too many syntax changes. I stopped at 40% for ADC_init():

	#define RCU_ADC RCU_ADC0
	#define RCU_DMA RCU_DMA0
	#define RCU_ADCCK_APB2_DIV6 RCU_CKADC_CKAPB2_DIV6
	#define dma_deinit(a) dma_deinit(DMA0, a)
	#define ADC_RDATA ADC_RDATA(ADC0)
	#define dma_init(a,b) dma_init(DMA0,a,b)
	#define dma_circulation_enable(a) dma_circulation_enable(DMA0,a)
	#define dma_memory_to_memory_disable(a) dma_memory_to_memory_disable(DMA0,a)
	
	#define DMA_Channel0_IRQn DMA0_Channel0_IRQn
	#define TARGET_nvic_irq_enable(a, b, c){nvic_irq_enable(a, b, c);}

And #define ADC_RDATA ADC_RDATA(ADC0) is not working because you can not redefine a define..
So i need a new define TARGET_ADC_RDATA that either maps to ADC_RDATA or ADC_RDATA(ADC0)

But this guy has already made the full port, so i could test his code with my Gen2.2.1 and then integrate it in my Gen2.x

But i do not really see any future for my old block commutation motor control.

It is a bit strange that you @I-hate-2FA Linux believer openly dislikes the EFeru firmware. You can find my rant here: EFeru/hoverboard-firmware-hack-FOC#134 So i dream that you have begun to love the beauty of OOP.

@I-hate-2FA
Copy link

According to the three issues, that firmware did actually work for some users.

i never doubted if itll work on the repo owners board, but i doubted it is modifiable for other layout(i have checked, it is actually better then i thought, not as good as mine but it is acceptable)

But i guess it would be better to add a setup_gd32f103.c because of too many syntax changes.

thats exactly what ill do , seperate initialize.c and hardware.c

But i do not really see any future for my old block commutation motor control.

indeed, sine wave is really good, but square wave is better then nothing

It is a bit strange that you @I-hate-2FA Linux believer openly dislikes the EFeru firmware.

i used to like gen1, but after actually working with it once i now understand it is terrible, and thats not the worst part, the maintainer is not helpful, it make me not want to use it

So i dream that you have begun to love the beauty of OOP.

maybe i will, i have already learned allot from this project, before this i actually write the pin number in the code without using define

@zimmii91
Copy link
Author

Hi guys! can i do anything to help here? i was trying to connect the board with my ST-link as mentioned earlier, i found the 3.3v and GND using the multimeter, but the other 2 pins does not seem to work as expected. i do not get the program to recognize the chip. do you have any tip on how i may solve this?

would is help to run the autodetect firmware once i get connected properly? @RoboDurden

@RoboDurden
Copy link
Owner

Sorry i have no happiness to help people who go silent for three weeks :-(

As you can read here, there is another github repo that succeeded with stm32f103 Gen2 board.
When you have succeeded with that firmware with the pins of your board traced manually,
you can come back here to help.

@I-hate-2FA
Copy link

for other 2 pin you can just try both combination
if it still doesnt work, it is not the swd pin, maybe rf remorte or serial
swd pin is reletively easy to trace manually

@zimmii91
Copy link
Author

Thank you for the suggestion, i do not have enough knowledge to follow everything you mentioned earlier, i only used the gen1 board which hade all this information available from different sources.

when i look at the datasheet for this chip i find that PA13 is for SWDIO and PA14 for SWCLK, but i get confused of the different pinvariations mentioned that i assume is for variant models of the chip. however it seems that they should be placed in the top right corner, one on top right and one on 3rd pin down from right side. not sure what i should expect when i meassure the pins to be honest, was expecting to find a connection similar to how i was able to define GND and 3,3V, but unfortunately i am not able to.

reading the datasheet i found this information, maybe this is helpful?
"Serial wire JTAG debug port (SWJ-DP)
The ARM SWJ-DP Interface is embedded. and is a combined JTAG and serial wire debug
port that enables either a serial wire debug or a JTAG probe to be connected to the target.
The JTAG TMS and TCK pins are shared with SWDIO and SWCLK, respectively, and a
specific sequence on the TMS pin is used to switch between JTAG-DP and SW-DP. "

@zimmii91
Copy link
Author

oh wait. i hade it connected wrong. and assumed the position of the board was stated as the text showed on it, which it is not. i will try finding that test firmware and try it out. thank you anyway.

@I-hate-2FA
Copy link

image
is it really that hard, just look at the wiki and the datasheet of the chip
remember, if it is gen1, theres no such customer support like im doing now!

@zimmii91
Copy link
Author

image is it really that hard, just look at the wiki and the datasheet of the chip remember, if it is gen1, theres no such customer support like im doing now!

Yes my bad. i seem to have tried tracing the pins PB12 and PB11 thinking that was the ones, not realizing the chip was turned. all on me. really appreciate the support, thank you!

@zimmii91
Copy link
Author

Hi again. For me, this was really a challenge. i have no experience in compiling firmware or understanding the code, but i have given it some time now. however i have to admit defeat as i do not get anywhere. i really wanted to be able to contribute at this point in time. As i know it is not on you to teach these basics i can only say, sorry to have waisted your time guys.

@I-hate-2FA
Copy link

sorry, working on the f103 is just a waste of time, because there is no easily adaptable firmware for this mcu, this repo is for gd32f130, i also have a repo for all mm32 series, which a brand new pair of board only cost $2, i dont understand why you would use other ones

@zimmii91
Copy link
Author

Oh that sounds great! i bought a couple of Hoverboards and have about 4 pairs of the same f103, it seems that is the only thing selling in Sweden. Tell me, where can i find the MM32 bords for $2? that would make it so much easier.

@I-hate-2FA
Copy link

www,aliexpress,com/item/1005005959910034.html
you can only get it for $2 in china unfortunately, but i think $3.5 is still good

@zimmii91
Copy link
Author

Wow Thank you! This is really helpful! i was hoping to find something like this. Appreciate the help!

@L1mp4
Copy link

L1mp4 commented Jun 23, 2024

Nice. Feels like a loss tho, does it not? Not being able to use perfectly good electronics lying on the table. Wish i was capable of solving this. I am not.

@I-hate-2FA
Copy link

f103 is core m3 insted of m0(gd32f130 is also m3, but the structure is copied from stm32f030, which is m0), so it is impossible to adapt firmware for it, only way is to rewrite everything

@I-hate-2FA
Copy link

you can always replace the mcu, but i think it is just not worth the effort, unless you need a board right now

@L1mp4
Copy link

L1mp4 commented Jun 24, 2024

Nah. I ordered something else to get the motors working. Maybe someone with the skills will get hold of a lot of these boards in the future and make it happend. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants