Skip navigation
Home > All Places > WICED Studio Wi-Fi/Combo > WICED Studio Wi-Fi/Combo Forums > Blog > 2019 > June
2019

This blog post discusses how to run a restricted set of WL commands along with iperf for limited memory platforms like BCM943438WCD1, CYW94343WWCD1_EVB, CY8CKIT-062 (A typical use-case would be something like adaptivity testing)

  1. If you are running the test.console example with CONSOLE_ENABLE_WL set to 1 and getting the APP_CODE overflow error, please follow the steps mentioned below to enable the particular set of WL commands your application requires.
  2. In console.mk file, please mark CONSOLE_ENABLE_WL :=  0. Along with that, you can make use of certain macros listed below to save some further memory.

CONSOLE_NO_P2P :=1

CONSOLE_DISABLE_WPS_COMMANDS := 1

CONSOLE_DISABLE_TRACEX_COMMANDS := 1

 

GLOBAL_DEFINES     += CONSOLE_DISABLE_ENTERPRISE_COMMANDS

$(NAME)_DEFINES    += CONSOLE_DISABLE_WPS_COMMANDS

$(NAME)_DEFINES    += CONSOLE_DISABLE_TRACEX_COMMANDS

$(NAME)_DEFINES    += CONSOLE_DISABLE_MALLINFO_COMMANDS

       GLOBAL_DEFINES += DISABLE_WIFI_AP_INTERFACE \

                       WICED_CONFIG_DISABLE_SSL_SERVER \

                       WICED_CONFIG_DISABLE_DTLS \

                       WICED_CONFIG_DISABLE_ENTERPRISE_SECURITY \

                       WICED_CONFIG_DISABLE_DES \

                       WICED_CONFIG_DISABLE_ADVANCED_SECURITY_CURVES \

                       WICED_DISABLE_WATCHDOG

      3. Now, you can use one more macro to enable a limited set of WL commands for your application.

$(NAME)_DEFINES    += CONSOLE_INCLUDE_WIFI_LIMITED_SET_COMMANDS

          This enables some fixed wifi related commands defined inside 43xxx_Wi-Fi/libraries/utilities/command_console/wifi/command_console_wifi.h

 

     4. The idea is now to keep adding the application specific WL commands to the WIF_LIMITED_SET_COMMANDS by modifying the existing code in 43xxx_Wi-Fi/libraries/utilities/command_console/wifi/command_console_wifi.h and 43xxx_Wi-Fi/libraries/utilities/command_console/wifi/command_console_wifi.c

 

     5. I am going to take up a sample WL command like wl down for which the sequence is mentioned below (modified command is wl_down):

 

    1. Add

{ (char*) "wl_down", wl_down, 0, NULL, NULL, (char*) "", (char*) "Getting the driver down"}, \

under the #define WIFI_COMMANDS_LIMITED_SET \

           b. Time to declare the wl_down function inside command_console_wifi.h

      int wl_down                (int argc, char* argv[] );

           c. The function may be defined in the following manner inside command_console_wifi.c

int wl_down(int argc, char* argv[])

{

wwd_result_t result = wwd_wifi_set_down();

 

if (result != WWD_SUCCESS)

{

        WPRINT_APP_INFO(("WLAN Driver down failed with result %d\n,result"));

}

 

    return result;

}

 

     6. Let’s try to take one more WL command like wl bi and follow almost the same steps as mentioned in 5a, 5b. But the function definition inside command_console_wifi.c will use some ioctl/iovar to set the parameter.

int wl_bi(int argc, char* argv[])

{

wwd_result_t result;

uint32_t bi = atoi(argv[1]);

 

result = wwd_wifi_set_ioctl_value(WLC_SET_BCNPRD, bi, WWD_STA_INTERFACE);

 

if(result != WWD_SUCCESS)

{

        WPRINT_APP_INFO(("Setting beacon interval failed with %d\n", result));

}

 

          return result;

 

}

More details on how to use the ioctl/iovars from application, you can go through  How to use IOCTL commands in CYW43907

 

To add any other WL command, you can first look for WWD APIs which can serve the same purpose inside 43xxx_Wi-Fi/WICED/WWD/include/wwd_wifi.h. If there is no such API available, you can look for the list of IOCTLs inside 43xxx_Wi-Fi/libraries/test/wl_tool/<chip_name>/common/include/devctrl.h and use the IOCTL GET/SET APIs to define the particular WL command.

 

An example screenshot for the above mentioned wl_down command can be found below.

   目标:

    主要去了解wiced中关于DEFINED_APP_DCT的用法, 在我们的释放的文档中,有一节描述,名字叫做APPLICNATION DCT data 有一句话这样描述:

    The DCT system allows for Applications to add Data to the end of the DCT area which will be maintained when the DCT is updated。

    我们释放的wiced sdk中的文档有不错的描述, 文档名字是:WICED-DCT.pdf

 

步骤:

     这是其中的描述, 3.1 3.4.1 都是描述如何使用application dct area

 

 

如上我们可以看到几个关键字和用法:

  a. Wiced_dct_read_lock, wiced_dct_read_unlock 必须成对使用, 不然会有memory leak.

  b. DCT_APP_SECTION, 是专用的名字,用来访问这部分区域。

  如下图中所显示,

     DCT_APP_SECTION 部分的offset是整个platform_dct_data_t, 表示这部分区域紧跟着后面,但是不会超过整个dct 分配的大小,

  比如16k-sizeof(platform_dct_data_t) 的大小。

 

 

测试开始:

  1. 我将会在apsta这个应用中按照文档来做一个测试来判定是否有效:

   搜索下, 发现我们的很多应用中都已经采用了这种方式:

 

2. 将dct_read_write_dct.c  dct_read_write_dct.h 直接拷贝到apsta的文件夹中,并且重命名为apsta_dct.c, apsta_dct.

    3.  Makefile 中添加编译:

4. 略作修改

5.添加调用的时候不要忘记头文件。

#include "apsta_dct.h"

6. log中查看是否有效:

7. 我们在结构体中添加了基本的类型,现在添加一个复杂结构体看是否有效。

将这段定义拷贝到新的dct.h中。

最后将几个结构体整合到一起就成了这样的情况, 所以只要按照我们的步骤就可以实现你想要的保存的信息:

 

测试成功了, 最后上传测试代码。

概要: 

   我们有四种方法在WICED中去设置wifi的mac地址, 这篇博客将展示如何通过这些方法去设置。 我的测试是基于

CYW954907AEVAL1F 这个开发板 。

 

  • 第一种:DCT mode:
  1. 1. app.mk中添加这个定义: GLOBAL_DEFINES     += MAC_ADDRESS_SET_BY_HOST
  2. App.mk是泛指,比如在apsta.mk 这样一个application中的定义。
    1. 2. 43xxx_Wi-Fi\generated_mac_address.txt

在前面的地址中修改如下红色重点的部分,可以看到mac地址修改成功。

#define NVRAM_GENERATED_MAC_ADDRESS "macaddr=00:A0:50:38:f6:35"

#define DCT_GENERATED_MAC_ADDRESS "\x00\xA0\x50\xe8\xf3\x48"

       #define DCT_GENERATED_ETHERNET_MAC_ADDRESS "\x00\xA0\x50\xe5\xf3\x47

 

  • 第二种 OTP mode
  1. 在相同的app.mk中屏蔽 //GLOBAL_DEFINES     += MAC_ADDRESS_SET_BY_HOST
  2. 需要点击clean 清楚掉编译文件,重新全部编译,看如下log,mac地址也被修改.

 

Starting WICED vWiced_006.002.001.0002

Platform CYW954907AEVAL1F initialised

Started ThreadX v5.8

Initialising NetX_Duo v5.10_sp3

Creating Packet pools

WLAN MAC Address : B8:D7:AF:4D:1D:D6

WLAN Firmware    : wl0: May 15 2018 19:39:17 version 7.15.168.114 (r689934) FWID 01-d6f88905

WLAN CLM         : API: 12.2 Data: 9.10.74 Compiler: 1.31.3 ClmImport: 1.36.3 Creation: 2018-05-15 19:33:15

下面我们使用MFG 工厂测试模式去查看下OTP 区域内的MAC地址, 注意这边需要重新编译并且下载一个新的应用,此应用专门用于工厂模式测试,命令如下:

test.mfg_test-CYW954907AEVAL1F download download_apps run

比较下地址,这部分完全一样,可以证实这个地址是从OTP 区域内读出:

WLAN MAC Address : B8:D7:AF:4D:1D:D6

 

  • 第三种 在NVRAM中修改

43xxx_Wi-Fi\platforms\CYW954907AEVAL1F\board_revision\P101

     static const char wifi_nvram_image[] =

      "sromrev=11" "\x00"

      "vendid=0x14e4" "\x00"

      "devid=0x43d0" "\x00"

      "macaddr=00:A0:50:38:f6:35" "\x00"

 

  1. 一样需要屏蔽 //GLOBAL_DEFINES     += MAC_ADDRESS_SET_BY_HOST
  2. 全部clean,然后重新编译.
  3. 从结果来看MAC地址依然是: WLAN MAC Address : B8:D7:AF:4D:1D:D6

现在还没有找到那边可以将MAC地址固定在NVRAM 输出,所以假设OTP和NVRAM是有优先级的排列,如果OTP 区域存在有效的mac地址,那么NVRAM的将会被忽略。

  • 第四种 客户定制模式:
  1. 同样需要使能这个宏的定义,app makefile: GLOBAL_DEFINES     += MAC_ADDRESS_SET_BY_HOST
  2. 用户模式的话,需要在代码中添加修改:

在这个路径下的文件中做代码的改动,

43xxx_Wi-Fi\WICED\platform\MCU\BCM4390x\bcm4390x_platform.c

wwd_result_t host_platform_get_mac_address( wiced_mac_t* mac )

{

#ifndef WICED_DISABLE_BOOTLOADER

    wiced_mac_t* temp_mac;

    wiced_result_t result;

result = wiced_dct_read_lock( (void**)&temp_mac, WICED_FALSE, DCT_WIFI_CONFIG_SECTION, OFFSETOF(platform_dct_wifi_config_t, mac_address), sizeof(mac->octet) );

    if ( result != WICED_SUCCESS )

{

        return (wwd_result_t) result;

}

memcpy( mac->octet, temp_mac, sizeof(mac->octet) );

mac->octet[0]= 0x00;

mac->octet[1]= 0x11;

mac->octet[2]= 0x22;

mac->octet[3]= 0x33;

mac->octet[4]= 0x44;

mac->octet[5]= 0x55;

wiced_dct_read_unlock( temp_mac, WICED_FALSE );

#else

UNUSED_PARAMETER( mac );

#endif

    return WWD_SUCCESS;

}

 

Starting WICED vWiced_006.002.001.0002

Platform CYW954907AEVAL1F initialised

Started ThreadX v5.8

Initialising NetX_Duo v5.10_sp3

Creating Packet pools

WLAN MAC Address : 00:11:22:33:44:55

WLAN Firmware : wl0: May 15 2018 19:39:17 version 7.15.168.114 (r689934) FWID 01-d6f88905

WLAN CLM         : API: 12.2 Data: 9.10.74 Compiler: 1.31.3 ClmImport: 1.36.3 Creation: 2018-05-15 19:33:15

Console app

 

从结果看WifiMAC 地址被强制改成了我们想要的地址, 忽略了其他的设置。

 

This blog post discusses the procedure to create a new application in Amazon FreeRTOS(AFR).

The SHA1 for repository cloned for this blog post is dae010944f32b403acff8a5a888222da11b8b5a4.

Please follow the steps mentioned in Getting Started with the Cypress CYW943907AEVAL1F Development Kit - Amazon FreeRTOS to setup AFR for CYW943907EVAL1F or CYW54907AEVAL1F

We will be using the APIs provided in AFR for writing SCAN application in this blog.

 

Please follow the steps mentioned below for adding scan application in AFR:

1. We will be forking the AFR repository and will make changes in the forked repository. Visit the FreeRTOS github repository and fork the repo.

Download the repository:

git clone https://github.com/<user_name>/amazon-freertos.git

 

2. To get your repository structure as per the repository used for this blog, checkout the mentioned SHA1:

git checkout dae010944f32b403acff8a5a888222da11b8b5a4

The same steps might be valid for a newer version of AFR with minor changes.

3. You will see an aws_demos project in WICED when you import the aws_demos project.

Let us add the new application in demos directory of aws_demos. Go to the exact path of demos directory in your cloned repo: I have it in C:\afr\amazon-freertos\demos

Create a new folder named scan.

4. Place the attached files(cy_scan.h and cy_scan.c) in the scan folder.

5. The scan folder is kept at the absolute path but is not linked in the aws_demos project in WICED hence it will not appear in the demos directory in aws_demos project in WICED.

To establish a link,  open .project file of the project in text editor and add the link in <linkedResources> as follows:

        <link>

            <name>demos/scan/cy_scan.c</name>

            <type>1</type>

            <locationURI>BASE_DIR/demos/scan/cy_scan.c</locationURI>

        </link>

        <link>

            <name>demos/scan/cy_scan.h</name>

            <type>1</type>

            <locationURI>BASE_DIR/demos/scan/cy_scan.h</locationURI>

        </link>

6. Open the iot_demo_runner.h file and add the following two lines along with the other MACROS defined:

 

#elif defined (CONFIG_CY_SCAN_DEMO_ENABLED)

    #define DEMO_entryFUNCTION                              vStartScanDemo

 

The vStartScanDemo is written in cy_scan.c file.

7. Open the aws_demo_config.h file and enable the defined MACRO instead of CONFIG_MQTT_DEMO_ENABLED

#define CONFIG_CY_SCAN_DEMO_ENABLED

 

8. Open the application makefile(aws_demos/vendors/cypress/WICED_SDK/apps/demo/aws_demo/aws_demo.mk) and add the file names as follows:

Add the cy_scan.c file in $(NAME)_RESOURCES

     $(AMAZON_FREERTOS_PATH)demos/scan/cy_scan.c \

Add the cy_scan.h file in GLOBAL_INCLUDES

    $(AMAZON_FREERTOS_PATH)demos/scan \

 

9. Build the target by clicking on the provided make target

demo.aws_demo-CYW943907AEVAL1F-FreeRTOS-LwIP HOST_OS=Win32 download run

 

10. Open serial terminal and check the UART logs for scan result:

Filter Blog

By date:
By tag: