8.13.8 Change Regulatory Domain Settings

Kernel's Central Regulatory Domain Agent (CRDA) acts as the udev helper for the communication between the kernel and for regulatory compliance. CRDA is enabled by default on the reference platform. To enable it for other platforms, it must be selected on buildroot's package using the menuconfig:

Target Packages>Networking applications>crda

CRDA uses a database that specifies the channels which are to be used at each country, with a restricting "World Regulatory Domain". This database is defined in db.txt file in the wireless-regdb package. World Regulatory Domain helps to apply some restrictions according to the country and the device is configured to operate, even if the user used it in a country that does not have these restrictions. For more details, see wireless.wiki.kernel.org/en/developers/Regulatory/CRDA#Using_iw_to_change_regulatory_domains.

Linux allows changing of the regulatory domains in compliance with worldwide regulatory restrictions, including the US FCC. In order to achieve this, this device always respects its programmed regulatory domain and a country code selection will enhance regulatory restrictions. This is in accordance with the FCC part 15 country code selection knowledge base publication number 594280. For example, if the device is programmed for operation in the US which allows operation on channels 1-11 on the 2.4 GHz band, and the user visits Japan which allows operation on channels 1-14 and the user changes the regulatory domain to JP, then the channel 12, 13 or 14 (CCK) cannot be used. However, if a device is programmed for operation in Japan and visits the US, selecting US as the regulatory domain will have channel 12-14 disabled.

The default database restricts channels 12 to 14 as listen only; therefore, use these channels for the AP mode. For example, the flag NO-IR must be removed.

  1. This is the world regulatory domain country 00: (2402 - 2472 @ 40), (20)
  2. Channel 12 - 13. (2457 - 2482 @ 20), (20), AUTO-BW
  3. Channel 14. Only JP enables this and for 802.11b only (2474 - 2494 @ 20), (20), NO-OFDM
  4. Channel 36 - 48 (5170 - 5250 @ 80), (20), NO-IR, AUTO-BW
  5. Channel 52 - 64 (5250 - 5330 @ 80), (20), NO-IR, DFS, AUTO-BW
  6. Channel 100 - 144 (5490 - 5730 @ 160), (20), NO-IR, DFS
  7. Channel 149 - 165 (5735 - 5835 @ 80), (20), NO-IR
  8. IEEE 802.11ad (60GHz), channels 1..3 (57240 - 63720 @ 2160), (0)

Generating a New Regulatory Database Binary

The regulatory domain database binary is digitally signed to ensure integrity; therefore, to generate a new database binary, the key must also be used while compiling CRDA, and also be copied to the target. To create a new regulatory file perform the following steps:
  1. Open an already built buildroot.
  2. Go to output/build/wireless-regdb-2017.03.07/.
  3. Change db.tx.
  4. Build regdb using make command.

    This creates a new public key, and can be used to generate and sign a new regulartory.bin file. The user must install m2crypto Python® package to build regdb # sudo apt-get install python-m2crypto.

  5. Copy the file to output/build/crda-3.18/pubkeys/.
  6. Modify wireless-regdb package to install the new key to the target as:
    • Go to wireless-regdb.mk.
    • Edit WIRELESS_REGDB_INSTALL_TARGET_CMDS to copy the new key to the target folder.
  7. Force rebuild and installation to target for both crda and wireless-regdb by removing .stamp_target_installed, .stamp_built from output/build/crda-3.18 and wireless-regdb-2017.03.07.
  8. Rebuild buildroot.
To verify the process, use regdbdump to make sure the new regulatory.bin can be verified.
# regdbdump /usr/lib/crda/regulatory.bin
Note: Starting from kernel 4.15 the regulatory domain is maintained as db file in /lib/firmware. We have to enable the BR2_PACKAGE_WIRELESS_REGDB in buildroot with following menu config option.

Target packages > Networking applications -> wireless-regdb

The regulatory.db & regulatory.db.p7s files should be present in /lib/firmware/ folder in rootFS.