Skip to content

Commit faca83f

Browse files
committed
Add uzlib to build
Add build changes needed for firmware compression. Enhance cyw43_write_bytes to allow us to use a src pointer part way through spid_buf which is used as a temorary buffer for firmware decompression
1 parent e308711 commit faca83f

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/rp2_common/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ if (NOT PICO_BARE_METAL)
6767
pico_add_subdirectory(pico_lwip)
6868
pico_add_subdirectory(pico_cyw43_arch)
6969
pico_add_subdirectory(pico_mbedtls)
70+
pico_add_subdirectory(pico_uzlib)
7071

7172
pico_add_subdirectory(pico_stdlib)
7273

@@ -84,4 +85,4 @@ set(CMAKE_EXECUTABLE_SUFFIX "${CMAKE_EXECUTABLE_SUFFIX}" PARENT_SCOPE)
8485
pico_add_doxygen(${CMAKE_CURRENT_LIST_DIR})
8586
pico_add_doxygen_exclude(${CMAKE_CURRENT_LIST_DIR}/cmsis)
8687

87-
pico_promote_common_scope_vars()
88+
pico_promote_common_scope_vars()

src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,14 @@ int cyw43_write_bytes(cyw43_int_t *self, uint32_t fn, uint32_t addr, size_t len,
534534
int res = cyw43_spi_transfer(self, (uint8_t *)&self->spi_header[1], aligned_len + 4, NULL, 0);
535535
logic_debug_set(pin_WIFI_TX, 0);
536536
return res;
537+
} else if (src > self->spid_buf + sizeof(uint32_t) && src < (self->spid_buf + sizeof(self->spid_buf))) {
538+
assert(src + len <= (self->spid_buf + sizeof(self->spid_buf))); // don't go over the end of the buffer
539+
uint32_t *spi_header = (void*)(self->spid_buf + (src - self->spid_buf) - sizeof(uint32_t));
540+
*spi_header = make_cmd(true, true, fn, addr, len);
541+
return cyw43_spi_transfer(self, (uint8_t *)spi_header, aligned_len + 4, NULL, 0);
537542
} else {
538543
// todo: would be nice to get rid of this. Only used for firmware download?
539-
assert(src < self->spid_buf || src >= (self->spid_buf + sizeof(self->spid_buf)));
544+
assert(src < self->spid_buf || src >= (self->spid_buf + sizeof(self->spid_buf))); // check we're not using self->spid_buf
540545
self->spi_header[1] = make_cmd(true, true, fn, addr, len);
541546
memcpy(self->spid_buf, src, len);
542547
return cyw43_spi_transfer(self, (uint8_t *)&self->spi_header[1], aligned_len + 4, NULL, 0);

test/kitchen_sink/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ target_link_libraries(kitchen_sink_libs INTERFACE
4242
pico_time
4343
pico_unique_id
4444
pico_util
45+
pico_uzlib
4546
)
4647

4748
add_library(kitchen_sink_options INTERFACE)
@@ -177,3 +178,7 @@ endif()
177178
if (TARGET pico_btstack_base AND COMMAND suppress_btstack_warnings)
178179
suppress_btstack_warnings()
179180
endif()
181+
182+
if (TARGET pico_uzlib AND COMMAND suppress_uzlib_warnings)
183+
suppress_uzlib_warnings()
184+
endif()

0 commit comments

Comments
 (0)