diff options
Diffstat (limited to 'cmd/sbc_harness/config')
-rw-r--r-- | cmd/sbc_harness/config/config.h | 85 | ||||
-rw-r--r-- | cmd/sbc_harness/config/tusb_config.h | 45 |
2 files changed, 92 insertions, 38 deletions
diff --git a/cmd/sbc_harness/config/config.h b/cmd/sbc_harness/config/config.h index b557287..ca23462 100644 --- a/cmd/sbc_harness/config/config.h +++ b/cmd/sbc_harness/config/config.h @@ -1,18 +1,24 @@ /* config.h - Compile-time configuration for sbc_harness * - * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com> + * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> * SPDX-License-Identifier: AGPL-3.0-or-later */ #ifndef _CONFIG_H_ #define _CONFIG_H_ -/* W5500 **********************************************************************/ +#include <stddef.h> /* for size_t */ -/** - * How many W5500 chips we have. - */ -#define CONFIG_W5500_NUM 1 +#define CONFIG_FLASH_DEBUG 1 + +#define _CONFIG_9P_MAX_CONNS 3 /* FIXME: bump this back up to 8 */ +#define _CONFIG_9P_MAX_REQS (2*_CONFIG_9P_MAX_CONNS) + +/* RP2040 *********************************************************************/ + +#define CONFIG_RP2040_SPI_DEBUG 1 /* bool */ + +/* W5500 **********************************************************************/ /** * When allocating an arbitrary local port, what range should it be @@ -25,9 +31,26 @@ #define CONFIG_W5500_LOCAL_PORT_MIN 32768 #define CONFIG_W5500_LOCAL_PORT_MAX 60999 +#define CONFIG_W5500_VALIDATE_SPI 1 /* bool */ +#define CONFIG_W5500_DEBUG 0 /* bool */ +#define CONFIG_W5500_LL_DEBUG 0 /* bool */ + /* 9P *************************************************************************/ -#define CONFIG_9P_PORT 564 +#define CONFIG_9P_MAX_ERR_SIZE 128 /* 128 is what Plan 9 4e uses */ + +#define CONFIG_9P_ENABLE_9P2000 1 /* bool */ +#define CONFIG_9P_ENABLE_9P2000_u 1 /* bool */ +#define CONFIG_9P_ENABLE_9P2000_e 0 /* bool */ +#define CONFIG_9P_ENABLE_9P2000_L 0 /* bool */ +#define CONFIG_9P_ENABLE_9P2000_p9p 0 /* bool */ + +/* 9P_SRV *********************************************************************/ + +#define CONFIG_9P_SRV_DEBUG 1 /* bool */ + +#define CONFIG_9P_SRV_MAX_MSG_SIZE ((4*1024)+24) + /** * This max-msg-size is sized so that a Twrite message can return * 8KiB of data. @@ -45,41 +68,53 @@ * negotiated. In Plan 9 1e it was (8*1024)+128, and was bumped to * (8*1024)+160 in 2e and 3e. */ -#define CONFIG_9P_MAX_MSG_SIZE ((4*1024)+24) +#define CONFIG_9P_SRV_MAX_MSG_SIZE ((4*1024)+24) /** * Maximum host-data-structure size. A message may be larger in * unmarshaled-host-structures than marshaled-net-bytes due to (1) - * struct padding, (2) nul-terminator byes for strings. + * struct padding, (2) array pointers. */ -#define CONFIG_9P_MAX_HOSTMSG_SIZE CONFIG_9P_MAX_MSG_SIZE+16 -#define CONFIG_9P_MAX_FIDS 16 -#define CONFIG_9P_MAX_REQS 2 -#define CONFIG_9P_MAX_ERR_SIZE 128 /* 128 is what Plan 9 4e uses */ -#define CONFIG_9P_ENABLE_9P2000 1 /* bool */ -#define CONFIG_9P_ENABLE_9P2000_u 1 /* bool */ -#define CONFIG_9P_ENABLE_9P2000_e 0 /* bool */ +#define CONFIG_9P_SRV_MAX_HOSTMSG_SIZE CONFIG_9P_SRV_MAX_MSG_SIZE+16 /* DHCP ***********************************************************************/ #define CONFIG_DHCP_CAN_RECV_UNICAST_IP_WITHOUT_IP 0 /* bool */ -#define CONFIG_DHCP_DEBUG 0 /* bool */ +#define CONFIG_DHCP_DEBUG 1 /* bool */ #define CONFIG_DHCP_OPT_SIZE 312 /* minimum of 312 */ #define CONFIG_DHCP_SELECTING_NS (5*NS_PER_S) +/* USB KEYBOARD ***************************************************************/ + +/** + * Which USB port to use for the Root Hub. + * + * The RP2040 only has 1 port, so it's gotta be port #0. + */ +#define CONFIG_USB_COMMON_RHPORT 0 + +#define CONFIG_USB_COMMON_DEBUG 1 /* bool */ + /* COROUTINE ******************************************************************/ -#define CONFIG_COROUTINE_DEFAULT_STACK_SIZE (2*1024) +extern const size_t CONFIG_COROUTINE_STACK_SIZE_dhcp_cr; +extern const size_t CONFIG_COROUTINE_STACK_SIZE_init_cr; +extern const size_t CONFIG_COROUTINE_STACK_SIZE_read9p_cr; +extern const size_t CONFIG_COROUTINE_STACK_SIZE_write9p_cr; +extern const size_t CONFIG_COROUTINE_STACK_SIZE_usb_common_cr; +extern const size_t CONFIG_COROUTINE_STACK_SIZE_usb_keyboard_cr; +extern const size_t CONFIG_COROUTINE_STACK_SIZE_w5500_irq_cr; +#define CONFIG_COROUTINE_NAME_LEN 16 #define CONFIG_COROUTINE_MEASURE_STACK 1 /* bool */ #define CONFIG_COROUTINE_PROTECT_STACK 1 /* bool */ #define CONFIG_COROUTINE_DEBUG 0 /* bool */ #define CONFIG_COROUTINE_VALGRIND 0 /* bool */ +#define CONFIG_COROUTINE_GDB 1 /* bool */ -#define _CONFIG_9P_NUM_SOCKS 7 -#define CONFIG_COROUTINE_NUM ( \ - 1 /* usb_common */ + \ - 1 /* usb_keyboard */ + \ - CONFIG_W5500_NUM /* irq handler */ + \ - _CONFIG_9P_NUM_SOCKS /* 9P accept()+read() */ + \ - (CONFIG_9P_MAX_REQS*_CONFIG_9P_NUM_SOCKS) /* 9P work+write() */ ) +#define CONFIG_COROUTINE_NUM ( \ + 1 /* usb_common */ + \ + 1 /* usb_keyboard */ + \ + 1 /* W5500 irq handler */ + \ + _CONFIG_9P_MAX_CONNS /* 9P accept()+read() */ + \ + _CONFIG_9P_MAX_REQS /* 9P work+write() */ ) #endif /* _CONFIG_H_ */ diff --git a/cmd/sbc_harness/config/tusb_config.h b/cmd/sbc_harness/config/tusb_config.h index aeff31c..5240311 100644 --- a/cmd/sbc_harness/config/tusb_config.h +++ b/cmd/sbc_harness/config/tusb_config.h @@ -1,6 +1,6 @@ /* tusb_config.h - Compile-time configuration for the TinyUSB library * - * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com> + * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> * SPDX-License-Identifier: AGPL-3.0-or-later * * SPDX-License-Identifier: MIT @@ -36,16 +36,35 @@ extern "C" { #endif //-------------------------------------------------------------------- -// TinyUSB Device (TUD) initialization for rp2040-based boards +// Override the default definition of TU_ASSERT() to use our logging //-------------------------------------------------------------------- -// Which USB port to use for the RootHub. -// The rp2040 only has 1 port, so it's gotta be port #0. -#define BOARD_TUD_RHPORT 0 - -// RHPort max operational speed. -// Use OPT_MODE_DEFAULT_SPEED for max speed supported by MCU. -#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED +// "magically" select between the 1-arg and 2-args variants, inject a +// stringified version of `_cond`. +// +// Note: Use GNU-C `, ##__VA_ARGS__`, not standard C `__VA_OPT__(,) +// __VA_ARGS__`; because __VA_OPT__ doesn't handle present-but-empty +// arguments the way that we need. +#define TU_ASSERT(_cond, ...) \ + _GET_3RD_ARG(_cond, ##__VA_ARGS__, \ + _LIBMISC_TU_ASSERT_2ARGS, _LIBMISC_TU_ASSERT_1ARGS, _dummy) \ + (_cond, #_cond, ##__VA_ARGS__) + +#define _LIBMISC_TU_ASSERT_1ARGS(_cond, _cond_str) \ + _LIBMISC_TU_ASSERT_2ARGS(_cond, _cond_str, false) + +#define _LIBMISC_TU_ASSERT_2ARGS(_cond, _cond_str, _ret) \ + do { \ + if ( !(_cond) ) { \ + _libmisc_tu_mess_failed(_cond_str, \ + __FILE__, __LINE__, __func__); \ + TU_BREAKPOINT(); \ + return _ret; \ + } \ + } while (0) + +void _libmisc_tu_mess_failed(const char *expr, + const char *file, unsigned int line, const char *func); //-------------------------------------------------------------------- // Configuration: common @@ -66,13 +85,13 @@ extern "C" { // Tinyusb use follows macros to declare transferring memory so that they can be put // into those specific section. // e.g -// - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") )) -// - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4))) +// - CFG_TUSB_MEM SECTION : [[gnu::section(".usb_ram")]] +// - CFG_TUSB_MEM_ALIGN : [[gnu::aligned(4)]] #define CFG_TUSB_MEM_SECTION /* blank */ -#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4))) +#define CFG_TUSB_MEM_ALIGN [[gnu::aligned(4)]] #define CFG_TUD_ENABLED 1 -#define CFG_TUD_MAX_SPEED BOARD_TUD_MAX_SPEED +#define CFG_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED //-------------------------------------------------------------------- // Configuration: TinyUSB Device (TUD) |