Skip to content

Commit

Permalink
V2.0
Browse files Browse the repository at this point in the history
- Improved build system
- Added stack debug framework
- Removed not used source files
- Added support DMX delta output
- Added Manufacturer PIDs (https://www.gd32-dmx.org/rdm.html)
- Added support for void __libc_init_array(void)
- Changed the layout of the config store.
    - Before upgrading the firmware it is advised to make a backup of the configuration.
    - After the upgrade, then restore the saved configuration.
- lib-artnet : V1.58
- lib-e131 : V1.27
- Removed  lib-artnet4
- Improved Network abstraction layer
- Improved PHY initialization process
- Improved embedded HTTP server
- Added support for secondary (permanent) IP address
    - The node is always available on the secondary IP address (2.x.x.x) for ping and http requests.
  • Loading branch information
vanvught committed Oct 18, 2023
1 parent 9cec995 commit 553a30d
Show file tree
Hide file tree
Showing 497 changed files with 37,515 additions and 59,134 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
*/lib_gd32/*
*.su
*.list
*.map
*.size

*.bin
udp_send
Expand All @@ -60,3 +62,4 @@ gd32f30x*.*
lib-gd32/gd32f30x/*
gd32f4xx*.*
lib-gd32/gd32f4xx/*

53 changes: 51 additions & 2 deletions firmware-template-gd32/Includes.mk
Original file line number Diff line number Diff line change
@@ -1,8 +1,57 @@
INCLUDES:= -I./include -I../include -I../lib-hal/include -I../lib-debug/include
INCLUDES:=-I./include -I../include -I../lib-hal/include -I../lib-debug/include
INCLUDES+=$(addprefix -I,$(EXTRA_INCLUDES))
INCLUDES+=-I../firmware-template-gd32/include
INCLUDES+=-I../firmware-template-gd32/template
INCLUDES+=-I../lib-gd32/${FAMILY}/${FAMILY_UC}_standard_peripheral/Include
INCLUDES+=-I../lib-gd32/${FAMILY}/CMSIS
INCLUDES+=-I../lib-gd32/${FAMILY}/CMSIS/GD/${FAMILY_UC}/Include
INCLUDES+=-I../lib-gd32/include
INCLUDES+=-I../lib-gd32/include

USB_HOST=
ifeq ($(findstring ENABLE_USB_HOST,$(DEFINES)), ENABLE_USB_HOST)
USB_HOST=1
endif
ifeq ($(findstring ENABLE_USB_HOST,$(MAKE_FLAGS)), ENABLE_USB_HOST)
USB_HOST=1
endif

USB_HOST_MSC=
ifeq ($(findstring ENABLE_USB_HOST,$(DEFINES)), ENABLE_USB_HOST)
USB_HOST_MSC=1
endif
ifeq ($(findstring ENABLE_USB_HOST,$(MAKE_FLAGS)), ENABLE_USB_HOST)
USB_HOST_MSC=1
endif

ifdef USB_HOST
INCLUDES+=-I../lib-gd32/device/usb
INCLUDES+=-I../lib-hal/device/usb/host/gd32
endif

ifeq ($(findstring gd32f20x,$(FAMILY)), gd32f20x)
ifdef USB_HOST
INCLUDES+=-I../lib-gd32/${FAMILY}/GD32F20x_usbfs_library/driver/Include
INCLUDES+=-I../lib-gd32/${FAMILY}/GD32F20x_usbfs_library/host/core/Include
INCLUDES+=-I../lib-gd32/${FAMILY}/GD32F20x_usbfs_library/ustd/common
ifdef USB_HOST_MSC
INCLUDES+=-I../lib-gd32/${FAMILY}/GD32F20x_usbfs_library/host/class/msc/Include
INCLUDES+=-I../lib-gd32/${FAMILY}/GD32F20x_usbfs_library/ustd/class/msc
endif
endif
endif

ifeq ($(findstring gd32f4xx,$(FAMILY)), gd32f4xx)
ifdef USB_HOST
INCLUDES+=-I../lib-gd32/${FAMILY}/GD32F4xx_usb_library/driver/Include
INCLUDES+=-I../lib-gd32/${FAMILY}/GD32F4xx_usb_library/host/core/Include
INCLUDES+=-I../lib-gd32/${FAMILY}/GD32F4xx_usb_library/ustd/common
ifdef USB_HOST_MSC
INCLUDES+=-I../lib-gd32/${FAMILY}/GD32F4xx_usb_library/host/class/msc/Include
INCLUDES+=-I../lib-gd32/${FAMILY}/GD32F4xx_usb_library/ustd/class/msc
endif
endif
endif

ifdef USB_HOST_MSC
EXTRA_INCLUDES+=../lib-hal/ff12c
endif
72 changes: 72 additions & 0 deletions firmware-template-gd32/Mcu.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
ifndef MCU
$(error MCU is not set)
endif

MCU_UC=$(shell echo $(MCU) | rev | cut -c3- | rev )
MCU_LC=$(shell echo $(MCU_UC) | tr A-Z a-z )

$(info $$MCU [${MCU}])
$(info $$MCU_LC [${MCU_LC}])
$(info $$MCU_UC [${MCU_UC}])

ifeq ($(strip $(MCU)),GD32F103RC)
LINKER=$(FIRMWARE_DIR)gd32f103rc_flash.ld
FAMILY=gd32f10x
LINE=gd32f10x_hd
endif

ifeq ($(strip $(MCU)),GD32F107RC)
LINKER=$(FIRMWARE_DIR)gd32f107rc_flash.ld
FAMILY=gd32f10x
LINE=gd32f10x_cl
endif

ifeq ($(strip $(MCU)),GD32F207VC)
LINKER=$(FIRMWARE_DIR)gd32f207vc_flash.ld
FAMILY=gd32f20x
LINE=gd32f20x_cl
endif

ifeq ($(strip $(MCU)),GD32F207RG)
LINKER=$(FIRMWARE_DIR)gd32f207rg_flash.ld
FAMILY=gd32f20x
LINE=gd32f20x_cl
endif

ifeq ($(strip $(MCU)),GD32F303RC)
LINKER=$(FIRMWARE_DIR)gd32f303rc_flash.ld
FAMILY=gd32f30x
LINE=gd32f30x_hd
endif

ifeq ($(strip $(MCU)),GD32F407RE)
LINKER=$(FIRMWARE_DIR)gd32f407re_flash.ld
FAMILY=gd32f4xx
LINE=gd32f407
endif

ifeq ($(strip $(MCU)),GD32F450VE)
LINKER=$(FIRMWARE_DIR)gd32f450ve_flash.ld
FAMILY=gd32f4xx
LINE=gd32f450
endif

ifeq ($(strip $(MCU)),GD32F450VI)
LINKER=$(FIRMWARE_DIR)gd32f450vi_flash.ld
FAMILY=gd32f4xx
LINE=gd32f450
endif

ifndef LINKER
$(error MCU is not configured)
endif

FAMILY_UC=$(shell echo $(FAMILY) | tr a-w A-W)

$(info $$FAMILY [${FAMILY}])
$(info $$FAMILY_UC [${FAMILY_UC}])

LINE_UC=$(shell echo $(LINE) | tr a-z A-Z)

$(info $$LINE [${LINE}])
$(info $$LINE_UC [${LINE_UC}])
42 changes: 24 additions & 18 deletions firmware-template-gd32/Rules.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$(info "Rules.mk")

PREFIX ?= arm-none-eabi-

CC = $(PREFIX)gcc
Expand All @@ -6,14 +8,8 @@ AS = $(CC)
LD = $(PREFIX)ld
AR = $(PREFIX)ar

FAMILY?=gd32f20x
BOARD?=BOARD_GD32F207C_EVAL

FAMILY:=$(shell echo $(FAMILY) | tr A-Z a-z)
FAMILY_UC=$(shell echo $(FAMILY) | tr a-w A-W)

$(info $$FAMILY [${FAMILY}])
$(info $$FAMILY_UC [${FAMILY_UC}])
ENET_PHY?=DP83848

# Output
TARGET=gd32f207.bin
Expand All @@ -24,17 +20,23 @@ BUILD=build_gd32/
# Input
SOURCE=./
FIRMWARE_DIR=./../firmware-template-gd32/
LINKER=$(FIRMWARE_DIR)gd32f207vc_flash.ld

DEFINES:=$(addprefix -D,$(DEFINES))
DEFINES+=-DCONFIG_STORE_USE_ROM

ifeq ($(findstring ARTNET_VERSION=4,$(DEFINES)),ARTNET_VERSION=4)
ifeq ($(findstring ARTNET_HAVE_DMXIN,$(DEFINES)),ARTNET_HAVE_DMXIN)
DEFINES+=-DE131_HAVE_DMXIN
endif
endif

MCU=GD32F207VC

include ../firmware-template-gd32/Mcu.mk
include ../firmware-template/libs.mk

LIBS+=c++ c gd32

$(info [${LIBS}])

DEFINES:=$(addprefix -D,$(DEFINES))
DEFINES+=-DCONFIG_STORE_USE_ROM

include ../firmware-template-gd32/Includes.mk

# The variable for the libraries include directory
Expand All @@ -51,15 +53,17 @@ LDLIBS:=$(addprefix -l,$(LIBS))
# The variables for the dependency check
LIBDEP=$(addprefix ../lib-,$(LIBS))

$(info $$BOARD [${BOARD}])
$(info $$ENET_PHY [${ENET_PHY}])
$(info $$DEFINES [${DEFINES}])
$(info $$LIBS [${LIBS}])
$(info $$LIBDEP [${LIBDEP}])

COPS=-DBARE_METAL -DGD32 -DGD32F20X_CL -D$(BOARD)
COPS+=$(DEFINES) $(MAKE_FLAGS) $(INCLUDES)
COPS+=$(LIBINCDIRS)
COPS=-DBARE_METAL -DGD32 -DGD32F20X_CL -D$(MCU) -D$(BOARD) -DPHY_TYPE=$(ENET_PHY)
COPS+=$(DEFINES) $(MAKE_FLAGS) $(INCLUDES) $(LIBINCDIRS)
COPS+=-Os -mcpu=cortex-m3 -mthumb
COPS+=-nostartfiles -ffreestanding -nostdlib
COPS+=-fstack-usage
COPS+=-Wstack-usage=10240
COPS+=-ffunction-sections -fdata-sections

CPPOPS=-std=c++11
Expand Down Expand Up @@ -119,7 +123,9 @@ lisdep: $(LIBDEP)
$(LIBDEP):
$(MAKE) -f Makefile.GD32 $(MAKECMDGOALS) 'MAKE_FLAGS=$(DEFINES)' -C $@

#
# Build bin
#

$(BUILD_DIRS) :
mkdir -p $(BUILD_DIRS)
Expand All @@ -133,6 +139,6 @@ $(BUILD)main.elf: Makefile.GD32 $(LINKER) $(BUILD)startup_$(FAMILY)_cl.o $(OBJEC
$(PREFIX)size -A -x $(BUILD)main.elf

$(TARGET) : $(BUILD)main.elf
$(PREFIX)objcopy $(BUILD)main.elf -O binary $(TARGET)
$(PREFIX)objcopy $(BUILD)main.elf -O binary $(TARGET) --remove-section=.sram1* --remove-section=.sram2*

$(foreach bdir,$(SRCDIR),$(eval $(call compile-objects,$(bdir))))
21 changes: 21 additions & 0 deletions firmware-template-gd32/calculate_unused_ram.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

if [ $# -lt 2 ]; then
echo "Usage: $0 <size_file> <linker_script>"
exit 1
fi

size_file="$1"
linker_script="$2"

used_stack=$(grep ".stack" "$size_file" | awk '{print $2}')
used_heap=$(grep ".heap" "$size_file" | awk '{print $2}')
used_data=$(grep '.data' "$size_file" | tail -n 1 | awk '{print $2}')
used_bss=$(grep ".bss" "$size_file" | awk '{print $2}')

total_ram=$(grep "RAM (xrw)" "$linker_script" | awk '{print $NF}' | sed 's/K$//' | awk '{printf "%d", $0 * 1024}')
unused_ram=$(( $(echo $total_ram) - $(echo $used_stack) - $(echo $used_heap) - $(echo $used_data) - $(echo $used_bss) ))

cat $1
echo "RAM $total_ram bytes, Unused: $unused_ram bytes"
echo
Loading

0 comments on commit 553a30d

Please sign in to comment.