Skip to content

Commit a034708

Browse files
committed
V2.0
- Improved build system - Added stack debug framework - Removed not used source files - 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.
1 parent 296932d commit a034708

File tree

144 files changed

+4398
-2997
lines changed

Some content is hidden

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

144 files changed

+4398
-2997
lines changed

bootloader-tftp/firmware/main.cpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,14 @@ int main(void) {
9494
}
9595

9696
Hardware hw;
97-
Network nw;
9897
Display display(4);
98+
ConfigStore configStore;
99+
StoreNetwork storeNetwork;
100+
Network nw(&storeNetwork);
99101
FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__);
100-
101-
fw.Print("Bootloader TFTP Server");
102-
103102
FlashCodeInstall flashCodeInstall;
104-
ConfigStore configStore;
105103

106-
StoreNetwork storeNetwork;
107-
nw.SetNetworkStore(&storeNetwork);
108-
nw.Init(&storeNetwork);
104+
fw.Print("Bootloader TFTP Server");
109105
nw.Print();
110106

111107
hw.SetMode(hardware::ledblink::Mode::OFF_ON);

bootloader-tftp/include/software_version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@
2626
#ifndef SOFTWARE_VERSION_H_
2727
#define SOFTWARE_VERSION_H_
2828

29-
constexpr char SOFTWARE_VERSION[] = "1.7";
29+
constexpr char SOFTWARE_VERSION[] = "2.0";
3030

3131
#endif /* SOFTWARE_VERSION_H_ */

bootloader-tftp/lib/networkdisplay.cpp

+15-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file networkdisplay.cpp
33
*
44
*/
5-
/* Copyright (C) 2022 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2022-2023 by Arjan van Vught mailto:info@gd32-dmx.org
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
@@ -33,13 +33,23 @@
3333
namespace network {
3434
static constexpr auto LINE_IP = 2U;
3535

36+
void display_emac_config() {
37+
Display::Get()->ClearEndOfLine();
38+
Display::Get()->Printf(LINE_IP, "Ethernet config");
39+
}
40+
3641
void display_emac_start() {
37-
Display::Get()->ClearLine(LINE_IP);
38-
Display::Get()->PutString("Ethernet start");
42+
Display::Get()->ClearEndOfLine();
43+
Display::Get()->Printf(LINE_IP, "Ethernet start");
44+
}
45+
46+
void display_emac_status(const bool isLinkUp) {
47+
Display::Get()->ClearEndOfLine();
48+
Display::Get()->Printf(LINE_IP, "Ethernet Link %s", isLinkUp ? "UP" : "DOWN");
3949
}
4050

4151
void display_ip() {
42-
Display::Get()->ClearLine(LINE_IP);
52+
Display::Get()->ClearEndOfLine();
4353
Display::Get()->Printf(LINE_IP, "" IPSTR "/%d %c", IP2STR(Network::Get()->GetIp()), Network::Get()->GetNetmaskCIDR(), Network::Get()->GetAddressingMode());
4454
}
4555

@@ -54,7 +64,7 @@ void display_hostname() {
5464
}
5565

5666
void display_emac_shutdown() {
57-
Display::Get()->ClearLine(LINE_IP);
67+
Display::Get()->ClearEndOfLine();
5868
Display::Get()->PutString("Ethernet shutdown");
5969
}
6070

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
if [ $# -lt 2 ]; then
4+
echo "Usage: $0 <size_file> <linker_script>"
5+
exit 1
6+
fi
7+
8+
size_file="$1"
9+
linker_script="$2"
10+
11+
used_stack=$(grep ".stack" "$size_file" | awk '{print $2}')
12+
used_heap=$(grep ".heap" "$size_file" | awk '{print $2}')
13+
used_data=$(grep '.data' "$size_file" | tail -n 1 | awk '{print $2}')
14+
used_bss=$(grep ".bss" "$size_file" | awk '{print $2}')
15+
16+
total_ram=$(grep "RAM (xrw)" "$linker_script" | awk '{print $NF}' | sed 's/K$//' | awk '{printf "%d", $0 * 1024}')
17+
unused_ram=$(( $(echo $total_ram) - $(echo $used_stack) - $(echo $used_heap) - $(echo $used_data) - $(echo $used_bss) ))
18+
19+
cat $1
20+
echo "Available RAM: $total_ram bytes"
21+
echo "Unused RAM: $unused_ram bytes"

firmware-template-gd32/gd32f207vc_flash.ld

+21-36
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MEMORY
22
{
3-
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 28K
3+
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 32K
44
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
55
}
66

@@ -9,7 +9,7 @@ ENTRY(Reset_Handler)
99
SECTIONS
1010
{
1111
__heap_size = DEFINED(__heap_size) ? __heap_size : 1K;
12-
__stack_size = DEFINED(__stack_size) ? __stack_size : 1K;
12+
__stack_size = DEFINED(__stack_size) ? __stack_size : 2K;
1313

1414
.vectors :
1515
{
@@ -30,10 +30,8 @@ SECTIONS
3030
*(.glue_7)
3131
*(.glue_7t)
3232
*(.eh_frame)
33-
3433
KEEP (*(.init))
3534
KEEP (*(.fini))
36-
3735
. = ALIGN(4);
3836
_etext = .;
3937
} >FLASH
@@ -46,19 +44,6 @@ SECTIONS
4644
. = ALIGN(4);
4745
} >FLASH
4846

49-
.ARM.extab :
50-
{
51-
*(.ARM.extab* .gnu.linkonce.armextab.*)
52-
} >FLASH
53-
54-
.ARM : {
55-
__exidx_start = .;
56-
*(.ARM.exidx*)
57-
__exidx_end = .;
58-
} >FLASH
59-
60-
.ARM.attributes : { *(.ARM.attributes) } > FLASH
61-
6247
.preinit_array :
6348
{
6449
PROVIDE_HIDDEN (__preinit_array_start = .);
@@ -82,6 +67,24 @@ SECTIONS
8267
PROVIDE_HIDDEN (__fini_array_end = .);
8368
} >FLASH
8469

70+
.stack :
71+
{
72+
. = ALIGN(4);
73+
PROVIDE( stack_low = . );
74+
. = __stack_size;
75+
PROVIDE( _sp = . );
76+
. = ALIGN(4);
77+
} >RAM AT>RAM
78+
79+
.heap :
80+
{
81+
. = ALIGN(4);
82+
heap_low = .;
83+
. = . + __heap_size;
84+
heap_top = .;
85+
. = ALIGN(4);
86+
} >RAM AT>RAM
87+
8588
_sidata = LOADADDR(.data);
8689
.data :
8790
{
@@ -109,28 +112,10 @@ SECTIONS
109112
. = ALIGN(8);
110113
PROVIDE ( end = _ebss );
111114
PROVIDE ( _end = _ebss );
112-
113-
.heap ORIGIN(RAM) + LENGTH(RAM) - __stack_size - __heap_size :
114-
{
115-
. = ALIGN(4);
116-
heap_low = .;
117-
. = . + __heap_size;
118-
heap_top = .;
119-
. = ALIGN(4);
120-
} >RAM AT>RAM
121-
122-
.stack ORIGIN(RAM) + LENGTH(RAM) - __stack_size :
123-
{
124-
. = ALIGN(4);
125-
PROVIDE( _heap_end = . );
126-
. = __stack_size;
127-
PROVIDE( _sp = . );
128-
. = ALIGN(4);
129-
} >RAM AT>RAM
130115

131116
/DISCARD/ :
132117
{
133-
*(*.ARM.attributes)
118+
*(*.ARM.*)
134119
*(*.comment)
135120
*(*.debug*)
136121
}

firmware-template-gd32/startup_gd32f20x_cl.S

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ Zerobss:
4141
ldr r3, = _ebss
4242
cmp r2, r3
4343
bcc FillZerobss
44-
bl SystemInit
44+
#if defined (DEBUG_STACK)
4545
bl stack_debug_init
46+
#endif
47+
bl SystemInit
4648
bl main
4749
bx lr
4850
.size Reset_Handler, .-Reset_Handler

include/.settings/org.eclipse.core.resources.prefs

100644100755
File mode changed.

include/README.md

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
A freestanding implementation has an implementation-defined set of headers. The following headers are provided by the C/C++ standard:
2+
3+
#c11
4+
> 4 Conformance
5+
>
6+
> 6 ... A conforming freestanding implementation shall accept any strictly conforming program that does not use complex types and in which the use of the features specified in the library clause (clause 7) is confined to the contents of the standard headers &lt;float.h>, &lt;iso646.h>, &lt;limits.h>, &lt;stdalign.h>, &lt;stdarg.h>, &lt;stdbool.h>, &lt;stddef.h>, and &lt;stdint.h>.
7+
8+
Reference: [https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf)
9+
10+
#c++11
11+
12+
13+
<table>
14+
<tr>
15+
<td>Types</td>
16+
<td>&lt;cstddef></td>
17+
</tr>
18+
<tr>
19+
<td rowspan="3">Implementation properties</td>
20+
<td>&lt;limits></td>
21+
</tr>
22+
<tr>
23+
<td>&lt;cfloat></td>
24+
</tr>
25+
<tr>
26+
<td>&lt;climits></td>
27+
</tr>
28+
<tr>
29+
<td>Integer types</td>
30+
<td>&lt;cstdint></td>
31+
</tr>
32+
<tr>
33+
<td>Start and termination</td>
34+
<td>&ltcstdlib> (partial)</td>
35+
</tr>
36+
<tr>
37+
<td>Dynamic memory management</td>
38+
<td>&lt;new></td>
39+
</tr>
40+
<tr>
41+
<td>Type identification</td>
42+
<td>&lt;typeinfo></td>
43+
</tr>
44+
<tr>
45+
<td>Exception handling</td>
46+
<td>&lt;exception></td>
47+
</tr>
48+
<tr>
49+
<td>Initializer lists</td>
50+
<td>&lt;initializer_list></td>
51+
</tr>
52+
<tr>
53+
<td>Other runtime support</td>
54+
<td>&lt;cstdarg></td>
55+
</tr>
56+
<tr>
57+
<td>Type traits</td>
58+
<td>&lt;type_traits></td>
59+
</tr>
60+
<tr>
61+
<td>Atomics</td>
62+
<td>&lt;atomic></td>
63+
</tr>
64+
</table>
65+
66+
Reference: [https://en.cppreference.com/w/cpp/freestanding](https://en.cppreference.com/w/cpp/freestanding)
67+
68+
[http://www.gd32-dmx.org](http://www.gd32-dmx.org)
69+
70+
[http://www.orangepi-dmx.org](http://www.orangepi-dmx.org)
71+
72+

include/algorithm

100644100755
File mode changed.

include/climits include/cmath

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
2-
* @file climits
2+
* @file cmath
33
*
44
*/
5-
/* Copyright (C) 2021 by Arjan van Vught mailto:info@orangepi-dmx.nl
5+
/* Copyright (C) 2023 by Arjan van Vught mailto:info@orangepi-dmx.nl
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
@@ -23,11 +23,11 @@
2323
* THE SOFTWARE.
2424
*/
2525

26-
#ifndef CLIMITS_
27-
#define CLIMITS_
26+
#ifndef CMATH_
27+
#define CMATH_
2828

2929
#ifdef __cplusplus
30-
# include <limits.h>
30+
# include <math.h>
3131
#endif
3232

33-
#endif /* CLIMITS_ */
33+
#endif /* CMATH_ */

include/ctype.h

+13-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file ctype.h
33
*
44
*/
5-
/* Copyright (C) 2017 by Arjan van Vught mailto:info@orangepi-dmx.nl
5+
/* Copyright (C) 2017-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
@@ -30,38 +30,42 @@
3030
extern "C" {
3131
#endif
3232

33-
inline static int isdigit(int c) {
33+
inline int isdigit(int c) {
3434
return (c >= (int) '0' && c <= (int) '9') ? 1 : 0;
3535
}
3636

37-
inline static int isxdigit(int c) {
37+
inline int isxdigit(int c) {
3838
return ((isdigit(c) != 0) || (((unsigned) c | 32) - (int) 'a' < 6)) ? 1 : 0;
3939
}
4040

41-
inline static int isprint(int c) {
41+
inline int isprint(int c) {
4242
return ((c >= (int) ' ' && c <= (int) '~')) ? 1 : 0;
4343
}
4444

45-
inline static int isupper(int c) {
45+
inline int isupper(int c) {
4646
return (c >= (int) 'A' && c <= (int) 'Z') ? 1 : 0;
4747
}
4848

49-
inline static int islower(int c) {
49+
inline int islower(int c) {
5050
return (c >= (int) 'a' && c <= (int) 'z') ? 1 : 0;
5151
}
5252

53-
inline static int isalpha(int c) {
53+
inline int isalpha(int c) {
5454
return ((isupper(c) != 0) || (islower(c) != 0)) ? 1 : 0;
5555
}
5656

57-
inline static int tolower(int c) {
57+
inline int tolower(int c) {
5858
return ((isupper(c) != 0) ? (c + 32) : c);
5959
}
6060

61-
inline static int toupper(int c) {
61+
inline int toupper(int c) {
6262
return ((islower(c) != 0) ? (c - 32) : c);
6363
}
6464

65+
inline int isspace(int c) {
66+
return (c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r' || c == ' ' ? 1 : 0);
67+
}
68+
6569
#ifdef __cplusplus
6670
}
6771
#endif

include/stdlib.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file stdlib.h
33
*
44
*/
5-
/* Copyright (C) 2017-2020 by Arjan van Vught mailto:info@orangepi-dmx.nl
5+
/* Copyright (C) 2017-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
@@ -34,13 +34,14 @@
3434
extern "C" {
3535
#endif
3636

37+
extern int atoi(const char *nptr);
38+
3739
extern void *malloc(size_t size);
3840
extern void free(void *ptr);
3941
extern void *calloc(size_t nmemb, size_t size);
4042
extern void *realloc(void *ptr, size_t size);
4143

42-
/* Return the absolute value of I. */
43-
inline static int abs(int i) {
44+
inline int abs(int i) {
4445
return i < 0 ? -i : i;
4546
}
4647

0 commit comments

Comments
 (0)