diff --git a/configs/photon/wlan/defconfig b/configs/photon/wlan/defconfig index 908f6f2d8f1..2698da8bf6a 100644 --- a/configs/photon/wlan/defconfig +++ b/configs/photon/wlan/defconfig @@ -1,4 +1,5 @@ # CONFIG_ARCH_LEDS is not set +# CONFIG_IEEE80211_BROADCOM_FWFILES is not set # CONFIG_MMCSD_HAVE_CARDDETECT is not set # CONFIG_MMCSD_MMCSUPPORT is not set # CONFIG_NSH_ARGCAT is not set @@ -17,7 +18,6 @@ CONFIG_DFU_BASE=0x8020000 CONFIG_DFU_BINARY=y CONFIG_DFU_PID=0xd006 CONFIG_DFU_VID=0x2b04 -CONFIG_DISABLE_POLL=y CONFIG_DRIVERS_IEEE80211=y CONFIG_DRIVERS_WIRELESS=y CONFIG_FS_PROCFS=y diff --git a/drivers/wireless/ieee80211/Kconfig b/drivers/wireless/ieee80211/Kconfig index fbedd586099..d431f242223 100644 --- a/drivers/wireless/ieee80211/Kconfig +++ b/drivers/wireless/ieee80211/Kconfig @@ -7,6 +7,11 @@ if DRIVERS_IEEE80211 config IEEE80211_BROADCOM_FULLMAC bool + default n + +config IEEE80211_BROADCOM_HAVE_CLM + bool + default n config IEEE80211_BROADCOM_BCM43362 bool "Broadcom 43362 chip support" @@ -17,15 +22,20 @@ config IEEE80211_BROADCOM_BCM43438 bool "Broadcom 43438 chip support" depends on IEEE80211_BROADCOM_FULLMAC default n + select IEEE80211_BROADCOM_HAVE_CLM config IEEE80211_BROADCOM_FWFILES bool "Firmware files" default y - depends on IEEE80211_BROADCOM_BCM43438 + depends on IEEE80211_BROADCOM_BCM43362 || IEEE80211_BROADCOM_BCM43438 ---help--- - By default, firmware files are provided in flash. This selection - enables an option to load the firmware files from a mounted file - system. + By default, firmware and CLM files are provided in memory. + This selection enables an option to load the firmware and CLM + files from a mounted file system. + + If not defined, then your board support logic will have to + to provide the firmware files (and CLM files for the CBM43438) + in board/src directory. config IEEE80211_BROADCOM_FWFILENAME string "Firmware file" @@ -39,7 +49,7 @@ config IEEE80211_BROADCOM_FWFILENAME config IEEE80211_BROADCOM_FWCLMNAME string "CLM file" default "/mnt/sdcard/blob.bin" - depends on IEEE80211_BROADCOM_FWFILES + depends on IEEE80211_BROADCOM_FWFILES && IEEE80211_BROADCOM_HAVE_CLM ---help--- If firmware files are provided on a file system, then this option provides the full path to the file on a mounted file system where diff --git a/drivers/wireless/ieee80211/bcmf_chip_43362.c b/drivers/wireless/ieee80211/bcmf_chip_43362.c index d09eae49d1c..4cc8c8d44ef 100644 --- a/drivers/wireless/ieee80211/bcmf_chip_43362.c +++ b/drivers/wireless/ieee80211/bcmf_chip_43362.c @@ -33,16 +33,32 @@ * ****************************************************************************/ -#include "bcmf_sdio.h" +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include #include +#include "bcmf_sdio.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + #define WRAPPER_REGISTER_OFFSET 0x100000 +/**************************************************************************** + * Public Data + ****************************************************************************/ + extern const char bcm43362_nvram_image[]; extern const unsigned int bcm43362_nvram_image_len; +#ifndef CONFIG_IEEE80211_BROADCOM_FWFILES extern const uint8_t bcm43362_firmware_image[]; extern const unsigned int bcm43362_firmware_image_len; +#endif const struct bcmf_sdio_chip bcmf_43362_config_sdio = { @@ -67,9 +83,11 @@ const struct bcmf_sdio_chip bcmf_43362_config_sdio = /* Firmware images */ /* TODO find something smarter than using image_len references */ - .firmware_image = (uint8_t *)bcm43362_firmware_image, - .firmware_image_size = (unsigned int *)&bcm43362_firmware_image_len, + .nvram_image = (FAR uint8_t *)bcm43362_nvram_image, + .nvram_image_size = (FAR unsigned int *)&bcm43362_nvram_image_len - .nvram_image = (uint8_t *)bcm43362_nvram_image, - .nvram_image_size = (unsigned int *)&bcm43362_nvram_image_len +#ifndef CONFIG_IEEE80211_BROADCOM_FWFILES + .firmware_image = (FAR uint8_t *)bcm43362_firmware_image, + .firmware_image_size = (FAR unsigned int *)&bcm43362_firmware_image_len, +#endif }; diff --git a/drivers/wireless/ieee80211/bcmf_chip_43438.c b/drivers/wireless/ieee80211/bcmf_chip_43438.c index 3f613fb38b8..a26fd270ab0 100644 --- a/drivers/wireless/ieee80211/bcmf_chip_43438.c +++ b/drivers/wireless/ieee80211/bcmf_chip_43438.c @@ -33,9 +33,15 @@ * ****************************************************************************/ -#include "bcmf_sdio.h" +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include #include +#include "bcmf_sdio.h" + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -79,22 +85,14 @@ const struct bcmf_sdio_chip bcmf_43438_config_sdio = /* Firmware images */ /* TODO find something smarter than using image_len references */ -#ifdef CONFIG_IEEE80211_BROADCOM_FWFILES - .firmware_image = (uint8_t *)NULL, - .firmware_image_size = (unsigned int *)NULL, -#else - .firmware_image = (uint8_t *)ap6212_firmware_image, - .firmware_image_size = (unsigned int *)&ap6212_firmware_len, -#endif + .nvram_image = (FAR uint8_t *)ap6212_nvram_image, + .nvram_image_size = (FAR unsigned int *)&ap6212_nvram_image_len, - .nvram_image = (uint8_t *)ap6212_nvram_image, - .nvram_image_size = (unsigned int *)&ap6212_nvram_image_len, +#ifndef CONFIG_IEEE80211_BROADCOM_FWFILES + .firmware_image = (FAR uint8_t *)ap6212_firmware_image, + .firmware_image_size = (FAR unsigned int *)&ap6212_firmware_len, -#ifdef CONFIG_IEEE80211_BROADCOM_FWFILES - .clm_blob_image = (uint8_t *)NULL, - .clm_blob_image_size = (unsigned int *)NULL, -#else - .clm_blob_image = (uint8_t *)ap6212_clm_blob, - .clm_blob_image_size = (unsigned int *)&ap6212_clm_blob_len, + .clm_blob_image = (FAR uint8_t *)ap6212_clm_blob, + .clm_blob_image_size = (FAR unsigned int *)&ap6212_clm_blob_len, #endif }; diff --git a/drivers/wireless/ieee80211/bcmf_core.c b/drivers/wireless/ieee80211/bcmf_core.c index d0a55e2dd71..73e5456eb59 100644 --- a/drivers/wireless/ieee80211/bcmf_core.c +++ b/drivers/wireless/ieee80211/bcmf_core.c @@ -39,13 +39,13 @@ #include #include -#include #include #include #include #include +#include #include "bcmf_core.h" #include "bcmf_sdio.h" @@ -255,7 +255,7 @@ int bcmf_upload_file(FAR struct bcmf_sdio_dev_s *sbus, uint32_t address, } while (nread == BCMF_UPLOAD_TRANSFER_SIZE); - file_close_detached(&finfo); + file_close(&finfo); kmm_free(buf); wlinfo("Upload complete\n"); @@ -265,7 +265,7 @@ errout_with_buf: kmm_free(buf); errout_with_file: - file_close_detached(&finfo); + file_close(&finfo); return ret; } #endif diff --git a/drivers/wireless/ieee80211/bcmf_driver.c b/drivers/wireless/ieee80211/bcmf_driver.c index ae0a7d526bd..65502168162 100644 --- a/drivers/wireless/ieee80211/bcmf_driver.c +++ b/drivers/wireless/ieee80211/bcmf_driver.c @@ -71,16 +71,20 @@ #define BCMF_AUTH_TIMEOUT_MS 20000 /* was 10000 */ #define BCMF_SCAN_RESULT_SIZE 1024 -/* clm file is cut into pieces of MAX_CHUNK_LEN. +/* CLM file is cut into pieces of MAX_CHUNK_LEN. * It is relatively small because dongles (FW) have a small maximum size input * payload restriction for ioctl's ... something like 1900'ish bytes. So chunk * len should not exceed 1400 bytes + * + * NOTE: CONFIG_NET_ETH_PKTSIZE is the MTU plus the size of the Ethernet + * header (14 bytes). */ #ifdef CONFIG_IEEE80211_BROADCOM_FWFILES /* REVISIT */ # define MAX_CHUNK_LEN (100) #else -# define MAX_CHUNK_LEN (CONFIG_NET_ETH_MTU > 1500 ? 1400 : CONFIG_NET_ETH_MTU - 100) +# define MAX_CHUNK_LEN \ + (CONFIG_NET_ETH_PKTSIZE > 1514 ? 1400 : CONFIG_NET_ETH_PKTSIZE - 114) #endif /* Helper to get iw_event size */ @@ -88,7 +92,7 @@ #define BCMF_IW_EVENT_SIZE(field) \ (offsetof(struct iw_event, u) + sizeof(((union iwreq_data *)0)->field)) -/* Clm blob marcos */ +/* CLM blob macros */ #define DLOAD_HANDLER_VER 1 /* Downloader version */ #define DLOAD_FLAG_VER_MASK 0xf000 /* Downloader version mask */ @@ -102,7 +106,7 @@ * Private Types ****************************************************************************/ -/* clm blob download head */ +/* CLM blob download head */ struct wl_dload_data { @@ -139,7 +143,9 @@ static void bcmf_free_device(FAR struct bcmf_dev_s *priv); static int bcmf_driver_initialize(FAR struct bcmf_dev_s *priv); +#ifdef CONFIG_IEEE80211_BROADCOM_HAVE_CLM static int bcmf_driver_download_clm(FAR struct bcmf_dev_s *priv); +#endif /* FIXME only for debug purpose */ @@ -257,10 +263,10 @@ int bcmf_wl_set_mac_address(FAR struct bcmf_dev_s *priv, struct ifreq *req) return OK; } +#ifdef CONFIG_IEEE80211_BROADCOM_HAVE_CLM #ifdef CONFIG_IEEE80211_BROADCOM_FWFILES int bcmf_driver_download_clm(FAR struct bcmf_dev_s *priv) { - FAR struct bcmf_sdio_dev_s *sbus = (FAR struct bcmf_sdio_dev_s *)priv->bus; FAR uint8_t *downloadbuff; struct file finfo; ssize_t nread; @@ -270,15 +276,15 @@ int bcmf_driver_download_clm(FAR struct bcmf_dev_s *priv) wlinfo("Download %d bytes\n", datalen); - ret = file_open(&tmp, CONFIG_IEEE80211_BROADCOM_FWCLMNAME, + ret = file_open(&finfo, CONFIG_IEEE80211_BROADCOM_FWCLMNAME, O_RDONLY | O_BINARY); if (ret < 0) { wlerr("ERROR: Failed to open the FILE MTD file \n", ret); - return ret + return ret; } - /* Divide clm blob into chunks */ + /* Divide CLM blob into chunks */ downloadbuff = kmm_malloc(sizeof(struct wl_dload_data) + MAX_CHUNK_LEN); if (downloadbuff == NULL) @@ -341,9 +347,10 @@ errout_with_buffer: kmm_free(downloadbuff); errout_with_file: - file_close_detached(&finfo); + file_close(&finfo); return ret; } + #else int bcmf_driver_download_clm(FAR struct bcmf_dev_s *priv) { @@ -356,7 +363,7 @@ int bcmf_driver_download_clm(FAR struct bcmf_dev_s *priv) if (srcbuff == NULL || datalen <= 0) { - wlinfo("Skip clm blob...\n"); + wlinfo("Skip CLM blob...\n"); return 0; } else @@ -364,12 +371,12 @@ int bcmf_driver_download_clm(FAR struct bcmf_dev_s *priv) wlinfo("Download %d bytes @ 0x%08x\n", datalen, srcbuff); } - /* Divide clm blob into chunks */ + /* Divide CLM blob into chunks */ downloadbuff = kmm_malloc(sizeof(struct wl_dload_data) + MAX_CHUNK_LEN); if (!downloadbuff) { - wlerr("No memory for clm data\n"); + wlerr("No memory for CLM data\n"); return -ENOMEM; } @@ -413,6 +420,7 @@ int bcmf_driver_download_clm(FAR struct bcmf_dev_s *priv) return ret; } #endif +#endif /* CONFIG_IEEE80211_BROADCOM_HAVE_CLM */ int bcmf_driver_initialize(FAR struct bcmf_dev_s *priv) { @@ -422,13 +430,15 @@ int bcmf_driver_initialize(FAR struct bcmf_dev_s *priv) uint8_t tmp_buf[64]; int interface = CHIP_STA_INTERFACE; - /* Download clm blob if needed */ +#ifdef CONFIG_IEEE80211_BROADCOM_HAVE_CLM + /* Download CLM blob if needed */ ret = bcmf_driver_download_clm(priv); if (ret != OK) { return -EIO; } +#endif /* Disable TX Gloming feature */ diff --git a/drivers/wireless/ieee80211/bcmf_sdio.h b/drivers/wireless/ieee80211/bcmf_sdio.h index dc5edf94cbc..6d7811485df 100644 --- a/drivers/wireless/ieee80211/bcmf_sdio.h +++ b/drivers/wireless/ieee80211/bcmf_sdio.h @@ -33,22 +33,29 @@ * ****************************************************************************/ +#ifndef __DRIVERS_WIRELESS_IEEE80211_BCMF_SDIO_H +#define __DRIVERS_WIRELESS_IEEE80211_BCMF_SDIO_H + /**************************************************************************** * Included Files ****************************************************************************/ -#ifndef __DRIVERS_WIRELESS_IEEE80211_BCMF_SDIO_H -#define __DRIVERS_WIRELESS_IEEE80211_BCMF_SDIO_H +#include -#include "bcmf_driver.h" #include #include #include #include + #include +#include "bcmf_driver.h" #include "bcmf_sdio_core.h" +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + #define HEADER_SIZE 0x12 /* Default sdpcm + bdc header size */ // TODO move to Kconfig #define BCMF_PKT_POOL_SIZE 4 /* Frame pool size */ @@ -57,24 +64,30 @@ * Public Types ****************************************************************************/ -/* sdio chip configuration structure */ +/* SDIO chip configuration structure */ struct bcmf_sdio_chip { uint32_t ram_size; uint32_t core_base[MAX_CORE_ID]; - uint8_t *firmware_image; - unsigned int *firmware_image_size; + /* In-memory file images */ - uint8_t *nvram_image; - unsigned int *nvram_image_size; + FAR uint8_t *nvram_image; + FAR unsigned int *nvram_image_size; - uint8_t *clm_blob_image; - unsigned int *clm_blob_image_size; +#ifndef CONFIG_IEEE80211_BROADCOM_FWFILES + FAR uint8_t *firmware_image; + FAR unsigned int *firmware_image_size; + +#ifdef CONFIG_IEEE80211_BROADCOM_HAVE_CLM + FAR uint8_t *clm_blob_image; + FAR unsigned int *clm_blob_image_size; +#endif +#endif }; -/* sdio bus structure extension */ +/* SDIO bus structure extension */ struct bcmf_sdio_dev_s {