Skip to content

Commit 0660106

Browse files
committed
Refine HAL, network config, and allocator
Updates across lib-hal and lib-network: - lib-hal/include/gd32/hal.h: bump copyright to 2025-2026; add IWYU pragma comments for gd32.h, softwaretimers.h and hwclock.h; simplify USB host conditional and always use usbh_core_task(&usb_host) when ENABLE_USB_HOST is defined. - lib-network/config/net_config.h: bump copyright to 2026; add RFC-1123 hostname validity notes; increase TCP_MAX_TCBS_ALLOWED on desktop builds from 16 to 32; change HOST_NAME_PREFIX values to use hyphens instead of underscores for H3 and other targets. - lib-network/src/core/network_memory.h: increase network memory blocks from 8 to 12 and improve allocator diagnostics by changing error messages to "Allocate:Full!\n". These changes adjust build/include handling, improve hostname defaults, expand networking resources, and make allocator failures clearer.
1 parent b087579 commit 0660106

3 files changed

Lines changed: 17 additions & 21 deletions

File tree

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-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/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

0 commit comments

Comments
 (0)