Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
362 changes: 362 additions & 0 deletions firmware/cyw43_btfw_43439.gz.h

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions firmware/cyw43_btfw_43439.h
Original file line number Diff line number Diff line change
Expand Up @@ -515,3 +515,6 @@ const unsigned char cyw43_btfw_43439[] CYW43_RESOURCE_ATTRIBUTE = {
0xed, 0xf7, 0x05, 0x00, 0x00, 0x00, 0x00, 0x01
};
const unsigned int cyw43_btfw_43439_len = 6164;
#define CYW43_BT_FW_LEN (6164)
#define CYW43_BT_FW_ADDR (cyw43_btfw_43439)
#define CYW43_RAW_BT_FW_LEN (cyw43_btfw_43439_len)
2,128 changes: 2,128 additions & 0 deletions firmware/cyw43_btfw_4343A1.gz.h

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions firmware/cyw43_btfw_4343A1.h
Original file line number Diff line number Diff line change
Expand Up @@ -2933,3 +2933,6 @@ const unsigned char cyw43_btfw_4343A1[] CYW43_RESOURCE_ATTRIBUTE = {
0xfe, 0x00, 0x00, 0x4e, 0xfc, 0x04, 0xff, 0xff, 0xff, 0xff
};
const unsigned int cyw43_btfw_4343A1_len = 35182;
#define CYW43_BT_FW_LEN (35182)
#define CYW43_BT_FW_ADDR (cyw43_btfw_4343A1)
#define CYW43_RAW_BT_FW_LEN (cyw43_btfw_4343A1_len)
11,966 changes: 11,966 additions & 0 deletions firmware/w43439A0_7_95_49_00_combined.gz.h

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion firmware/w43439A0_7_95_49_00_combined.h
Original file line number Diff line number Diff line change
Expand Up @@ -18770,6 +18770,9 @@ static const unsigned char w43439A0_7_95_49_00_combined[] CYW43_RESOURCE_ATTRIBU
0x08, 0x09, 0x0a, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaf, 0xa9, 0x00, 0x00
};
static const unsigned int w43439A0_7_95_49_00_combined_len = 225240;
#define CYW43_WIFI_FW_LEN (224190) // launch_firmware/43439A0.bin
#define CYW43_CLM_LEN (984) // launch_tuning/43439_raspberrypi_picow_v5_220624.clm_blob
const uintptr_t fw_data = (uintptr_t)&w43439A0_7_95_49_00_combined[0];
#define CYW43_WIFI_FW_ADDR (w43439A0_7_95_49_00_combined)
#define CYW43_RAW_WIFI_FW_LEN (w43439A0_7_95_49_00_combined_len)
const uintptr_t fw_data = (uintptr_t)CYW43_WIFI_FW_ADDR;
22,128 changes: 22,128 additions & 0 deletions firmware/w4343WA1_7_45_98_50_combined.gz.h

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions firmware/w4343WA1_7_45_98_50_combined.h
Original file line number Diff line number Diff line change
Expand Up @@ -32576,6 +32576,9 @@ static const unsigned char w4343WA1_7_45_98_50_combined[] CYW43_RESOURCE_ATTRIBU
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
#define CYW43_WIFI_FW_LEN (383110) // 7.45.98.50
#define CYW43_CLM_LEN (7222)
const uintptr_t fw_data = (uintptr_t)&w4343WA1_7_45_98_50_combined[0];
static const unsigned int w4343WA1_7_45_98_50_combined_len = 390912;
#define CYW43_WIFI_FW_LEN (383110) // a1_firmware/43439A1.bin
#define CYW43_CLM_LEN (7222) // a1_firmware/43439A1.clm_blob
#define CYW43_WIFI_FW_ADDR (w4343WA1_7_45_98_50_combined)
#define CYW43_RAW_WIFI_FW_LEN (w4343WA1_7_45_98_50_combined_len)
const uintptr_t fw_data = (uintptr_t)CYW43_WIFI_FW_ADDR;
12,424 changes: 12,424 additions & 0 deletions firmware/wb43439A0_7_95_49_00_combined.gz.h

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions firmware/wb43439A0_7_95_49_00_combined.h
Original file line number Diff line number Diff line change
Expand Up @@ -19368,6 +19368,9 @@ static const unsigned char wb43439A0_7_95_49_00_combined[] CYW43_RESOURCE_ATTRIB
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xaf, 0xa9, 0x00, 0x00
};
#define CYW43_WIFI_FW_LEN (231077) // bluetooth_firmware_jan2023/43439A0.bin
static const unsigned int wb43439A0_7_95_49_00_combined_len = 232408;
#define CYW43_WIFI_FW_LEN (231077) // wb_firmware_jan2023/43439A0.bin
#define CYW43_CLM_LEN (984) // launch_tuning/43439_raspberrypi_picow_v5_220624.clm_blob
const uintptr_t fw_data = (uintptr_t)&wb43439A0_7_95_49_00_combined[0];
#define CYW43_WIFI_FW_ADDR (wb43439A0_7_95_49_00_combined)
#define CYW43_RAW_WIFI_FW_LEN (wb43439A0_7_95_49_00_combined_len)
const uintptr_t fw_data = (uintptr_t)CYW43_WIFI_FW_ADDR;
30 changes: 30 additions & 0 deletions src/cyw43_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,31 @@
#define CYW43_ENABLE_BLUETOOTH (0)
#endif

// Whether to compress firware
#ifndef CYW43_ENABLE_FIRMWARE_COMPRESSION
#define CYW43_ENABLE_FIRMWARE_COMPRESSION 0
#endif

// This include should define:
// - CYW43_WIFI_FW_LEN
// - CYW43_CLM_LEN
// - const uintptr_t fw_data
// - const unsigned int fw_data_len
#ifndef CYW43_CHIPSET_FIRMWARE_INCLUDE_FILE
#if CYW43_ENABLE_BLUETOOTH
#if CYW43_ENABLE_FIRMWARE_COMPRESSION
#define CYW43_CHIPSET_FIRMWARE_INCLUDE_FILE "firmware/wb43439A0_7_95_49_00_combined.gz.h"
#else
#define CYW43_CHIPSET_FIRMWARE_INCLUDE_FILE "firmware/wb43439A0_7_95_49_00_combined.h"
#endif
#else
#if CYW43_ENABLE_FIRMWARE_COMPRESSION
#define CYW43_CHIPSET_FIRMWARE_INCLUDE_FILE "firmware/w43439A0_7_95_49_00_combined.gz.h"
#else
#define CYW43_CHIPSET_FIRMWARE_INCLUDE_FILE "firmware/w43439A0_7_95_49_00_combined.h"
#endif
#endif
#endif

// This include should define a wifi_nvram_4343[] variable.
#ifndef CYW43_WIFI_NVRAM_INCLUDE_FILE
Expand All @@ -78,6 +92,18 @@
#define CYW43_RESOURCE_ATTRIBUTE __attribute__((aligned(4)))
#endif

// This include should define:
// - CYW43_BT_FW_LEN
// - const unsigned char *bt_fw_data
// - const unsigned int bt_fw_data_len
#ifndef CYW43_BT_FIRMWARE_INCLUDE_FILE
#if CYW43_ENABLE_FIRMWARE_COMPRESSION
#define CYW43_BT_FIRMWARE_INCLUDE_FILE "firmware/cyw43_btfw_43439.gz.h"
#else
#define CYW43_BT_FIRMWARE_INCLUDE_FILE "firmware/cyw43_btfw_43439.h"
#endif
#endif

// Timing and timeout configuration.

#ifndef CYW43_IOCTL_TIMEOUT_US
Expand Down Expand Up @@ -166,3 +192,7 @@
#ifndef CYW43_DEFAULT_IP_DNS
#define CYW43_DEFAULT_IP_DNS LWIP_MAKEU32(8, 8, 8, 8)
#endif

#ifndef cyw43_get_firmware_funcs
#define cyw43_get_firmware_funcs cyw43_get_firmware_funcs_default
#endif
148 changes: 148 additions & 0 deletions src/cyw43_firmware_defs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/*
* This file is part of the cyw43-driver
*
* Copyright (C) 2019-2022 George Robotics Pty Ltd
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Any redistribution, use, or modification in source or binary form is done
* solely for personal benefit and not for any commercial purpose or for
* monetary gain.
*
* THIS SOFTWARE IS PROVIDED BY THE LICENSOR AND COPYRIGHT OWNER "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE LICENSOR OR COPYRIGHT OWNER BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software is also available for use with certain devices under different
* terms, as set out in the top level LICENSE file. For commercial licensing
* options please email contact@georgerobotics.com.au.
*/

#ifndef CYW43_FIRMWARE_DEFS_H
#define CYW43_FIRMWARE_DEFS_H

/*!
* \brief Structure to store firmware details
*/
//!\{
typedef struct cyw43_firmware_details {
size_t raw_wifi_fw_len; ///< Size in bytes of the combined wifi firmware data before extraction
size_t wifi_fw_len; ///< Size of the wifi firmware in bytes after extraction
size_t clm_len; ///< Size of the clm blob in bytes after extraction
const uint8_t *wifi_fw_addr;///< Pointer to the raw wifi firmware
const uint8_t *clm_addr; ///< Pointer to the raw clm blob in uncompressed firmware
size_t wifi_nvram_len; ///< Size of nvram data
const uint8_t *wifi_nvram_addr; ///< Pointer to nvram data
size_t raw_bt_fw_len; ///< size of bluetooth firmware data before extraction
size_t bt_fw_len; ///< size of bluetooth firmware data after extraction
const uint8_t *bt_fw_addr; ///< Pointer to the bluetooth firmware
} cyw43_firmware_details_t;
//!\}

/** \brief Firmware types
*/
typedef enum cyw43_firmare_type {
CYW43_FIRMWARE_WIFI,
CYW43_FIRMWARE_NVRAM,
CYW43_FIRMWARE_CLM,
CYW43_FIRMWARE_BLUETOOTH,
} cyw43_firmare_type_t;

/*!
* \brief Structure to hold function pointers for loading firmware
*/
//!\{
typedef struct cyw43_firmware_funcs {
const cyw43_firmware_details_t* (*firmware_details)(void); ///< get wifi firmware details
int (*start_fw_stream)(const cyw43_firmware_details_t *fw_details, cyw43_firmare_type_t which_firmware, void **streaming_context); ///< start fw streaming
const uint8_t* (*stream_fw)(void *streaming_context, size_t sz_required, uint8_t *working_buffer); ///< get block of firmware data
void (*end_fw_stream)(void *streaming_context, cyw43_firmare_type_t which_firmware); ///< end firmware loading
} cyw43_firmware_funcs_t;
//!\}

/*!
* \brief Get the functions used to load firmware
*
* Return pointers to functions that load firmware
*
* \return structure that contains functions that load firmware
*/
const cyw43_firmware_funcs_t *cyw43_get_firmware_funcs(void);

/*!
* \brief Start reading wifi firmware data
*
* Starts the process of reading uncompressed wifi firmware
*
* \param fw_details Firmware details
* \param which_firmware Firmware to start reading
* \param streaming_context On return a pointer to the internal streaming state
* \return Zero on success or else an error code
*/

int cyw43_start_uncompressed_firmware(const cyw43_firmware_details_t *fw_details, cyw43_firmare_type_t which_firmware, void **streaming_context);

/*!
* \brief Read an uncompressed firmware data
*
* Reads uncompressed firmware data
*
* \param streaming_context context created by the start function
* \param sz_required Amount data to read in bytes
* \param buffer Temporary buffer that can be used to read data into
* \return Pointer to data read
*/
const uint8_t *cyw43_read_uncompressed_firmware(void *streaming_context, size_t sz_required, __unused uint8_t *buffer);

/*!
* \brief End reading uncompressed firmware data
*
* Ends the process of reading compressed firmware and frees resources
*/
void cyw43_end_uncompressed_firmware(void *streaming_context, cyw43_firmare_type_t which_firmware);

/*!
* \brief Start reading compressed wifi firmware data
*
* Starts the process of reading compressed wifi firmware
*
* \param fw_details Firmware details
* \param which_firmware Firmware to start reading
* \param streaming_context On return a pointer to the internal streaming state
* \return Zero on success or else an error code
*/
int cyw43_start_compressed_firmware(const cyw43_firmware_details_t *fw_details, cyw43_firmare_type_t which_firmware, void **streaming_context);

/*!
* \brief Read compressed firmware data
*
* Reads compressed firmware data
*
* \param streaming_context context created by the start function
* \param sz_required Amount data to read in bytes
* \param buffer Temporary buffer that can be used to read data into
* \return Pointer to data read
*/
const uint8_t* cyw43_read_compressed_firmware(void *streaming_context, size_t sz_required, uint8_t *buffer);

/*!
* \brief End reading compressed firmware data
*
* Ends the process of reading compressed firmware and frees resources
*/
void cyw43_end_compressed_firmware(void *streaming_context, cyw43_firmare_type_t which_firmware);

#endif
116 changes: 116 additions & 0 deletions src/cyw43_gz_read.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/*
* This file is part of the cyw43-driver
*
* Copyright (C) 2019-2022 George Robotics Pty Ltd
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Any redistribution, use, or modification in source or binary form is done
* solely for personal benefit and not for any commercial purpose or for
* monetary gain.
*
* THIS SOFTWARE IS PROVIDED BY THE LICENSOR AND COPYRIGHT OWNER "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE LICENSOR OR COPYRIGHT OWNER BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software is also available for use with certain devices under different
* terms, as set out in the top level LICENSE file. For commercial licensing
* options please email contact@georgerobotics.com.au.
*/

#include <stdio.h>
#include <string.h>

#include "pico/stdlib.h"
#include "uzlib.h"
#include "cyw43_gz_read.h"
#include "cyw43.h"

#define DICT_SIZE 4096
typedef struct uzlib_data {
uint8_t dict[DICT_SIZE];
struct uzlib_uncomp state;
size_t amount_left;
} uzlib_data_t;

#define CYW43_DECOMPRESS_ERR_NO_MEM -1
#define CYW43_DECOMPRESS_ERR_BAD_HEADER -2
#define CYW43_DECOMPRESS_ERR_NO_MORE -3
#define CYW43_DECOMPRESS_ERR_DECOMPRESS -4

int cyw43_gz_read_start(void **uzlib_context, const uint8_t *raw_data, size_t raw_size)
{
uzlib_init();

uzlib_data_t *uzlib = cyw43_malloc(sizeof(uzlib_data_t));
assert(uzlib);
if (!uzlib) {
return CYW43_DECOMPRESS_ERR_NO_MEM;
}
uzlib->amount_left = raw_data[raw_size - 1];
uzlib->amount_left = 256 * uzlib->amount_left + raw_data[raw_size - 2];
uzlib->amount_left = 256 * uzlib->amount_left + raw_data[raw_size - 3];
uzlib->amount_left = 256 * uzlib->amount_left + raw_data[raw_size - 4];

uzlib_uncompress_init(&uzlib->state, uzlib->dict, sizeof(uzlib->dict));

uzlib->state.source = raw_data;
uzlib->state.source_limit = raw_data + raw_size - 4;
uzlib->state.source_read_cb = NULL;

int res = uzlib_gzip_parse_header(&uzlib->state);
assert(res == TINF_OK);
if (res != TINF_OK) {
cyw43_free(uzlib);
return CYW43_DECOMPRESS_ERR_BAD_HEADER;
}

*uzlib_context = uzlib;
return (int)uzlib->amount_left;
}

int cyw43_gz_read_next(void *uzlib_context, uint8_t *buffer, size_t sz)
{
assert(uzlib_context);
uzlib_data_t *uzlib = (uzlib_data_t *)uzlib_context;

assert(uzlib->amount_left > 0);
if (uzlib->amount_left <= 0) {
return CYW43_DECOMPRESS_ERR_NO_MORE;
}
const size_t chunk_sz = uzlib->amount_left < sz ? uzlib->amount_left : sz;
uzlib->state.dest = buffer;
uzlib->state.dest_limit = uzlib->state.dest + chunk_sz;
int res = uzlib_uncompress_chksum(&uzlib->state);
assert(res == TINF_OK);
if (res != TINF_OK) {
return CYW43_DECOMPRESS_ERR_DECOMPRESS;
}
uzlib->amount_left -= chunk_sz;
return chunk_sz;
}

void cyw43_gz_read_end(void *uzlib_context)
{
assert(uzlib_context);
uzlib_data_t *uzlib = (uzlib_data_t *)uzlib_context;

uzlib->amount_left = 0;
if (uzlib) {
cyw43_free(uzlib);
uzlib = NULL;
}
}
Loading