Skip to content

Commit b86a4dc

Browse files
committed
Add flashcode libs and GD32 FMC support
Introduces new `lib-flashcode` and `lib-flashcodeinstall` modules for firmware image handling and flash programming, including platform-specific install paths for GD32 and H3 plus U-Boot header validation/CRC flow. Adds a new `gd32::fmc` API in `lib-gd32` with read/erase/write support (blocking and state-machine variants) and wires FMC sources through updated build rules. The build system was also cleaned up by moving/centralizing feature-dependent source selection into `lib-gd32/Rules.mk`, adjusting template/link define handling, and adding PHY/link-check define logic in GD32 validation. Smaller updates include debug/formatting tweaks (`PrintBits` labeling, `asctime` null check style, `Atof` expression clarity) and Eclipse project/settings refresh files.
1 parent 744d0a7 commit b86a4dc

46 files changed

Lines changed: 2315 additions & 249 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

common/.settings/language.settings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
66
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
77
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
8-
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1124212694268444622" id="org.eclipse.embedcdt.managedbuild.cross.arm.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Arm Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
8+
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1512171763420795725" id="org.eclipse.embedcdt.managedbuild.cross.arm.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Arm Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
99
<language-scope id="org.eclipse.cdt.core.gcc"/>
1010
<language-scope id="org.eclipse.cdt.core.g++"/>
1111
</provider>

common/include/common/utils/utils_string.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ inline float Atof(const char* buffer, uint32_t size) {
8181
}
8282

8383
while (size > 0 && *p >= '0' && *p <= '9') {
84-
result = result * 10.0F + static_cast<float>(*p - '0');
84+
result = (result * 10.0F) + static_cast<float>(*p - '0');
8585
++p;
8686
--size;
8787
}

common/include/firmware/debug/debug_printbits.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
namespace debug {
3636
template <typename T>
3737
requires std::unsigned_integral<T>
38-
inline void PrintBits(T value) {
38+
inline void PrintBits(T value, const char* string = nullptr) {
3939
if constexpr (!config::kDumpEnabled) {
4040
return;
4141
}
@@ -46,7 +46,10 @@ inline void PrintBits(T value) {
4646

4747
static_assert(sizeof(T) <= sizeof(unsigned));
4848

49-
printf("%.*x ", kHexDigits, static_cast<unsigned>(value));
49+
if (string != nullptr) {
50+
printf("%s :", string);
51+
}
52+
printf("0x%.*x ", kHexDigits, static_cast<unsigned>(value));
5053

5154
for (int bit_number = kMaxBitIndex; bit_number >= 0; --bit_number) {
5255
const auto kMask = static_cast<T>(1) << bit_number;

common/make/gd32/Validate.mk

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ endif
2424

2525
ifeq ($(findstring CONFIG_REMOTECONFIG_MINIMUM,$(FLAGS)),CONFIG_REMOTECONFIG_MINIMUM)
2626
DEFINES+=-DCONFIG_NET_APPS_NO_MDNS
27+
DEFINES+=-DCONFIG_UDP_NO_OPTIMIZE
28+
DEFINES+=-DDISABLE_RTC
2729
else
2830
ifeq ($(findstring NO_EMAC,$(FLAGS)),NO_EMAC)
2931
else
@@ -56,8 +58,23 @@ ifdef FATFS_MKFS
5658
DEFINES+=-DCONFIG_FATFS_MKFS
5759
endif
5860

61+
# Hardware Scenario Flag Condition Resulting Compiler Definitions (DEFINES)
62+
# Using RTL8201F ENET_LINK_CHECK is missing -DRTL8201F_LED1_LINK_ALL -DENET_LINK_CHECK_USE_INT (Uses Interrupts)
63+
# Using RTL8201F ENET_LINK_CHECK is present -DRTL8201F_LED1_LINK_ALL
64+
# Other Hardware Any -DENET_LINK_CHECK_REG_POLL (Uses Polling)
65+
66+
ifneq ($(findstring RTL8201F,$(FLAGS)),)
67+
DEFINES+=-DRTL8201F_LED1_LINK_ALL
68+
ifeq ($(findstring ENET_LINK_CHECK,$(FLAGS)),)
69+
DEFINES+=-DENET_LINK_CHECK_USE_INT
70+
endif
71+
else
72+
DEFINES+=-DENET_LINK_CHECK_REG_POLL
73+
endif
74+
5975
$(info $$DEFINES [${DEFINES}])
6076

6177
DEFINES:= $(sort $(DEFINES))
6278

6379
$(info $$DEFINES [${DEFINES}])
80+

firmware-template-gd32/Rules.mk

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ PROJECT=$(notdir $(patsubst %/,%,$(CURDIR)))
2525
$(info $$PROJECT [${PROJECT}])
2626

2727
DEFINES:=$(addprefix -D,$(DEFINES))
28+
DEFINES+=-DHTTPD_CONTENT_SIZE=2048
29+
DEFINES+=-DTCP_MAX_TCBS_ALLOWED=10
30+
DEFINES+=-DCONFIG_NETWORK_MEMORY_BLOCKS=12
31+
DEFINES+=-DPHY_TYPE=$(ENET_PHY)
2832

2933
include ../common/make/gd32/Board.mk
3034
include ../common/make/gd32/Mcu.mk
@@ -36,7 +40,7 @@ include ../common/make/Artnet.mk
3640
include ../common/make/gd32/mbedtls.mk
3741
include ../common/make/gd32/Validate.mk
3842

39-
LIBS+=gd32 clib
43+
LIBS+=clib gd32
4044

4145
# The variable for the libraries include directory
4246
LIBINCDIRS:=$(addprefix -I../lib-,$(LIBS))
@@ -52,12 +56,7 @@ LDLIBS:=$(addprefix -l,$(LIBS))
5256
# The variables for the dependency check
5357
LIBDEP=$(addprefix ../lib-,$(LIBS))
5458

55-
DEFINES+=-DHTTPD_CONTENT_SIZE=2048
56-
DEFINES+=-DTCP_MAX_TCBS_ALLOWED=10
57-
DEFINES+=-DCONFIG_NETWORK_MEMORY_BLOCKS=12
58-
#DEFINES+=-DCONFIG_TCP_NO_OPTIMIZE
59-
60-
COPS=-DGD32 -D$(FAMILY_UCA) -D$(LINE_UC) -D$(MCU) -D$(BOARD) -DPHY_TYPE=$(ENET_PHY)
59+
COPS=-DGD32 -D$(FAMILY_UCA) -D$(LINE_UC) -D$(MCU) -D$(BOARD)
6160
COPS+=$(strip $(DEFINES) $(MAKE_FLAGS) $(INCLUDES) $(LIBINCDIRS))
6261
COPS+=$(strip $(ARMOPS) $(CMSISOPS))
6362
COPS+=-Os -nostartfiles -ffreestanding -nostdlib

gd32_emac_artnet_dmx_multi/Common.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ DEFINES+=RDM_CONTROLLER
1111

1212
DEFINES+=CONFIG_STORE_USE_SPI
1313

14-
DEFINES+=RTL8201F_LED1_LINK_ALL
15-
1614
DEFINES+=DISPLAY_UDF
1715

1816
DEFINES+=ENABLE_HTTPD

gd32_emac_artnet_dmx_multi/Makefile-bw.GD32

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ DEFINES=DMXNODE_PORTS=4
44

55
DEFINES+=ENET_RXBUF_NUM=16 ENET_TXBUF_NUM=4
66

7-
DEFINES+=CONSOLE_NULL
87
DEFINES+=CONFIG_CLIB_USE_NULL
98

109
DEFINES+=NDEBUG

gd32_emac_artnet_dmx_multi/Makefile-dmx4.GD32

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ DEFINES=DMXNODE_PORTS=4
44

55
DEFINES+=ENET_RXBUF_NUM=16 ENET_TXBUF_NUM=4
66

7-
DEFINES+=CONSOLE_NULL
87
DEFINES+=CONFIG_CLIB_USE_NULL
98

109
DEFINES+=NDEBUG

gd32_emac_e131_dmx_multi/.cproject

Lines changed: 5 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -11,97 +11,23 @@
1111
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
1212
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
1313
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
14+
<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
15+
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
1416
</extensions>
1517
</storageModule>
1618
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
1719
<configuration artifactName="${ProjName}" buildProperties="" description="" id="cdt.managedbuild.toolchain.gnu.cross.base.308843693.732003918.1233927160.238350928" name="GD32" optionalBuildProperties="" parent="org.eclipse.cdt.build.core.emptycfg">
1820
<folderInfo id="cdt.managedbuild.toolchain.gnu.cross.base.308843693.732003918.1233927160.238350928." name="/" resourcePath="">
19-
<toolChain id="cdt.managedbuild.toolchain.gnu.cross.base.731037805" name="Cross GCC" superClass="cdt.managedbuild.toolchain.gnu.cross.base">
21+
<toolChain id="cdt.managedbuild.toolchain.gnu.cross.base.731037805" name="Cross GCC">
2022
<option id="cdt.managedbuild.option.gnu.cross.prefix.1857752619" name="Prefix" superClass="cdt.managedbuild.option.gnu.cross.prefix"/>
2123
<option id="cdt.managedbuild.option.gnu.cross.path.1313803083" name="Path" superClass="cdt.managedbuild.option.gnu.cross.path"/>
22-
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.20294688" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
23-
<builder arguments="-f Makefile.GD32 -j" id="cdt.managedbuild.builder.gnu.cross.235790201" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="cdt.managedbuild.builder.gnu.cross"/>
24-
<tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.1316814100" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
25-
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.include.paths.717726303" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
26-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/firmware-template-gd32/include}&quot;"/>
27-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-gd32/gd32f4xx/CMSIS}&quot;"/>
28-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-gd32/gd32f4xx/CMSIS/GD/GD32F4xx/Include}&quot;"/>
29-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-gd32/gd32f4xx/GD32F4xx_standard_peripheral/Include}&quot;"/>
30-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-gd32/include}&quot;"/>
31-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-network/include}&quot;"/>
32-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/include}&quot;"/>
33-
</option>
34-
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.preprocessor.def.symbols.695385220" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
35-
<listOptionValue builtIn="false" value="GD32"/>
36-
<listOptionValue builtIn="false" value="BOARD_GD32F407RE"/>
37-
<listOptionValue builtIn="false" value="GD32F4XX"/>
38-
<listOptionValue builtIn="false" value="DISABLE_FS"/>
39-
<listOptionValue builtIn="false" value="DISABLE_TFTP"/>
40-
<listOptionValue builtIn="false" value="OUTPUT_DMX_SEND_MULTI"/>
41-
<listOptionValue builtIn="false" value="NODE_RDMNET_LLRP_ONLY"/>
42-
<listOptionValue builtIn="false" value="NODE_E131_MULTI"/>
43-
<listOptionValue builtIn="false" value="NODE_E131"/>
44-
</option>
45-
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1396438666" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
46-
</tool>
47-
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.1762661716" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler">
48-
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.include.paths.2125730819" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
49-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/firmware-template-gd32/include}&quot;"/>
50-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-gd32/gd32f4xx/CMSIS}&quot;"/>
51-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-gd32/gd32f4xx/CMSIS/GD/GD32F4xx/Include}&quot;"/>
52-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-gd32/gd32f4xx/GD32F4xx_standard_peripheral/Include}&quot;"/>
53-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-gd32/include}&quot;"/>
54-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-network/include}&quot;"/>
55-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/include}&quot;"/>
56-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-display/include}&quot;"/>
57-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-displayudf/include}&quot;"/>
58-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-dmx/include}&quot;"/>
59-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-e131/include}&quot;"/>
60-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-dmxnode/include}&quot;"/>
61-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-rdm/include}&quot;"/>
62-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-remoteconfig/include}&quot;"/>
63-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-flash/include}&quot;"/>
64-
</option>
65-
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.preprocessor.def.1318952549" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" useByScannerDiscovery="false" valueType="definedSymbols">
66-
<listOptionValue builtIn="false" value="GD32F4XX"/>
67-
<listOptionValue builtIn="false" value="GD32"/>
68-
<listOptionValue builtIn="false" value="BOARD_GD32F407RE"/>
69-
<listOptionValue builtIn="false" value="DISABLE_FS"/>
70-
<listOptionValue builtIn="false" value="DISABLE_TFTP"/>
71-
<listOptionValue builtIn="false" value="OUTPUT_DMX_SEND_MULTI"/>
72-
<listOptionValue builtIn="false" value="ENABLE_HTTPD"/>
73-
<listOptionValue builtIn="false" value="NODE_RDMNET_LLRP_ONLY"/>
74-
<listOptionValue builtIn="false" value="NODE_E131_MULTI"/>
75-
<listOptionValue builtIn="false" value="NODE_E131"/>
76-
</option>
77-
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1530648100" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
78-
</tool>
79-
<tool id="cdt.managedbuild.tool.gnu.cross.c.linker.1923078425" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker"/>
80-
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.767861544" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker">
81-
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.2033719162" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
82-
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
83-
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
84-
</inputType>
85-
</tool>
86-
<tool id="cdt.managedbuild.tool.gnu.cross.archiver.1375772517" name="Cross GCC Archiver" superClass="cdt.managedbuild.tool.gnu.cross.archiver"/>
87-
<tool id="cdt.managedbuild.tool.gnu.cross.assembler.855561011" name="Cross GCC Assembler" superClass="cdt.managedbuild.tool.gnu.cross.assembler">
88-
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.both.asm.option.include.paths.2143952516" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
89-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/firmware-template-gd32/include}&quot;"/>
90-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-gd32/gd32f4xx/CMSIS}&quot;"/>
91-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-gd32/gd32f4xx/CMSIS/GD/GD32F4xx/Include}&quot;"/>
92-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-gd32/gd32f4xx/GD32F4xx_standard_peripheral/Include}&quot;"/>
93-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-gd32/include}&quot;"/>
94-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-network/include}&quot;"/>
95-
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/include}&quot;"/>
96-
</option>
97-
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.2098270591" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
98-
</tool>
24+
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.20294688" isAbstract="false" osList="all"/>
25+
<builder arguments="-f Makefile.GD32 -j" id="cdt.managedbuild.builder.gnu.cross.235790201" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" parallelBuildOn="true"/>
9926
</toolChain>
10027
</folderInfo>
10128
<sourceEntries>
10229
<entry excluding="src|lib|firmware" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
10330
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="firmware"/>
104-
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="lib"/>
10531
</sourceEntries>
10632
</configuration>
10733
</storageModule>

lib-clib/.settings/language.settings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
66
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
77
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
8-
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1124212694268444622" id="org.eclipse.embedcdt.managedbuild.cross.arm.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Arm Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
8+
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1512171763420795725" id="org.eclipse.embedcdt.managedbuild.cross.arm.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Arm Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
99
<language-scope id="org.eclipse.cdt.core.gcc"/>
1010
<language-scope id="org.eclipse.cdt.core.g++"/>
1111
</provider>

0 commit comments

Comments
 (0)