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 72eec81 commit 4a8709c
Show file tree
Hide file tree
Showing 480 changed files with 19,716 additions and 52,891 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
*/lib_gd32/*
*.su
*.list
*.map
*.size

*.bin
udp_send
do-tftp.sh
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,11 @@ The ready to use firmware is build to use with the bootloader TFTP server -> [ht
* Full Art-Net 4 implementation
* Default firmware is using USART2 en USART5

### Art-Net 4 Pixel 8x 4 Universes
* Full Art-Net 4 implementation
* No FPS limitation, except for what there is with the pixel chip protocol

### sACN E1.31 DMX 1-4 ports
* Full sACN E1.31 implementation
* Default firmware is using USART2 en USART5
* RDMNet LLRP Device only

### sACN E1.31 Pixel 8x 4 Universes
* Full sACN E1.31 implementation
* No FPS limitation, except for what there is with the pixel chip protocol
* RDMNet LLRP Device only

## Remote Configuration Manager
[https://github.com/vanvught/Remote-Config-UI/releases](https://github.com/vanvught/Remote-Config-UI/releases)<br>
<img alt="GitHub release" src="https://img.shields.io/github/v/release/vanvught/Remote-Config-UI">
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
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}])
77 changes: 42 additions & 35 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 @@ -8,40 +10,33 @@ AR = $(PREFIX)ar

BOARD?=BOARD_GD32F407RE
ENET_PHY?=DP83848
FAMILY?=gd32f4xx
MCU?=gd32f407

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

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

# Output
TARGET=$(FAMILY).bin
LIST=$(FAMILY).list
MAP=$(FAMILY).map
SIZE=$(FAMILY).size
BUILD=build_gd32/

# Input
SOURCE = ./
FIRMWARE_DIR = ./../firmware-template-gd32/
LINKER = $(FIRMWARE_DIR)/gd32f407re_flash.ld

include ../firmware-template/libs.mk
SOURCE=./
FIRMWARE_DIR=./../firmware-template-gd32/

LIBS+=c++ c gd32

$(info [${LIBS}])

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

ifeq ($(findstring DMX4,$(BOARD)), DMX4)
DEFINES+=-DCONSOLE_I2C
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=GD32F407RE

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

LIBS+=c++ c gd32

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

# The variable for the libraries include directory
Expand All @@ -58,19 +53,24 @@ 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 -DGD32F407 -D$(BOARD) -DPHY_TYPE=$(ENET_PHY)
COPS+=$(DEFINES) $(MAKE_FLAGS) $(INCLUDES) $(LIBINCDIRS)
COPS+=-Os -mcpu=cortex-m4 -mthumb -g -mfloat-abi=hard -fsingle-precision-constant -mfpu=fpv4-sp-d16
COPS+=-DARM_MATH_CM4 -D__FPU_PRESENT=1
COPS+=-Os -mcpu=cortex-m4 -mthumb -g -mfloat-abi=hard -fsingle-precision-constant -mfpu=fpv4-sp-d16 -DARM_MATH_CM4 -D__FPU_PRESENT=1
COPS+=-nostartfiles -ffreestanding -nostdlib
COPS+=-fstack-usage -Wstack-usage=10240
COPS+=-fstack-usage
COPS+=-ffunction-sections -fdata-sections
COPS+=-Wall -Werror -Wpedantic -Wextra -Wunused -Wsign-conversion -Wconversion
COPS+=-Wduplicated-cond -Wlogical-op

CPPOPS=-std=c++11
CPPOPS=-std=c++11
CPPOPS+=-Wnon-virtual-dtor -Woverloaded-virtual -Wnull-dereference -fno-rtti -fno-exceptions -fno-unwind-tables
#CPPOPS+=-Wuseless-cast -Wold-style-cast
CPPOPS+=-Wuseless-cast -Wold-style-cast
CPPOPS+=-fno-threadsafe-statics

LDOPS=--gc-sections --print-gc-sections
Expand Down Expand Up @@ -98,7 +98,6 @@ $(BUILD)$1/%.o: $(SOURCE)$1/%.S
$(CC) $(COPS) -D__ASSEMBLY__ -c $$< -o $$@
endef


all : builddirs prerequisites $(TARGET)

.PHONY: clean builddirs
Expand All @@ -113,6 +112,7 @@ clean: $(LIBDEP)
rm -f $(TARGET)
rm -f $(MAP)
rm -f $(LIST)
rm -f $(SIZE)

#
# Libraries
Expand All @@ -123,22 +123,29 @@ clean: $(LIBDEP)
lisdep: $(LIBDEP)

$(LIBDEP):
$(MAKE) -f Makefile.GD32 $(MAKECMDGOALS) 'FAMILY=${FAMILY}' 'BOARD=${BOARD}' 'PHY_TYPE=${ENET_PHY}' 'MAKE_FLAGS=$(DEFINES)' -C $@
$(MAKE) -f Makefile.GD32 $(MAKECMDGOALS) 'FAMILY=${FAMILY}' 'MCU=${MCU}' 'BOARD=${BOARD}' 'ENET_PHY=${ENET_PHY}' 'MAKE_FLAGS=$(DEFINES)' -C $@

#
# Build bin
#

$(BUILD_DIRS) :
mkdir -p $(BUILD_DIRS)

$(BUILD)startup_$(MCU).o : $(FIRMWARE_DIR)/startup_$(MCU).S
$(AS) $(COPS) -D__ASSEMBLY__ -c $(FIRMWARE_DIR)/startup_$(MCU).S -o $(BUILD)startup_$(MCU).o
$(BUILD)startup_$(MCU_LC).o : $(FIRMWARE_DIR)/startup_$(MCU_LC).S
$(AS) $(COPS) -D__ASSEMBLY__ -c $(FIRMWARE_DIR)/startup_$(MCU_LC).S -o $(BUILD)startup_$(MCU_LC).o

$(BUILD)main.elf: Makefile.GD32 $(LINKER) $(BUILD)startup_$(MCU).o $(OBJECTS) $(LIBDEP)
$(LD) $(BUILD)startup_$(MCU).o $(OBJECTS) -Map $(MAP) -T $(LINKER) $(LDOPS) -o $(BUILD)main.elf $(LIBGD32) $(LDLIBS) $(PLATFORM_LIBGCC) -lgcc
$(BUILD)main.elf: Makefile.GD32 $(LINKER) $(BUILD)startup_$(MCU_LC).o $(OBJECTS) $(LIBDEP)
$(LD) $(BUILD)startup_$(MCU_LC).o $(OBJECTS) -Map $(MAP) -T $(LINKER) $(LDOPS) -o $(BUILD)main.elf $(LIBGD32) $(LDLIBS) $(PLATFORM_LIBGCC) -lgcc
$(PREFIX)objdump -D $(BUILD)main.elf | $(PREFIX)c++filt > $(LIST)
$(PREFIX)size -A -x $(BUILD)main.elf
$(PREFIX)size -A -x $(BUILD)main.elf > $(FAMILY).size
$(MAKE) -f Makefile.GD32 calculate_unused_ram SIZE_FILE=$(FAMILY).size LINKER_SCRIPT=$(LINKER)

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

$(foreach bdir,$(SRCDIR),$(eval $(call compile-objects,$(bdir))))
$(foreach bdir,$(SRCDIR),$(eval $(call compile-objects,$(bdir))))

.PHONY: calculate_unused_ram
calculate_unused_ram: $(FAMILY).size $(LINKER)
@$(FIRMWARE_DIR)/calculate_unused_ram.sh $(FAMILY).size $(LINKER)
45 changes: 45 additions & 0 deletions firmware-template-gd32/calculate_unused_ram.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/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_tcmsram=$(grep ".tcmsram" "$size_file" | awk '{print $2}')
used_heap=$(grep ".heap" "$size_file" | awk '{print $2}')

total_tcmsram=$(grep "TCMSRAM (rw)" "$linker_script" | awk '{print $NF}' | sed 's/K$//' | awk '{printf "%d", $0 * 1024}')
unused_tcmsram=$(( $(echo $total_tcmsram) - $(echo $used_stack) - $(echo $used_tcmsram) - $(echo $used_heap) ))

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_data) - $(echo $used_bss) ))

used_ram1=$(grep ".sram1" "$size_file" | awk '{print $2}')

total_ram1=$(grep "RAM1 (xrw)" "$linker_script" | awk '{print $NF}' | sed 's/K$//' | awk '{printf "%d", $0 * 1024}')
unused_ram1=$(( $(echo $total_ram1) - $(echo $used_ram1)))

used_ram2=$(grep ".sram2" "$size_file" | awk '{print $2}')

total_ram2=$(grep "RAM2 (xrw)" "$linker_script" | awk '{print $NF}' | sed 's/K$//' | awk '{printf "%d", $0 * 1024}')
unused_ram2=$(( $(echo $total_ram2) - $(echo $used_ram2)))

used_ramadd=$(grep ".ramadd" "$size_file" | awk '{print $2}')

total_ramadd=$(grep "RAMADD (xrw)" "$linker_script" | awk '{print $NF}' | sed 's/K$//' | awk '{printf "%d", $0 * 1024}')
unused_ramadd=$(( $(echo $total_ramadd) - $(echo $used_ramadd)))

cat $1
echo "TCMSRAM $total_tcmsram bytes, Unused TCMSRAM: $unused_tcmsram bytes"
echo "SRAM0 $total_ram bytes, Unused: $unused_ram bytes"
echo "SRAM1 $total_ram1 bytes, Unused: $unused_ram1 bytes"
echo "SRAM2 $total_ram2 bytes, Unused: $unused_ram2 bytes"
echo "RAMADD $total_ramadd bytes, Unused: $unused_ramadd bytes"
echo
Loading

0 comments on commit 4a8709c

Please sign in to comment.