Skip to content

Commit

Permalink
feat(mcknly#20): add basic build infrastructure for including pico_w …
Browse files Browse the repository at this point in the history
…wifi support
  • Loading branch information
Kintar committed Jun 26, 2024
1 parent 9d393cb commit deafc4c
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ set(hardware_dir ${CMAKE_CURRENT_SOURCE_DIR}/hardware/${PLATFORM})
if(EXISTS ${hardware_dir}/prebuild.cmake)
include(${hardware_dir}/prebuild.cmake)
endif()
if(DEFINED WIFI_ENABLED)
include(wifi_optional.cmake)
endif()
project(${PROJ_NAME} C CXX ASM)

add_definitions(-DPROJECT_NAME=${PROJ_NAME}) # pass the project name to the preprocessor for use in the code
Expand Down
89 changes: 89 additions & 0 deletions hardware/rp2040/lwip_config/lwipopts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#ifndef __LWIPOPTS_H__
#define __LWIPOPTS_H__


#define TCPIP_THREAD_PRIO 2
#define TCPIP_THREAD_STACKSIZE 2048 //1024
#define DEFAULT_THREAD_STACKSIZE 1024
#define DEFAULT_RAW_RECVMBOX_SIZE 8
#define TCPIP_MBOX_SIZE 8
#define LWIP_TIMEVAL_PRIVATE 0

#define LWIP_SOCKET 1

#define MEM_LIBC_MALLOC 0

#define MEM_ALIGNMENT 4
#define MEM_SIZE 4000
#define MEMP_NUM_TCP_SEG 32
#define MEMP_NUM_ARP_QUEUE 10
#define PBUF_POOL_SIZE 24
#define LWIP_ARP 1
#define LWIP_ETHERNET 1
#define LWIP_ICMP 1
#define LWIP_RAW 1
#define TCP_WND (8 * TCP_MSS)
#define TCP_MSS 1460
#define TCP_SND_BUF (8 * TCP_MSS)
#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1)) / (TCP_MSS))
#define LWIP_NETIF_STATUS_CALLBACK 1
#define LWIP_NETIF_LINK_CALLBACK 1
#define LWIP_NETIF_HOSTNAME 1
#define LWIP_NETCONN 1
#define MEM_STATS 0
#define SYS_STATS 0
#define MEMP_STATS 0
#define LINK_STATS 0
// #define ETH_PAD_SIZE 2
#define LWIP_CHKSUM_ALGORITHM 3
#define LWIP_DHCP 1
#define LWIP_IPV4 1
#define LWIP_TCP 1
#define LWIP_UDP 1
#define LWIP_DNS 1
#define LWIP_TCP_KEEPALIVE 1
#define LWIP_NETIF_TX_SINGLE_PBUF 1
#define DHCP_DOES_ARP_CHECK 1
#define LWIP_DHCP_DOES_ACD_CHECK 0

#ifndef NDEBUG
#define LWIP_DEBUG 1
#define LWIP_STATS 1
#define LWIP_STATS_DISPLAY 1
#endif

#define ETHARP_DEBUG LWIP_DBG_OFF
#define NETIF_DEBUG LWIP_DBG_OFF
#define PBUF_DEBUG LWIP_DBG_OFF
#define API_LIB_DEBUG LWIP_DBG_OFF
#define API_MSG_DEBUG LWIP_DBG_OFF
#define SOCKETS_DEBUG LWIP_DBG_OFF
#define ICMP_DEBUG LWIP_DBG_OFF
#define INET_DEBUG LWIP_DBG_OFF
#define IP_DEBUG LWIP_DBG_OFF
#define IP_REASS_DEBUG LWIP_DBG_OFF
#define RAW_DEBUG LWIP_DBG_OFF
#define MEM_DEBUG LWIP_DBG_OFF
#define MEMP_DEBUG LWIP_DBG_OFF
#define SYS_DEBUG LWIP_DBG_OFF
#define TCP_DEBUG LWIP_DBG_OFF
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
#define TCP_RTO_DEBUG LWIP_DBG_OFF
#define TCP_CWND_DEBUG LWIP_DBG_OFF
#define TCP_WND_DEBUG LWIP_DBG_OFF
#define TCP_FR_DEBUG LWIP_DBG_OFF
#define TCP_QLEN_DEBUG LWIP_DBG_OFF
#define TCP_RST_DEBUG LWIP_DBG_OFF
#define UDP_DEBUG LWIP_DBG_OFF
#define TCPIP_DEBUG LWIP_DBG_OFF
#define PPP_DEBUG LWIP_DBG_OFF
#define SLIP_DEBUG LWIP_DBG_OFF
#define DHCP_DEBUG LWIP_DBG_OFF


#define DEFAULT_TCP_RECVMBOX_SIZE 128



#endif /* __LWIPOPTS_H__ */
2 changes: 1 addition & 1 deletion rtos/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
#define configUSE_QUEUE_SETS 1
#define configUSE_TIME_SLICING 1
#define configUSE_NEWLIB_REENTRANT 0
#define configENABLE_BACKWARD_COMPATIBILITY 0
#define configENABLE_BACKWARD_COMPATIBILITY 1
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5

/* System */
Expand Down
26 changes: 26 additions & 0 deletions wifi_optional.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# configures the wifi service if a compatible board is selected
# included automatically if WIFI_ENABLED is defined
message(STATUS "wifi requested")

if(${BOARD} STREQUAL pico_w)
# pico_w specific configuration

# set up path for WIFI_INTERFACE library
set(WIFI_INCLUDE_PATH ${hardware_dir}/lwip_config)
# remove the intial cyw43 arch file from the hardware libs
list(REMOVE_ITEM hardware_libs pico_cyw43_arch_none)
# add the freeRTOS lwip lib
list(APPEND hardware_libs pico_cyw43_arch_lwip_sys_freertos)
else()
message(FATAL_ERROR "selected board '${BOARD}' is not supported for wifi")
endif()

# once board-specific configuration is done, add an interface library to
# bundle the necessary wifi includes and append that library to the hardware libs list and
# add in the wifi service code
add_library(WIFI_INTERFACE INTERFACE)
target_include_directories(WIFI_INTERFACE INTERFACE
${WIFI_INCLUDE_PATH})
list(APPEND hardware_libs WIFI_INTERFACE)

add_compile_definitions(WIFI_ENABLED)

0 comments on commit deafc4c

Please sign in to comment.