Skip to content

Commit d082279

Browse files
committed
Enhance GD32 flashing and UID handling
Expand the GD32 flash script with device database lookup, flash-size/UID reads, part-number detection, and optional GO execution. Add a shared GD32 unique-ID helper and route MAC/serial/UUID generation through it. Also update LCD config includes after the config rename and apply a set of small cleanup fixes across the C++ runtime and network stack.
1 parent 35cb8a5 commit d082279

25 files changed

Lines changed: 713 additions & 380 deletions

File tree

common/scripts/gd32/flash.py

Lines changed: 366 additions & 86 deletions
Large diffs are not rendered by default.

lib-clib/src/c++/delete.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file delete.cpp
33
*
44
*/
5-
/* Copyright (C) 2017-2025 by Arjan van Vught mailto:info@info@gd32-dmx.org
5+
/* Copyright (C) 2017-2026 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
@@ -31,25 +31,25 @@
3131
* These are the global operator delete overloads for single objects (delete) and arrays (delete[]).
3232
*/
3333

34-
void operator delete(void *p) {
35-
free(p);
34+
void operator delete(void *pointer) noexcept {
35+
free(pointer);
3636
}
3737

38-
void operator delete[](void *p) {
39-
free(p);
38+
void operator delete[](void *pointer) noexcept {
39+
free(pointer);
4040
}
4141

4242
/*
4343
* Introduced in C++14.
4444
* These overloads include the size of the object being deleted as an additional parameter (std::size_t size).
4545
*/
4646

47-
void operator delete(void *p, [[maybe_unused]] std::size_t size) noexcept {
48-
free(p);
47+
void operator delete(void *pointer, [[maybe_unused]] std::size_t size) noexcept {
48+
free(pointer);
4949
}
5050

51-
void operator delete[](void *p, [[maybe_unused]]std::size_t size) noexcept {
52-
free(p);
51+
void operator delete[](void *pointer, [[maybe_unused]]std::size_t size) noexcept {
52+
free(pointer);
5353
}
5454

5555
/*

lib-clib/src/c++/dso_handle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file dso_handle.cpp
33
*
44
*/
5-
/* Copyright (C) 2023 by Arjan van Vught mailto:info@info@gd32-dmx.org
5+
/* Copyright (C) 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

lib-clib/src/c++/new.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file new.cpp
33
*
44
*/
5-
/* Copyright (C) 2017-2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2017-2026 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
@@ -49,6 +49,6 @@ void *operator new[](std::size_t size) {
4949
* Placement new does not allocate memory.
5050
*/
5151

52-
void *operator new([[maybe_unused]] std::size_t, void *ptr) noexcept {
52+
void *operator new([[maybe_unused]] std::size_t size, void *ptr) noexcept {
5353
return ptr;
5454
}

lib-display/include/spi/config.h renamed to lib-display/include/spi/config/config_lcd.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @file config.h
2+
* @file config_lcd.h
33
*
44
*/
55
/* Copyright (C) 2022-2026 by Arjan van Vught mailto:info@gd32-dmx.org
@@ -28,7 +28,7 @@
2828

2929
#include <cstdint>
3030

31-
namespace config {
31+
namespace config::lcd {
3232
#if defined(SPI_LCD_240X240)
3333
inline constexpr uint32_t kWidth = 240;
3434
inline constexpr uint32_t kHeight = 240;
@@ -44,38 +44,38 @@ inline constexpr uint32_t kHeight = 160;
4444
#else
4545
#error lib-display spi config
4646
#endif
47-
} // namespace config
47+
} // namespace config::lcd
4848

4949
#if defined(H3)
50-
#define SPI_LCD_RST_GPIO GPIO_EXT_7 // GPIO6
51-
#define SPI_LCD_DC_GPIO GPIO_EXT_26 // GPIO10
52-
#define SPI_LCD_BL_GPIO GPIO_EXT_22 // GPIO2
50+
#define SPI_LCD_RST_GPIO GPIO_EXT_7 // GPIO6
51+
#define SPI_LCD_DC_GPIO GPIO_EXT_26 // GPIO10
52+
#define SPI_LCD_BL_GPIO GPIO_EXT_22 // GPIO2
5353
#if defined(SPI_LCD_HAVE_CS_GPIO)
54-
#define SPI_LCD_CS_GPIO GPIO_EXT_24 // GPIO13 / SPI CS0
55-
#endif // defined(SPI_LCD_HAVE_CS_GPIO)
56-
#elif defined(GD32) // See board file
54+
#define SPI_LCD_CS_GPIO GPIO_EXT_24 // GPIO13 / SPI CS0
55+
#endif // defined(SPI_LCD_HAVE_CS_GPIO)
56+
#elif defined(GD32) // See board file
5757
#elif defined(RASPPI)
5858
#include "gpio_rasppi.h"
59-
#define SPI_LCD_RST_GPIO GPIO_EXT_7 // GPIO4
60-
#define SPI_LCD_DC_GPIO GPIO_EXT_31 // GPIO6
61-
#define SPI_LCD_BL_GPIO GPIO_EXT_29 // GPIO5
59+
#define SPI_LCD_RST_GPIO GPIO_EXT_7 // GPIO4
60+
#define SPI_LCD_DC_GPIO GPIO_EXT_31 // GPIO6
61+
#define SPI_LCD_BL_GPIO GPIO_EXT_29 // GPIO5
6262
#if defined(SPI_LCD_HAVE_CS_GPIO)
63-
#define SPI_LCD_CS_GPIO GPIO_EXT_22 // GPIO25
64-
#endif // defined(SPI_LCD_HAVE_CS_GPIO)
63+
#define SPI_LCD_CS_GPIO GPIO_EXT_22 // GPIO25
64+
#endif // defined(SPI_LCD_HAVE_CS_GPIO)
6565
#elif defined(ODROID)
6666
#include "gpio_odroid.h"
67-
#define SPI_LCD_RST_GPIO GPIO_EXT_7 // GPIO4
68-
#define SPI_LCD_DC_GPIO GPIO_EXT_31 // GPIO6
69-
#define SPI_LCD_BL_GPIO GPIO_EXT_29 // GPIO5
67+
#define SPI_LCD_RST_GPIO GPIO_EXT_7 // GPIO4
68+
#define SPI_LCD_DC_GPIO GPIO_EXT_31 // GPIO6
69+
#define SPI_LCD_BL_GPIO GPIO_EXT_29 // GPIO5
7070
#if defined(SPI_LCD_HAVE_CS_GPIO)
71-
#define SPI_LCD_CS_GPIO GPIO_EXT_22 // GPIO25
72-
#endif // defined(SPI_LCD_HAVE_CS_GPIO)
71+
#define SPI_LCD_CS_GPIO GPIO_EXT_22 // GPIO25
72+
#endif // defined(SPI_LCD_HAVE_CS_GPIO)
7373
#else
74-
#define SPI_LCD_RST_GPIO 0
75-
#define SPI_LCD_DC_GPIO 0
76-
#define SPI_LCD_BL_GPIO 0
74+
#define SPI_LCD_RST_GPIO 0
75+
#define SPI_LCD_DC_GPIO 0
76+
#define SPI_LCD_BL_GPIO 0
7777
#if defined(SPI_LCD_HAVE_CS_GPIO)
78-
#define SPI_LCD_CS_GPIO 0
78+
#define SPI_LCD_CS_GPIO 0
7979
#endif // defined(SPI_LCD_HAVE_CS_GPIO)
8080
#endif
8181

lib-display/include/spi/ili9341.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <cstdint>
3030
#include <cassert>
3131

32-
#include "spi/config.h"
32+
#include "spi/config/config_lcd.h"
3333

3434
namespace ili9341 {
3535
namespace cmd {
@@ -178,23 +178,23 @@ class ILI9341 : public Paint {
178178
switch (nRotation) {
179179
case 0:
180180
WriteDataByte(ili9341::data::kMadctlBgr);
181-
width_ = config::kWidth;
182-
height_ = config::kHeight;
181+
width_ = config::lcd::kWidth;
182+
height_ = config::lcd::kHeight;
183183
break;
184184
case 1:
185185
WriteDataByte(ili9341::data::kMadctlMx | ili9341::data::kMadctlMv | ili9341::data::kMadctlBgr);
186-
width_ = config::kHeight;
187-
height_ = config::kWidth;
186+
width_ = config::lcd::kHeight;
187+
height_ = config::lcd::kWidth;
188188
break;
189189
case 2:
190190
WriteDataByte(ili9341::data::kMadctlMx | ili9341::data::kMadctlMy | ili9341::data::kMadctlBgr);
191-
width_ = config::kWidth;
192-
height_ = config::kHeight;
191+
width_ = config::lcd::kWidth;
192+
height_ = config::lcd::kHeight;
193193
break;
194194
case 3:
195195
WriteDataByte(ili9341::data::kMadctlMy | ili9341::data::kMadctlMv | ili9341::data::kMadctlBgr);
196-
width_ = config::kHeight;
197-
height_ = config::kWidth;
196+
width_ = config::lcd::kHeight;
197+
height_ = config::lcd::kWidth;
198198
break;
199199
default:
200200
assert(0);

lib-display/include/spi/paint.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
#include "spi/lcd_font.h"
3434
#include "spi/spilcd.h"
35-
#include "spi/config.h"
35+
#include "spi/config/config_lcd.h"
3636
#include "firmware/debug/debug_debug.h"
3737

3838
class Paint : public SpiLcd {
@@ -57,7 +57,7 @@ class Paint : public SpiLcd {
5757
ClearCS();
5858
SetDC();
5959

60-
for (uint32_t i = 0; i < config::kHeight / kFrameBufferRows; i++) {
60+
for (uint32_t i = 0; i < config::lcd::kHeight / kFrameBufferRows; i++) {
6161
WriteDataContinue(reinterpret_cast<uint8_t*>(s_frame_buffer), sizeof(s_frame_buffer));
6262
}
6363

@@ -225,8 +225,8 @@ class Paint : public SpiLcd {
225225
}
226226

227227
protected:
228-
uint32_t width_{config::kWidth};
229-
uint32_t height_{config::kHeight};
228+
uint32_t width_{config::lcd::kWidth};
229+
uint32_t height_{config::lcd::kHeight};
230230
uint32_t rotate_{0};
231231

232232
#if !defined(SPI_LCD_kFrameBufferRows)
@@ -235,7 +235,7 @@ class Paint : public SpiLcd {
235235
static constexpr uint32_t kFrameBufferRows = SPI_LCD_kFrameBufferRows;
236236
#endif
237237

238-
static inline uint16_t s_frame_buffer[config::kWidth * kFrameBufferRows];
238+
static inline uint16_t s_frame_buffer[config::lcd::kWidth * kFrameBufferRows];
239239
};
240240

241241
#endif // SPI_PAINT_H_

lib-display/include/spi/spilcd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#define SPI_SPILCD_H_
2828

2929
#include "timing.h"
30-
#include "spi/config.h"
30+
#include "spi/config/config_lcd.h"
3131
#include "spi.h"
3232
#include "gpio.h"
3333
#include "firmware/debug/debug_debug.h"

lib-display/include/spi/st7735s.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include <cstdint>
3939
#include <cassert>
4040

41-
#include "spi/config.h"
41+
#include "spi/config/config_lcd.h"
4242
#include "spi/st77xx.h"
4343
#include "firmware/debug/debug_debug.h"
4444

@@ -128,29 +128,29 @@ class ST7735S : public ST77XX {
128128
WriteDataByte(st77xx::data::kMadctlMx | st77xx::data::kMadctlMy | st77xx::data::kMadctlBgr);
129129
shift_x_ = st7735s::kRotation0ShiftX;
130130
shift_y_ = st7735s::kRotation0ShiftY;
131-
width_ = config::kWidth;
132-
height_ = config::kHeight;
131+
width_ = config::lcd::kWidth;
132+
height_ = config::lcd::kHeight;
133133
break;
134134
case 1:
135135
WriteDataByte(st77xx::data::kMadctlMy | st77xx::data::kMadctlMv | st77xx::data::kMadctlBgr);
136136
shift_x_ = st7735s::kRotation1ShiftX;
137137
shift_y_ = st7735s::kRotation1ShiftY;
138-
width_ = config::kHeight;
139-
height_ = config::kWidth;
138+
width_ = config::lcd::kHeight;
139+
height_ = config::lcd::kWidth;
140140
break;
141141
case 2:
142142
WriteDataByte(st77xx::data::kMadctlBgr);
143143
shift_x_ = st7735s::kRotation2ShiftX;
144144
shift_y_ = st7735s::kRotation2ShiftY;
145-
width_ = config::kWidth;
146-
height_ = config::kHeight;
145+
width_ = config::lcd::kWidth;
146+
height_ = config::lcd::kHeight;
147147
break;
148148
case 3:
149149
WriteDataByte(st77xx::data::kMadctlMx | st77xx::data::kMadctlMv | st77xx::data::kMadctlBgr);
150150
shift_x_ = st7735s::kRotation3ShiftX;
151151
shift_y_ = st7735s::kRotation3ShiftY;
152-
width_ = config::kHeight;
153-
height_ = config::kWidth;
152+
width_ = config::lcd::kHeight;
153+
height_ = config::lcd::kWidth;
154154
break;
155155
default:
156156
assert(0);

lib-display/include/spi/st7789.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <cstdint>
3030
#include <cassert>
3131

32-
#include "spi/config.h"
32+
#include "spi/config/config_lcd.h"
3333
#include "spi/st77xx.h"
3434
#include "timing.h"
3535
#include "firmware/debug/debug_debug.h"
@@ -143,29 +143,29 @@ class ST7789 : public ST77XX {
143143
WriteDataByte(st77xx::data::kMadctlMx | st77xx::data::kMadctlMy | st77xx::data::kMadctlRgb);
144144
shift_x_ = st7789::kRotation0ShiftX;
145145
shift_y_ = st7789::kRotation0ShiftY;
146-
width_ = config::kWidth;
147-
height_ = config::kHeight;
146+
width_ = config::lcd::kWidth;
147+
height_ = config::lcd::kHeight;
148148
break;
149149
case 1:
150150
WriteDataByte(st77xx::data::kMadctlMy | st77xx::data::kMadctlMv | st77xx::data::kMadctlRgb);
151151
shift_x_ = st7789::kRotation1ShiftX;
152152
shift_y_ = st7789::kRotation1ShiftY;
153-
width_ = config::kHeight;
154-
height_ = config::kWidth;
153+
width_ = config::lcd::kHeight;
154+
height_ = config::lcd::kWidth;
155155
break;
156156
case 2:
157157
WriteDataByte(st77xx::data::kMadctlRgb);
158158
shift_x_ = st7789::kRotation2ShiftX;
159159
shift_y_ = st7789::kRotation2ShiftY;
160-
width_ = config::kWidth;
161-
height_ = config::kHeight;
160+
width_ = config::lcd::kWidth;
161+
height_ = config::lcd::kHeight;
162162
break;
163163
case 3:
164164
WriteDataByte(st77xx::data::kMadctlMx | st77xx::data::kMadctlMv | st77xx::data::kMadctlRgb);
165165
shift_x_ = st7789::kRotation3ShiftX;
166166
shift_y_ = st7789::kRotation3ShiftY;
167-
width_ = config::kHeight;
168-
height_ = config::kWidth;
167+
width_ = config::lcd::kHeight;
168+
height_ = config::lcd::kWidth;
169169
break;
170170
default:
171171
assert(0);

0 commit comments

Comments
 (0)