1.主题
Android如何修改国家地区的信道监管规则
2.问题背景
产品:OTT BOX
硬件:H618
软件:AndroidS+AW869A 模块
其他:特有版本信息添加自由描述 (如固件版本,复现概率,特定环境)
3.问题描述
3.1复现步骤
无
3.2具体表现
客户的产品属于电子产品按照马来西亚当地的规定不允许WIFI 5G 频段使用5470-5725MHz频段,要求销售的产品需要遵循此规则。通过执行iw reg get可以看到,当前AW平台使用的无线监管规则在亚洲地区允许使用
5470-5725MHz频段。不符合客户使用场景要求。
马来西亚的WIFI国家码"MY"可以使用的WIFI频段是2.4 GHz和5 GHz。以下是马来西亚可以使用的WIFI信道列表:
2.4 GHz频段:
信道 1: 2.412 GHz
信道 2: 2.417 GHz
信道 3: 2.422 GHz
信道 4: 2.427 GHz
信道 5: 2.432 GHz
信道 6: 2.437 GHz
信道 7: 2.442 GHz
信道 8: 2.447 GHz
信道 9: 2.452 GHz
信道 10: 2.457 GHz
信道 11: 2.462 GHz
5 GHz频段:
信道 36: 5.180 GHz
信道 40: 5.200 GHz
信道 44: 5.220 GHz
信道 48: 5.240 GHz
信道 52: 5.260 GHz
信道 56: 5.280 GHz
信道 60: 5.300 GHz
信道 64: 5.320 GHz
信道 100: 5.500 GHz
信道 104: 5.520 GHz
信道 108: 5.540 GHz
信道 112: 5.560 GHz
信道 116: 5.580 GHz
信道 120: 5.600 GHz
信道 124: 5.620 GHz
信道 128: 5.640 GHz
信道 132: 5.660 GHz
信道 136: 5.680 GHz
信道 140: 5.700 GHz
信道 149: 5.745 GHz
信道 153: 5.765 GHz
信道 157: 5.785 GHz
信道 161: 5.805 GHz
信道 165: 5.825 GHz
需注意,使用无线网络设备时,需确保遵守马来西亚当地的无线电频谱规定,以避免产生干扰或违反当地的法规。
4.问题分析
当前全志SDK国家地区监管规则实现方式:
1)使用Google发布更新的数据库,其会按照各地规定对数据库进行更新
https://kernel.googlesource.com/pub/scm/linux/kernel/git/sforshee/wireless-regdb/
2)对应SDK中的路径android/hardware/aw/wireless/regulatory/wireless-regdb/
3)全部国家码的信道频率可以查看android/hardware/aw/wireless/regulatory/wireless-regdb/upstream/db.txt
4)括号内地频率范围就表示该地区支持的频率范围,例如2402 - 2482就是信道1(中心频率2412)-13(中心频率2472),没有显示的就不支持,例如日本支持14信道则会显示2474 - 2494
其它国家则不显示。具体信道与频率对应关系可以搜索无线局域网信道列表。
5.根本原因
1)Google数据库不区分产品的使用位置是等
2)AW869A不支持DFS,无法避开检查
6.解决办法
无Google签名无法直接修改Google数据库,需使用Allwinner Key生成监管数据库,此FAQ仅提供一种使用Allwinner Key生成监管规则的方法,不构成具体修改建议,具体规则修改建议请与各地检测机构核实。
1)按照如下修改删除Google数据库
仓库路径:android/hardware/aw/wireless/
diff --git a/regulatory/Android.mk b/regulatory/Android.mk
old mode 100644
new mode 100755
index 684df18..06b13b0
--- a/regulatory/Android.mk
+++ b/regulatory/Android.mk
@@ -9,10 +9,5 @@ LOCAL_MODULE_TAGS := optional
LOCAL_REQUIRED_MODULES := crda crda.uevent regdbdump
LOCAL_REQUIRED_MODULES += allwinner.key.pub.pem regulatory.bin
-DB_FIRMWARE_SUPPORT := $(shell [ $(PLATFORM_VERSION) -ge 11 ] && echo true || echo false)
-ifeq ($(DB_FIRMWARE_SUPPORT),true)
-LOCAL_REQUIRED_MODULES := regulatory.db regulatory.db.p7s
-endif
-
LOCAL_REQUIRED_MODULES += dom2reg
include $(BUILD_PHONY_PACKAGE)
diff --git a/regulatory/wireless-regdb/Android.mk b/regulatory/wireless-regdb/Android.mk
old mode 100644
new mode 100755
index dcef4f7..3ee3f17
--- a/regulatory/wireless-regdb/Android.mk
+++ b/regulatory/wireless-regdb/Android.mk
@@ -15,19 +15,3 @@ LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/crda
LOCAL_SRC_FILES := $(LOCAL_MODULE)
include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := regulatory.db
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_CLASS := ETC
-LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/firmware
-LOCAL_SRC_FILES := upstream/$(LOCAL_MODULE)
-include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := regulatory.db.p7s
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_CLASS := ETC
-LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/firmware
-LOCAL_SRC_FILES := upstream/$(LOCAL_MODULE)
-include $(BUILD_PREBUILT)
diff --git a/regulatory/wireless-regdb/upstream/regulatory.db b/regulatory/wireless-regdb/upstream/regulatory.db
deleted file mode 100644
index 6019e8f..0000000
Binary files a/regulatory/wireless-regdb/upstream/regulatory.db and /dev/null differ
diff --git a/regulatory/wireless-regdb/upstream/regulatory.db.p7s b/regulatory/wireless-regdb/upstream/regulatory.db.p7s
deleted file mode 100644
index d04cb25..0000000
Binary files a/regulatory/wireless-regdb/upstream/regulatory.db.p7s and /dev/null differ
2)按需修改地区监管规则,找到对应国家码修改相应规则,以马来亚西为例删除其5470-5725MHz频段
diff --git a/regulatory/wireless-regdb/upstream/db.txt b/regulatory/wireless-regdb/upstream/db.txt
index ac2429e..f779a4e 100644
--- a/regulatory/wireless-regdb/upstream/db.txt
+++ b/regulatory/wireless-regdb/upstream/db.txt
@@ -641,7 +641,6 @@ country FM: DFS-FCC
+++ b/hardware/aw/wireless/regulatory/wireless-regdb/upstream/db.txt
@@ -1242,7 +1242,6 @@ country MY: DFS-FCC
(2402 - 2482 @ 40), (20)
(5170 - 5250 @ 80), (24), AUTO-BW
(5250 - 5330 @ 80), (24), DFS, AUTO-BW
- (5490 - 5650 @ 160), (24), DFS
(5735 - 5835 @ 80), (24)
country NG: DFS-ETSI
3)更新哈希校验值,执行sha1sum upstream/db.txt将计算的值填入sha1sum.txt文件内
$ sha1sum upstream/db.txt
2bfd5fece6bfcb2343881b2516eefe3366bd0771 upstream/db.txt
/hardware/aw/wireless/regulatory/wireless-regdb$ git diff upstream/sha1sum.txt
diff --git a/hardware/aw/wireless/regulatory/wireless-regdb/upstream/sha1sum.txt b/hardware/aw/wireless/regulatory/wireless-regdb/upstream/sha1sum.txt
index 7865603ac3..20391ec917 100644
--- a/hardware/aw/wireless/regulatory/wireless-regdb/upstream/sha1sum.txt
+++ b/hardware/aw/wireless/regulatory/wireless-regdb/upstream/sha1sum.txt
@@ -1 +1 @@
-7ed3866486ee6b403a9a6af1ac267dbd5ddda06a db.txt
+2bfd5fece6bfcb2343881b2516eefe3366bd0771 db.txt
4)执行./regdb-gen.sh脚本编译数据库生成新的regulatory.bin文件
hardware/aw/wireless/regulatory/wireless-regdb$ ./regdb-gen.sh
Traceback (most recent call last):
File "upstream/db2bin.py", line 128, in <module>
from M2Crypto import RSA
ImportError: No module named M2Crypto
1)提示无法编译通过
安装M2Crypto:
2)pip show M2Crypto
Command 'pip' not found, but can be installed with:
3)sudo apt install python3-pip
4)pip install M2Crypto
Collecting M2Crypto
Downloading M2Crypto-0.39.0.tar.gz (1.2 MB)
|████████████████████████████████| 1.2 MB 16 kB/s
Building wheels for collected packages: M2Crypto
Building wheel for M2Crypto (setup.py) ... done
Created wheel for M2Crypto: filename=M2Crypto-0.39.0-cp38-cp38-linux_x86_64.whl size=722350 sha256=7b32fa4da85dbcef2b100e9000bb6a18cacf2ed4fd1cca1fa90e742d2e403f26
Stored in directory: /home/yxt-rd01/.cache/pip/wheels/2c/13/5b/95cbe0e9cda84f3be0a68f7e3bb165100d8d5047d529f53b5a
Successfully built M2Crypto
Installing collected packages: M2Crypto
Successfully installed M2Crypto-0.39.0
5)sudo apt update
sudo apt install python-m2crypto
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package python-m2crypto is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'python-m2crypto' has no installation candidate
6)出现以上可能是当前的Ubuntu环境有变化,执行
apt-cache search m2crypto
python-m2crypto-doc - Python wrapper for the OpenSSL library (docs)
python3-m2crypto - Python wrapper for the OpenSSL library (Python 3 modules)
7)检查 M2Crypto 安装路径:
pip show M2Crypto | grep "Location:"
Location: /usr/lib/python3/dist-packages
8)手动切换python
sudo update-alternatives --config python
There are 2 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/python2.7 2 auto mode
1 /usr/bin/python2.7 2 manual mode
2 /usr/bin/python3.10 1 manual mode
Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/bin/python3.10 to provide /usr/bin/python (python) in manual mode
ubuntu@ubuntu-System-Product-Name:~$ sudo update-alternatives --config python
There are 2 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/python2.7 2 auto mode
1 /usr/bin/python2.7 2 manual mode
* 2 /usr/bin/python3.10 1 manual mode
9)再次执行命令:
./regdb-gen.sh
这次执行成功
git status ./
On branch H618
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: Android.mk
modified: wireless-regdb/Android.mk
modified: wireless-regdb/regulatory.bin
modified: wireless-regdb/upstream/db.txt
modified: wireless-regdb/upstream/sha1sum.txt
5)执行make clean后重新编译Android固件,开机后将时区改到马来西亚
[ro.boot.wificountrycode]: [MY]
[persist.sys.timezone]: [Asia/Kuala_Lumpur]
6)执行iw reg get可以看到5250 - 5350已经被删除,路由器设置该频段也无法搜到。
修改马来西亚WIFI 5G频段去掉5450~5725 5G 频段
最新推荐文章于 2024-06-20 17:05:08 发布