Actually, patch exists only for MQX 3.6.2 and MQX 3.7, No official patch for MQX 4.0 at the moment.
What can be done is to take MQX 3.7 patch for TWR-WIFI-AR4100 and integrate the source code files into MQX 4.0. This solution uses the MQX 4.0 I/O SPI driver to communicate with the Wi-fi chip. Some time ago I did this work for TWR-K60D100M, I describe my steps here.
1)
Download and install TWR-WIFI-AR100 patch for MQX 3.7. This doesn't require to have MQX 3.7 installed and I would recommend to use an empty directory for the installation path, as the source code files of the patch would be isolated from MQX 3.7 source code files.
If MQX 3.7 is installed, no problem, the patch can be installed to this folder too; the patch source files are listed then in the text file "atheros_manifest.txt".
2)
copy all files and subfolders from:
C:\Freescale\Freescale MQX 3.7\Mqx\source\io\enet\atheros_wifi\*.*
copy to:
C:\Freescale\Freescale MQX 4.0\Mqx\source\io\enet\atheros_wifi\*.*
3)
overwrite file. from:
c:\Freescale\Freescale MQX 3.7\mqx\source\io\enet\enet_wifi.h
to:
c:\Freescale\Freescale_MQX_4_0\mqx\source\io\enet\enet_wifi.h
(we need
#define ENET_MEDIACTL_VENDOR_SPECIFIC _IO(IO_TYPE_MEDIACTL_WIFI,0x81)
4)
copy from:
c:\Freescale\Freescale MQX 3.7\mqx\source\io\enet\phy\atheros_phy.c
c:\Freescale\Freescale MQX 3.7\mqx\source\io\enet\phy\atheros_phy.h
copy to:
c:\Freescale\Freescale_MQX_4_0\mqx\source\io\enet\phy\atheros_phy.c
c:\Freescale\Freescale_MQX_4_0\mqx\source\io\enet\phy\atheros_phy.h
5)
clone BSP of your board. for example I use MQX 4.0 bsp clone tool to clone twrk60d100m BSP into twrk60d100m_atheros.
6)
CW 10.3 (or 10.2 if you wish), drag & drop the .wsd file of the new BSP to the CW 10.x Projects window.
c:\Freescale\Freescale_MQX_4_0\config\twrk60d100m_atheros\cw10\twrk60d100m_atheros.wsd
7)
Add the new folder files (from steps 1) to 4) above) to the bsp build project.
(in CW 10.3, we can just drag atheros_wifi folder and drop into bsp->Peripheral IO Drivers->enet. I choose the option to "Link to files and recreate folder structure with virtual folders" relative to MQX_ROOT_DIR.
Add the following C compiler include search paths into the C compiler properties:
"${MQX_ROOT_DIR}/mqx/source/io/enet/atheros_wifi"
"${MQX_ROOT_DIR}/mqx/source/io/enet/atheros_wifi/include"
"${MQX_ROOT_DIR}/mqx/source/io/enet/atheros_wifi/include/AR6002"
"${MQX_ROOT_DIR}/mqx/source/io/enet/atheros_wifi/custom_src/include"
"${MQX_ROOT_DIR}/mqx/source/io/enet/atheros_wifi/custom_src/stack_custom"
"${MQX_ROOT_DIR}/mqx/source/io/enet/atheros_wifi/common_src/include"
"${MQX_ROOT_DIR}/mqx/source/io/enet/atheros_wifi/common_src/stack_common"
"${MQX_ROOT_DIR}/mqx/source/io/enet/atheros_wifi/common_src/wmi"
9)
in user_config.h for the new BSP,
c:\Freescale\Freescale_MQX_4_0\config\twrk60d100m_atheros\user_config.h
define the following definitions:
#define BSPCFG_ENABLE_GPIODEV 1
#define BSPCFG_ENABLE_SPI2 1
#define BSPCFG_ENABLE_ATHEROS_WIFI 1
#define RTCSCFG_ENABLE_IP_REASSEMBLY 1
#define RTCSCFG_ENABLE_IGMP 1
10)
in BSP init_enet.c we need to add 2nd enet device:
#if BSPCFG_ENABLE_ATHEROS_WIFI
#include <atheros_wifi.h>
#include <atheros_phy.h>
#endif /* BSPCFG_ENABLE_ATHEROS_WIFI */
#if BSPCFG_ENABLE_ATHEROS_WIFI
const ENET_IF_STRUCT ENET_1 = {
&ATHEROS_WIFI_IF,
&ATHEROS_PHY_IF,
1,
1,
0,
};
ATHEROS_PARAM_WIFI_STRUCT atheros_wifi_param = {
BSP_ATHEROS_WIFI_SPI_DEVICE,
BSP_ATHEROS_WIFI_GPIO_INT_DEVICE,
BSP_ATHEROS_WIFI_GPIO_INT_PIN,
BSP_ATHEROS_WIFI_GPIO_PWD_DEVICE,
BSP_ATHEROS_WIFI_GPIO_PWD_PIN
};
#endif /* BSPCFG_ENABLE_ATHEROS_WIFI */
additions to the ENET_PARAM_STRUCT struct:
#if BSPCFG_ENABLE_ATHEROS_WIFI
{
&ENET_1,
// # Default WiFi Device parameter
Auto_Negotiate,
0,
BSPCFG_TX_RING_LEN, // # NOT USED IN ATHEROS WIFI
BSPCFG_TX_RING_LEN, // # NOT USED IN ATHEROS WIFI
ENET_FRAMESIZE, // # NOT USED IN ATHEROS WIFI
BSPCFG_RX_RING_LEN, // # NOT USED IN ATHEROS WIFI
BSPCFG_RX_RING_LEN, // # NOT USED IN ATHEROS WIFI
ENET_FRAMESIZE, // # NOT USED IN ATHEROS WIFI
BSP_CONFIG_ATHEROS_PCB, // # rx PCBs
0,
0 ,
(pointer)&atheros_wifi_param
},
#endif /* BSPCFG_ENABLE_ATHEROS_WIFI */
11)
in BSP init_spi.c
-----------------------------------
change _bsp_spi2_init structure Baudrate from 10000000 to 20000000
12)
in BSP twrk60d100m_atheros.h
-----------------------------------
change BSP_ENET_DEVICE_COUNT to
#define BSP_ENET_DEVICE_COUNT (MACNET_DEVICE_COUNT +(BSPCFG_ENABLE_ATHEROS_WIFI?1:0))
add:
#define ATHEROS_WIFI_DEFAULT_ENET_DEVICE 1
#if BSPCFG_ENABLE_SPI2
/* in file name, number after : is the mask for chip select. chip select 0 in this case. */
#define BSP_ATHEROS_WIFI_SPI_DEVICE "spi2:1"
#else
#error "SPI2 must be defined in user_config.h"
#endif
#define BSP_ATHEROS_WIFI_GPIO_INT_DEVICE "gpio:input"
#define BSP_ATHEROS_WIFI_GPIO_INT_PIN (GPIO_PORT_A|GPIO_PIN_IRQ_FALLING|GPIO_PIN27)
#define BSP_ATHEROS_WIFI_GPIO_PWD_DEVICE "gpio:write"
// corresponds to B23 on elevator
#define BSP_ATHEROS_WIFI_GPIO_PWD_PIN (GPIO_PORT_E|GPIO_PIN28)
13)
in atheros low level, we need to add couple of minor modifications:
c:\Freescale\Freescale_MQX_4_0\mqx\source\io\enet\atheros_wifi\custom_src\hw_interface\cust_hw_api.c
on lines 112 adn 157 add the source code line:
fflush(GET_DRIVER_CXT(pCxt)->spi_cxt);
remove lines 265-268 ioctl(SPI_SET_CS). it is not needed.
14)
in file:
C:\Freescale\Freescale_MQX_4_0\mqx\source\io\enet\atheros_wifi\custom_src\driver\cust_driver_netbuf.c
on line 52
change from:
a_netbuf_ptr->native.FREE = (_pcb_free_fn)freefn;
change to:
a_netbuf_ptr->native.FREE = (PCB_FREE_FPTR)freefn;
15)
Ready to build BSP and other MQX libs.
16)
After build, copy two header files
copy from:
"c:\Freescale\Freescale_MQX_4_0\mqx\source\io\enet\atheros_wifi\custom_src\include\a_types.h"
c:\Freescale\Freescale_MQX_4_0\mqx\source\io\enet\atheros_wifi\atheros_wifi_api.h
copy to:
"c:\Freescale\Freescale_MQX_4_0\lib\twrk60d100m_atheros.cw10\debug\bsp\a_types.h"
"c:\Freescale\Freescale_MQX_4_0\lib\twrk60d100m_atheros.cw10\debug\bsp\atheros_wifi_api.h"
At this point we should be fine to make a Wi-fi application. For this we can use c:\Freescale\Freescale_MQX_4_0\rtcs\examples\httpsrv\
Import this project into your workspace.
c:\Freescale\Freescale_MQX_4_0\rtcs\examples\httpsrv\cw10\httpsrv_twrk60d100m_atheros\
after import, set its build configuration to Int_Flash_Debug.
Attached are the httpsrv example demo files with Atheros Wifi.
It runs two http servers.
One over Ethernet on 192.168.1.200
Second over Wi-fi on 192.168.1.201
Wi-fi access point name is "atheros_demo"
Tried on TWR-K60D100M, TWR-SER, TWR-WIFI-AR4100, with CW 10.3 IDE to build MQX 4.0 and twrk60d100m_atheros BSP. "ttyd:" = RS232 on TWR-SER used as default MQX IO channel (BSP_DEFAULT_IO_CHANNEL).