RK3588&Android12 动态兼容4G模组

平台:RK3588&Android12 

内容:实现4G模组的兼容

实现一个固件可以动态兼容多种4G模块,不用换个模块就需要重新打包升级。

主要改系统层,根据模块的PID和VID使用对应的固件

hardware\ril\rild\rild.c

++    #include <dirent.h>

++	static lte_device supported_lte_devices[] = {
++		{"U9507C",	"2df3:9d01", "vendor/lib64/libreference-ril-u9507c.so"},
++		{"E9730C",	"2df3:9b33", "vendor/lib64/libreference-ril-e9730c.so"},
++		{"EC200A",	"2c7c:6005", "vendor/lib64/libreference-ril-ec200a.so"},
++		{"EC2x",	"2c7c:0125", "vendor/lib64/libreference-ril-ec2x.so"},	
++		{"SLM770",	"2dee:4d57", "vendor/lib64/libreference-ril-slm770.so"},    //vid+pid
++		{"U9300C",	"1c9e:9b3c", "vendor/lib64/libreference-ril-u9300c.so"},
++	  //{"N720V5",	"2df3:9d01", "vendor/lib64/libec20.so"},
++	};
++	
++	int get_rillib_from_id(char *libPath)
++	{
++		char *bus_dir = "/sys/bus/usb/devices";
++		char *prefix = "PRODUCT=";
++		int idnum;
++		int i = 0;
++		int ret = 0;
++		DIR *dir;
++		struct dirent *next;
++		FILE *fp = NULL;
++		idnum = sizeof(supported_lte_devices) / sizeof(supported_lte_devices[0]);
++		dir = opendir(bus_dir);
++		if (!dir) {
++			return -1;
++		}
++	
++		while ((next = readdir(dir)) != NULL) {
++			char line[256];
++			char uevent_file[256] = {0};
++			sprintf(uevent_file, "%s/%s/uevent", bus_dir, next->d_name);
++			//PLOG(DEBUG) << "uevent path:" << uevent_file;
++			RLOGD("**uevent path :=%s**", uevent_file);
++			fp = fopen(uevent_file, "r");
++			if (NULL == fp) {
++				continue;
++			}
++	
++			while (fgets(line, sizeof(line), fp)) {
++				char *pos = NULL;
++				int product_vid = 0;
++				int product_did = 0;
++				int producd_bcddev = 0;
++				char temp[10] = {0};
++				pos = strstr(line, prefix);
++				//PLOG(DEBUG) << "line:" << line << ", prefix:" << prefix << ".";
++				if (pos != NULL) {
++					sscanf(pos + 8, "%x/%x/%x", &product_vid, &product_did, &producd_bcddev);
++					
++					sprintf(temp, "%04x:%04x", product_vid, product_did);
++					RLOGD("**found vid:pid =%04x:%04x, temp=%s **", product_vid, product_did, temp);
++					for (i = 0; i < idnum; i++) {
++						if (0 == strncmp(temp, supported_lte_devices[i].vid_pid, 9)) {
++							//PLOG(ERROR) << "found device pid:vid :" << temp;
++							RLOGD("**found device pid:vid :=%s, module_name :=%s**", temp, supported_lte_devices[i].module_name);
++							strcpy(libPath, supported_lte_devices[i].path);
++							ret = 0;
++							fclose(fp);
++							goto ready;
++						}
++					}
++				}
++			}
++			fclose(fp);
++		}
++	
++		ret = -1;
++	ready:
++		closedir(dir);
++		//PLOG(DEBUG) << "wifi detectd return ret:" << ret;
++		RLOGD("**get_rillib_from_id=%d**", ret);
++		return ret;
++	}

int main(int argc, char **argv) {
......
if (rilLibPath == NULL) {
        if ( 0 == property_get(LIB_PATH_PROPERTY, libPath, NULL)) {
            // No lib sepcified on the command line, and nothing set in props.
            // Assume "no-ril" case.
            goto done;
        } else {
            rilLibPath = libPath;
        }
    }

++	if (get_rillib_from_id(libPath) == 0) 	
++		rilLibPath = libPath;
++	  RLOGD("**RILd rilLibPath=%s**", rilLibPath);

把对应RIL库文件放到 device\rockchip\common\4g_modem\lib64\

再修改4g_modem.mk把文件加载到对应位置,例如:


/device/rockchip/common:
--- a/modules/4g_modem.mk
+++ b/modules/4g_modem.mk

PRODUCT_COPY_FILES += \
    $(LOCAL_PATH)/../4g_modem/bin64/dhcpcd:$(TARGET_COPY_OUT_VENDOR)/bin/dhcpcd \
    $(LOCAL_PATH)/../4g_modem/lib64/librk-ril.so:$(TARGET_COPY_OUT_VENDOR)/lib64/librk-ril.so \
+	$(LOCAL_PATH)/../4g_modem/lib64/libreference-ril-ec2x.so:$(TARGET_COPY_OUT_VENDOR)/lib64/libreference-ril-ec2x.so \
+	$(LOCAL_PATH)/../4g_modem/lib64/libreference-ril-ec200a.so:$(TARGET_COPY_OUT_VENDOR)/lib64/libreference-ril-ec200a.so \
+	$(LOCAL_PATH)/../4g_modem/lib64/libreference-ril-u9300c.so:$(TARGET_COPY_OUT_VENDOR)/lib64/libreference-ril-u9300c.so

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值