communitygd32cores / arduinocore-gd32 Goto Github PK
View Code? Open in Web Editor NEWArduino core for GD32 devices, community developed, based on original GigaDevice's core
License: Other
Arduino core for GD32 devices, community developed, based on original GigaDevice's core
License: Other
Per title.
Currently manufacturing hardware is in the works to get test board.
I observed it multiple times in a hardware configuration with a SSD1306 I2C OLED display that reflashing the firmware at specific points would cause the new firmware to hangup in the i2c_stop()
function (as I observed in the debugger).
This code does not have timeouts (as opposed to other I2C functions) and in case the I2C peripherhal wants to assert a STOP condition but the bus just doesn't let it be driven that way (some other device is interfering?) this hangs up forever.
This should be investigated and fixed.
The core should be built automatically on a new commit and tested against reference projects.
One could probably set up a Rasberry Pi with an actual board to act as a CI host (instead of using probably paid-for Github CI actions).
Flashing a GD32F303CC board with the popular STM32Duino USB DFU bootloader, e.g. https://github.com/rogerclarkmelbourne/STM32duino-bootloader/blob/master/binaries/generic_boot20_pc13_fastboot.bin, shows that this exact binary works without problems on the board, although it's meant for a STM32F103C8 (which seems to be register-compatible for the USB and GPIO side)
The device is being recognized via USB and opens the Maple serial as expected.
This should make it possible to add USB DFU uploads for those chips having USB but no built-in USB bootloader, that is for F30x series the 303 chips.
Important logic in PlatformIO
probably also needs LDScript changes to respect the offset.
Also needs to be implemented for the Arduino IDE.
It should also be investigated what other boards can make use of this USB bootloader.
ArduinoCore-GD32/cores/arduino/HardwareSerial.h
Lines 138 to 151 in 2616a45
If a board enables both UART0 and UART1 there would be two Serial
objects. Needs to be fixed.
This core should have a SD
library like https://github.com/arduino-libraries/SD to be able to access SD cards.
Along this should probably be some sort of file and filesystem support, like with the ESP32.
Note that our boards do have a SDIO peripheral which is meant to interface with SD cards. But I guess it also works in SPI mode.
It should be investigated how the library can be ported or support for it can otherwise be sensibly added.
the PWM class / timer functionality seems to have a problem if the output pin requires a function remap. e.g.,
Test code
#include <Arduino.h>
PWM pwm_output(PA6);
void setup() {
pwm_output.setPeriodCycle(500, 250, FORMAT_MS);
pwm_output.start();
}
void loop() {}
and change PA6
to PB6
to observe the difference. Tested on a GD32F303CC board.
Some libraries require this function, it seems to be missing in this core.
From max:
todo note: equalize default uart pins between arduino and SPL UART examples
What STM32 duino does for a bluepill
yeah they also do PA9, what we do in SPL.
#ifndef PIN_SERIAL_RX
#define PIN_SERIAL_RX PA10
#endif
#ifndef PIN_SERIAL_TX
#define PIN_SERIAL_TX PA9
#endif
https://github.com/stm32duino/Arduino_Core_STM32/blob/master/variants/STM32F1xx/F103C8T_F103CB(TU)/variant_PILL_F103Cx.h#L140-L145
Hey,
I'm trying to use software serial with F130 but it is failing to compile in Arduino IDE with the following error.
SoftwareSerial.cpp:264:5: error: 'noInterrupts' was not declared in this scope
264 | noInterrupts();
SoftwareSerial.cpp:266:5: error: 'interrupts' was not declared in this scope
266 | interrupts();
Any help is really appreciated. Thanks in advance.
The example projects which are currently hosted at https://github.com/maxgerhardt/gd32-pio-projects should be included here as test sketches, once the projects and the core have matured a bit. This also serves as documentation of "what works" and "what was tested".
OS: macOS12.6.6
IDE: vscode with arduino-cli
[Starting] Install package - GD32Community...
GD32Community:gd32:0.0.1
Invalid argument passed: Found 0 platform for reference "GD32Community:[email protected]":
[Error] Exit with code=7
When I add the url to Arduino settings and want to install this package some problems occurred like above.
I have googled it but nothing found, so how to aim the problem and shoot it down?
Many of the GD chips support two or even three can busses.
Would be nice to have support for that peripheral.
Should be as easy as taking the code from the STM core and moving it to the GD core.
Dear Sir, first of all: Many thanks for your great work!
My problem is that although there are lots of GD32XNNN micros supported in Plaformio, there are only around 5 in Arduino.
As I tend to prefer to use the Eclipse based Sloeber IDE against the Platformio, I would greatly appreciate if I can program and debug GD32E230 micros there. Unfortunately, the Sloeber plugin only accepts Arduino-style .json file.
I would geratly appreciate if you update the Arduino plugin in order to support more MCUs, namely the GD32E230K8T6, should it provided no major difficulty for you.
Best regards,
Tomáš Jíra
As I understand it, the board startup code in https://github.com/CommunityGD32Cores/ArduinoCore-GD32/tree/main/system/CMSIS/GD/GD32F30x/Source/GCC is being generated by hand run sed
scripts from the upstream firmware library source in GD32F30x_Firmware_Library_V2.0.2/Firmware/CMSIS/GD/GD32F30x/Source/ARM
(which is missing in this repository).
In order to better support drop-in firmware library upgrades, the GCC-compatible startup code should be generated as part of the build process, with the relevant translation scripts checked in to the source tree.
I was wondering if there is going to be support for GD32F103.
For now, I use the Android version from this repo: platform-ststm32, and is working but is not optimal.
Would be great to use ArduinoCore-GD32 for the GD32F103
This is not an issue in the current core, but in @bjc's bjc/gd32usb-test
branch. As issues aren't available in the fork, and the feature will - hopefully - make it back here in the not too distant future, I'm opening the bug here.
The core of the issue is that CDCACM_::available()
returns the count of what's already been read into the buffers, rather than what's really available, rendering the function almost useless.
To showcase the problem, use the following sketch:
#include "Arduino.h"
void setup() {
Serial.begin(9600);
};
void loop() {
if (Serial.available()) {
uint8_t b = Serial.read();
Serial.println(b);
}
}
Feeding data onto the serial port from one terminal, and reading from the other, this currently never outputs anything.
If we change the sketch, and do a read before calling .available()
:
#include "Arduino.h"
void setup() {
Serial.begin(9600);
};
void loop() {
uint8_t b = Serial.read();
if (Serial.available()) {
b = Serial.read();
Serial.println(b);
}
}
And then feed the port with two bytes written at a time (eg, echo a >/dev/ttyACM1
, which will send a newline along), we'll quickly discover that the first byte is read, and because we read more than one byte at a time into an internal buffer, .available()
will return 1
too, and we'll read the second byte too.
The core should state how it is supposed to be installed / used.
Currently all the projects are hosted at https://github.com/maxgerhardt/gd32-pio-projects and one needs PlatformIO and a modification to the platform_packages
expression (replace with link to this repo) to get it working, but a nicer and more hand-holding tutorial should be written, once things have stabilized a bit.
Right now this core is primarily built with PlatformIO (see https://github.com/maxgerhardt/gd32-pio-projects).
Original Arduino-IDE support was probably there as there is a platform.txt
, board.txt
and a package index at https://github.com/CommunityGD32Cores/GD32Core but it seems slightly incomplete to me (no download URLS?).
Since development and debugging is a thousand times easier and faster in PlatformIO, Arduino IDE is not a priority as of now.
EDIT: A package json was added with instructions at https://github.com/CommunityGD32Cores/GD32Core-New#using-this-core-with-the-arduino-ide, but uploading does not work yet due to missing uploader packages and logic.
I was trying to run the following code to test two serial ports and I was having this issue.
void setup() { Serial.begin(9600); Serial1.begin(9600); }
void loop() { Serial.println("looping S1"); Serial1.println("looping S2"); delay(1000); }
The issue I'm having is I'm getting the output for both serial print lines on the first serial output.
Then I tried to run SPL example with changed parameters to check whether it is a issue with my PCB but after I made same changes, I was able to use UART1.
Then I tried to use only Serial1 with the following code and on the debug mode I noticed the following.
void setup() { Serial1.begin(9600); } void loop() { Serial1.println("looping S2"); delay(1000); }
It seems like it is still passing the same parameters for 1st serial port. Please can you help me to fix this ? Any help is really appreciated.
Thanks.
The core should have a builtin FreeRTOS library, akin to STM32FreeRTOS.
This additionally requires that the core allows hooking of the SysTick function and possibly other functions.
Hello, i have a question about device support for this boards package. How well is the serial upload support? Do i need to download any external software to use this feature, or is it built-in to the package? I am not able to use external software for safety reasons, so i need to know if it will work without or if there is an alternative method for serial upload. Thank you for your help.
A previously noted issue was that if something like
Serial.println("ABC");
Serial.flush();
was done it would hang up the MCU in an infinite loop. This was fixed in 3770a80 by marking the member variables of the ring buffer implementation as volatile
, forcing them to be reloaded from RAM very time for a check. The original problem being, that the compiler optimized away further loading of this variable since it didn't see how it could be modified, although it was being modified in the ISR.
Fixing the ringbuffers was one part but there could potentially be another source of hangup through missing volatile
in
through the .tx_state
member.
However, marking that as volatile resulted in lots of compiler errors.
It should be investigated whether it possible to trigger this bug (lockup) and then fix it.
There may be other places where volatile
is missing, causing potential lockups.
As introduced with #22, we now have a Python, C and C++ linter active in the project.
It already throws quite a bit of errors and has suggestions for code improval.
Some errors are wrong however, the linter just does not know about SCons / PlatformIO specifics.
For now it has been temporarily disabled to mark the linter errors as run errors per 240b9d7, so that we don't get spammed with failure emails.
The code needs to be progressively improved and the linter settings need to be tweaked so that we have sensible output and good linting.
A list of all previous errors can be found in https://github.com/CommunityGD32Cores/GD32Core-New/actions/workflows/linter.yml.
A sample file is attached
The currently does the original GD32 USB libraries (https://github.com/CommunityGD32Cores/GD32Core-New/tree/main/system/GD32F30x_firmware/GD32F30x_usbd_driver) but these are not used.
No USB functionality is available, e.g. USB CDC, USB HID, etc.
It should be thought out very carefully how USB support is added.
The ArduinoCore-API repo has the PluggableUSB class which is e.g. used in the ArduinoCore-mbed USB implementation.
Other cores use something like e.g. tinyUSB (Adafruit fork).
Since I'm no expert on USB, design thoughts & implementation help is appreciated.
Right now USB seems like a complex feature and maybe other smaller features can take precendence first.
Depends on CommunityGD32Cores/platform-gd32#21.
The low-power GD32L23x series of chips should be supported here in ArduinoCore-GD32, with libraries such as LowPower or SleepyDog and friends to take care of the new functionality.
The core, or a library, should be able to expose the low-power functionality of the chip, such as
(I have not checked that these are the low-power modes available, just a guess from STM32 chips)
It should also be supported to put every known peripheral to sleep, or better yet, automatically put it to sleep if not needed.
I have been waiting for GD32E230C to support Arduino , Is there a plan to support? schedule?
Very thanks.
The readme "Using this core with the Arduino IDE" section is incompatible with arduino2 IDE(Version: 2.0.0-beta.12-nightly.20211019)
Since the boards do have an I2S peripheral it would be nice to have a library that makes use of it, with audio examples.
Some recent versions of the BTT TFT Touchscreens (https://github.com/bigtreetech/BIGTREETECH-TouchScreenFirmware) make use of the GD32F205VC MCU so this project should consider adding support for these boards. Even though they are not development boards, the number of peripherals they include make them an excellent choice for custom projects. As a matter of fact, we are currently making use of this code base for implementing a custom motor controller on one of these boards (https://www.biqu.equipment/collections/lcd/products/btt-tft35-e3-v3-0-display-touch-screen-two-working-modes). Here is the link to the Github repo for this project (https://github.com/vovan888/ArduinoCore-GD32).
Per
and
something is missing here to get a normal printf()
working and showing on the default Serial
. Serial.printf()
works fine though. We probably just want a redirect.
Per CommunityGD32Cores/platform-gd32#28.
No output when using provided standard code.
Please add support on this m4 gd32 chip - GD32F350. Thanks.
Hi All.
Have started to develop with GigaDevice chips.
I have followed the instructions to use the Arduino Ide and successfully compiled a the "Blink" example for the "GD32F30x MBed Series"
The following "blink-build.txt" shows the debug output of a build command.
I would appreciate it if somebody could explain the use of "-isystem" include paths and where I can find information on it.
I have never come across it before.
Any help much appreciated
I look forward to participating in the Community.
Best regards Noel Diviney
The hardware comes with independent watchdog and windowed watchdogs. The library https://github.com/stm32duino/Arduino_Core_STM32/tree/master/libraries/IWatchdog should be ported to this core.
Refer #6.
The platform.txt
etc. is referencing a missing upload package
It is partly available from https://github.com/CommunityGD32Cores/GD32Core (JLink & Serial but no GDLink).
However, I don't like this particular setup of calling into a batch file for multiple different OSes and then having helper scripts there. Also I don't like that the upload method uses .bin
files, this is missing a potential upload offset if one is used (e.g., for bootloaders). At least for SWD / JTAG based uploads, we should be able to directly reference OpenOCD as a package and call into it with the right flags, just like I do in PlatformIO. (
An OpenOCD upload via a ST-Link (SWD) e.g. looks like
openocd -d2 -s C:\Users\Max\.platformio\packages\tool-openocd/scripts -f interface/stlink.cfg -c "transport select hla_swd" -c "set CPUTAPID 0x2ba01477" -f target/stm32f1x.cfg -c "program {.pio\build\genericGD32F303CC\firmware.elf} verify reset; shutdown;"
And similiarily for the GDLink (which is a cmsis-dap -- and actually the STLink can be treated as a cmsis-dap.cfg
as well).
I see a custom OpenOCD version being developed at https://github.com/GigaDevice-Semiconductor/openocd/ but actually I did not have the need to use it since it also works well-enough treating the chips as STM32 chips in regards to uploading to flash.
Once the core has reached a certain level of stability and maturity, it should be thought about how to "get the word out" about this new core. This would attract new users and contributers for sure.
Some thoughs:
Currently the system_gd32f30x.c
has a hardcoded clock source of HSE+PLL to 120MHz.
This should be changable via defines (in the Arduino IDE: via a menu selection) to be able to boot from
As this core grows and gains its own set of functionality, there should be a documentation that users can refer to.
We may think about using DoxyGen or create Wiki pages for several topics (e.g., libraries, core features, ...)
PR #43 changed some -I
includes to -isystem
includes so that we don't get warnings from the SDK and ArduinoCore-API code that we don't touch.
Further, the Arduino core builds with warning flags (-Wall -Wextra
) that PlatformIO doesn't use.
All these flags should be equalized.
A possible caveat with changing -I
to -isystem
flags in the PlatformIO system is however that when moving folders from the CPPPATH
to CCFLAGS
(-isystem
flags), they might disappear from the include search directory in generated IntelliSense configuration files (c_cpp_properties.json
). This would greatly limit IDE usefullness when using PlatformIO. If that is the case, an issue in the PlatformIO core must be opened (or accepted that we can't change -I
to -isystem
comfortably yet).
This is a master issue regarding the testing of all the components that were already in the core. It should be noted what features were tested, which worked, which did not work, and which features were not present. If a feature is marked with tickmark, it means it was working, otherwise it is untested, or tested to be non-working if there is a comment below it.
attachInterrupts()
works in all cases (FALLING
, RISING
, CHANGE
, NONE
)
FALLLING
worksnoInterrupts()
and interrupts()
workanalogRead()
on a channelanalogReadResolution()
worksprintln()
with all data typesHardwareTimer
workstone()
/ noTone()
Currently calling analogWrite
will attempt to write the value into the DAC peripheral, producing an exact analog voltage.
The regulard Arduino API analogWrite would start a PWM output with some default parameters (e.g., PWM frequency, PWM resolution etc.) on that pin.
The functionality should be changed so that analogWrite
also starts a PWM wave and friend functions for setting resolution and frequency should be added.
Currently, PWM functionality is available via the PWM
class
(and is partly not working, see #4)
The DAC functionality should still be accessible of course -- it has to be thought to which API it should be moved, or if an "auto-detection" between PWM and DAC should be made.
The code for the servo class and header are copied from the Arduino AVR source code but the copyright statements have been removed. Please ensure that all copyright material used in this repository include existing copyright statements
The Keyboardio board added in #39 defines one possible upload method for the board as DFU, with an flash_offset of 0x2000.
This is however not respected in the platform.txt
DFU upload method. It is respected when building the firmware through relocating the vector table etc. See #39 (comment).
Line 33 in 30bac5f
Lines 110 to 112 in 30bac5f
We need to very / fix the workings of the DFU upload methods in regards to the upload offset.
Linked to PlatformIO board definition (PR CommunityGD32Cores/platform-gd32#15) too, since DFU upload is also done there but without an upload offset (since the board definition file doesn't have one).
Depends on CommunityGD32Cores/platform-gd32#20.
The WiFi-capable GD32W51x series of chips should be supported here in ArduinoCore-GD32, with libraries such as WiFi and friends to take care of the new functionality.
(int)DAC0 -> (int)DAC
https://www.arduino.cc/reference/en/language/functions/interrupts/nointerrupts/ says they're part of the standard API.
We don't implement them.
It looks like it they should be implemented as wrappers around __disableIrq
and __enableIrq()
per https://stm32f4-discovery.net/2015/06/how-to-properly-enabledisable-interrupts-in-arm-cortex-m/ and some grepping of the GD32 code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.