Skip to content

Commit

Permalink
V1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
vanvught committed Mar 19, 2022
1 parent 374f87e commit 142c6a2
Show file tree
Hide file tree
Showing 32 changed files with 9,952 additions and 9,644 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ File: `spiflashinstall.h`

The 1rK difference is needed for other `new` (`malloc`) within the bootloader.

The change to be made in your application is in the file `gd32f407_flash.ld `.
The change to be made in your build configuration is in the file `gd32f407_flash.ld `.

MEMORY
{
Expand Down
2 changes: 1 addition & 1 deletion bootloader-tftp/.settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="761286263330094823" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="761336211882286823" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
14 changes: 1 addition & 13 deletions bootloader-tftp/firmware/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#include <cstdio>
#include <cstdint>
#include <cassert>

#include "hardware.h"
#include "network.h"
Expand All @@ -46,14 +45,6 @@

#include "gd32.h"

#include "debug.h"

#ifndef NDEBUG
extern "C" {
void mem_info(void);
}
#endif

int main(void) {
rcu_periph_clock_enable(KEY_BOOTLOADER_TFTP_RCU_GPIOx);
#if !defined (GD32F4XX)
Expand All @@ -63,6 +54,7 @@ int main(void) {
rcu_periph_clock_enable(RCU_PMU);
pmu_backup_ldo_config(PMU_BLDOON_ON);
rcu_periph_clock_enable(RCU_BKPSRAM);
pmu_backup_write_enable();
gpio_mode_set(KEY_BOOTLOADER_TFTP_GPIOx, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, KEY_BOOTLOADER_TFTP_GPIO_PINx);
#endif

Expand Down Expand Up @@ -127,10 +119,6 @@ int main(void) {

lb.SetMode(ledblink::Mode::FAST);

#ifndef NDEBUG
mem_info();
#endif

while (1) {
nw.Run();
remoteConfig.Run();
Expand Down
17,082 changes: 8,522 additions & 8,560 deletions bootloader-tftp/gd32f4xx.list

Large diffs are not rendered by default.

1,950 changes: 1,001 additions & 949 deletions bootloader-tftp/gd32f4xx.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bootloader-tftp/include/software_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
#ifndef SOFTWARE_VERSION_H_
#define SOFTWARE_VERSION_H_

constexpr char SOFTWARE_VERSION[] = "1.0";
constexpr char SOFTWARE_VERSION[] = "1.1";

#endif /* SOFTWARE_VERSION_H_ */
42 changes: 22 additions & 20 deletions firmware-template-gd32/gd32f407_flash.ld
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* memory map */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 32K
Expand All @@ -13,8 +12,7 @@ SECTIONS
{
__heap_size = DEFINED(__heap_size) ? __heap_size : 107K;
__stack_size = DEFINED(__stack_size) ? __stack_size : 1K;

/* ISR vectors */

.vectors :
{
. = ALIGN(4);
Expand All @@ -27,8 +25,8 @@ SECTIONS
.text :
{
. = ALIGN(4);
*(.text.unlikely*)
*(.text.hot*)
*(.text.unlikely*)
*(.text.hot*)
*(.text)
*(.text*)
*(.glue_7)
Expand Down Expand Up @@ -86,7 +84,6 @@ SECTIONS
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH

/* provide some necessary symbols for startup file to initialize data */
_sidata = LOADADDR(.data);
.data :
{
Expand Down Expand Up @@ -115,37 +112,42 @@ SECTIONS
PROVIDE ( end = _ebss );
PROVIDE ( _end = _ebss );

.heap ORIGIN(RAM) + LENGTH(RAM) - __stack_size - __heap_size :
.heap ORIGIN(RAM) + LENGTH(RAM) - __heap_size :
{
. = ALIGN(4);
heap_low = .;
. = . + __heap_size;
heap_top = .;
. = ALIGN(4);
} >RAM AT>RAM

.stack ORIGIN(RAM) + LENGTH(RAM) - __stack_size :
.tcmsram :
{
_stcmsram = .;
. = ALIGN(4);
*(.tcmsram)
*(.tcmsram*)
*(.lightset*)
*(.network*)
. = ALIGN(4);
_etcmsram = .;
} >TCMSRAM AT>TCMSRAM

.stack ORIGIN(TCMSRAM) + LENGTH(TCMSRAM) - __stack_size :
{
. = ALIGN(4);
PROVIDE( _heap_end = . );
. = __stack_size;
PROVIDE( _sp = . );
. = ALIGN(4);
} >RAM AT>RAM

.tcmsram :
{
. = ALIGN(4);
*(.tcmsram)
*(.tcmsram*)
} >TCMSRAM
} >TCMSRAM AT>TCMSRAM

.bkpsram :
{
. = ALIGN(4);
. = ALIGN(4);
*(.bkpsram)
*(.bkpsram*)
} >BKPSRAM
} >BKPSRAM AT>BKPSRAM

/DISCARD/ :
{
Expand All @@ -156,4 +158,4 @@ SECTIONS
}

/* input sections */
GROUP(libgcc.a libc.a)
GROUP(libgcc.a libc.a)
31 changes: 0 additions & 31 deletions firmware-template-gd32/include/software_version.h

This file was deleted.

2 changes: 1 addition & 1 deletion lib-c++/.settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="761286263330094823" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="761336211882286823" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
2 changes: 1 addition & 1 deletion lib-c/.settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="761286263330094823" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="761336211882286823" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
2 changes: 1 addition & 1 deletion lib-c/Makefile.GD32
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
DEFINES=#MEM_DEBUG
#DEFINES=MEM_DEBUG

include ../firmware-template-gd32/lib/Rules.mk
2 changes: 1 addition & 1 deletion lib-debug/.settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="761286263330094823" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="761336211882286823" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
2 changes: 1 addition & 1 deletion lib-display/.settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="761286263330094823" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="761336211882286823" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
5 changes: 5 additions & 0 deletions lib-gd32/Makefile.GD32
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ ifeq ($(findstring gd32f20x,$(FAMILY)), gd32f20x)
EXTRA_SRCDIR+=gd32f20x/GD32F20x_standard_peripheral/Source
endif

ifeq ($(findstring gd32f30x,$(FAMILY)), gd32f30x)
EXTRA_SRCDIR=gd32f30x/CMSIS/GD/GD32F30x/Source
EXTRA_SRCDIR+=gd32f30x/GD32F30x_standard_peripheral/Source
endif

ifeq ($(findstring gd32f4xx,$(FAMILY)), gd32f4xx)
EXTRA_SRCDIR=gd32f4xx/CMSIS/GD/GD32F4xx/Source
EXTRA_SRCDIR+=gd32f4xx/GD32F4xx_standard_peripheral/Source
Expand Down
85 changes: 85 additions & 0 deletions lib-gd32/include/board/logic_analyzer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
* @file logic_analyzer.h
*
*/
/* Copyright (C) 2022 by Arjan van Vught mailto:[email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#ifndef BOARD_LOGIC_ANALYZER_H_
#define BOARD_LOGIC_ANALYZER_H_

#if defined (BOARD_GD32F207C_EVAL)
# define LOGIC_ANALYZER_CH0_GPIO_PINx GPIO_PIN_0
# define LOGIC_ANALYZER_CH1_GPIO_PINx GPIO_PIN_1
# define LOGIC_ANALYZER_CH2_GPIO_PINx GPIO_PIN_7
//#define LOGIC_ANALYZER_CH3_GPIO_PINx
//#define LOGIC_ANALYZER_CH4_GPIO_PINx
//#define LOGIC_ANALYZER_CH5_GPIO_PINx
//#define LOGIC_ANALYZER_CH6_GPIO_PINx
//#define LOGIC_ANALYZER_CH7_GPIO_PINx

# define LOGIC_ANALYZER_CH0_GPIOx GPIOE
# define LOGIC_ANALYZER_CH1_GPIOx GPIOE
# define LOGIC_ANALYZER_CH2_GPIOx GPIOD
# define LOGIC_ANALYZER_CH3_GPIOx
# define LOGIC_ANALYZER_CH4_GPIOx
# define LOGIC_ANALYZER_CH5_GPIOx
# define LOGIC_ANALYZER_CH6_GPIOx
# define LOGIC_ANALYZER_CH7_GPIOx

# define LOGIC_ANALYZER_CH0_RCU_GPIOx RCU_GPIOE
# define LOGIC_ANALYZER_CH1_RCU_GPIOx RCU_GPIOE
# define LOGIC_ANALYZER_CH2_RCU_GPIOx RCU_GPIOD
# define LOGIC_ANALYZER_CH3_RCU_GPIOx
# define LOGIC_ANALYZER_CH4_RCU_GPIOx
# define LOGIC_ANALYZER_CH5_RCU_GPIOx
# define LOGIC_ANALYZER_CH6_RCU_GPIOx
# define LOGIC_ANALYZER_CH7_RCU_GPIOx
#else
# define LOGIC_ANALYZER_CH0_GPIO_PINx GPIO_PIN_3 // GPIO_EXT_23
# define LOGIC_ANALYZER_CH1_GPIO_PINx GPIO_PIN_4 // GPIO_EXT_21
# define LOGIC_ANALYZER_CH2_GPIO_PINx GPIO_PIN_5 // GPIO_EXT_19
# define LOGIC_ANALYZER_CH3_GPIO_PINx GPIO_PIN_14 // GPIO_EXT_26
//# define LOGIC_ANALYZER_CH4_GPIO_PINx GPIO_PIN_11 // GPIO_EXT_22
# define LOGIC_ANALYZER_CH5_GPIO_PINx GPIO_PIN_13 // GPIO_EXT_18
//# define LOGIC_ANALYZER_CH6_GPIO_PINx GPIO_PIN_
//# define LOGIC_ANALYZER_CH7_GPIO_PINx GPIO_PIN_

# define LOGIC_ANALYZER_CH0_GPIOx GPIOB
# define LOGIC_ANALYZER_CH1_GPIOx GPIOB
# define LOGIC_ANALYZER_CH2_GPIOx GPIOB
# define LOGIC_ANALYZER_CH3_GPIOx GPIOA
# define LOGIC_ANALYZER_CH4_GPIOx GPIOA
# define LOGIC_ANALYZER_CH5_GPIOx GPIOA
# define LOGIC_ANALYZER_CH6_GPIOx GPIO
# define LOGIC_ANALYZER_CH7_GPIOx GPIO

# define LOGIC_ANALYZER_CH0_RCU_GPIOx RCU_GPIOB
# define LOGIC_ANALYZER_CH1_RCU_GPIOx RCU_GPIOB
# define LOGIC_ANALYZER_CH2_RCU_GPIOx RCU_GPIOB
# define LOGIC_ANALYZER_CH3_RCU_GPIOx RCU_GPIOA
# define LOGIC_ANALYZER_CH4_RCU_GPIOx RCU_GPIOA
# define LOGIC_ANALYZER_CH5_RCU_GPIOx RCU_GPIOA
# define LOGIC_ANALYZER_CH6_RCU_GPIOx RCU_GPIO
# define LOGIC_ANALYZER_CH7_RCU_GPIOx RCU_GPIO
#endif

#endif /* BOARD_LOGIC_ANALYZER_H_ */
9 changes: 9 additions & 0 deletions lib-gd32/include/gd32.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ extern "C" {
# define GD32F20X
# include "gd32f20x.h"
# include "gd32f20x_libopt.h"
#elif defined (GD32F30X_HD)
# define GD32F30X
# include "gd32f30x.h"
# include "gd32f30x_libopt.h"
#elif defined (GD32F407)
# define GD32F4XX
# include "gd32f4xx.h"
Expand All @@ -61,6 +65,11 @@ extern "C" {
}
#endif

#if defined(GD32F30X)
# define bkp_data_write bkp_write_data
# define bkp_data_read bkp_read_data
#endif

#if defined(GD32F4XX) && defined(__cplusplus)
typedef enum
{
Expand Down
4 changes: 4 additions & 0 deletions lib-gd32/include/gd32_board.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@
# include "board/gd32f207r.h"
#elif defined (BOARD_GD32F207C_EVAL)
# include "board/gd32f207c_eval.h"
#elif defined (BOARD_GD32F303R)
# include "board/gd32f303r.h"
#elif defined (BOARD_GD32F407R)
# include "board/gd32f407r.h"
#else
# error Board is unknown / not defined
#endif

#include "board/logic_analyzer.h"

#if defined(USART0_REMAP) && !defined (I2C0_REMAP)
# error Configuration error
#endif
Expand Down
Loading

0 comments on commit 142c6a2

Please sign in to comment.