用户工具

站点工具


jaysnote:kernel_compile

差别

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

到此差别页面的链接

两侧同时换到之前的修订记录 前一修订版
后一修订版
前一修订版
jaysnote:kernel_compile [2019/12/11 21:37]
lijie
jaysnote:kernel_compile [2020/01/16 19:45]
lijie
行 1: 行 1:
 <markdown> <markdown>
 +# Kernel Compile
  
-xgac sdk usage+## 命令
  
-## compile+* 单独编译Kernel
  
-* 下载解压 [sdk](/home/lijie/my_project/gac-350)+    ```shell 
 +    ./build.sh -p sun50iw1p1_debian -m kernel -k linux-3.10 
 +    ```
  
-    ```bash +* 清除 
-    $ tree -L 1 + 
-    ├── brandy                     #boot0、uboot +    ``` 
-    ├── buildroot                  #编译相关工具 +    ./build.sh -p sun50iw1p1_debian -m distclean -k linux-3.10
-    ├── build.sh                   #编译、打包脚本 +
-    ├── clean.sh                   #清除编译中间件 +
-    ├── debian                     #debian rootfs +
-    ├── img_release.sh              +
-    ├── lib                        #allwinner sysconfig 配置脚本 +
-    ├── linux-3.10                 #内核 +
-    ├── out                        #编译输出目录 +
-    ├── readme.txt                 #简要的编译的说明 +
-    └── tools                      #编译依赖工具集+
     ```     ```
  
-    +* menuconfig
  
-* 解压缩 带上--numeirc-owner 保留数字用户/ 用户权限;+    ``` 
 +    sudo make ARCH=arm64 CROSS_COMPILE=../out/sun50iw1p1/debian/common/buildroot/external-toolchain/bin/aarch64-linux-gnu- menuconfig 
 +    ```
  
-解压缩后请确定debian rootfs 用户id/组id,/为0:/home/chen home/pi 用户目录为1000:1000;+拷贝 
 + 
 +    ``` 
 +    scp jay@10.28.3.204:/home/jay/a64/linux-3.10/drivers/net/usb/* ./ 
 +    ``` 
 + 
 +* 更新kernel
  
     ```bash     ```bash
-    sudo  chown -R 0:0 debian+    #/bin/bash 
-    sudo  chown -R 1000:1000 debian/home/+ 
 +    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
     ```     ```
  
-* ramdisk 通过软连接到cpio 目录 
  
-  ```bash +## 驱动
-  ln -s -f ../../cpio/release/rootfs.cpio.gz rootfs.cpio.gz +
-  ```+
  
-* 编译过程+### 摄像头(ov5640.ko vfl2.ko )
  
-  暂时地,在root用户下完成操作。+需要修改vfe.c
  
-  ```bash +```c 
-  #编译步骤 +//linux-3.10/drivers/media/platform/sunxi-vfe/vfe.c 
-  1. 设置XY变量,配置屏幕类型 +static int vidioc_g_input(struct file *file, void *priv, unsigned int *i)  { 
-   +        struct vfe_dev *dev = video_drvdata(file);
-  800X480分辨率屏幕配置 +
-  $ export XY=800x480 +
-   +
-  2. 源码编译 +
-  $ ./build.sh +
-   +
-  3. 源码打包 +
-  $ ./build.sh pack +
-   +
-  #可选操作 +
-  4.设置文件系统版本号 +
-  ./debian/home/chen/update_buildtime.sh debian -w +
-   +
-  5.按照日志版本号重命名镜像 do 表示支持操作,后面表示文件标签 +
-  ./img_release.sh do -cv2_run_2.0.7 +
-  ```+
  
-内核编译+        //*i = dev->input; 
 +        *i = 0; 
 +        return 0; 
 +
 +```
  
-    参考[内核编译] (/jaysnote/kernel_compile+```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; 
 + } 
 +```
  
-## download+> Device Drivers > Multimedia support > V4L platform devices
  
-### windows+![v4l2 编译选项](http://www.leconiot.com/md_res/jaysnote/kernel_compile/images/v4l2.png)
  
-* 安装 [PhoenixSuit_V1.10.zip](https://doc.mxj360.com/lib/exe/fetch.php?media=projects:gac:gac-350:phoenixsuit_v1.10.zip) 软件;+### GPIO libc(built in)
  
-* 下载已经编译好镜像[当前最新镜像直接下载](http://mdp-embedded.oss-cn-beijing.aliyuncs.com/gac-350/GAC350_2019-02-18_16-44-2.1.8-online_bug_fix-2.img);+> Device Drivers > GPIO Support 
  
-* 连接micro usb 接口,按住boot 按键(蜂鸣器位置,有丝印)启动系统(上电/或者reset),等待下载完成;+![GPIO 支持](http://www.leconiot.com/md_res/jaysnote/kernel_compile/images/gpio.png)
  
-    ![镜像下载](images/img_program_win.png)+### SMT32 I2C& 开机动画(stm_s103.ko)
  
-### linux +>Device Drivers > Staging drivers > Support for MXJ private driver
  
-* 下载 livesuit 源码包;+![梦想加私有驱动](http://www.leconiot.com/md_res/jaysnote/kernel_compile/images/mdp_driver.png)
  
-    ```bash +### USB Net(usbnet.ko asix.ko)
-    $git clone https://github.com/linux-sunxi/sunxi-livesuite.git  +
-    ```+
  
-    **提示**:详细说明参考根路径README +Device Drivers > Network device support > USB Network Adapters
  
-* bianyi 安装awusb 驱动;+![](http://www.leconiot.com/md_res/jaysnote/kernel_compile/images/usb_net.png)
  
-    ```bash +同时直接干掉无线网卡支持。
-    $sudo  apt-get install dkms +
-    $make +
-    $sudo  cp awusb.ko /lib/modules/`uname -r`/kernel/ +
-    $ modprobe awusb +
-    ```+
  
-* 运行LiveSuit.sh 工具+### oui mac 和基于sid md5计算mac地址
  
-    ```bash +* 接收用户传参,用以用户通过应用空间传递oui mac。 
-    $sudo ./LiveSuit.sh +```
-    ```+//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)); 
 + 
 +        //1fill 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]); 
 + 
 + 
 +        //2calc 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**
  
-* 连接micro usb 接口,按住boot 按键(蜂鸣器位置,有丝印)启系统(上电/或者reset)等待下载完成;+更新为源码自带i2c通用驱动,并且更新速率为`100k`
  
-    ![linux 下载](images/img_program_linux.png)+> Device Drivers > I2C support
  
-## troubleshooting+![](http://www.leconiot.com/md_res/jaysnote/kernel_compile/images/i2c_change.png)
  
-* 编译错误`awk: line 2: function strtonum never defined` 
  
-  ```bash 
-  sudo apt-get install gawk 
-  ``` 
  
-* 编译错误 `-bash: ./mkbootimg: No such file or directory`+## fex
  
-  ```bash + http://linux-sunxi.org/Fex_Guide
-  sudo apt-get install gcc-multilib g++-multilib +
-  ```+
  
 </markdown> </markdown>
jaysnote/kernel_compile.txt · 最后更改: 2021/06/22 23:14 (外部编辑)