回顾下移远4G模块移植过程, 还是蛮简单的。一通百通,无论是其他4G模块都是一样的。这里记录下过程,分享给有需要的人。环境使用正点原子的imax6ul开发板,板子默认支持中兴和移远EC20的驱动,这里要移植使用的是移远4G模块EC800。
环境准备
imax6ul开发板
虚拟机(Ubuntu18.04)
交叉编译工具链
内核源码
安装依赖
# 安装 lzop 工具,用于生成压缩或解压镜像
sudo apt-get install lzop
# 安装 ncurese 相关库, U-boot 或者内核菜单显示时需要
sudo apt-get install libncurses*
内核配置
imx6ul开发板的imx_v7_defconfig的linux内核配置:
CONFIG_APM_EMULATION=y
CONFIG_KERNEL_LZO=y
CONFIG_SYSVIPC=y
CONFIG_NO_HZ=y
CONFIG_HIGH_RES_TIMERS=y
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
CONFIG_LOG_BUF_SHIFT=18
CONFIG_CGROUPS=y
CONFIG_RELAY=y
CONFIG_BLK_DEV_INITRD=y
CONFIG_EXPERT=y
CONFIG_KALLSYMS_ALL=y
CONFIG_PERF_EVENTS=y
CONFIG_PRINTK_TIME=y
# CONFIG_SLUB_DEBUG is not set
# CONFIG_COMPAT_BRK is not set
CONFIG_MODULES=y
CONFIG_MODULE_UNLOAD=y
CONFIG_MODVERSIONS=y
CONFIG_MODULE_SRCVERSION_ALL=y
# CONFIG_BLK_DEV_BSG is not set
CONFIG_ARCH_MXC=y
CONFIG_SOC_IMX50=y
CONFIG_SOC_IMX53=y
CONFIG_SOC_IMX6Q=y
CONFIG_SOC_IMX6SL=y
CONFIG_SOC_IMX6SX=y
CONFIG_SOC_IMX6ULL=y
CONFIG_SOC_IMX7D=y
CONFIG_SOC_IMX6SLL=y
CONFIG_SOC_VF610=y
# CONFIG_SWP_EMULATE is not set
CONFIG_SMP=y
CONFIG_HAVE_ARM_ARCH_TIMER=y
CONFIG_VMSPLIT_2G=y
CONFIG_PREEMPT=y
CONFIG_AEABI=y
CONFIG_HIGHMEM=y
CONFIG_CMA=y
CONFIG_CMDLINE="noinitrd console=ttymxc0,115200"
CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=y
CONFIG_CPU_FREQ_GOV_USERSPACE=y
CONFIG_CPU_FREQ_GOV_INTERACTIVE=y
CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
CONFIG_ARM_IMX6Q_CPUFREQ=y
CONFIG_ARM_IMX7D_CPUFREQ=y
CONFIG_CPU_IDLE=y
CONFIG_VFP=y
CONFIG_NEON=y
CONFIG_BINFMT_MISC=m
CONFIG_PM_DEBUG=y
CONFIG_PM_TEST_SUSPEND=y
CONFIG_NET=y
CONFIG_PACKET=y
CONFIG_UNIX=y
CONFIG_INET=y
CONFIG_IP_PNP=y
CONFIG_IP_PNP_DHCP=y
# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
# CONFIG_INET_XFRM_MODE_TUNNEL is not set
# CONFIG_INET_XFRM_MODE_BEET is not set
# CONFIG_INET_LRO is not set
CONFIG_IPV6=y
CONFIG_VLAN_8021Q=y
CONFIG_LLC2=y
CONFIG_CAN=y
CONFIG_CAN_FLEXCAN=y
CONFIG_CAN_M_CAN=y
CONFIG_BT=y
CONFIG_BT_RTKBTUSB=m
CONFIG_BT_RFCOMM=y
CONFIG_BT_RFCOMM_TTY=y
CONFIG_BT_BNEP=y
CONFIG_BT_BNEP_MC_FILTER=y
CONFIG_BT_BNEP_PROTO_FILTER=y
CONFIG_BT_HIDP=y
CONFIG_BT_HCIBTUSB=y
CONFIG_BT_HCIUART=y
CONFIG_BT_HCIUART_BCSP=y
CONFIG_BT_HCIUART_ATH3K=y
CONFIG_BT_HCIBCM203X=y
CONFIG_BT_ATH3K=y
CONFIG_CFG80211=y
CONFIG_CFG80211_WEXT=y
CONFIG_USB_ZD1201=m
CONFIG_MAC80211=y
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
# CONFIG_STANDALONE is not set
CONFIG_DMA_CMA=y
CONFIG_CMA_SIZE_MBYTES=0
CONFIG_IMX_WEIM=y
CONFIG_CONNECTOR=y
CONFIG_MTD=y
CONFIG_MTD_CMDLINE_PARTS=y
CONFIG_MTD_BLOCK=y
CONFIG_MTD_CFI=y
CONFIG_MTD_JEDECPROBE=y
CONFIG_MTD_CFI_INTELEXT=y
CONFIG_MTD_CFI_AMDSTD=y
CONFIG_MTD_CFI_STAA=y
CONFIG_MTD_PHYSMAP_OF=y
CONFIG_MTD_DATAFLASH=y
CONFIG_MTD_M25P80=y
CONFIG_MTD_SST25L=y
CONFIG_MTD_NAND=y
CONFIG_MTD_NAND_GPMI_NAND=y
CONFIG_MTD_NAND_MXC=y
CONFIG_MTD_SPI_NOR=y
CONFIG_SPI_FSL_QUADSPI=y
CONFIG_MTD_UBI=y
CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_SIZE=65536
CONFIG_SENSORS_FXOS8700=y
CONFIG_SENSORS_FXAS2100X=y
CONFIG_EEPROM_AT24=y
CONFIG_EEPROM_AT25=y
# CONFIG_SCSI_PROC_FS is not set
CONFIG_BLK_DEV_SD=y
CONFIG_SCSI_CONSTANTS=y
CONFIG_SCSI_LOGGING=y
CONFIG_SCSI_SCAN_ASYNC=y
# CONFIG_SCSI_LOWLEVEL is not set
CONFIG_ATA=y
CONFIG_SATA_AHCI_PLATFORM=y
CONFIG_AHCI_IMX=y
CONFIG_PATA_IMX=y
CONFIG_NETDEVICES=y
# CONFIG_NET_VENDOR_BROADCOM is not set
CONFIG_CS89x0=y
CONFIG_CS89x0_PLATFORM=y
# CONFIG_NET_VENDOR_FARADAY is not set
# CONFIG_NET_VENDOR_INTEL is not set
# CONFIG_NET_VENDOR_MARVELL is not set
# CONFIG_NET_VENDOR_MICREL is not set
# CONFIG_NET_VENDOR_MICROCHIP is not set
# CONFIG_NET_VENDOR_NATSEMI is not set
# CONFIG_NET_VENDOR_SEEQ is not set
CONFIG_SMC91X=y
CONFIG_SMC911X=y
CONFIG_SMSC911X=y
CONFIG_SMSC_PHY=y
# CONFIG_NET_VENDOR_STMICRO is not set
CONFIG_MICREL_PHY=y
CONFIG_PPP=y
CONFIG_PPP_BSDCOMP=y
CONFIG_PPP_DEFLATE=y
CONFIG_PPP_FILTER=y
CONFIG_PPP_MPPE=y
CONFIG_PPP_MULTILINK=y
CONFIG_PPPOE=y
CONFIG_PPP_ASYNC=y
CONFIG_PPP_SYNC_TTY=y
CONFIG_USB_PEGASUS=m
CONFIG_USB_RTL8150=m
CONFIG_USB_RTL8152=m
CONFIG_USB_USBNET=y
CONFIG_USB_NET_CDC_EEM=m
CONFIG_BCMDHD=y
CONFIG_BCMDHD_SDIO=y
CONFIG_BCMDHD_FW_PATH="/lib/firmware/bcm/ZP_BCM4339/fw_bcmdhd.bin"
CONFIG_BCMDHD_NVRAM_PATH="/lib/firmware/bcm/ZP_BCM4339/bcmdhd.ZP.OOB.cal"
CONFIG_RTL_CARDS=m
CONFIG_RTL8188EUS=m
CONFIG_USB_GOBI_NET=m
CONFIG_EXTRA_RTL8192CU=m
CONFIG_BRIDGE=y
CONFIG_RFKILL=y
CONFIG_RFKILL_INPUT=y
# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
CONFIG_INPUT_EVDEV=y
CONFIG_INPUT_EVBUG=m
CONFIG_KEYBOARD_GPIO=y
CONFIG_KEYBOARD_IMX=y
CONFIG_MOUSE_PS2=m
CONFIG_MOUSE_PS2_ELANTECH=y
CONFIG_INPUT_TOUCHSCREEN=y
CONFIG_TOUCHSCREEN_ADS7846=y
CONFIG_TOUCHSCREEN_EGALAX=y
CONFIG_TOUCHSCREEN_ELAN_TS=y
CONFIG_TOUCHSCREEN_MAX11801=y
CONFIG_TOUCHSCREEN_IMX6UL_TSC=y
CONFIG_TOUCHSCREEN_MC13783=y
CONFIG_TOUCHSCREEN_TSC2007=y
CONFIG_TOUCHSCREEN_STMPE=y
CONFIG_TOUCHSCREEN_EDT_FT5X06=y
CONFIG_TOUCHSCREEN_GT9XX=y
CONFIG_INPUT_MISC=y
CONFIG_INPUT_MMA8450=y
CONFIG_INPUT_MPL3115=y
CONFIG_SENSOR_FXLS8471=y
CONFIG_INPUT_ISL29023=y
CONFIG_SERIO_SERPORT=m
# CONFIG_LEGACY_PTYS is not set
# CONFIG_DEVKMEM is not set
CONFIG_SERIAL_IMX=y
CONFIG_SERIAL_IMX_CONSOLE=y
CONFIG_SERIAL_FSL_LPUART=y
CONFIG_SERIAL_FSL_LPUART_CONSOLE=y
CONFIG_FSL_OTP=y
CONFIG_LITEON_AP3216C=y
CONFIG_HW_RANDOM_IMX_RNG=y
# CONFIG_I2C_COMPAT is not set
CONFIG_I2C_CHARDEV=y
# CONFIG_I2C_HELPER_AUTO is not set
CONFIG_I2C_ALGOPCF=m
CONFIG_I2C_ALGOPCA=m
CONFIG_I2C_IMX=y
CONFIG_SPI=y
CONFIG_SPI_GPIO=y
CONFIG_SPI_IMX=y
CONFIG_SPI_SPIDEV=y
CONFIG_GPIO_SYSFS=y
CONFIG_GPIO_MAX732X=y
CONFIG_GPIO_PCA953X=y
CONFIG_GPIO_74X164=y
CONFIG_POWER_SUPPLY=y
CONFIG_SABRESD_MAX8903=y
CONFIG_POWER_RESET=y
CONFIG_POWER_RESET_SYSCON_POWEROFF=y
CONFIG_SENSORS_MAX17135=y
CONFIG_SENSORS_MAG3110=y
CONFIG_THERMAL=y
CONFIG_CPU_THERMAL=y
CONFIG_IMX_THERMAL=y
CONFIG_DEVICE_THERMAL=y
CONFIG_WATCHDOG=y
CONFIG_IMX2_WDT=y
CONFIG_MFD_DA9052_I2C=y
CONFIG_MFD_MC13XXX_SPI=y
CONFIG_MFD_MC13XXX_I2C=y
CONFIG_MFD_MAX17135=y
CONFIG_MFD_SI476X_CORE=y
CONFIG_MFD_STMPE=y
CONFIG_REGULATOR=y
CONFIG_REGULATOR_FIXED_VOLTAGE=y
CONFIG_REGULATOR_ANATOP=y
CONFIG_REGULATOR_DA9052=y
CONFIG_REGULATOR_GPIO=y
CONFIG_REGULATOR_MAX17135=y
CONFIG_REGULATOR_MC13783=y
CONFIG_REGULATOR_MC13892=y
CONFIG_REGULATOR_PFUZE100=y
CONFIG_MEDIA_SUPPORT=y
CONFIG_MEDIA_CAMERA_SUPPORT=y
CONFIG_MEDIA_RADIO_SUPPORT=y
CONFIG_MEDIA_RC_SUPPORT=y
CONFIG_RC_DEVICES=y
CONFIG_IR_GPIO_CIR=y
CONFIG_MEDIA_USB_SUPPORT=y
CONFIG_USB_VIDEO_CLASS=m
CONFIG_V4L_PLATFORM_DRIVERS=y
CONFIG_VIDEO_MXC_OUTPUT=y
CONFIG_VIDEO_MXC_CAPTURE=m
CONFIG_MXC_CAMERA_OV5640=m
CONFIG_MXC_CAMERA_OV5642=m
CONFIG_MXC_CAMERA_OV5640_MIPI=m
CONFIG_MXC_TVIN_ADV7180=m
CONFIG_MXC_IPU_DEVICE_QUEUE_SDC=m
CONFIG_VIDEO_MXC_IPU_OUTPUT=y
CONFIG_VIDEO_MXC_PXP_V4L2=y
CONFIG_VIDEO_MXC_CSI_CAMERA=m
CONFIG_MXC_VADC=m
CONFIG_MXC_MIPI_CSI=m
CONFIG_MXC_CAMERA_OV5647_MIPI=m
CONFIG_SOC_CAMERA=y
CONFIG_VIDEO_MX3=y
CONFIG_V4L_MEM2MEM_DRIVERS=y
CONFIG_VIDEO_CODA=y
CONFIG_RADIO_SI476X=y
CONFIG_SOC_CAMERA_OV2640=m
CONFIG_SOC_CAMERA_OV772X=m
CONFIG_DRM=y
CONFIG_DRM_VIVANTE=y
CONFIG_FB=y
CONFIG_FB_MXS=y
CONFIG_FB_MXC_SYNC_PANEL=y
CONFIG_FB_MXC_MIPI_DSI=y
CONFIG_FB_MXC_MIPI_DSI_SAMSUNG=y
CONFIG_FB_MXC_TRULY_WVGA_SYNC_PANEL=y
CONFIG_FB_MXC_TRULY_PANEL_TFT3P5079E=y
CONFIG_FB_MXC_TRULY_PANEL_TFT3P5581E=y
CONFIG_FB_MXC_LDB=y
CONFIG_FB_MXC_HDMI=y
CONFIG_FB_MXS_SII902X=y
CONFIG_FB_MXC_DCIC=m
CONFIG_HANNSTAR_CABC=y
CONFIG_FB_MXC_EINK_PANEL=y
CONFIG_FB_MXC_EINK_V2_PANEL=y
CONFIG_LCD_CLASS_DEVICE=y
CONFIG_LCD_L4F00242T03=y
CONFIG_LCD_PLATFORM=y
CONFIG_BACKLIGHT_PWM=y
CONFIG_FRAMEBUFFER_CONSOLE=y
CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
CONFIG_LOGO=y
CONFIG_SOUND=y
CONFIG_SND=y
CONFIG_SND_USB_AUDIO=m
CONFIG_SND_SOC=y
CONFIG_SND_IMX_SOC=y
CONFIG_SND_SOC_EUKREA_TLV320=y
CONFIG_SND_SOC_IMX_WM8960=y
CONFIG_SND_SOC_IMX_SII902X=y
CONFIG_SND_SOC_IMX_WM8958=y
CONFIG_SND_SOC_IMX_CS42888=y
CONFIG_SND_SOC_IMX_WM8962=y
CONFIG_SND_SOC_IMX_SGTL5000=y
CONFIG_SND_SOC_IMX_MQS=y
CONFIG_SND_SOC_IMX_SPDIF=y
CONFIG_SND_SOC_IMX_MC13783=y
CONFIG_SND_SOC_IMX_SI476X=y
CONFIG_SND_SOC_IMX_HDMI=y
CONFIG_USB=y
CONFIG_USB_OTG_WHITELIST=y
CONFIG_USB_OTG_FSM=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_EHCI_MXC=y
CONFIG_USB_HCD_TEST_MODE=y
CONFIG_USB_ACM=m
CONFIG_USB_STORAGE=y
CONFIG_USB_CHIPIDEA=y
CONFIG_USB_CHIPIDEA_UDC=y
CONFIG_USB_CHIPIDEA_HOST=y
CONFIG_USB_SERIAL=m
CONFIG_USB_SERIAL_GENERIC=y
CONFIG_USB_SERIAL_FTDI_SIO=m
CONFIG_USB_SERIAL_OPTION=m
CONFIG_USB_EHSET_TEST_FIXTURE=y
CONFIG_NOP_USB_XCEIV=y
CONFIG_USB_MXS_PHY=y
CONFIG_USB_GADGET=y
CONFIG_USB_CONFIGFS=m
CONFIG_USB_CONFIGFS_SERIAL=y
CONFIG_USB_CONFIGFS_ACM=y
CONFIG_USB_CONFIGFS_OBEX=y
CONFIG_USB_CONFIGFS_NCM=y
CONFIG_USB_CONFIGFS_ECM=y
CONFIG_USB_CONFIGFS_ECM_SUBSET=y
CONFIG_USB_CONFIGFS_RNDIS=y
CONFIG_USB_CONFIGFS_EEM=y
CONFIG_USB_CONFIGFS_MASS_STORAGE=y
CONFIG_USB_CONFIGFS_F_LB_SS=y
CONFIG_USB_CONFIGFS_F_FS=y
CONFIG_USB_ZERO=m
CONFIG_USB_ETH=m
CONFIG_USB_G_NCM=m
CONFIG_USB_GADGETFS=m
CONFIG_USB_MASS_STORAGE=m
CONFIG_USB_G_SERIAL=m
CONFIG_USB_SERIAL_CH341=m
CONFIG_USB_SERIAL_CP210X=m
CONFIG_MMC=y
CONFIG_MMC_SDHCI=y
CONFIG_MMC_SDHCI_PLTFM=y
CONFIG_MMC_SDHCI_ESDHC_IMX=y
CONFIG_MXC_IPU=y
CONFIG_MXC_IPU_V3_PRE=y
CONFIG_MXC_GPU_VIV=y
CONFIG_MXC_SIM=y
CONFIG_MXC_MIPI_CSI2=y
CONFIG_MXC_HDMI_CEC=y
CONFIG_NEW_LEDS=y
CONFIG_LEDS_CLASS=y
CONFIG_LEDS_GPIO=y
CONFIG_LEDS_TRIGGERS=y
CONFIG_LEDS_TRIGGER_TIMER=y
CONFIG_LEDS_TRIGGER_ONESHOT=y
CONFIG_LEDS_TRIGGER_HEARTBEAT=y
CONFIG_LEDS_TRIGGER_BACKLIGHT=y
CONFIG_LEDS_TRIGGER_GPIO=y
CONFIG_RTC_CLASS=y
CONFIG_RTC_INTF_DEV_UIE_EMUL=y
CONFIG_RTC_DRV_MC13XXX=y
CONFIG_RTC_DRV_MXC=y
CONFIG_RTC_DRV_SNVS=y
CONFIG_DMADEVICES=y
CONFIG_MXC_PXP_V2=y
CONFIG_MXC_PXP_V3=y
CONFIG_IMX_SDMA=y
CONFIG_MXS_DMA=y
CONFIG_DMATEST=m
CONFIG_STAGING=y
CONFIG_STAGING_MEDIA=y
# CONFIG_IOMMU_SUPPORT is not set
CONFIG_IIO=y
CONFIG_IMX7D_ADC=y
CONFIG_VF610_ADC=y
CONFIG_PWM=y
CONFIG_PWM_IMX=y
CONFIG_EXT2_FS=y
CONFIG_EXT2_FS_XATTR=y
CONFIG_EXT2_FS_POSIX_ACL=y
CONFIG_EXT2_FS_SECURITY=y
CONFIG_EXT3_FS=y
CONFIG_EXT3_FS_POSIX_ACL=y
CONFIG_EXT3_FS_SECURITY=y
CONFIG_EXT4_FS=y
CONFIG_EXT4_FS_POSIX_ACL=y
CONFIG_EXT4_FS_SECURITY=y
CONFIG_QUOTA=y
CONFIG_QUOTA_NETLINK_INTERFACE=y
# CONFIG_PRINT_QUOTA_WARNING is not set
CONFIG_AUTOFS4_FS=y
CONFIG_FUSE_FS=y
CONFIG_ISO9660_FS=m
CONFIG_JOLIET=y
CONFIG_ZISOFS=y
CONFIG_UDF_FS=m
CONFIG_MSDOS_FS=m
CONFIG_VFAT_FS=y
CONFIG_TMPFS=y
CONFIG_JFFS2_FS=y
CONFIG_UBIFS_FS=y
CONFIG_NFS_FS=y
CONFIG_NFS_V3_ACL=y
CONFIG_NFS_V4=y
CONFIG_ROOT_NFS=y
CONFIG_NLS_DEFAULT="cp437"
CONFIG_NLS_CODEPAGE_437=y
CONFIG_FAT_DEFAULT_IOCHARSET="utf8"
CONFIG_NLS_ASCII=y
CONFIG_NLS_ISO8859_1=y
CONFIG_NLS_ISO8859_15=m
CONFIG_NLS_UTF8=y
CONFIG_DEBUG_FS=y
CONFIG_MAGIC_SYSRQ=y
# CONFIG_SCHED_DEBUG is not set
# CONFIG_DEBUG_BUGVERBOSE is not set
# CONFIG_FTRACE is not set
CONFIG_SECURITYFS=y
CONFIG_CRYPTO_USER=y
CONFIG_CRYPTO_TEST=m
CONFIG_CRYPTO_CTS=y
CONFIG_CRYPTO_LRW=y
CONFIG_CRYPTO_XTS=y
CONFIG_CRYPTO_MD4=y
CONFIG_CRYPTO_MD5=y
CONFIG_CRYPTO_MICHAEL_MIC=y
CONFIG_CRYPTO_RMD128=y
CONFIG_CRYPTO_RMD160=y
CONFIG_CRYPTO_RMD256=y
CONFIG_CRYPTO_RMD320=y
CONFIG_CRYPTO_SHA512=y
CONFIG_CRYPTO_TGR192=y
CONFIG_CRYPTO_WP512=y
CONFIG_CRYPTO_BLOWFISH=y
CONFIG_CRYPTO_CAMELLIA=y
CONFIG_CRYPTO_DES=y
CONFIG_CRYPTO_TWOFISH=y
# CONFIG_CRYPTO_ANSI_CPRNG is not set
CONFIG_CRYPTO_DEV_FSL_CAAM=y
CONFIG_CRYPTO_DEV_FSL_CAAM_SM=y
CONFIG_CRYPTO_DEV_FSL_CAAM_SM_TEST=y
CONFIG_CRYPTO_DEV_FSL_CAAM_SECVIO=y
CONFIG_CRYPTO_DEV_MXS_DCP=y
CONFIG_CRC_CCITT=m
CONFIG_CRC_T10DIF=y
CONFIG_CRC7=m
CONFIG_LIBCRC32C=m
CONFIG_FONTS=y
CONFIG_FONT_8x8=y
CONFIG_FONT_8x16=y
内核编译步骤:
#使用Yocto SDK里的GCC 5.3.0交叉编译器编译出厂Linux源码,可不用指定ARCH等,直接执行Make
source /opt/fsl-imx-x11/4.1.15-2.1.0/environment-setup-cortexa7hf-neon-poky-linux-gnueabi
#!/bin/bash
#编译前先清除
make distclean
#配置defconfig文件
make imx_v7_defconfig -j 16
#开始编译zImage
make zImage -j 16
设备树编译:
#NandFlash类型核心板
#编译正点原子各种显示设备的设备树,若用户没有屏,
#启动时默认会选择imx6ull-14x14-nand-4.3-480x272-c.dtb加载
make imx6ull-14x14-nand-10.1-1280x800-c.dtb
make imx6ull-14x14-nand-7-1024x600-c.dtb
make imx6ull-14x14-nand-7-800x480-c.dtb
make imx6ull-14x14-nand-4.3-800x480-c.dtb
make imx6ull-14x14-nand-4.3-480x272-c.dtb
make imx6ull-14x14-nand-vga.dtb
make imx6ull-14x14-nand-hdmi.dtb
内核驱动模块编译
#编译内核模块
make modules -j 16
#在当前目录下新建一个tmp目录,用于存放编译后的目标文件
if [ ! -e "./tmp" ]; then
mkdir tmp
fi
rm -rf tmp/*
make modules_install INSTALL_MOD_PATH=tmp
cd tmp/lib/modules
tar -jcvf ../../modules.tar.bz2 .
cd -
rm -rf tmp/lib
#拷贝zImage到tmp目录下
cp arch/arm/boot/zImage tmp
#拷贝所有编译的设备树文件到当前的tmp目录下
cp arch/arm/boot/dts/imx6ull*.dtb tmp
echo "编译完成,请查看当前目录下的tmp文件夹查看编译好的目标文件"
驱动移植
USB 转串口驱动修改
模块加载 USB 转串口 option 驱动程序后,会在/dev 目录下创建 ttyUSB0、ttyUSB1 和 ttyUSB2 等设备文件。以下介绍如何将 USB 转串口 option 驱动程序移植到 Linux 操作系统中。
移植的第一步,找到你的4G模块的usb的VID和PID添加进去。
为了识别模块,需将模块的 VID 和 PID 信息添加到[KERNEL]/drivers/usb/serial/option.c 文件中,对应的 VID 和 PID 。
以EC25列模块为例:高于2.6.30 的 Linux 内核版本,可在[KERNEL]/drivers/usb/serial/option.c 文件中添加以下语句:
static const struct usb_device_id option_ids[] = {
#if 1 //Added by Quectel
{ USB_DEVICE(0x2C7C, 0x0125) },
#endif
我的EC800模块的PID和VID是0x2c7c,0x6002。
/* EC20,EC800 4G*/
#define QUECTEL_VENDOR_ID 0x2C7C
#define QUECTEL_PRODUCT_EC20 0X0125
#define QUECTEL_PRODUCT_EC800 0x6002
static const struct usb_device_id option_ids[] = {
{ USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC20)},/* EC20*/
{ USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC800)},/* EC800*/
{ USB_DEVICE(GOSUNCN_VENDOR_ID, GOSUNCN_PRODUCT_0117)},/* ME3630-w */
{ USB_DEVICE(GOSUNCN_VENDOR_ID, GOSUNCN_PRODUCT_0199)},/* ME3630-w */
{ USB_DEVICE(GOSUNCN_VENDOR_ID, GOSUNCN_PRODUCT_1476)},/* ME3630-w */
使用 USBNet 驱动
接下来配置使模块的所有 USB 接口均绑定 USB 转串口 option 驱动程序,导致 USBNet 驱动程序接口无法工作。用户可以添加以下语句来防止 USBNet 驱动程序接口绑定 USB 转串口 option 驱动程序。
static int option_probe(struct usb_serial *serial,
const struct usb_device_id *id)
{
struct usb_interface_descriptor *iface_desc =
&serial->interface->cur_altsetting->desc;
struct usb_device_descriptor *dev_desc = &serial->dev->descriptor;
const struct option_blacklist_info *blacklist;
/* GOSUNCN 4G modems */
printk("idVendor=%x, idProduct=%x, bInterfaceNumber =%d\r\n",
serial->dev->descriptor.idVendor,
serial->dev->descriptor.idProduct,
serial->interface->cur_altsetting->desc. bInterfaceNumber);
//..........
if (dev_desc->idVendor == cpu_to_le16(0x2c7C) &&
iface_desc->bInterfaceNumber >= 4)
return -ENODEV;
if (serial->dev->descriptor.idVendor == cpu_to_le16(0x2C7C)) {
__u16 idProduct = le16_to_cpu(serial->dev->descriptor.idProduct);
struct usb_interface_descriptor *intf = &serial->interface->cur_altsetting->desc;
if (intf->bInterfaceClass != 0xFF || intf->bInterfaceSubClass == 0x42) {
//ECM, RNDIS, NCM, MBIM, ACM, UAC, ADB
return -ENODEV;
}
if ((idProduct&0xF000) == 0x0000) {
//MDM interface 4 is QMI
if (intf->bInterfaceNumber == 4 && intf->bNumEndpoints == 3
&& intf->bInterfaceSubClass==0xFF && intf->bInterfaceProtocol == 0xFF){
return -ENODEV;
}
}
}
/* Store the blacklist info so we can use it during attach. */
usb_set_serial_data(serial, (void *)blacklist);
return 0;
}
添加零包机制
根据 USB 协议的要求,通过添加如下语句在 bulk-out 传输过程中添加处理零包的机制:
高于 2.6.34 的 Linux 内核版本,需在[KERNEL]/drivers/usb/serial/usb_wwan.c 文件中添加以下语句。低于 2.6.35 的 Linux 内核版本,需在[KERNEL]/drivers/usb/serial/option.c 文件中添加。
static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port,
int endpoint,
int dir, void *ctx, char *buf, int len,
void (*callback) (struct urb *))
{
struct usb_serial *serial = port->serial;
struct urb *urb;
urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */
if (!urb)
return NULL;
usb_fill_bulk_urb(urb, serial->dev,
usb_sndbulkpipe(serial->dev, endpoint) | dir,
buf, len, callback, ctx);
if (dir == USB_DIR_OUT) {
struct usb_device_descriptor *desc = &serial->dev->descriptor;
if (desc->idVendor == cpu_to_le16(0x05C6) && desc->idProduct == cpu_to_le16(0x9090))
urb->transfer_flags |= URB_ZERO_PACKET;
if (desc->idVendor == cpu_to_le16(0x05C6) && desc->idProduct == cpu_to_le16(0x9003))
urb->transfer_flags |= URB_ZERO_PACKET;
if (desc->idVendor == cpu_to_le16(0x05C6) && desc->idProduct == cpu_to_le16(0x9215))
urb->transfer_flags |= URB_ZERO_PACKET;
if (desc->idVendor == cpu_to_le16(0x2C7C))
urb->transfer_flags |= URB_ZERO_PACKET;
}
return urb;
}
添加 Reset-resume 机制
部分 USB 主机控制器或 USB hub 在 MCU 进入 Suspend/Sleep(挂起/睡眠)模式时会发生掉电或复位,并且在 MCU 退出 Suspend/Sleep 模式后不能使模块恢复。需要通过添加以下语句来启用 reset-resume机制。高于 3.4 的 Linux 内核版本,需在[KERNEL]/drivers/usb/serial/option.c 文件中添加以下语句。
static struct usb_serial_driver option_1port_device = {
……
#ifdef CONFIG_PM
.suspend = usb_wwan_suspend,
.resume = usb_wwan_resume,
#if 1 //Added by Quectel
.reset_resume = usb_wwan_resume,
#endif
#endif
};
拨号测试,无论使用ppp模式或者是ECM模式,都是需要拨号的。所谓的拨号直观上看就是通过串口操作AT指令,让模块联网的过程。所以开头的第一步,让能识别出ttyUSB0,ttyUSB1等是必须的。 以下是拨号的AT指令日志。
正式用建议用官方提供的拨号程序quectel-CM即可,简单且功能强大。
拨号源码下载
附上拨号源码应用程序quectel-CM的下载地址,可以直接正式用。该应用程序会自动查找设备并使用相应的驱动自动拨号:
拨号源码下载地址:
https://download.csdn.net/download/qq8864/88050116
以下的拨号日志:
root@ATK-IMX6U:~# ls
driver quectel-CM shell
root@ATK-IMX6U:~# ./quectel-CM
[07-22_07:32:47:407] QConnectManager_Linux_V1.6.4
[07-22_07:32:47:410] Find /sys/bus/usb/devices/1-1 idVendor=0x2c7c idProduct=0x6002, bus=0x001, dev=0x005
[07-22_07:32:47:412] Auto find qmichannel = /dev/ttyUSB1
[07-22_07:32:47:412] Auto find usbnet_adapter = usb0
[07-22_07:32:47:413] netcard driver = cdc_ether, driver version = 22-Aug-2005
[07-22_07:32:47:416] Modem works in ECM_RNDIS_NCM mode
[07-22_07:32:47:436] atc_fd = 7
[07-22_07:32:47:438] AT> ATE0Q0V1
[07-22_07:32:47:441] AT< ATE0Q0V1
[07-22_07:32:47:443] AT< OK
[07-22_07:32:48:444] AT> AT+QCFG="usbnet"
[07-22_07:32:48:447] AT< +QCFG: "usbnet",1
[07-22_07:32:48:447] AT< OK
[07-22_07:32:48:447] AT> AT+QNETDEVCTL=?
[07-22_07:32:48:449] AT< +QNETDEVCTL: (0-3),(1-15),(0-1)
[07-22_07:32:48:449] AT< OK
[07-22_07:32:48:450] AT> AT+CGREG=2
[07-22_07:32:48:451] AT< OK
[07-22_07:32:48:451] AT> AT+CEREG=2
[07-22_07:32:48:453] AT< OK
[07-22_07:32:48:454] AT> AT+C5GREG=2
[07-22_07:32:48:456] AT< ERROR
[07-22_07:32:48:456] AT> AT+QNETDEVSTATUS=?
[07-22_07:32:48:458] AT< ERROR
[07-22_07:32:48:458] AT> AT+QCFG="NAT"
[07-22_07:32:48:460] AT< +QCFG: "nat",1
[07-22_07:32:48:460] AT< OK
[07-22_07:32:48:461] AT> AT+CGMR
[07-22_07:32:48:463] AT< EC800MCNLCR06A05M04
[07-22_07:32:48:463] AT< OK
[07-22_07:32:48:463] AT> AT+CPIN?
[07-22_07:32:48:465] AT< +CPIN: READY
[07-22_07:32:48:465] AT< OK
[07-22_07:32:48:465] AT> AT+QCCID
[07-22_07:32:48:468] AT< +QCCID: 898604C6062260003592
[07-22_07:32:48:468] AT< OK
[07-22_07:32:48:468] requestGetICCID 898604C6062260003592
[07-22_07:32:48:468] AT> AT+CIMI
[07-22_07:32:48:471] AT< 460084674003592
[07-22_07:32:48:471] AT< OK
[07-22_07:32:48:471] requestGetIMSI 460084674003592
[07-22_07:32:48:471] AT> AT+QICSGP=1
[07-22_07:32:48:474] AT< +QICSGP: 3,"","","",0
[07-22_07:32:48:474] AT< OK
[07-22_07:32:48:474] requestGetProfile[1] ///0/IPV4V6
[07-22_07:32:48:474] AT> AT+COPS=3,0;+COPS?;+COPS=3,1;+COPS?;+COPS=3,2;+COPS?
[07-22_07:32:48:478] AT< +COPS: 0,0,"CHINA MOBILE",7
[07-22_07:32:48:478] AT< +COPS: 0,1,"CMCC",7
[07-22_07:32:48:478] AT< +COPS: 0,2,"46000",7
[07-22_07:32:48:478] AT< OK
[07-22_07:32:48:478] AT> AT+CEREG?
[07-22_07:32:48:480] AT< +CEREG: 2,1,"4978","EF555C2",7
[07-22_07:32:48:481] AT< OK
[07-22_07:32:48:481] AT> at+cops?
[07-22_07:32:48:483] AT< +COPS: 0,2,"46000",7
[07-22_07:32:48:483] AT< OK
[07-22_07:32:48:483] AT> at+qeng="servingcell"
[07-22_07:32:48:492] AT< +QENG: "servingcell","NOCONN","LTE","TDD",460,00,EF555C2,316,41134,41,5,5,4978,-86,-3,-81,15,40
[07-22_07:32:48:492] AT< OK
[07-22_07:32:48:492] AT> AT+QNETDEVCTL?
[07-22_07:32:48:495] AT< +QNETDEVCTL: 0,0,0,0
[07-22_07:32:48:495] AT< OK
[07-22_07:32:48:496] ifconfig usb0 0.0.0.0
[07-22_07:32:48:547] ifconfig usb0 down
[07-22_07:32:48:607] AT> AT+CGACT?
[07-22_07:32:48:611] AT< +CGACT: 1,1
[07-22_07:32:48:611] AT< OK
[07-22_07:32:48:611] AT> AT+QNETDEVCTL=1,1,1
[07-22_07:32:50:613] AT< OK
[07-22_07:32:50:614] AT> AT+CGPADDR=1
[07-22_07:32:50:621] AT< +CGPADDR: 1,"10.68.39.96","::0:0:0:0:0:0:0"
[07-22_07:32:50:621] AT< OK
[07-22_07:32:50:621] requestGetIPAddress 10.68.39.96
[07-22_07:32:50:622] AT> at+cops?
[07-22_07:32:50:624] AT< +COPS: 0,2,"46000",7
[07-22_07:32:50:624] AT< OK
[07-22_07:32:50:625] AT> at+qeng="servingcell"
[07-22_07:32:50:633] AT< +QENG: "servingcell","NOCONN","LTE","TDD",460,00,EF555C2,316,41134,41,5,5,4978,-87,-4,-81,14,40
[07-22_07:32:50:633] AT< OK
[07-22_07:32:50:634] AT> AT+QNETDEVCTL?
[07-22_07:32:50:635] AT< +QNETDEVSTATUS: 1
[07-22_07:32:50:636] AT< +QNETDEVCTL: 1,1,1,1
[07-22_07:32:50:636] AT< OK
[07-22_07:32:50:637] AT> AT+CGACT?
[07-22_07:32:50:640] AT< +CGACT: 1,1
[07-22_07:32:50:640] AT< OK
[07-22_07:32:50:641] ifconfig usb0 up
[07-22_07:32:50:701] busybox udhcpc -f -n -q -t 5 -i usb0
[07-22_07:32:50:741] udhcpc (v1.24.1) started
[07-22_07:32:50:947] Sending discover...
[07-22_07:32:51:007] Sending select for 10.68.39.96...
[07-22_07:32:51:067] Lease of 10.68.39.96 obtained, lease time 86400
[07-22_07:32:51:227] /etc/udhcpc.d/50default: Adding DNS 120.196.165.7
[07-22_07:32:51:228] /etc/udhcpc.d/50default: Adding DNS 221.179.38.7
[07-22_07:32:51:257] AT> at+cops?
[07-22_07:32:51:260] AT< +COPS: 0,2,"46000",7
[07-22_07:32:51:261] AT< OK
[07-22_07:32:51:261] AT> at+qeng="servingcell"
[07-22_07:32:51:267] AT< +QENG: "servingcell","NOCONN","LTE","TDD",460,00,EF555C2,316,41134,41,5,5,4978,-87,-3,-81,15,40
[07-22_07:32:51:267] AT< OK
[07-22_07:32:51:267] AT> AT+QNETDEVCTL?
[07-22_07:32:51:270] AT< +QNETDEVCTL: 1,1,1,1
[07-22_07:32:51:270] AT< OK
[07-22_07:32:51:270] AT> AT+CGACT?
[07-22_07:32:51:274] AT< +CGACT: 1,1
[07-22_07:32:51:274] AT< OK
[07-22_07:33:06:288] AT> at+cops?
[07-22_07:33:06:291] AT< +COPS: 0,2,"46000",7
[07-22_07:33:06:291] AT< OK
[07-22_07:33:06:291] AT> at+qeng="servingcell"
[07-22_07:33:06:299] AT< +QENG: "servingcell","NOCONN","LTE","TDD",460,00,EF555C2,316,41134,41,5,5,4978,-87,-3,-81,14,40
[07-22_07:33:06:299] AT< OK
[07-22_07:33:06:299] AT> AT+QNETDEVCTL?
[07-22_07:33:06:302] AT< +QNETDEVCTL: 1,1,1,1
[07-22_07:33:06:302] AT< OK
[07-22_07:33:06:302] AT> AT+CGACT?
[07-22_07:33:06:306] AT< +CGACT: 1,1
[07-22_07:33:06:306] AT< OK
[07-22_07:33:21:317] AT> at+cops?
[07-22_07:33:21:320] AT< +COPS: 0,2,"46000",7
[07-22_07:33:21:321] AT< OK
[07-22_07:33:21:321] AT> at+qeng="servingcell"
[07-22_07:33:21:328] AT< +QENG: "servingcell","NOCONN","LTE","TDD",460,00,EF555C2,316,41134,41,5,5,4978,-87,-3,-81,15,39
[07-22_07:33:21:328] AT< OK
[07-22_07:33:21:328] AT> AT+QNETDEVCTL?
[07-22_07:33:21:331] AT< +QNETDEVCTL: 1,1,1,1
[07-22_07:33:21:331] AT< OK
[07-22_07:33:21:331] AT> AT+CGACT?
[07-22_07:33:21:335] AT< +CGACT: 1,1
[07-22_07:33:21:335] AT< OK
[07-22_07:33:36:346] AT> at+cops?
[07-22_07:33:36:349] AT< +COPS: 0,2,"46000",7
[07-22_07:33:36:349] AT< OK
[07-22_07:33:36:349] AT> at+qeng="servingcell"
[07-22_07:33:36:356] AT< +QENG: "servingcell","NOCONN","LTE","TDD",460,00,EF555C2,316,41134,41,5,5,4978,-87,-3,-81,15,39
[07-22_07:33:36:356] AT< OK
[07-22_07:33:36:357] AT> AT+QNETDEVCTL?
[07-22_07:33:36:359] AT< +QNETDEVCTL: 1,1,1,1
[07-22_07:33:36:360] AT< OK
[07-22_07:33:36:360] AT> AT+CGACT?
[07-22_07:33:36:363] AT< +CGACT: 1,1
[07-22_07:33:36:364] AT< OK
[07-22_07:33:51:366] AT> at+cops?
[07-22_07:33:51:369] AT< +COPS: 0,2,"46000",7
[07-22_07:33:51:369] AT< OK
[07-22_07:33:51:370] AT> at+qeng="servingcell"
[07-22_07:33:51:378] AT< +QENG: "servingcell","NOCONN","LTE","TDD",460,00,EF555C2,316,41134,41,5,5,4978,-88,-3,-81,14,39
[07-22_07:33:51:379] AT< OK
[07-22_07:33:51:379] AT> AT+QNETDEVCTL?
[07-22_07:33:51:381] AT< +QNETDEVCTL: 1,1,1,1
[07-22_07:33:51:381] AT< OK
[07-22_07:33:51:382] AT> AT+CGACT?
[07-22_07:33:51:385] AT< +CGACT: 1,1
[07-22_07:33:51:385] AT< OK
[07-22_07:34:06:393] AT> at+cops?
[07-22_07:34:06:396] AT< +COPS: 0,2,"46000",7
[07-22_07:34:06:397] AT< OK
[07-22_07:34:06:397] AT> at+qeng="servingcell"
[07-22_07:34:06:404] AT< +QENG: "servingcell","NOCONN","LTE","TDD",460,00,EF555C2,316,41134,41,5,5,4978,-88,-4,-81,14,39
[07-22_07:34:06:405] AT< OK
[07-22_07:34:06:405] AT> AT+QNETDEVCTL?
[07-22_07:34:06:408] AT< +QNETDEVCTL: 1,1,1,1
[07-22_07:34:06:408] AT< OK
[07-22_07:34:06:408] AT> AT+CGACT?
[07-22_07:34:06:412] AT< +CGACT: 1,1
[07-22_07:34:06:412] AT< OK
需要注意的问题是,上述编译内核和驱动时,把这几个驱动模块usbserial.ko,usb_wwan.ko,option.ko等都单独编译成驱动模块了,默认开机启动时并没有加载。
所以如果上述移植都ok,但是插上usb的4G模块后还不认,可以lsmod指令看下有没加载这几个驱动模块。测试可进入/lib/modules/4.1.15-g3dc0a4b/kernel/drivers/usb/serial/目录下,通过insmod命令加载驱动到内核系统中。注意,这几个有先后依赖顺序,必须先insmod usbserial.ko,再 usb_wwan.ko,最后加载option.ko.
以上操作后,应该能够在/dev/目录下看到ttyUSB0等这几个设备节点。
可通过串口命令测试下AT指令,看看模块是否有响应。
通过串口发送AT命令
echo -e "AT+QCFG=\"usbnet\",0\r\n" > /dev/ttyUSB2 #设定模式
或者使用mincom串口打开com口,看下模块的AT指令输出。
网关路由配置
如果IP都已经自动获取到了还是无法联网,则需检查下路由对不对。
因为你的板子上可能用了以太网口,走的路由限制了。可以以下改下默认网关路由。
ip route show
route del default
route add default dev usb0
设置自启动脚本
在Linux中,rc.local是一个启动脚本,位于/etc/rc.d/目录或/etc/init.d/目录下。它用于在系统启动时执行自定义命令或脚本。rc.local文件中的命令或脚本会在系统启动的最后阶段执行,可以用来执行一些需要在系统启动时运行的自定义任务。这些任务可以包括启动特定的服务、设置环境变量、挂载文件系统等。
rc.local文件的作用类似于其他Linux发行版中的/etc/rc.local文件,但在一些发行版中,如Ubuntu,已经不再默认提供rc.local文件。如果需要使用rc.local文件,可以自行创建并设置权限。
需要注意的是,rc.local文件中的命令或脚本应该是可执行的,并且应该在文件的末尾添加"exit 0"以确保正常退出。
在/etc/init.d/rc.local内容如下:
#! /bin/sh
### BEGIN INIT INFO
# Provides: rc.local
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Run /etc/rc.local if it exist
### END INIT INFO
PATH=/sbin:/usr/sbin:/bin:/usr/bin
do_start() {
if [ -x /etc/rc.local ]; then
echo -n "Running local boot scripts (/etc/rc.local)"
/etc/rc.local
[ $? = 0 ] && echo "." || echo "error"
return $ES
fi
}
case "$1" in
start)
do_start
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop)
;;
*)
echo "Usage: $0 start|stop" >&2
exit 3
;;
esac
在/etc/rc.local内容如下:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
echo 30000 > /proc/sys/vm/min_free_kbytes
source /etc/profile
/opt/QDesktop >/dev/null 2>&1 &
/etc/myuser.sh
exit 0
自定义的myuser.sh脚本,内容如下,后续有需要自定义开机启动的内容都可以在这里添加。
#!/bin/bash
echo "=================user define shell exec..."
insmod /lib/modules/$(uname -r)/kernel/drivers/usb/serial/usbserial.ko
insmod /lib/modules/$(uname -r)/kernel/drivers/usb/serial/usb_wwan.ko
insmod /lib/modules/$(uname -r)/kernel/drivers/usb/serial/option.ko
ifconfig eth0 192.168.21.96 netmask 255.255.255.0
route add gw 192.168.21.1
route del default
route add default dev usb0
quectel-CM &
其他资源
嵌入式Linux驱动开发初级-内核模块编译方法_芬达在学习的博客-CSDN博客
https://www.cnblogs.com/dream397/p/13984263.html
Linux内核模块(Module)的单独编译 - 知乎
Linux设备驱动之IIO子系统——IIO框架及IIO数据结构
iio子系统框架分析_chongyuzhao的博客-CSDN博客
一文带你深入了解Linux IIO 子系统_iio框架_Linux加油站的博客-CSDN博客
linux kernel iio 架构
https://i.vycc.cn/article/1164591.html
FS4412开发板使用Linux IIO驱动框架实现ADC驱动 - 代码先锋网
Linux route 命令_mayue_csdn的博客-CSDN博客文章来源:https://www.toymoban.com/news/detail-582862.html
正点原子IMX6U仓库 (GuangzhouXingyi) - Gitee.com文章来源地址https://www.toymoban.com/news/detail-582862.html
到了这里,关于嵌入式linux驱动开发之移远4G模块EC800驱动移植指南的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!