Hoverboard-Firmware-Hack-Gen2.x icon indicating copy to clipboard operation
Hoverboard-Firmware-Hack-Gen2.x copied to clipboard

Gen2.4.1 (ex2.8) = MM32SPIN05PFOP :-(

Open RoboDurden opened this issue 2 years ago • 315 comments

master front/back

https://www.mindmotion.com.cn/en/products/mm32mcu/mm32spin/mm32spin_specific_mcu/mm32spin05/

  • 32bit Arm® Cortex®M0 processor as the core
  • Maximum operating frequency is up to 72M
  • 32K bytes of Flash memory
  • 4K bytes of SRAM
  • Boot loader supports Chip Flash and ISP (InSystem Programming)
  • Embedded factorytuned 48/72MHz high speed oscillator
  • One 12bit ADC and 1μS of conversion time (up to 13 channel)
  • Supported peripherals: Timer, UART, I2C, SPI and ADC
  • One 16bit 4channel advancedcontrol timer with 4channel PWM output, dead-time generation and emergency stop
  • Serial wire debug (SWD)
  • Two UARTs
  • One I2C
  • Two SPIs

https://www.keil.com/dd2/mindmotion/mm32spin05nt/

https://github.com/topics/mm32

Would be nice if someone knows how to add this device to the Keil IDE.

RoboDurden avatar Sep 19 '23 09:09 RoboDurden

Does the information here help add it to KEIL?

https://github.com/iclite/mm32_startup/tree/master

reed-dan avatar Oct 30 '23 17:10 reed-dan

Would be nice if @WizzardDr would explain how he added the GD32E230 target to the project: grafik If a new target would be added, then your MM mcu can be choosen: grafik

Then this repo might already compile. It might need some fixes like fore the E230 mcu in target.h

#ifdef GD32E230
	#include "gd32e23x.h"
	#define TARGET_nvic_irq_enable(a, b, c){nvic_irq_enable(a, b);}
	#define TARGET_nvic_priority_group_set(a)	// that function does not exist for this target = not needed ?
	#define TARGET_adc_vbat_disable()
#else
	#include "gd32f1x0.h"
	
	#define TARGET_nvic_irq_enable(a, b, c){nvic_irq_enable(a, b, c);}
	#define TARGET_nvic_priority_group_set(a){nvic_priority_group_set(a);}
	#define TARGET_adc_vbat_disable(){adc_vbat_disable();}
#endif

But as WizzardDr succeeded with adding a new target, i now am quite optimistic that he and me could add your MM mcu and i/we resolve all compiler errors.

But are you willing to invest some hours to trace the pins ??

RoboDurden avatar Oct 30 '23 17:10 RoboDurden

Okay, a target can be added in menu->Project->Manage->ProjectItems.. grafik

But now i am stuck at adding the Device files and i do not know the name of the propper #include file: grafik

ideas welcome.

RoboDurden avatar Oct 31 '23 08:10 RoboDurden

When I look at my board it is slightly different than this board, appears to have the same processor though.

20231031_112219 20231031_111844 20231031_111811

Board Source: Jetson Plasma Model: Plasma (JPLSM-BLK) Construction: Plastic Base Plastic wheel UPC: 811991031504 Battery: ELITOP-1001U-JD LI-ION 36V 90Wh 2500mAh -Shenzhen Elite Electric Co. Ltd. MH63800 HY-JD-A20GNB3642 Input: 36VDC 0.85A Max capicity 2.5AH Max Speed 10 Mph Max Weight 220LB

Slave Board Identifiers Taotao Technology 2025 pu20200616011 94v-0 y-d e253642 816117r

reed-dan avatar Oct 31 '23 16:10 reed-dan

To me this looks identical to the photos of the first board.

But i have no idea from where to get the MM counterplay of the Standard Peripherals: grafik

I have nearly zero experience with the Keil Ide :-/

RoboDurden avatar Oct 31 '23 16:10 RoboDurden

Yes thanks, i have added the pdf documents to the manuals folder. But i fear we still do not know how to install the Standard Peripherals like ADC, DMA, GPIO

RoboDurden avatar Nov 02 '23 17:11 RoboDurden

Also found in

Board Source: JETSON ALPA Model: Alpha (JALPHA-BLK) Construction: Plastic Base FCC: 2AV54ALPHA https://fcc.report/FCC-ID/2AV54ALPHA

reed-dan avatar Nov 22 '23 00:11 reed-dan

Looking for help on this board. I've burned through many of the RioRand motor controllers and decided to use one of the 4 different hoverboard motors that I have. Any help will be appreciated. I'm a newbie, but I love tinkering and learning new things.

BigVoo avatar Jan 06 '24 01:01 BigVoo

If you have different boards you better start with a GD32F130 MCU and not this not yet supported MM32SPIN05.

RoboDurden avatar Jan 06 '24 11:01 RoboDurden

I do have a GD32F130 C8T6 MCU board, but it's a newer board and does not match any of the examples. I wasn't sure if I could flash or not since it didn't exactly match. If I can, then that will be perfect since that's the board and motor that I want to use.

BigVoo avatar Jan 06 '24 12:01 BigVoo

No you need to start a new issue here, upload high res photos of front and backside and start tracing the pins. See the 2.6.1 issue currently being active. This 2.8 is not yet traced either.

I always like to add new layouts, so feel free to go ahead :-)

RoboDurden avatar Jan 06 '24 12:01 RoboDurden

@RoboDurden heres a toturial of using keil with mm32spin maybe itll help i cannot tell mm32spinexample(changeZIPto7Z).zip MM32_KEIL_Pack_2.18.zip

ghost avatar Jan 06 '24 14:01 ghost

Okay, a target can be added in menu->Project->Manage->ProjectItems.. grafik

But now i am stuck at adding the Device files and i do not know the name of the propper #include file: grafik

ideas welcome.

i am not sure if this is your problem but i think you can copy it from example image

ghost avatar Jan 06 '24 18:01 ghost

@RoboDurden can you please look into it now i have included the new build target it still have 83 error but those are related to constant not defined can you fix them image #50

ghost avatar Jan 08 '24 08:01 ghost

Thanks for you work ! I have accepted the pull request :-) But i did not like that you changed

#ifndef ADC_BATTERY_VOLT
	#define ADC_BATTERY_VOLT      0.024169921875 

to

#ifndef ADC_BATTERY_VOLT
	#define ADC_BATTERY_VOLT      0.02488682634 	// V_Batt to V_BattMeasure = factor 30: ( (ADC-Data/4095) *3,3V *30 )

This would apply to all other layouts and not only the 2.6. Instead i will add

#define ADC_BATTERY_VOLT 0.02488682634 // V_Batt to V_BattMeasure = factor 30: ( (ADC-Data/4095) *3,3V *30 ) to the defines_2-6.h

RoboDurden avatar Jan 08 '24 09:01 RoboDurden

i have uploaded my first changes, so please @AILIFE4798 sync your code.

#ifdef GD32E230
	#define LAYOUT 7
#elif MM32SPIN05
	#define LAYOUT 8
#else
	#define LAYOUT 6
#endif

//#define MASTER		// uncomment for MASTER firmware. Choose USART0_MASTERSLAVE or USART1_MASTERSLAVE in your defines_2-?.h file
//#define SLAVE			// uncomment for SLAVE firmware. Choose USART0_MASTERSLAVE or USART1_MASTERSLAVE in your defines_2-?.h file
#define SINGLE			// uncomment if firmware is for single board and no master-slave dual board setup

Looks like many files in the Inc project folder should not be there. Maybe you can fix this: grafik

RoboDurden avatar Jan 08 '24 09:01 RoboDurden

I am down to 75 errors and 0 warning. Many errors are to my PB8 -> PORT_B + PIN_8 marcors that i introduced lately to make the defines_2-x.h easier. But these macros are GD32 specific so i now first have to investigate how MM is coding PORT and PIN. This might take some hours.

I am still struggeling to get water and electricity running in my autarcic train station: grafik It is -7°C outside (10:44 o' clock)

RoboDurden avatar Jan 08 '24 09:01 RoboDurden

yes,the adc calibration should be done on every board because the resistors and mcus are not exactly identical

you can delete those files in inc its not needed i am just experimenting with it and those file is included in device already image

ghost avatar Jan 08 '24 09:01 ghost

done and repo updated :-)

RoboDurden avatar Jan 08 '24 09:01 RoboDurden

do you have real hardware layout2.8 to test on or should i buy more of them to test because the real problem will start from how to flash it

ghost avatar Jan 08 '24 09:01 ghost

MM is also using port defines like GPIOB but not pin defines like GPIO_PIN_9 :-/ So i must learn the defines to acces a port/pin for MM. With GD32 the GPIO_PIN_9 is defined in gd32f1x0_gpio.h:


/* GPIO pin definitions */
#define GPIO_PIN_0                 BIT(0)                /*!< GPIO pin 0 */
#define GPIO_PIN_1                 BIT(1)                /*!< GPIO pin 1 */
#define GPIO_PIN_2                 BIT(2)                /*!< GPIO pin 2 */
#define GPIO_PIN_3                 BIT(3)                /*!< GPIO pin 3 */
#define GPIO_PIN_4                 BIT(4)                /*!< GPIO pin 4 */
#define GPIO_PIN_5                 BIT(5)                /*!< GPIO pin 5 */
#define GPIO_PIN_6                 BIT(6)                /*!< GPIO pin 6 */
#define GPIO_PIN_7                 BIT(7)                /*!< GPIO pin 7 */
#define GPIO_PIN_8                 BIT(8)                /*!< GPIO pin 8 */
#define GPIO_PIN_9                 BIT(9)                /*!< GPIO pin 9 */
#define GPIO_PIN_10                BIT(10)               /*!< GPIO pin 10 */
#define GPIO_PIN_11                BIT(11)               /*!< GPIO pin 11 */
#define GPIO_PIN_12                BIT(12)               /*!< GPIO pin 12 */
#define GPIO_PIN_13                BIT(13)               /*!< GPIO pin 13 */
#define GPIO_PIN_14                BIT(14)               /*!< GPIO pin 14 */
#define GPIO_PIN_15                BIT(15)               /*!< GPIO pin 15 */
#define GPIO_PIN_ALL               BITS(0,15)            /*!< GPIO pin all */

The PORT definitions for MM are in reg_gpio.h :

#define GPIOA                           ((GPIO_TypeDef*) GPIOA_BASE)
#define GPIOB                           ((GPIO_TypeDef*) GPIOB_BASE)
#define GPIOC                           ((GPIO_TypeDef*) GPIOC_BASE)
#define GPIOD                           ((GPIO_TypeDef*) GPIOD_BASE)

But i can no identify the PIN definitions yet. Maye a MM32 code example would help

I think i have 2.8 but not here in the train station i think. And honestly i do not have the time=happiness at the moment to build yet another test setup. So it would be great if you had 2.8 hardware. Was $2 a typo or can you really buy fully assembled 2.8 boards for USD 2 ???

RoboDurden avatar Jan 08 '24 09:01 RoboDurden

Maybe these are the definitions we need: https://github.com/koendv/MM32SPIN27-Arduino/blob/525f27bd91b756aeabad3b7a706f60cb9fb75275/mm32/cores/arduino/HAL_Lib/hal_gpio.h#L89

But i would like to find these defines in the target files you added.

RoboDurden avatar Jan 08 '24 10:01 RoboDurden

image here is a example of mm32 blynk

$2 is for a pair of master and slave layout2.8.1 board by razor no led or motor i think its hard to beat heres a link not sure if you can open it outside of china if not you have to use VPN https://m.intl.taobao.com/detail/detail.html?id=722577319258 a set of gen1 board with mainboard+2 side board+led board is $12 still cheap(seller say its full GD32 so compatiable with eferu) keep in mind its china everything is dirt cheap

ghost avatar Jan 08 '24 10:01 ghost

Where can i download this blynk example ?

We have problems to port the EFeru gen1 firmware to the newer AT32 Gen1 boards ! So if there is no GD32 mcu on theser $12 boards i would be caucious.

RoboDurden avatar Jan 08 '24 10:01 RoboDurden

you can download example in pack installer image

ghost avatar Jan 08 '24 10:01 ghost

yes i have also seen the at32 board its selling for even cheaper but i know its not supported so i wont try to buy it it is very easy to identify by theres no mcu on the side board every single gpio goes to the main board so the main board to side board cable is very wide idk how they get so much gpio from just one mcu maybe with multiplex idk

ghost avatar Jan 08 '24 10:01 ghost

Incase you cannot open the link I downloaded the image from seller for you to confirm layout 2.8.1 Screenshot_2024-01-08-18-24-42-121_com google android apps photos~2 Screenshot_2024-01-08-18-24-57-922_com google android apps photos~2

ghost avatar Jan 08 '24 10:01 ghost

Well this is definitely not a 2.8 layout. See my photos in Schematics_2.8/ folder.

I do not find the gpio_bit_write() definition for the MM target. When i search my project with strg+shift+F i only find the GD definition :-/ This would help me to cast PA6 to the correct types ..

RoboDurden avatar Jan 08 '24 10:01 RoboDurden

48 errors. code uploaded. i have to make a break. sun is finally shining so i can saw some wood to feed my oven ! It is currently -6°C outside and +11°C inside !

RoboDurden avatar Jan 08 '24 10:01 RoboDurden