这里会显示出您选择的修订版和当前版本之间的差别。
后一修订版 | 前一修订版 | ||
jaysnote:kernel_compile [2018/11/14 14:16] jaylee 创建 |
jaysnote:kernel_compile [2021/06/22 23:14] (当前版本) |
||
---|---|---|---|
行 1: | 行 1: | ||
- | # GAC-350 | + | < |
+ | # Kernel Compile | ||
## 命令 | ## 命令 | ||
行 27: | 行 28: | ||
``` | ``` | ||
- | * 完整测试命令 | + | * 更新kernel |
- | ```shell | + | ```bash |
- | | + | |
- | + | ||
- | asix.ko cdc_ether.ko mcs7830.ko | + | scp jay@10.28.3.204:/ |
- | root@350-c1-emmc ~/asix# | + | |
- | | + | [ -f boot.img ] && { |
- | asix.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 ./ | + | |
- | root@350-c1-emmc ~/asix# dmesg -T | + | |
- | [Thu Jun 14 15:26:27 2018] asix 1-1:1.0 eth0: register ' | + | |
- | [Thu Jun 14 15:26:27 2018] usbcore: registered new interface driver asix | + | |
- | root@350-c1-emmc ~/asix# | + | |
- | ``` | + | |
- | * 更改boot | + | sudo dd if=boot.img of=/ |
+ | sync | ||
+ | echo " | ||
+ | exit 0 | ||
+ | } | ||
- | | + | |
- | | + | |
- | dd if=boot.img of=/ | + | |
``` | ``` | ||
行 95: | 行 86: | ||
> Device Drivers > Multimedia support > V4L platform devices | > Device Drivers > Multimedia support > V4L platform devices | ||
- |  | ### GPIO libc(built in) | ||
行 101: | 行 92: | ||
> Device Drivers > GPIO Support | > Device Drivers > GPIO Support | ||
- |  | ### SMT32 I2C& 开机动画(stm_s103.ko) | ||
行 107: | 行 98: | ||
>Device Drivers > Staging drivers > Support for MXJ private driver | >Device Drivers > Staging drivers > Support for MXJ private driver | ||
- |  | ### USB Net(usbnet.ko asix.ko) | ||
行 113: | 行 104: | ||
> Device Drivers > Network device support > USB Network Adapters | > Device Drivers > Network device support > USB Network Adapters | ||
- | ; | + | static bool user_flag |
- | buf[0] | + | module_param(user_mac, |
- | | + | ``` |
- | | + | * 如果用户没有传递参数,则通过 sid md5 随机mac; |
- | | + | ```c |
- | | + | //inux-3.10/ |
- | | + | |
- | | + | |
- | buf[1], buf[2], buf[3], | + | |
- | buf[4], buf[5]); | + | |
- | asix_set_netdev_dev_addr(dev, buf); | + | # |
+ | //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 | ```c | ||
// | // | ||
- | pr_info("%s,%d: sun50i_sid_base | + | user_flag=true; |
- | // | + | printk(KERN_INFO |
- | // | + | if(user_mac!=NULL&& |
- | // | + | for(i=0; |
- | | + | buf[i]=0; |
- | sunxi_soc_chipid[0] = readl(sun50i_sid_base ); | + | if(user_mac[3*i]> |
- | sunxi_soc_chipid[1] = readl(sun50i_sid_base + 0x4); | + | 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 | ||
+ | }else { | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
``` | ``` | ||
行 154: | 行 199: | ||
> Device Drivers > Character devices | > Device Drivers > Character devices | ||
- |  | ### 显示(built-in) | ||
行 160: | 行 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/ | + | ![](http:// |
行 176: | 行 221: | ||
> Device Drivers > I2C support | > Device Drivers > I2C support | ||
- | ![](images/ | + | ![](http:// |
行 183: | 行 228: | ||
* http:// | * http:// | ||
+ | |||
+ | </ |