Skip to content

Commit 9e49c58

Browse files
Fix LWIP defines, remove dup'd includes (#3065)
Fixes #3064 Actually call the noInterrupts() function for SYS_ARCH_PROTECT. Remove config header redirects to tools/libpico. Instead, keep single copy in include/XX and add that path to the CMake file.
1 parent b886471 commit 9e49c58

File tree

7 files changed

+282
-285
lines changed

7 files changed

+282
-285
lines changed

include/btstack_config.h

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,75 @@
1-
#include "../tools/libpico/btstack_config.h"
1+
#pragma once
2+
3+
// BTstack features that can be enabled
4+
#define ENABLE_LOG_INFO
5+
#define ENABLE_LOG_DEBUG
6+
#define ENABLE_LOG_ERROR
7+
#define ENABLE_PRINTF_HEXDUMP
8+
#define ENABLE_SCO_OVER_HCI
9+
10+
#ifdef ENABLE_CLASSIC
11+
#define ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE
12+
#endif
13+
14+
#ifdef ENABLE_BLE
15+
#define ENABLE_L2CAP_LE_CREDIT_BASED_FLOW_CONTROL_MODE
16+
#define ENABLE_LE_PERIPHERAL
17+
#define ENABLE_LE_CENTRAL
18+
#endif
19+
20+
// BTstack configuration. buffers, sizes, ...
21+
#define HCI_OUTGOING_PRE_BUFFER_SIZE 4
22+
#define HCI_ACL_PAYLOAD_SIZE (1691 + 4)
23+
#define HCI_ACL_CHUNK_SIZE_ALIGNMENT 4
24+
#define MAX_NR_AVDTP_CONNECTIONS 1
25+
#define MAX_NR_AVDTP_STREAM_ENDPOINTS 1
26+
#define MAX_NR_AVRCP_CONNECTIONS 2
27+
#define MAX_NR_BNEP_CHANNELS 1
28+
#define MAX_NR_BNEP_SERVICES 1
29+
#define MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES 2
30+
#define MAX_NR_GATT_CLIENTS 1
31+
#define MAX_NR_HCI_CONNECTIONS 2
32+
#define MAX_NR_HID_HOST_CONNECTIONS 1
33+
#define MAX_NR_HIDS_CLIENTS 1
34+
#define MAX_NR_HFP_CONNECTIONS 1
35+
#define MAX_NR_L2CAP_CHANNELS 4
36+
#define MAX_NR_L2CAP_SERVICES 3
37+
#define MAX_NR_RFCOMM_CHANNELS 1
38+
#define MAX_NR_RFCOMM_MULTIPLEXERS 1
39+
#define MAX_NR_RFCOMM_SERVICES 1
40+
#define MAX_NR_SERVICE_RECORD_ITEMS 4
41+
#define MAX_NR_SM_LOOKUP_ENTRIES 3
42+
#define MAX_NR_WHITELIST_ENTRIES 16
43+
#define MAX_NR_LE_DEVICE_DB_ENTRIES 16
44+
45+
// Limit number of ACL/SCO Buffer to use by stack to avoid cyw43 shared bus overrun
46+
#define MAX_NR_CONTROLLER_ACL_BUFFERS 3
47+
#define MAX_NR_CONTROLLER_SCO_PACKETS 3
48+
49+
// Enable and configure HCI Controller to Host Flow Control to avoid cyw43 shared bus overrun
50+
#define ENABLE_HCI_CONTROLLER_TO_HOST_FLOW_CONTROL
51+
#define HCI_HOST_ACL_PACKET_LEN 1024
52+
#define HCI_HOST_ACL_PACKET_NUM 3
53+
#define HCI_HOST_SCO_PACKET_LEN 120
54+
#define HCI_HOST_SCO_PACKET_NUM 3
55+
56+
// Link Key DB and LE Device DB using TLV on top of Flash Sector interface
57+
#define NVM_NUM_DEVICE_DB_ENTRIES 16
58+
#define NVM_NUM_LINK_KEYS 16
59+
60+
// We don't give btstack a malloc, so use a fixed-size ATT DB.
61+
#define MAX_ATT_DB_SIZE 512
62+
63+
// BTstack HAL configuration
64+
#define HAVE_EMBEDDED_TIME_MS
65+
66+
// map btstack_assert onto Pico SDK assert()
67+
#define HAVE_ASSERT
68+
69+
// Some USB dongles take longer to respond to HCI reset (e.g. BCM20702A).
70+
#define HCI_RESET_RESEND_TIMEOUT_MS 1000
71+
72+
#define ENABLE_SOFTWARE_AES128
73+
#define ENABLE_MICRO_ECC_FOR_LE_SECURE_CONNECTIONS
74+
75+
#undef HAVE_BTSTACK_STDIN

include/lwipopts.h

Lines changed: 115 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,115 @@
1-
#include "../tools/libpico/lwipopts.h"
1+
#pragma once
2+
3+
#ifdef __cplusplus
4+
extern "C" {
5+
#endif // __cplusplus
6+
7+
// Critical section protection
8+
extern void noInterrupts();
9+
extern void interrupts();
10+
#define SYS_ARCH_DECL_PROTECT int
11+
#define SYS_ARCH_PROTECT(lev) {(void) lev; noInterrupts();}
12+
#define SYS_ARCH_UNPROTECT(lev) {(void) lev; interrupts();}
13+
14+
extern unsigned long __lwip_rand(void);
15+
#define LWIP_RAND() __lwip_rand()
16+
17+
#ifndef __LWIP_MEMMULT
18+
#define __LWIP_MEMMULT 1
19+
#endif
20+
21+
// Common settings used in most of the pico_w examples
22+
// (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html for details)
23+
24+
#define NO_SYS 1
25+
#define LWIP_SOCKET 0
26+
#define MEM_LIBC_MALLOC 0
27+
28+
#define MEM_ALIGNMENT 4
29+
#define MEM_SIZE (__LWIP_MEMMULT * 16384)
30+
#define MEMP_NUM_TCP_SEG (32)
31+
#define MEMP_NUM_ARP_QUEUE (10)
32+
#define PBUF_POOL_SIZE (__LWIP_MEMMULT > 1 ? 32 : 24)
33+
#define LWIP_ARP 7
34+
#define LWIP_ETHERNET 1
35+
#define LWIP_ICMP 1
36+
#define LWIP_RAW 1
37+
#define TCP_WND (8 * TCP_MSS)
38+
#define TCP_MSS 1460
39+
#define TCP_SND_BUF (8 * TCP_MSS)
40+
#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1)) / (TCP_MSS))
41+
#define LWIP_NETIF_STATUS_CALLBACK 1
42+
#define LWIP_NETIF_LINK_CALLBACK 1
43+
#define LWIP_NETIF_HOSTNAME 1
44+
#define LWIP_NUM_NETIF_CLIENT_DATA 5
45+
#define LWIP_NETCONN 0
46+
#define LWIP_STATS 0
47+
#define LWIP_STATS_DISPLAY 0
48+
#define MEM_STATS 0
49+
#define SYS_STATS 0
50+
#define MEMP_STATS 0
51+
#define LINK_STATS 0
52+
#define LWIP_CHKSUM_ALGORITHM 0
53+
#define LWIP_DHCP 1
54+
#define LWIP_IPV4 1
55+
#define LWIP_TCP 1
56+
#define LWIP_UDP 1
57+
#define LWIP_DNS 1
58+
#define LWIP_DNS_SUPPORT_MDNS_QUERIES 1
59+
#define LWIP_TCP_KEEPALIVE 1
60+
#define LWIP_NETIF_TX_SINGLE_PBUF 1
61+
#define DHCP_DOES_ARP_CHECK 0
62+
#define LWIP_DHCP_DOES_ACD_CHECK 0
63+
#define LWIP_IGMP 1
64+
#define LWIP_MDNS_RESPONDER 1
65+
#define MDNS_MAX_SERVICES 4
66+
67+
// See #1285
68+
#define MEMP_NUM_UDP_PCB (__LWIP_MEMMULT * 7)
69+
#define MEMP_NUM_TCP_PCB (__LWIP_MEMMULT * 5)
70+
71+
#if LWIP_IPV6
72+
#define LWIP_IPV6_DHCP6 1
73+
#define LWIP_IPV6_MLD 1
74+
#endif
75+
76+
// NTP
77+
extern void __setSystemTime(unsigned long long sec, unsigned long us);
78+
#define SNTP_SET_SYSTEM_TIME_US(sec, us) __setSystemTime(sec, us)
79+
#define SNTP_MAX_SERVERS 2
80+
//#define SNTP_SERVER_ADDRESS "pool.ntp.org"
81+
#define SNTP_SERVER_DNS 1
82+
83+
#define LWIP_DEBUG 0
84+
#define ETHARP_DEBUG LWIP_DBG_OFF
85+
#define NETIF_DEBUG LWIP_DBG_OFF
86+
#define PBUF_DEBUG LWIP_DBG_OFF
87+
#define API_LIB_DEBUG LWIP_DBG_OFF
88+
#define API_MSG_DEBUG LWIP_DBG_OFF
89+
#define SOCKETS_DEBUG LWIP_DBG_OFF
90+
#define ICMP_DEBUG LWIP_DBG_OFF
91+
#define INET_DEBUG LWIP_DBG_OFF
92+
#define IP_DEBUG LWIP_DBG_OFF
93+
#define IP_REASS_DEBUG LWIP_DBG_OFF
94+
#define RAW_DEBUG LWIP_DBG_OFF
95+
#define MEM_DEBUG LWIP_DBG_OFF
96+
#define MEMP_DEBUG LWIP_DBG_OFF
97+
#define SYS_DEBUG LWIP_DBG_OFF
98+
#define TCP_DEBUG LWIP_DBG_OFF
99+
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
100+
#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
101+
#define TCP_RTO_DEBUG LWIP_DBG_OFF
102+
#define TCP_CWND_DEBUG LWIP_DBG_OFF
103+
#define TCP_WND_DEBUG LWIP_DBG_OFF
104+
#define TCP_FR_DEBUG LWIP_DBG_OFF
105+
#define TCP_QLEN_DEBUG LWIP_DBG_OFF
106+
#define TCP_RST_DEBUG LWIP_DBG_OFF
107+
#define UDP_DEBUG LWIP_DBG_OFF
108+
#define TCPIP_DEBUG LWIP_DBG_OFF
109+
#define PPP_DEBUG LWIP_DBG_OFF
110+
#define SLIP_DEBUG LWIP_DBG_OFF
111+
#define DHCP_DEBUG LWIP_DBG_OFF
112+
113+
#ifdef __cplusplus
114+
}
115+
#endif // __cplusplus

include/tusb_config.h

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,91 @@
1-
#include "../tools/libpico/tusb_config.h"
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2019 Ha Thach (tinyusb.org)
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*
24+
*/
25+
26+
#ifndef _TUSB_CONFIG_H_
27+
#define _TUSB_CONFIG_H_
28+
29+
#ifdef __cplusplus
30+
extern "C" {
31+
#endif
32+
33+
//--------------------------------------------------------------------
34+
// COMMON CONFIGURATION
35+
//--------------------------------------------------------------------
36+
37+
#ifndef CFG_TUSB_MCU
38+
#define CFG_TUSB_MCU OPT_MCU_RP2040
39+
#endif
40+
41+
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE
42+
#define CFG_TUSB_OS OPT_OS_PICO
43+
44+
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
45+
#ifndef CFG_TUSB_DEBUG
46+
#define CFG_TUSB_DEBUG 0
47+
#endif
48+
49+
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
50+
* Tinyusb use follows macros to declare transferring memory so that they can be put
51+
* into those specific section.
52+
* e.g
53+
* - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") ))
54+
* - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4)))
55+
*/
56+
#ifndef CFG_TUSB_MEM_SECTION
57+
#define CFG_TUSB_MEM_SECTION
58+
#endif
59+
60+
#ifndef CFG_TUSB_MEM_ALIGN
61+
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
62+
#endif
63+
64+
//--------------------------------------------------------------------
65+
// DEVICE CONFIGURATION
66+
//--------------------------------------------------------------------
67+
68+
#ifndef CFG_TUD_ENDPOINT0_SIZE
69+
#define CFG_TUD_ENDPOINT0_SIZE 64
70+
#endif
71+
72+
//------------- CLASS -------------//
73+
#define CFG_TUD_HID (2)
74+
#define CFG_TUD_CDC (1)
75+
#define CFG_TUD_MSC (1)
76+
#define CFG_TUD_MIDI (0)
77+
#define CFG_TUD_VENDOR (0)
78+
79+
#define CFG_TUD_CDC_RX_BUFSIZE (256)
80+
#define CFG_TUD_CDC_TX_BUFSIZE (256)
81+
82+
#define CFG_TUD_MSC_EP_BUFSIZE (64)
83+
84+
// HID buffer size Should be sufficient to hold ID (if any) + Data
85+
#define CFG_TUD_HID_EP_BUFSIZE (64)
86+
87+
#ifdef __cplusplus
88+
}
89+
#endif
90+
91+
#endif /* _TUSB_CONFIG_H_ */

tools/libpico/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ target_compile_options(common-${cpu} INTERFACE
151151
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
152152
)
153153

154-
include_directories(BEFORE ${PICO_SDK_PATH}/../tools/libpico)
154+
include_directories(BEFORE ${PICO_SDK_PATH}/../include)
155155

156156
add_library(pico-${cpu} STATIC)
157157
target_compile_definitions(pico-${cpu} PUBLIC

tools/libpico/btstack_config.h

Lines changed: 0 additions & 75 deletions
This file was deleted.

0 commit comments

Comments
 (0)