Country Code

Country Code Configuration Table

Ameba provides a country code configuration table where each country code corresponds to specific channel plans and transmit power to comply with wireless regulations across different countries.

Users can view and modify this file at: component/soc/usrcfg/amebaxxx/ameba_wifi_country_code_table_usrcfg.c

Column 1: Country code (2 ASCII characters);

Column 2: Channel plan (details refer to Usage Instructions);

Column 3: Transmit power (details refer to Overview);

const struct rtw_country_code_table country_code_table[] = {
   {{'A', 'R'}, 0x4d, TXPWR_LMT_FCC}, /* 0000 Argentina */
   {{'B', 'O'}, 0x11, TXPWR_LMT_FCC}, /* 0001 Bolivia */
   {{'B', 'R'}, 0x62, TXPWR_LMT_FCC}, /* 0002 Brazil */
   {{'C', 'L'}, 0x76, TXPWR_LMT_CHILE}, /* 0003 Chile */
   {{'M', 'X'}, 0x4d, TXPWR_LMT_MEXICO}, /* 0010 Mexico */
   {{'U', 'S'}, 0x1b, TXPWR_LMT_FCC}, /* 0015 USA */
   ...
};

Note

  1. Country codes follow ISO 3166-1

  2. Configuration values are Realtek’s recommendations based on regional regulations

  3. Custom country codes may be added if they don’t conflict with existing ones

  4. Characters ‘0’’0’ represent World Wide mode (global compatibility):

    {{'0','0'}, 0x17, TXPWR_LMT_WW}, /* 0238 World Wide */
    

Country Code Setup Interfaces

SDK provides 4 configuration methods:

Typically configured during mass production. Uses ASCII codes at efuse offsets 0x13B and 0x13C.

Example 1: China
iwpriv config_set wmap,13B,434E  /* 'C'=0x43, 'N'=0x4E */
Example 2: Worldwide
iwpriv config_set wmap,13B,3030   /* '0'=0x30 */
Verification:
iwpriv efuse_get rmap,13B,2

Note

  1. Config file method overrides Efuse when values are valid

  2. API/802.11d have highest priority and override other methods

802.11d

802.11d is disabled by default. Enable it in the Wi-Fi config file (component/soc/usrcfg/amebaxxx/ameba_wificfg.c):

wifi_user_config.rtw_802_11d_en = 1;  /* 1=Enable, 0=Disable */

When enabled, the device automatically selects the most frequently broadcasted country code from nearby APs’ Country Elements, dynamically adapting to local radio regulations.

Country code sources for different Wi-Fi states:

Wi-Fi State

Country Code Source

Initialization completed

Hardwired Efuse value / Config file preset / API setting (ref: Country Code Setup Interfaces)

Scanning completed

Most frequent country code in scanned AP broadcasts

Connection established

Country code of currently connected AP

Disconnected

Most frequent country code in scanned AP broadcasts

Debug Commands

Check current settings via AT+WLDBG=regu
#AT+WLDBG=regu
[WLDBG]: _AT_WLAN_IWPRIV_
[WLAN-A] [iwpriv_command] cmd name: regu
[WLAN-A] Country code: 00
[WLAN-A] Channel plan: 17
[WLAN-A] Regulation: WW[WW disable]
[WLAN-A] Country code Version: R45
[WLAN-A] Channel plan Version: R70
[WLAN-A] Power limit: on

Channel Plan

Usage Instructions

Realtek maintains a channel plan table (Released by FAE/AE): WS-xxdate-Willis-Efuse_Channel_Plan_new_define-Rxx.xlsx

This table defines channel lists and scanning modes (active/passive) corresponding to different encoding values.

Taking USA as an example, its default configuration in the country code table is:

{'U', 'S'}, 0x1b, TXPWR_LMT_FCC}, /* 0015 USA */

The channel plan value 0x1b corresponds to entry 1Bh in the channel plan table, which provides full 2G/5G channel details:

../../_images/channel_plan_1b.png

The 2G channel encoding 2G_02 provides detailed 2G channel specifications:

../../_images/channel_plan_2g02.png

The 5G channel encoding 5G_52 provides detailed 5G channel specifications:

../../_images/channel_plan_5g52.png

Note

  1. Ignore the “2G Regulation” and “5G Regulation” columns - these are retained for legacy compatibility only and unused in Ameba series.

FAQs

  1. How to modify channel plans?

    Example: Disabling channels 12/13 (2G) and 169/173/177 (5G) for USA.

    The channel plan table shows 0x25 meets this requirement:

    ../../_images/channel_plan_25.png

    Update the channel plan value in the country code table from 0x1b to 0x25:

    {'U', 'S'}, 0x25, TXPWR_LMT_FCC}, /* 0015 USA */
    
  2. No suitable existing channel plan?

    • Custom channel plans are currently unsupported

    • Workaround: Specify operating channels directly when calling scanning/connection/SoftAP APIs

    • Contact Realtek to request new channel plan additions if needed

  3. How to check channel plan version?

    Use the debug command Debug Commands to retrieve the version used by the Wi-Fi driver.

Transmit Power

Overview

Realtek provides two transmit power tables:

  • Power by rate : Maximum transmit power achievable at each data rate while meeting EVM requirements

  • Power by limit : Regulatory power limits for compliance

Both are consolidated in this file (Released by FAE/AE): WR-TX_Power by Rate&Limit Table-RTLxxx_Rxx.xls

Power by Rate

Locate Power by Rate table in WR-TX_Power by Rate&Limit Table-RTLxxx_Rxx.xls:

../../_images/pwr_by_rate.png

Default values are based on EVB tests with units of 0.25dB. Modify data directly in the spreadsheet and update firmware via Loading Power Tables.

Warning

Do not alter non-power data fields - may cause update failures.

Power by Limit

Common Regulations

Five standard regulatory profiles are provided:

../../_images/pwr_by_limit_countrys.png

FCC example (default values):

../../_images/pwr_by_limit_fcc.png

Similarly, modify spreadsheet data and update firmware via Loading Power Tables.

Warning

Do not alter non-power data fields.

Power Limit Table Selection

Selection follows country code settings (ref: Country Code Configuration Table).

USA example (default uses FCC):

{'U', 'S'}, 0x1b, TXPWR_LMT_FCC}, /* 0015 USA */

To switch to ETSI:

{'U', 'S'}, 0x1b, TXPWR_LMT_ETSI}, /* 0015 USA */

Adding New Regulations

Supported regulatory types (enum definition):

enum rtw_txpwr_lmt {
   TXPWR_LMT_FCC = 0,      /**< Federal Communications Commission (USA) */
   TXPWR_LMT_MKK = 1,      /**< Japan */
   TXPWR_LMT_ETSI = 2,     /**< European Telecommunications Standards Institute (CE) */
   TXPWR_LMT_IC = 3,       /**< Canada */
   TXPWR_LMT_KCC = 4,      /**< South Korea */
   TXPWR_LMT_ACMA = 5,    /**< Australia */
   TXPWR_LMT_CHILE = 6,    /**< Chile */
   TXPWR_LMT_MEXICO = 7,   /**< Mexico */
   TXPWR_LMT_WW = 8,       /**< Worldwide (Minimum of all) */
   TXPWR_LMT_GL = 9,              /**< Global (Legacy compatibility) */
   TXPWR_LMT_UKRAINE = 10, /**< Ukraine */
   TXPWR_LMT_CN = 11,      /**< China */
   TXPWR_LMT_QATAR = 12,   /**< Qatar */
   TXPWR_LMT_UK = 13,      /**< United Kingdom */
   TXPWR_LMT_NCC = 14,     /**< Taiwan */
   TXPWR_LMT_EXT = 15,     /**< Custom */
   /* ===== Add new power limit above this line. ===== */
   TXPWR_LMT_CONST_MAX     /**< Boundary value */
};

Implementation steps:

  1. Duplicate existing regulation sheet and rename:

    ../../_images/pwr_by_limit_add.png
  2. Modify power values in new sheet

Note

  1. Ignore TXPWR_LMT_GL (legacy compatibility only)

Custom Regulations

(TBD - Content pending)

Loading Power Tables

Use GenTxPowerTool to convert Excel data → .c file:

  1. Run GenTxPowerTool.exe:

    ../../_images/pwr_tool_run.png
  2. Locate spreadsheet via Browser:

    ../../_images/pwr_tool_s2.png
  3. Click Generate (success displays OK):

    ../../_images/pwr_tool_s3.png
  4. Retrieve generated .c file:

    ../../_images/pwr_tool_s4.png
  5. Replace original file at: component/soc/usrcfg/amebaxxx

  6. Recompile firmware

Power Table Enable Settings

Configured during mass production.

Efuse offset 0x131[2:0] controls modes:

0x131[2:0]

Description

0

Power by rate ONLY

1

MIN(Power by rate, Power by limit)

2

Disable both tables

Note

  1. Config file overrides Efuse when tx_pwr_table_selection 2

Other Tx Power Interfaces

API

Description

wifi_set_tx_power()

Force-set transmit power to a fixed value for all data rates

wifi_get_tx_power()

Retrieve transmit power for a specified data rate

Adaptivity Test

Introduction

Standard

Adaptivity is an automatic channel access protocol that inhibits a device from transmitting on a channel when ongoing transmissions are detected. Devices with a maximum declared RF output power level greater than 10 dBm effective isotropic radiated power (e.i.r.p.) are required to implement this Adaptivity protocol.

Since December 31, 2017, ETSI has required Adaptivity certification. The applicable standards are ETSI EN 300 328 V2.2.2 for 2.4 GHz bands and ETSI EN 301 893 V2.1.1 for 5 GHz bands.

The Adaptivity test procedures are specified by ETSI as follows:

  1. Establish a connection between the DUT (Device Under Test) and the companion device and start data transmission.

  2. Add the interference signal, and ensure that out-of-band blocking signals are also added for 2G compliance.

  3. Check whether the DUT has stopped transmitting data.

  4. The DUT is restricted to transmitting only short control signals, such as acknowledgment (ACK) frames, to the companion device.

  5. Check the test result.

    • For 2G compliance, check whether the Tx duty cycle is below 10% within any 50ms interval. If yes, pass; otherwise, fail.

    • For 5G compliance, check whether the Tx duty cycle is below 5% within any 50ms interval. If yes, pass; otherwise, fail.

  6. Repeat the steps above for each channel, bandwidth, and mode.

Interference Power

The energy detection formula specified by ETSI is as follows:

2G: TL = -70dBm/MHz + 10*log10(100mW/Pout)
5G: TL = -75dBm/MHz

Note

Pout is the maximum TX power of test object. The interference signal must exceed BW of the test object and have a 100% duty cycle.

Realtek conducts testing under the most stringent conditions in the LAB.

2G: TL = -70dBm/MHz
5G: TL = -75dBm/MHz

The table below illustrates the interference power with different frequencies and bandwidths. When the interference power exceeds the threshold, the MAC layer will be instructed to pause data transmission.

Item

2G

5G

20MHZ

40MHZ

20MHZ

40MHZ

80MHZ

160MHZ

Interference Power (dBm)

-57

-54

-62

-59

-56

-53

The following section details the software configuration and debug SOP essential for successfully passing the Adaptivity test.

Software Configuration

EDCCA Mode

Ameba supports multiple EDCCA modes, please refer to the configuration parameters rtw_edcca_mode. For regulatory testing, the device must be configured to the specific EDCCA mode required by the applicable regulations.

  • Static Adjustment

    File path: component/soc/usrcfg/amebadplus/ameba_wificfg.c

    Function: wifi_set_user_config()

    • For the ETSI Adaptivity test, configure the EDCCA mode to RTW_EDCCA_ADAPT

      wifi_user_config.rtw_edcca_mode = RTW_EDCCA_ADAPT;
      
    • For Carrier Sense, configure the EDCCA mode to RTW_EDCCA_CS

      wifi_user_config.rtw_edcca_mode = RTW_EDCCA_CS;
      

    The configuration will be applied during the Wi-Fi initialization process.

  • Dynamic Adjustment

    Not support.

EDCCA Threshold

Once connected to the AP, retrieve the current EDCCA threshold using the following command:

AT+WLDBG=get_edcca_th

In most scenarios, the default settings suffice to pass the Adaptivity test. If modification is required, adjust the EDCCA threshold using the following command:

AT+WLDBG=fix_edcca_th <value>

Note

The value’s unit is dBm and the scope is [-60, -80], and the minimum step is 1.

For example:

AT+WLDBG=get_edcca_th
[WLDBG]: _AT_WLAN_IWPRIV_
[WLAN-A] [iwpriv_command] cmd name: get_edcca_th
[WLAN-A] edcca thre=-60 dbm

AT+WLDBG=fix_edcca_th -62
[WLDBG]: _AT_WLAN_IWPRIV_
[WLAN-A] [iwpriv_command] cmd name: fix_edcca_th

Debug SOP

Checklist

Points

Test SDK

  • The SDK is in normal mode, not in manufacturing (MP) mode.

  • The EDCCA mode is set to RTW_EDCCA_ADAPT.

Test Environment

  • Testing should be conducted in a shielding room.

  • Connect all antennas to controlled interference sources.

  • When packet loss occurs, verify that the packet type transmitted by the DUT is not an ACK (Acknowledgment) packet.

  • Maintain the device’s RSSI at -50dBm or higher.

  • Adaptivity test measures the Tx of the DUT, not the Rx.

  • Interference energy is measured in dBm, not dBm/MHz.

Optimize the EDCCA threshold

  • Use ATWZ command to modify EDCCA threshold.

DFS

DFS Slave

The SDK defaults to supporting DFS Slave functionality, allowing the STA to automatically process the CSA IE in AP beacon and action frames.

Although DFS regulations vary across different countries and regions in terms of specific requirements, the primary impact is on the DFS Master. For a DFS Slave, meeting the following requirements is generally sufficient for regulatory testing:

  1. Cease Wi-Fi transmissions on the current channel as required by the AP

  2. Switch to the new channel punctually as required by the AP

DFS Master

Not currently supported

Wi-Fi Logo Certification

How to Obtain a Wi-Fi Logo Certificate?

The process for obtaining a Wi-Fi Logo Certificate is illustrated in the below figure:

../../_images/wifi_logo_flow.svg

The members of the Wi-Fi Alliance (WFA) must submit certification applications via the online “Certification System” (accessible on the WFA official website). Subsequently, they shall select an Authorized Test Laboratory (ATL), inquire about quotation details, and arrange for test scheduling.

  • The customer contacts relevant engineers at Realtek to seek technical support for certification compliance.

  • The customer confirms the certification pathway (FlexTrack Certification, QuickTrack Certification, or Derivative Certification, refer to Three Certification Pathways) based on their own products.

  • The customer submits a test application to the WFA and obtains a Certification ID (CID).

  • The customer coordinates with the ATL to confirm the test date, settle financial arrangements, and provide the test devices.

  • The ATL does the tests and issues test reports to both the customer and the WFA.

  • If some items of tests is failed, the customer works with Realtek to debug and resolve the issues, then re-submits the product for retesting (additional fees may be required to be paid to the ATL).

  • WFA staff review the test results. If the results are verified as valid and the product passes the tests successfully, and no other reasons for rejecting the certification are identified, the WFA will issue the certificate for the product.

Note

  • Official website of the Wi-Fi Alliance: https://www.cert.wi-fi.org/

  • We have each established a laboratory with test environments identical to those of ATLs. The laboratory can be used for pre-testing, as well as analyzing and debugging issues encountered during the certification process.

Three Certification Pathways

Within the WFA certification framework, there are three certification pathways: FlexTrack Certification, QuickTrack Certification, and Derivative Certification. These three pathways cater to different product development models, offering differentiated options in terms of test scope, cycle, and cost while ensuring the rigor of certification. Detailed descriptions are as follows:

Three Certification Pathways

Certification Pathway

FlexTrack Certification

QuickTrack Certification

Derivative Certification

Applicable Product Types

Customized and innovative products

Improved products based on qualified solutions

Products that fully reuse a certified design

Testing Requirements

Full-functionality testing

Partial-functionality testing

No testing required

Testing Location

ATL

ATL or enterprise laboratory

None

Cycle

Long (4-8 weeks)

Medium (2-4 weeks)

Short (1-2 weeks)

Cost

High

Medium

Low (administrative fees only)

Typical Application

New chipsets

Products based on a specific chip (inheriting the chip’s certificate)

Modified models (sub-models of chips within a specific chipset)

Certification Status of Our Chips

The following is the certification status of our chips:
  • RTL8721DGx

    • CID: RTL8721DG

    • Certification Items:

      • CERTIFIED 11n 20M/40M

      • PMF

      • KRACK

      • FFD

      • WPA2-Personal

      • WPA3-Personal

      • Forward Compatibility

    • Certificate Type: Inheritable QuickTrack Certification Certificate.

    • Certificate Link: Visit https://www.wi-fi.org/product-finder and search for “RTL8721DG” to look up the certificate.

  • RTL8721DCx

    • CID: RTL8721DC

    • Certification Items:

      • CERTIFIED 11n 20M/40M

      • PMF

      • KRACK

      • FFD

      • WPA2-Personal

      • WPA3-Personal

      • Forward Compatibility

    • Certificate Type: Inheritable QuickTrack Certification Certificate.

    • Certificate Link: Visit https://www.wi-fi.org/product-finder and search for “RTL8721DC” to look up the certificate.