这里会显示出您选择的修订版和当前版本之间的差别。
jaysnote:kernel_compile [2019/12/11 21:38] lijie 已恢复为旧版 (2019/04/26 17:59) |
jaysnote:kernel_compile [2021/06/22 23:14] |
||
---|---|---|---|
行 1: | 行 1: | ||
- | < | ||
- | # GAC-350 Kernel Compile | ||
- | ## 命令 | ||
- | |||
- | * 单独编译Kernel | ||
- | |||
- | ```shell | ||
- | ./build.sh -p sun50iw1p1_debian -m kernel -k linux-3.10 | ||
- | ``` | ||
- | |||
- | * 清除 | ||
- | |||
- | ``` | ||
- | ./build.sh -p sun50iw1p1_debian -m distclean -k linux-3.10 | ||
- | ``` | ||
- | |||
- | * menuconfig | ||
- | |||
- | ``` | ||
- | sudo make ARCH=arm64 CROSS_COMPILE=../ | ||
- | ``` | ||
- | |||
- | * 拷贝 | ||
- | |||
- | ``` | ||
- | scp jay@10.28.3.204:/ | ||
- | ``` | ||
- | |||
- | * 更新kernel | ||
- | |||
- | ```bash | ||
- | #/bin/bash | ||
- | |||
- | scp jay@10.28.3.204:/ | ||
- | |||
- | [ -f boot.img ] && { | ||
- | |||
- | sudo dd if=boot.img of=/ | ||
- | sync | ||
- | echo " | ||
- | exit 0 | ||
- | } | ||
- | |||
- | echo " | ||
- | exit 1 | ||
- | ``` | ||
- | |||
- | |||
- | ## 驱动 | ||
- | |||
- | ### 摄像头(ov5640.ko vfl2.ko ) | ||
- | |||
- | 需要修改vfe.c | ||
- | |||
- | ```c | ||
- | // | ||
- | static int vidioc_g_input(struct file *file, void *priv, unsigned int *i) { | ||
- | struct vfe_dev *dev = video_drvdata(file); | ||
- | |||
- | //*i = dev-> | ||
- | *i = 0; | ||
- | return 0; | ||
- | } | ||
- | ``` | ||
- | |||
- | ```c | ||
- | // | ||
- | static int vidioc_enum_input(struct file *file, void *priv, struct v4l2_input *inp) { | ||
- | | ||
- | if (inp-> | ||
- | | ||
- | | ||
- | } | ||
- | | ||
- | if (0 == dev-> | ||
- | | ||
- | | ||
- | | ||
- | } | ||
- | | ||
- | | ||
- | } | ||
- | ``` | ||
- | |||
- | > Device Drivers > Multimedia support > V4L platform devices | ||
- | |||
- | ![v4l2 编译选项](http:// | ||
- | |||
- | ### GPIO libc(built in) | ||
- | |||
- | > Device Drivers > GPIO Support | ||
- | |||
- | ![GPIO 支持](http:// | ||
- | |||
- | ### SMT32 I2C& 开机动画(stm_s103.ko) | ||
- | |||
- | >Device Drivers > Staging drivers > Support for MXJ private driver | ||
- | |||
- | ![梦想加私有驱动](http:// | ||
- | |||
- | ### USB Net(usbnet.ko asix.ko) | ||
- | |||
- | > Device Drivers > Network device support > USB Network Adapters | ||
- | |||
- | ![](http:// | ||
- | |||
- | 同时直接干掉无线网卡支持。 | ||
- | |||
- | ### oui mac 和基于sid md5计算mac地址。 | ||
- | |||
- | * 接收用户传参,用以用户通过应用空间传递oui mac。 | ||
- | ```c | ||
- | // | ||
- | static char *user_mac | ||
- | static bool user_flag = true; | ||
- | module_param(user_mac, | ||
- | ``` | ||
- | * 如果用户没有传递参数,则通过 sid md5 随机mac; | ||
- | ```c | ||
- | // | ||
- | |||
- | # | ||
- | //generate mac by hash cpuid | ||
- | void hash_gen_mac(u8 *mac){ | ||
- | |||
- | u32 data[16] = {0}; | ||
- | u32 hash[ 4] = {0}; | ||
- | |||
- | memset(hash, | ||
- | memset(data, | ||
- | |||
- | //1. fill chipid to data | ||
- | sunxi_get_soc_chipid((u8*)data); | ||
- | // | ||
- | |||
- | printk(KERN_INFO " | ||
- | |||
- | |||
- | //2. calc md5 | ||
- | md5_transform(hash, | ||
- | //hash[0] ^= hash[2]; | ||
- | //hash[1] ^= hash[3]; | ||
- | printk(KERN_INFO " | ||
- | |||
- | //3. fill mac | ||
- | memset(mac, 0, ETH_ALEN); | ||
- | |||
- | mac[0] = 0x06; // | ||
- | // | ||
- | memcpy(& | ||
- | } | ||
- | ``` | ||
- | |||
- | * 业务逻辑 | ||
- | ```c | ||
- | // | ||
- | user_flag=true; | ||
- | printk(KERN_INFO "asix: user mac address is %s", | ||
- | if(user_mac!=NULL&& | ||
- | for(i=0; | ||
- | buf[i]=0; | ||
- | if(user_mac[3*i]> | ||
- | buf[i]|=((user_mac[3*i]-' | ||
- | }else if(user_mac[3*i]> | ||
- | buf[i]|=((user_mac[3*i]-' | ||
- | }else if(user_mac[3*i]> | ||
- | buf[i]|=((user_mac[3*i]-' | ||
- | }else { | ||
- | user_flag=false; | ||
- | break; | ||
- | } | ||
- | if(user_mac[3*i+1]> | ||
- | buf[i]|=(user_mac[3*i+1]-' | ||
- | }else if(user_mac[3*i+1]> | ||
- | buf[i]|=(user_mac[3*i+1]-' | ||
- | }else if(user_mac[3*i+1]> | ||
- | buf[i]|=(user_mac[3*i+1]-' | ||
- | }else { | ||
- | user_flag=false; | ||
- | break; | ||
- | } | ||
- | |||
- | } | ||
- | }else { | ||
- | user_flag=false; | ||
- | } | ||
- | if(user_flag&& | ||
- | printk(KERN_INFO "asix: mac form user setting: | ||
- | }else { | ||
- | printk(KERN_INFO "asix: mac form user is null or wrong format. "); | ||
- | hash_gen_mac(buf); | ||
- | printk(KERN_INFO "asix: mac form chip id hash: %02x: | ||
- | } | ||
- | ``` | ||
- | |||
- | 并且需要使能`system info driver`。 | ||
- | |||
- | > Device Drivers > Character devices | ||
- | |||
- | ![系统信息](http:// | ||
- | |||
- | ### 显示(built-in) | ||
- | |||
- | > Device Drivers > Graphics support > Support for frame buffer devices > Video support for sunxi | ||
- | |||
- | ![](http:// | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | ### STM32& | ||
- | |||
- | **19:27 2018/7/31** | ||
- | |||
- | 更新为源码自带i2c通用驱动,并且更新速率为`100k` | ||
- | |||
- | > Device Drivers > I2C support | ||
- | |||
- | ![](http:// | ||
- | |||
- | |||
- | |||
- | ## fex | ||
- | |||
- | * http:// | ||
- | |||
- | </ |