单独编译Kernel
./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
#/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
需要修改vfe.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;
}
//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
Device Drivers > GPIO Support
Device Drivers > Staging drivers > Support for MXJ private driver
Device Drivers > Network device support > USB Network Adapters
同时直接干掉无线网卡支持。
//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;
//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);
}
业务逻辑
//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
Device Drivers > Graphics support > Support for frame buffer devices > Video support for sunxi
19:27 2018/7/31
更新为源码自带i2c通用驱动,并且更新速率为100k
Device Drivers > I2C support