Skip to content

Commit a6081aa

Browse files
committed
Fix console output newlines and update configs
Append missing trailing newlines to various console::Error/console messages across network, timer, DHCP/IGMP and TCP/UDP code to improve log formatting. Add console::Write declaration and use it in perror, include <cstdint> where needed, and add IWYU pragmas in hal.h. Update copyright years, increase network memory blocks from 8 to 12, raise TCP_MAX_TCBS_ALLOWED from 16 to 32, and normalize HOST_NAME_PREFIX strings (use hyphen). Also simplify ENABLE_USB_HOST conditionals and adjust related includes. Small allocator and error message tweaks included to make diagnostics clearer.
1 parent d3fdd5f commit a6081aa

11 files changed

Lines changed: 35 additions & 37 deletions

File tree

lib-clib/src/malloc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ extern "C"
150150

151151
if (next > block_limit)
152152
{
153-
console::Error("malloc: out of memory");
153+
console::Error("malloc: out of memory\n");
154154
#ifdef DEBUG_HEAP
155155
debug_heap();
156156
#endif

lib-clib/src/perror.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file perror.cpp
33
*
44
*/
5-
/* Copyright (C) 2020-2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2020-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,6 +31,7 @@ namespace console
3131
void Error(const char*);
3232
int Putc(int);
3333
int Puts(const char*);
34+
void Write(const char*, unsigned int);
3435
} // namespace console
3536

3637
/*
@@ -107,7 +108,7 @@ extern "C"
107108
if (s && *s)
108109
{
109110
console::Error(s);
110-
console::Puts(": ");
111+
console::Write(": ", 2);
111112
}
112113

113114
console::Error(ptr);

lib-hal/console/uart0/console.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* THE SOFTWARE.
2424
*/
2525

26+
#include <cstdint>
2627
#include <cstring>
2728

2829
#include "console.h"

lib-hal/include/gd32/hal.h

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file hal.h
33
*
44
*/
5-
/* Copyright (C) 2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2025-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
@@ -28,17 +28,13 @@
2828

2929
#include <cstdint>
3030

31-
#include "gd32.h"
31+
#include "gd32.h" // IWYU pragma: keep
3232

33-
#if defined(ENABLE_USB_HOST) && defined(CONFIG_USB_HOST_MSC)
33+
#if defined(ENABLE_USB_HOST)
3434
extern "C"
3535
{
3636
#include "usbh_core.h"
37-
#if defined(GD32H7XX) || defined(GD32F4XX)
38-
extern usbh_host usb_host_msc;
39-
#else
4037
extern usbh_host usb_host;
41-
#endif
4238
}
4339
#endif
4440

@@ -54,10 +50,10 @@ void emac_debug_run();
5450
#include "task.h"
5551
#endif
5652

57-
#include "softwaretimers.h"
53+
#include "softwaretimers.h" // IWYU pragma: keep
5854

5955
#if !defined(DISABLE_RTC)
60-
#include "hwclock.h"
56+
#include "hwclock.h" // IWYU pragma: keep
6157
#endif
6258

6359
#include "hal_panelled.h"
@@ -74,13 +70,9 @@ inline constexpr float kCoreTemperatureMax = +85.0;
7470

7571
inline void Run()
7672
{
77-
#if defined(ENABLE_USB_HOST) && defined(CONFIG_USB_HOST_MSC)
78-
#if defined(GD32H7XX) || defined(GD32F4XX)
79-
usbh_core_task(&usb_host_msc);
80-
#else
73+
#if defined(ENABLE_USB_HOST)
8174
usbh_core_task(&usb_host);
8275
#endif
83-
#endif
8476
#if !defined(USE_FREE_RTOS)
8577
SoftwareTimerRun();
8678
#endif

lib-hal/superloop/softwaretimers.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ TimerHandle_t SoftwareTimerAdd(uint32_t interval_millis, const TimerCallbackFunc
7777
if (s_timers_count >= hal::kSoftwareTimersMax)
7878
{
7979
#ifndef NDEBUG
80-
console::Error("SoftwareTimerAdd: Max timer limit reached");
80+
console::Error("SoftwareTimerAdd: Max timer limit reached\n");
8181
#endif
8282
return -1;
8383
}
@@ -134,7 +134,7 @@ bool SoftwareTimerDelete(TimerHandle_t& id)
134134
}
135135

136136
#ifndef NDEBUG
137-
console::Error("SoftwareTimerDelete: Timer not found");
137+
console::Error("SoftwareTimerDelete: Timer not found\n");
138138
#endif
139139

140140
DEBUG_EXIT();
@@ -163,7 +163,7 @@ bool SoftwareTimerChange(TimerHandle_t id, uint32_t interval_millis)
163163
}
164164

165165
#ifndef NDEBUG
166-
console::Error("SoftwareTimerChange: Timer not found");
166+
console::Error("SoftwareTimerChange: Timer not found\n");
167167
#endif
168168

169169
return false;

lib-network/config/net_config.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file net_config.h
33
*
44
*/
5-
/* Copyright (C) 2021-2024 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2021-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
@@ -26,16 +26,20 @@
2626
#ifndef NET_CONFIG_H_
2727
#define NET_CONFIG_H_
2828

29+
// Valid hostnames (as per RFC 1123) must consist only of ASCII letters (a-z, A-Z), digits (0-9), and hyphens (-).
30+
// Labels must be 1-63 characters, with a maximum total length of 253 characters.
31+
// They cannot start or end with a hyphen, and should not be all-numeric.
32+
2933
#if defined(__linux__) || defined (__APPLE__)
3034
# define UDP_MAX_PORTS_ALLOWED 32
3135
# define IGMP_MAX_JOINS_ALLOWED (4 + (8 * 4)) /* 8 outputs x 4 Universes */
32-
# define TCP_MAX_TCBS_ALLOWED 16
36+
# define TCP_MAX_TCBS_ALLOWED 32
3337
# define TCP_MAX_PORTS_ALLOWED 2
3438
#else
3539
# define TCP_MAX_PORTS_ALLOWED 1
3640
# if defined (H3)
3741
# if !defined(HOST_NAME_PREFIX)
38-
# define HOST_NAME_PREFIX "allwinner_"
42+
# define HOST_NAME_PREFIX "allwinner-"
3943
# endif
4044
# define UDP_MAX_PORTS_ALLOWED 16
4145
# define IGMP_MAX_JOINS_ALLOWED (4 + (8 * 4)) /* 8 outputs x 4 Universes */
@@ -46,7 +50,7 @@
4650
*/
4751
# define CHECKSUM_BY_HARDWARE
4852
# if !defined(HOST_NAME_PREFIX)
49-
# define HOST_NAME_PREFIX "gigadevice_"
53+
# define HOST_NAME_PREFIX "gigadevice-"
5054
# endif
5155
# if !defined (UDP_MAX_PORTS_ALLOWED)
5256
# define UDP_MAX_PORTS_ALLOWED 8

lib-network/src/core/ipv4/dhcp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ void Inform()
250250
#ifndef NDEBUG
251251
if (kHandle < 0)
252252
{
253-
console::Error("DHCP Inform");
253+
console::Error("DHCP Inform\n");
254254
return;
255255
}
256256
#endif
@@ -766,7 +766,7 @@ bool Start()
766766
#ifndef NDEBUG
767767
if (dhcp->handle < 0)
768768
{
769-
console::Error("DHCP Start");
769+
console::Error("DHCP Start\n");
770770
DEBUG_EXIT();
771771
return false;
772772
}

lib-network/src/core/ipv4/igmp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ void static Join(uint32_t group_address)
378378
}
379379

380380
#ifndef NDEBUG
381-
console::Error("igmp::Join");
381+
console::Error("igmp::Join\n");
382382
#endif
383383
DEBUG_ENTRY();
384384
}

lib-network/src/core/network_memory.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace network::memory
3939
{
4040
inline constexpr uint32_t kBlocks =
4141
#if !defined(CONFIG_NETWORK_MEMORY_BLOCKS)
42-
8;
42+
12;
4343
#else
4444
CONFIG_NETWORK_MEMORY_BLOCKS;
4545
#endif
@@ -93,7 +93,7 @@ class Allocator
9393
{
9494
if (IsFull())
9595
{
96-
console::Error("Full!");
96+
console::Error("Allocate:Full!\n");
9797
return nullptr;
9898
}
9999

@@ -113,7 +113,7 @@ class Allocator
113113

114114
if (IsFull())
115115
{
116-
console::Error("Full!");
116+
console::Error("Allocate:Full!\n");
117117
return UINT16_MAX;
118118
}
119119

lib-network/src/core/tcp.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,7 +1664,7 @@ int32_t Connect(uint32_t remote_ip, uint16_t remote_port, CallbackConnect cb_con
16641664
const auto& netif = netif::global::netif_default;
16651665
if (__builtin_expect((netif.ip.addr == 0), 0))
16661666
{
1667-
console::Error("Connect: No ip!");
1667+
console::Error("Connect: No ip!\n");
16681668
return -1;
16691669
}
16701670

@@ -1673,7 +1673,7 @@ int32_t Connect(uint32_t remote_ip, uint16_t remote_port, CallbackConnect cb_con
16731673
auto* tcb = AllocTcb(remote_port, &out_index);
16741674
if (tcb == nullptr)
16751675
{
1676-
console::Error("Connect: No TCB!");
1676+
console::Error("Connect: No TCB!\n");
16771677
return -2;
16781678
}
16791679

@@ -1714,15 +1714,15 @@ int32_t Close(ConnHandle conn_handle) // graceful FIN
17141714
{
17151715
if (conn_handle >= TCP_MAX_TCBS_ALLOWED)
17161716
{
1717-
console::Error("Close: Connection handle!");
1717+
console::Error("Close: Connection handle!\n");
17181718
return -1;
17191719
}
17201720

17211721
auto* c = &s_tcbs[conn_handle];
17221722

17231723
if (!c->in_use || c->state == kStateClosed)
17241724
{
1725-
console::Error("Close: TCB!");
1725+
console::Error("Close: TCB!\n");
17261726
return -1;
17271727
}
17281728

@@ -1743,7 +1743,7 @@ int32_t Close(ConnHandle conn_handle) // graceful FIN
17431743
// We only support graceful close from states where FIN makes sense here.
17441744
if (c->state != kStateEstablished && c->state != kStateCloseWait)
17451745
{
1746-
console::Error("Close: Not graceful!");
1746+
console::Error("Close: Not graceful!\n");
17471747
return -1;
17481748
}
17491749

0 commit comments

Comments
 (0)