Skip to content

Commit

Permalink
update to Pico-SDK 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
scaprile committed Dec 2, 2024
1 parent 85613ab commit 716c84c
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 201 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ target_include_directories(firmware PUBLIC
.
)

target_link_libraries(firmware hardware_pio hardware_dma pico_stdlib pico_rand cyw43_driver_picow)
target_link_libraries(firmware pico_stdlib pico_rand pico_cyw43_driver pico_cyw43_arch_none)
pico_add_extra_outputs(firmware) # create map/bin/hex file etc.

pico_enable_stdio_usb(firmware 1) # Route stdio
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ build: pico-sdk build/firmware.uf2

build/firmware.uf2:
$(MKBUILD)
cd build && cmake -G "Unix Makefiles" .. && make
cd build && cmake -DPICO_BOARD="pico_w" -G "Unix Makefiles" .. && make

pico-sdk:
git clone --depth 1 -b 1.5.1 https://github.com/raspberrypi/pico-sdk $@
git clone --depth 1 -b 2.0.0 https://github.com/raspberrypi/pico-sdk $@
cd $@ && git submodule update --init

clean:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#include "pico/stdlib.h"
#include "pico/unique_id.h"
#include "pico/cyw43_arch.h"
#include "cyw43.h"
#include "cyw43_country.h"

#include "mongoose.h"
#include "driver_pico-w.h"
Expand All @@ -19,10 +19,11 @@ static struct mg_tcpip_if *s_ifp;
static bool mg_tcpip_driver_pico_w_init(struct mg_tcpip_if *ifp) {
struct mg_tcpip_driver_pico_w_data *d = (struct mg_tcpip_driver_pico_w_data *) ifp->driver_data;
s_ifp = ifp;
// initialize WiFi chip and connect to network
cyw43_init(&cyw43_state);
cyw43_wifi_set_up(&cyw43_state, CYW43_ITF_STA, true, CYW43_COUNTRY_WORLDWIDE);
cyw43_wifi_join(&cyw43_state, strlen(d->ssid), d->ssid, strlen(d->pass), d->pass, CYW43_AUTH_WPA2_AES_PSK, NULL, CYW43_ITF_STA);
if (cyw43_arch_init() != 0) return false; // initialize async_context and WiFi chip
cyw43_arch_enable_sta_mode();
// start connecting to network
if (cyw43_arch_wifi_connect_bssid_async(d->ssid, NULL, d->pass, CYW43_AUTH_WPA2_AES_PSK) != 0)
return false;
cyw43_wifi_get_mac(&cyw43_state, CYW43_ITF_STA, ifp->mac);
return true;
}
Expand All @@ -34,11 +35,7 @@ static size_t mg_tcpip_driver_pico_w_tx(const void *buf, size_t len,
}

static bool mg_tcpip_driver_pico_w_up(struct mg_tcpip_if *ifp) {
return cyw43_wifi_link_status(&cyw43_state, CYW43_ITF_STA) == CYW43_LINK_JOIN ? 1 : 0;
}

void driver_pico_w_poll(void) {
cyw43_poll();
return (cyw43_wifi_link_status(&cyw43_state, CYW43_ITF_STA) == CYW43_LINK_JOIN);
}

struct mg_tcpip_driver mg_tcpip_driver_pico_w = {
Expand All @@ -48,32 +45,17 @@ struct mg_tcpip_driver mg_tcpip_driver_pico_w = {
mg_tcpip_driver_pico_w_up,
};

void cyw43_cb_tcpip_init(cyw43_t *self, int itf) {}
void cyw43_cb_tcpip_deinit(cyw43_t *self, int itf) {}
void cyw43_cb_tcpip_set_link_up(cyw43_t *self, int itf) {}
void cyw43_cb_tcpip_set_link_down(cyw43_t *self, int itf) {}

// Called once per outstanding frame during a call to cyw43_poll
// Called once per outstanding frame by async_context
void cyw43_cb_process_ethernet(void *cb_data, int itf, size_t len, const uint8_t *buf) {
if (itf != CYW43_ITF_STA) return;
mg_tcpip_qwrite((void *) buf, len, s_ifp);
(void) cb_data;
}

// Return mac address
void cyw43_hal_get_mac(__unused int idx, uint8_t buf[6]) {
memcpy(buf, cyw43_state.mac, 6);
}
// Called by async_context
void cyw43_cb_tcpip_set_link_up(cyw43_t *self, int itf) {}
void cyw43_cb_tcpip_set_link_down(cyw43_t *self, int itf) {}

// Generate a mac address if one is not set in otp
void cyw43_hal_generate_laa_mac(__unused int idx, uint8_t buf[6]) {
pico_unique_board_id_t board_id;
MG_DEBUG(("No MAC in cyw43 OTP, generated from board id"));
pico_get_unique_board_id(&board_id);
memcpy(buf, &board_id.id[2], 6);
buf[0] &= (uint8_t)~0x1; // unicast
buf[0] |= 0x2; // locally administered
}

// there's life beyond lwIP
void pbuf_copy_partial(void){(void)0;}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ struct mg_tcpip_driver_pico_w_data {
};

extern struct mg_tcpip_driver mg_tcpip_driver_pico_w;

void driver_pico_w_poll(void);
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ int main(void) {

MG_INFO(("Starting event loop"));
for (;;) {
driver_pico_w_poll();
mg_mgr_poll(&mgr, 0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,20 @@ if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_P
message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')")
endif ()

if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_TAG} AND (NOT PICO_SDK_FETCH_FROM_GIT_TAG))
set(PICO_SDK_FETCH_FROM_GIT_TAG $ENV{PICO_SDK_FETCH_FROM_GIT_TAG})
message("Using PICO_SDK_FETCH_FROM_GIT_TAG from environment ('${PICO_SDK_FETCH_FROM_GIT_TAG}')")
endif ()

if (PICO_SDK_FETCH_FROM_GIT AND NOT PICO_SDK_FETCH_FROM_GIT_TAG)
set(PICO_SDK_FETCH_FROM_GIT_TAG "master")
message("Using master as default value for PICO_SDK_FETCH_FROM_GIT_TAG")
endif()

set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK")
set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable")
set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK")
set(PICO_SDK_FETCH_FROM_GIT_TAG "${PICO_SDK_FETCH_FROM_GIT_TAG}" CACHE FILEPATH "release tag for SDK")

if (NOT PICO_SDK_PATH)
if (PICO_SDK_FETCH_FROM_GIT)
Expand All @@ -34,14 +45,14 @@ if (NOT PICO_SDK_PATH)
FetchContent_Declare(
pico_sdk
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
GIT_TAG master
GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG}
GIT_SUBMODULES_RECURSE FALSE
)
else ()
FetchContent_Declare(
pico_sdk
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
GIT_TAG master
GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG}
)
endif ()

Expand Down
164 changes: 0 additions & 164 deletions examples/pico-sdk/pico-w-picosdk-builtin/cyw43_configport.h

This file was deleted.

0 comments on commit 716c84c

Please sign in to comment.