drivers/wireless/ieee802.11: Extend Add capabilility to get firmware from a mounted file system to BCM43362. Also fix some compile/link issues introduced in the previous commit.

This commit is contained in:
Gregory Nutt 2018-10-07 15:00:13 -06:00
parent b539d04cfb
commit 31e4981192
7 changed files with 103 additions and 54 deletions

View File

@ -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

View File

@ -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

View File

@ -33,16 +33,32 @@
*
****************************************************************************/
#include "bcmf_sdio.h"
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#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
};

View File

@ -33,9 +33,15 @@
*
****************************************************************************/
#include "bcmf_sdio.h"
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#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
};

View File

@ -39,13 +39,13 @@
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <nuttx/kmalloc.h>
#include <debug.h>
#include <errno.h>
#include <fcntl.h>
#include <nuttx/arch.h>
#include <nuttx/kmalloc.h>
#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

View File

@ -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 */

View File

@ -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 <nuttx/config.h>
#include "bcmf_driver.h"
#include <stdint.h>
#include <stdbool.h>
#include <queue.h>
#include <semaphore.h>
#include <nuttx/sdio.h>
#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
{