Welcome! Log In Create A New Profile

Advanced

Trying to add a GD32F303 board in Marlin

Posted by mlewiseverley 
Trying to add a GD32F303 board in Marlin
September 28, 2024 07:39PM
Hi All,

Hopefully this is the right place to ask this? If not, if someone could point me in a good direction, that would be appreciated!

I am trying to create a custom Marlin install for a new Kingroon KP3s 3.0. From my understanding the board is based on a Makerbase Robin Nano, but Kingroon appear to have switched to using the GigaDevices GD32 chipset.

Support for this chip is pretty contentious on the Marlin GitHub, but there is a Creality board that uses GD32F303 and seems to be supported. Some uses have reported success using the maple branch of STM32 chipsets, but when I tried that for this board the printer would just reboot when I tried to start a print (possibly because of Watchdog).

My hope was that I could use the config for the Creality GD32F303 board and combine it with the pin mappings for the Robin Nano. I have added a new board in Marlin/src/core/boards.h:

#define BOARD_KINGROON_KP3_V1_3_GD    5301  // Kingroon KP3s v1.3 (GD32F303RET6)

I also added the the pin definition in Marlin/src/pins/gd32f3/pins_KINGROON_KP3S_V1_3_GD.h

/**
 * Marlin 3D Printer Firmware
 * Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
 *
 * Based on Sprinter and grbl.
 * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see [www.gnu.org].
 *
 */
#pragma once

/**
 * Kingroon KP3s 1.3 (GD32F303VET6) board pin assignments
 * Sold as "Kingroon KP3s Mainboard"
 * Preliminary support for the Professional Firmwware
 */

#include "env_validate.h"

#if HOTENDS > 2 || E_STEPPERS > 2
  #error "KINGROONKP3SV1.3 only supports two hotend / E-stepper."
#endif

// Validate stepper driver selections.
//#if !AXIS_DRIVER_TYPE_hot smileyTMC2208) || !AXIS_DRIVER_TYPE_Y(TMC2208) || !AXIS_DRIVER_TYPE_Z(TMC2208) || !AXIS_DRIVER_TYPE_E0(TMC2208)
//  #error "This board has onboard TMC2208 drivers for X, Y, Z, and E0."
//#endif

#ifndef BOARD_INFO_NAME
  #define BOARD_INFO_NAME      "KINGROONKP3SV1.3"
#endif
#ifndef DEFAULT_MACHINE_NAME
  #define DEFAULT_MACHINE_NAME "Kingroon KP3s"
#endif
#define BOARD_WEBSITE_URL      "kingroon.com"
#define ALLOW_STM32DUINO
#include "env_validate.h"

#define BOARD_INFO_NAME "MKS Robin Nano V1"

//
// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role
//
#define DISABLE_JTAG

//
// Thermocouples
//
//#define TEMP_0_CS_PIN                     PE5   // TC1 - CS1
//#define TEMP_0_CS_PIN                     PE6   // TC2 - CS2

//#define LED_PIN                           PB2

#include "../stm32f1/pins_MKS_ROBIN_NANO_common.h"

#if HAS_TFT_LVGL_UI && FAN1_PIN != PB0 && HEATER_1_PIN != PB0
  #define BOARD_INIT() OUT_WRITE(PB0, LOW)
#endif

I then added a check in Marlin/src/pins/pins.h

#elif MB(KINGROON_KP3_V1_3_GD)
  #include "gd32f3/pins_KINGROON_KP3S_V1_3_GD.h"

Next I added the ini config for the board ini/gd32.ini (I am trying to use the CommonGD32 cores repo):


[env:GD32F303VET6_kingroon_kp3s]
platform             = [github.com]
platform_packages    = framework-arduinogd32
board                = genericGD32F303VE
board_build.core     = gd32
monitor_speed        = 115200
build_flags          = ${common.build_flags} -std=gnu++14
                       -DHAL_STM32 -DPLATFORM_M997_SUPPORT
                       -DUSBCON -DUSBD_USE_CDC -DTIM_IRQ_PRIO=13 -DADC_RESOLUTION=12
build_unflags        = -std=gnu11 -std=gnu++11
build_src_filter     = ${common.default_src_filter} + - +

lib_ignore           = SPI, FreeRTOS701, FreeRTOS821
lib_deps             = ${common.lib_deps}
                       SoftwareSerialM

board_build.address  = 0x08007000
board_build.ldscript = mks_robin_nano.ld
board_build.rename   = ROBIN_NANO.bin
debug_tool           = jlink
upload_protocol      = jlink
extra_scripts        = ${common.extra_scripts}
                       pre:buildroot/share/PlatformIO/scripts/fix_framework_weakness.py
                       pre:buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py
                           buildroot/share/PlatformIO/scripts/custom_board.py
                           buildroot/share/PlatformIO/scripts/offset_and_rename.py

When I try and build using PlatformIO I get the following error (no suggested environments are generated):

Error: Build environment 'GD32F303VET6_kingroon_kp3s' is incompatible with BOARD_KINGROON_KP3_V1_3_GD. Use one of these environments:

I suspect that I need to add this new board to a definitions config somewhere? If so, I cannot find how the boards in boards.h are mapped to platformio build config?

Any help on what I am doing would be greatly appreciated!
Re: Trying to add a GD32F303 board in Marlin
September 28, 2024 08:20PM
Look at Marlin/src/pins/pins.h

In the comment for each board is a list of valid build environments for the board.
Re: Trying to add a GD32F303 board in Marlin
September 29, 2024 06:58AM
Hi Dust,

That worked perfectly! Thanks!!

I did see those comments, but didn't realise that Marlin was somehow mapping these to PlatformIO...

So now I have another problem. If I use the PlatformIO community GD libraries (https://github.com/CommunityGD32Cores/platform-gd32) I get the error:

Error: This board doesn't support arduino framework!

Instead, I tried reverting my environmental config to a mashup of the Creality GD32F303 board and the MKS Robin Nano:

[env:GD32F303VET6_kingroon_kp3s]
extends              = envconfused smileyTM32F103RE_maple
build_flags          = ${envconfused smileyTM32F103RE_maple.build_flags} -DMCU_STM32F103VE -DTEMP_TIMER_CHAN=4
board_build.address  = 0x08007000
board_build.ldscript = mks_robin_nano.ld
board_build.rename   = ROBIN_NANO.bin
debug_tool           = jlink
upload_protocol      = jlink

Which gets me further, but unfortunately the MKS Robin Nano v1 uses a non-standard screen connector for 3D printer boards, which gives me this error:

In file included from Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp:30:0:
~/.platformio/packages/framework-arduinoststm32-maple/STM32F1/system/libmaple/include/libmaple/fsmc.h:47:2: error: #error "FSMC is unavailable on your MCU"
 #error "FSMC is unavailable on your MCU"

If I disable, the MKS_ROBIN_TFT24 screen (and associated features) in Configuration.h then the firmware compiles!

I am guessing that there is some configuration somewhere that maps the Robin TFT touchscreen to the STM32 chipset? If so, is there a way to add this GD32 chipset to the mapping?

Edited 1 time(s). Last edit at 09/29/2024 06:58AM by mlewiseverley.
Re: Trying to add a GD32F303 board in Marlin
September 30, 2024 01:46AM
This is why GD32 chips are not well supported..

The required subsystems are just not there


maple is a kludge, it doesnt really support gd32 very well at all..
Re: Trying to add a GD32F303 board in Marlin
September 30, 2024 04:20PM
Yea, I get that, there is a lot of chatter about this on the Marlin Github.

Unfortunately it seems more printer manufacturers are moving to the GD chipset (I guess they are cheaper than the ARM ST32 chipset), so sooner or later I feel the Marlin dev's will have to address them confused smiley. At the moment however most conversations around GD32 seem to be shutdown with a "Do not support" sad smiley

Saying that, I did think I should check the pull requests for GD32 support and there are a few open that seem to address some of the issues I am getting and found a few that are in the works:

[github.com]
[github.com]

I guess I have a bit of reading to do!
Sorry, only registered users may post in this forum.

Click here to login