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 */
...
};
Countries with identical regulations are grouped into 3 categories:
country_code_FCC
const struct country country_code_FCC[] = { {{'C', 'O'}}, /* 0004 Colombia */ {{'C', 'R'}}, /* 0005 Costa Rica */ {{'E', 'C'}}, /* 0006 Ecuador */ ... };
country_code_ETSI
const struct country country_code_ETSI[] = { {{'A', 'T'}}, /* 0020 Austria */ {{'B', 'E'}}, /* 0021 Belgium */ {{'C', 'Y'}}, /* 0022 Cyprus */ ... };
country_code_ETSI2
const struct country country_code_ETSI2[] = { {{'S', 'N'}}, /* 0077 Senegal */ {{'M', 'E'}}, /* 0079 Montenegro */ {{'Y', 'E'}}, /* 0084 Yemen */ ... };
Corresponding configurations:
const struct country_code_table_common_t country_code_table_common[] = { {country_code_FCC, 0x76, TXPWR_LMT_FCC, sizeof(country_code_FCC)/sizeof(country_code_FCC[0])}, {country_code_ETSI, 0x5e, TXPWR_LMT_ETSI, sizeof(country_code_ETSI)/sizeof(country_code_ETSI[0])}, {country_code_ETSI2, 0x3a, TXPWR_LMT_ETSI, sizeof(country_code_ETSI2)/sizeof(country_code_ETSI2[0])}, };
Note
Country codes follow ISO 3166-1
Configuration values are Realtek’s recommendations based on regional regulations
Custom country codes may be added if they don’t conflict with existing ones
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
Location: component/soc/usrcfg/amebaxxx/ameba_wificfg.c
- Default (Use Efuse setting):
wifi_user_config.country_code[0] = 0; wifi_user_config.country_code[1] = 0;
- Example 1: China
wifi_user_config.country_code[0] = 'C'; wifi_user_config.country_code[1] = 'N';
- Example 2: Worldwide
wifi_user_config.country_code[0] = '0'; wifi_user_config.country_code[1] = '0';
For dynamic post-initialization changes.
Reference: wifi_set_countrycode()
- Example:
u8 country_code[2] = {'C','N'}; wifi_set_countrycode(country_code);
Automatic country code detection via AP beacons.
Details: 802.11d
Note
Config file method overrides Efuse when values are valid
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:
The 2G channel encoding 2G_02 provides detailed 2G channel specifications:
The 5G channel encoding 5G_52 provides detailed 5G channel specifications:
Note
Ignore the “2G Regulation” and “5G Regulation” columns - these are retained for legacy compatibility only and unused in Ameba series.
FAQs
How to modify channel plans?
Example: Disabling channels 12/13 (2G) and 169/173/177 (5G) for USA.
The channel plan table shows
0x25meets this requirement:
Update the channel plan value in the country code table from
0x1bto0x25:{'U', 'S'}, 0x25, TXPWR_LMT_FCC}, /* 0015 USA */
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
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:
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:
FCC example (default values):
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:
Note
Ignore
TXPWR_LMT_GL(legacy compatibility only)
Custom Regulations
(TBD - Content pending)
Loading Power Tables
Use GenTxPowerTool to convert Excel data → .c file:
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 |
Location: component/soc/usrcfg/amebaxxx/ameba_wificfg.c
Control field:
wifi_user_config.tx_pwr_table_selection
Value |
Description |
|---|---|
0 |
Power by rate ONLY |
1 |
MIN(Power by rate, Power by limit) |
2 |
Use Efuse setting (default) |
Note
Config file overrides Efuse when
tx_pwr_table_selection ≠ 2
Other Tx Power Interfaces
API |
Description |
|---|---|
Force-set transmit power to a fixed value for all data rates |
|
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:
Establish a connection between the DUT (Device Under Test) and the companion device and start data transmission.
Add the interference signal, and ensure that out-of-band blocking signals are also added for 2G compliance.
Check whether the DUT has stopped transmitting data.
The DUT is restricted to transmitting only short control signals, such as acknowledgment (ACK) frames, to the companion device.
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.
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.cFile path:
component/soc/usrcfg/amebalite/ameba_wificfg.cFile path:
component/soc/usrcfg/amebalite/ameba_wificfg.cFile path:
component/soc/usrcfg/amebalite/ameba_wificfg.cFile path:
component/soc/usrcfg/amebasmart/ameba_wificfg.cFunction:
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.
Static Adjustment
File path:
firmware/component/wifi/whc/whc_host_linux/fullmac/ipc/ameba_wificfg.cFunction:
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
EDCCA mode has been integrated at the path
/proc/net/whc_fullmac/wlan0/edcca_mode. Use the following commands to read or write this setting:echo n > /proc/net/whc_fullmac/wlan0/edcca_mode cat /proc/net/whc_fullmac/wlan0/edcca_mode
Note
n is in [0, 1, 2, 9].
The network interface may not be designated as
wlan0, utilize the actual interface identifier specific to the system configuration.
For example:
/ # echo 1 > /proc/net/whc_fullmac/wlan0/edcca_mode / # cat /proc/net/whc_fullmac/wlan0/edcca_mode 1
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
There is no command to set or retrieve the EDCCA threshold. Customers can use it by compiling the following code.
Get Current EDCCA Threshold
ATWZ get_edcca_th
Set EDCCA Threshold
ATWZ fix_edcca_th <value>
Note
The value’s unit is dBm and the scope is [-60, -80], and the minimum step is 1.
Customers can refer to the following link to add “ATWZ” commands, which should be adapted for the Linux operating system.
https://github.com/Ameba-AIoT/ameba-linux-development/tree/ameba-6.6.y/wifi/ATWZ
Once connected to the AP, retrieve the current EDCCA threshold using the following command:
ATWZ 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:
ATWZ fix_edcca_th <value>
Note
The value’s unit is dBm, the scope is [-60, -80], and the minimum step is 1.
For example:
/ # ATWZ get_edcca_th
[WLDBG]: _AT_WLAN_IWPRIV_
[WLAN-A] [iwpriv_command] cmd name: get_edcca_th
[WLAN-A] edcca thre=-60 dbm
/ # ATWZ fix_edcca_th -61
[WLAN-A] [iwpriv_command] cmd name: fix_edcca_th
/ # ATWZ get_edcca_th
[WLDBG]: _AT_WLAN_IWPRIV_
[WLAN-A] [iwpriv_command] cmd name: get_edcca_th
[WLAN-A] edcca thre=-61 dbm
Debug SOP
Checklist |
Points |
|---|---|
Test SDK |
|
Test Environment |
|
Optimize the 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:
Cease Wi-Fi transmissions on the current channel as required by the AP
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:
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.
CID: RTL8730E
Certification Items:
CERTIFIED 11n
CERTIFIED 11ac 5G
PMF
KRACK
FFD
WPA2-Personal
WPA3-Personal
Forward Compatibility
WIFI6 2.4G
WIFI6 5G
MBO
Certificate Type: Inheritable QuickTrack Certification Certificate.
Certificate Link: Visit https://www.wi-fi.org/product-finder and search for “RTL8730E” to look up the certificate.
Currently, the company has not yet obtained separate certification for this chip independently. However, some customers have obtained certificates for their products that incorporate this chip model.
Certification Items:
CERTIFIED 11n
PMF
KRACK
FFD
WPA2-Personal
WPA3-Personal
Forward Compatibility
WIFI6 2.4G
MBO