用户工具

站点工具


jaysnote:kernel_compile

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

jaysnote:kernel_compile [2019/12/11 21:38]
lijie 已恢复为旧版 (2019/04/26 17:59)
jaysnote:kernel_compile [2021/06/22 23:14]
行 1: 行 1:
-<markdown> 
-# 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=../out/sun50iw1p1/debian/common/buildroot/external-toolchain/bin/aarch64-linux-gnu- menuconfig 
-    ``` 
- 
-* 拷贝 
- 
-    ``` 
-    scp jay@10.28.3.204:/home/jay/a64/linux-3.10/drivers/net/usb/* ./ 
-    ``` 
- 
-* 更新kernel 
- 
-    ```bash 
-    #/bin/bash 
- 
-    scp jay@10.28.3.204:/home/jay/a64_v4l2/linux-3.10/output/boot.img ./ 
- 
-    [ -f boot.img ] && { 
- 
-            sudo dd if=boot.img of=/dev/mmcblk0p6 bs=1M 
-            sync 
-            echo "update kernel succeed"  
-            exit 0  
-    } 
- 
-    echo "update kernel failed" 
-    exit 1 
-    ``` 
- 
- 
-## 驱动 
- 
-### 摄像头(ov5640.ko vfl2.ko ) 
- 
-需要修改vfe.c 
- 
-```c 
-//linux-3.10/drivers/media/platform/sunxi-vfe/vfe.c 
-static int vidioc_g_input(struct file *file, void *priv, unsigned int *i)  { 
-        struct vfe_dev *dev = video_drvdata(file); 
- 
-        //*i = dev->input; 
-        *i = 0; 
-        return 0; 
-} 
-``` 
- 
-```c 
-//linux-3.10/drivers/media/platform/sunxi-vfe/vfe.c 
-static int vidioc_enum_input(struct file *file, void *priv, struct v4l2_input *inp) { 
-         struct vfe_dev *dev = video_drvdata(file); 
-         if (inp->index > dev->dev_qty-1) { 
-                 vfe_err("input index(%d) > dev->dev_qty(%d)-1 invalid!\n", inp->index, dev->dev_qty); 
-                 return -EINVAL; 
-         } 
-         vidioc_s_input(file,priv,inp->index); 
-         if (0 == dev->device_valid_flag[inp->index]) { 
-                 vfe_err("input index(%d) > dev->dev_qty(%d)-1 invalid!, device_valid_flag[%d] = %d\n", 
-                         inp->index, dev->dev_qty,inp->index, dev->device_valid_flag[inp->index]); 
-                 return -EINVAL; 
-         } 
-         inp->type = V4L2_INPUT_TYPE_CAMERA; 
-         return 0; 
- } 
-``` 
- 
-> Device Drivers > Multimedia support > V4L platform devices 
- 
-![v4l2 编译选项](http://www.leconiot.com/md_res/jaysnote/kernel_compile/images/v4l2.png) 
- 
-### GPIO libc(built in) 
- 
-> Device Drivers > GPIO Support  
- 
-![GPIO 支持](http://www.leconiot.com/md_res/jaysnote/kernel_compile/images/gpio.png) 
- 
-### SMT32 I2C& 开机动画(stm_s103.ko) 
- 
->Device Drivers > Staging drivers > Support for MXJ private driver 
- 
-![梦想加私有驱动](http://www.leconiot.com/md_res/jaysnote/kernel_compile/images/mdp_driver.png) 
- 
-### USB Net(usbnet.ko asix.ko) 
- 
-> Device Drivers > Network device support > USB Network Adapters 
- 
-![](http://www.leconiot.com/md_res/jaysnote/kernel_compile/images/usb_net.png) 
- 
-同时直接干掉无线网卡支持。 
- 
-### oui mac 和基于sid md5计算mac地址。 
- 
-* 接收用户传参,用以用户通过应用空间传递oui mac。 
-```c 
-//inux-3.10/drivers/char/sunxi_sys_info/chipid-sunxi.c         
-static char *user_mac  = "00:00:00:00:00:00"; 
-static bool  user_flag = true; 
-module_param(user_mac,charp,S_IRUSR); 
-``` 
-* 如果用户没有传递参数,则通过 sid md5 随机mac; 
-```c 
-//inux-3.10/drivers/char/sunxi_sys_info/chipid-sunxi.c         
- 
- #include "linux/cryptohash.h" //for md5 
-//generate mac by hash cpuid 
-void hash_gen_mac(u8 *mac){ 
- 
-    u32 data[16] = {0}; 
-        u32 hash[ 4] = {0}; 
- 
-    memset(hash, 0, sizeof(hash)); 
-    memset(data, 0, sizeof(data)); 
- 
-        //1. fill chipid to data 
-        sunxi_get_soc_chipid((u8*)data); 
-    //memcpy(data, dat, len); 
- 
-        printk(KERN_INFO "hash_gen_mac chipid: %08x %08x %08x %08x", data[0], data[1], data[2], data[3]); 
- 
- 
-        //2. calc md5 
-    md5_transform(hash, data); 
-    //hash[0] ^= hash[2]; 
-    //hash[1] ^= hash[3]; 
-        printk(KERN_INFO "hash_gen_mac   hash: %08x %08x %08x %08x", hash[0], hash[1], hash[2], hash[3]); 
- 
-        //3. fill mac 
-    memset(mac, 0, ETH_ALEN); 
- 
-    mac[0] = 0x06; //((0x1<<2) & 0xfe | 0x02); //clr multicast, set local bit// 0x06:* 
-    //memcpy(&mac[1], hash, 5);  
-    memcpy(&mac[1], hash, ETH_ALEN); 
-} 
-``` 
- 
-* 业务逻辑 
-```c 
-//inux-3.10/drivers/char/sunxi_sys_info/chipid-sunxi.c         
-user_flag=true; 
-printk(KERN_INFO "asix: user mac address is %s",user_mac); 
-if(user_mac!=NULL&&strlen(user_mac)==17&&strcmp(user_mac,"00:00:00:00:00:00")!=0) { 
-        for(i=0;i<6;i++) { 
-                buf[i]=0; 
-                if(user_mac[3*i]>='0'&&user_mac[3*i]<='9') { 
-                        buf[i]|=((user_mac[3*i]-'0')*16); 
-                }else if(user_mac[3*i]>='a'&&user_mac[3*i]<='f') { 
-                        buf[i]|=((user_mac[3*i]-'a'+10)*16); 
-                }else if(user_mac[3*i]>='A'&&user_mac[3*i]<='F') { 
-                        buf[i]|=((user_mac[3*i]-'A'+10)*16); 
-                }else { 
-                        user_flag=false; 
-                        break; 
-                } 
-                if(user_mac[3*i+1]>='0'&&user_mac[3*i+1]<='9') { 
-                        buf[i]|=(user_mac[3*i+1]-'0'); 
-                }else if(user_mac[3*i+1]>='a'&&user_mac[3*i+1]<='f') { 
-                        buf[i]|=(user_mac[3*i+1]-'a'+10); 
-                }else if(user_mac[3*i+1]>='A'&&user_mac[3*i+1]<='F') { 
-                        buf[i]|=(user_mac[3*i+1]-'A'+10); 
-                }else { 
-                        user_flag=false; 
-                        break; 
-                } 
- 
-        } 
-}else { 
-        user_flag=false; 
-} 
-if(user_flag&&((buf[0]&0x0F)%2)==0) { 
-        printk(KERN_INFO "asix: mac form user setting:%02x:%02x:%02x:%02x:%02x:%02x", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]); 
-}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:%02x:%02x:%02x:%02x:%02x", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]); 
-} 
-``` 
- 
-并且需要使能`system info driver`。 
- 
-> Device Drivers > Character devices  
- 
-![系统信息](http://www.leconiot.com/md_res/jaysnote/kernel_compile/images/sys_info.png) 
- 
-### 显示(built-in) 
- 
-> Device Drivers > Graphics support > Support for frame buffer devices > Video support for sunxi 
- 
-![](http://www.leconiot.com/md_res/jaysnote/kernel_compile/images/disp2.png) 
- 
- 
- 
- 
- 
- 
- 
-### STM32&I2C更新 
- 
-**19:27 2018/7/31** 
- 
-更新为源码自带i2c通用驱动,并且更新速率为`100k` 
- 
-> Device Drivers > I2C support 
- 
-![](http://www.leconiot.com/md_res/jaysnote/kernel_compile/images/i2c_change.png) 
- 
- 
- 
-## fex 
- 
-*  http://linux-sunxi.org/Fex_Guide 
- 
-</markdown> 
jaysnote/kernel_compile.txt · 最后更改: 2021/06/22 23:14 (外部编辑)