RK3588Android12 动态兼容4G模组
平台RK3588Android12内容实现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}, //vidpid {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