用户工具

站点工具


jaysnote:kernel_compile

差别

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

到此差别页面的链接

两侧同时换到之前的修订记录 前一修订版
后一修订版
前一修订版
jaysnote:kernel_compile [2018/11/14 14:16]
jaylee
jaysnote:kernel_compile [2021/06/22 23:14] (当前版本)
行 1: 行 1:
 <markdown> <markdown>
-GAC-350 Kernel Compile+# Kernel Compile
  
 ## 命令 ## 命令
行 28: 行 28:
     ```     ```
  
-完整测试命令+更新kernel
  
-    ```shell +    ```bash 
-    t/usb/*.ko ./    ~/asix# scp jay@10.28.3.204:/home/jay/a64/linux-3.10/drivers/ne  +    #/bin/bash 
-     + 
-    asix.ko  cdc_ether.ko  mcs7830.ko  qf9700.ko  rtl8150.ko  usbnet.ko +    scp jay@10.28.3.204:/home/jay/a64_v4l2/linux-3.10/output/boot.img ./ 
-    root@350-c1-emmc ~/asix#     + 
-    root@350-c1-emmc ~/asix# ls +    [ -f boot.img && {
-    asix.ko  cdc_ether.ko  mcs7830.ko  qf9700.ko  rtl8150.ko  usbnet.ko +
-    root@350-c1-emmc ~/asix# lsmod +
-    root@350-c1-emmc ~/asix# rmmod asix +
-    root@350-c1-emmc ~/asix# rmmod usbnet +
-    root@350-c1-emmc ~/asix# lsmod +
-    root@350-c1-emmc ~/asix# dmesg -C +
-    root@350-c1-emmc ~/asix# insmod ./usbnet.ko  +
-    root@350-c1-emmc ~/asix# insmod ./asix.ko    +
-    root@350-c1-emmc ~/asix# dmesg -T +
-    [Thu Jun 14 15:26:27 2018] asix 1-1:1.0 eth0: register 'asix' at usb-sunxi-ehci-1, ASIX AX88772B USB 2.0 Ethernet, 02:00:00:00:00:00 +
-    [Thu Jun 14 15:26:27 2018usbcore: registered new interface driver asix +
-    root@350-c1-emmc ~/asix#  +
-    ```+
  
-* 更改boot+            sudo dd if=boot.img of=/dev/mmcblk0p6 bs=1M 
 +            sync 
 +            echo "update kernel succeed"  
 +            exit 0  
 +    }
  
-    ```powershell +    echo "update kernel failed" 
-    scp jay@10.28.3.204:/home/jay/a64_jay/linux-3.10/output/boot.img ./ +    exit 1
-    dd if=boot.img of=/dev/mmcblk0p6 bs=1M+
     ```     ```
  
行 96: 行 86:
 > Device Drivers > Multimedia support > V4L platform devices > Device Drivers > Multimedia support > V4L platform devices
  
-![v4l2 编译选项](images/v4l2.png)+![v4l2 编译选项](http://www.leconiot.com/md_res/jaysnote/kernel_compile/images/v4l2.png)
  
 ### GPIO libc(built in) ### GPIO libc(built in)
行 102: 行 92:
 > Device Drivers > GPIO Support  > Device Drivers > GPIO Support 
  
-![GPIO 支持](images/gpio.png)+![GPIO 支持](http://www.leconiot.com/md_res/jaysnote/kernel_compile/images/gpio.png)
  
 ### SMT32 I2C& 开机动画(stm_s103.ko) ### SMT32 I2C& 开机动画(stm_s103.ko)
行 108: 行 98:
 >Device Drivers > Staging drivers > Support for MXJ private driver >Device Drivers > Staging drivers > Support for MXJ private driver
  
-![梦想加私有驱动](images/mdp_driver.png)+![梦想加私有驱动](http://www.leconiot.com/md_res/jaysnote/kernel_compile/images/mdp_driver.png)
  
 ### USB Net(usbnet.ko asix.ko) ### USB Net(usbnet.ko asix.ko)
行 114: 行 104:
 > Device Drivers > Network device support > USB Network Adapters > Device Drivers > Network device support > USB Network Adapters
  
-![](images/usb_net.png)+![](http://www.leconiot.com/md_res/jaysnote/kernel_compile/images/usb_net.png)
  
 同时直接干掉无线网卡支持。 同时直接干掉无线网卡支持。
  
-### 通过SID 生成mac地址。+### oui mac 和基于sid md5计算mac地址。
  
 +* 接收用户传参,用以用户通过应用空间传递oui mac。
 ```c ```c
-//linux-3.10/drivers/net/usb/asix_devices.c +//inux-3.10/drivers/char/sunxi_sys_info/chipid-sunxi.c         
-extern int sunxi_get_soc_chipid(u8 *chipid); +static char *user_mac  "00:00:00:00:00:00"
-sunxi_get_soc_chipid(chipid); +static bool  user_flag true
-        buf[0] 0x02/* Non OUI / registered MAC address */ +module_param(user_mac,charp,S_IRUSR)
-        buf[1] chipid[0]+``` 
-        buf[2] = chipid[12]+* 如果用户没有传递参数,则通过 sid md5 随机mac; 
-        buf[3] = chipid[13]; +```c 
-        buf[4] = chipid[14]; +//inux-3.10/drivers/char/sunxi_sys_info/chipid-sunxi.c        
-        buf[5] = chipid[15]; +
-        netdev_dbg(dev->net,"MDP MAC from SID: 02:%02x:%02x:%02x:%02x:%02x", +
-                buf[1], buf[2], buf[3], +
-                buf[4], buf[5]);+
  
-        asix_set_netdev_dev_addr(devbuf);+ #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], hashETH_ALEN); 
 +}
 ``` ```
  
 +* 业务逻辑
 ```c ```c
 //inux-3.10/drivers/char/sunxi_sys_info/chipid-sunxi.c         //inux-3.10/drivers/char/sunxi_sys_info/chipid-sunxi.c        
-pr_info("%s,%dsun50i_sid_base  :%08x \n", __func__, __LINE__,(unsigned int)sun50i_sid_base ); +user_flag=true; 
-        //sunxi_soc_chipid[1] = readl(sun50i_sid_base 0x200 0x4); +printk(KERN_INFO "asix: user mac address is %s",user_mac); 
-        //sunxi_soc_chipid[2] = readl(sun50i_sid_base 0x200 0x8); +if(user_mac!=NULL&&strlen(user_mac)==17&&strcmp(user_mac,"00:00:00:00:00:00")!=0) { 
-        //sunxi_soc_chipid[3] = readl(sun50i_sid_base 0x200 0xc); +        for(i=0;i<6;i++
-        pr_info("%s,%dsunxi_soc_chipid  :0x%04x-%04x-%04x-%04x \n", __func__, __LINE__,sunxi_soc_chipid[0],sunxi_soc_chipid[1],sunxi_soc_chipid[2],sunxi_soc_chipid[3]); +                buf[i]=0; 
-        sunxi_soc_chipid[0= readl(sun50i_sid_base ); +                if(user_mac[3*i]>='0'&&user_mac[3*i]<='9') { 
-        sunxi_soc_chipid[1= readl(sun50i_sid_base + 0x4); +                        buf[i]|=((user_mac[3*i]-'0')*16); 
-        sunxi_soc_chipid[2] = readl(sun50i_sid_base + 0x8); +                }else if(user_mac[3*i]>='a'&&user_mac[3*i]<='f') { 
-        sunxi_soc_chipid[3] = readl(sun50i_sid_base + 0xc); +                        buf[i]|=((user_mac[3*i]-'a'+10)*16); 
-        pr_info("%s,%dsunxi_soc_chipid  :0x%04x-%04x-%04x-%04x \n", __func__, __LINE__,sunxi_soc_chipid[0],sunxi_soc_chipid[1],sunxi_soc_chipid[2],sunxi_soc_chipid[3]);+                }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]); 
 +}
 ``` ```
  
行 155: 行 199:
 > Device Drivers > Character devices  > Device Drivers > Character devices 
  
-![系统信息](images/sys_info.png)+![系统信息](http://www.leconiot.com/md_res/jaysnote/kernel_compile/images/sys_info.png)
  
 ### 显示(built-in) ### 显示(built-in)
行 161: 行 205:
 > Device Drivers > Graphics support > Support for frame buffer devices > Video support for sunxi > Device Drivers > Graphics support > Support for frame buffer devices > Video support for sunxi
  
-![](images/disp2.png)+![](http://www.leconiot.com/md_res/jaysnote/kernel_compile/images/disp2.png)
  
  
行 177: 行 221:
 > Device Drivers > I2C support > Device Drivers > I2C support
  
-![](images/i2c_change.png.)+![](http://www.leconiot.com/md_res/jaysnote/kernel_compile/images/i2c_change.png)
  
  
jaysnote/kernel_compile.1542176208.txt.gz · 最后更改: 2021/06/22 23:14 (外部编辑)