linux设备内核怎样升级,整理:linux kernel firmware update 内核设备固件升级方法

//firmware update test

//2014.07.11

#include #include const struct firmware *cust_firmware;

static struct miscdevice misc = {

.minor = MISC_DYNAMIC_MINOR,

.name = "test",

};

void devices_upgrade_start(void)

{

int i;

for(i=0;isize;i++)

{

printk("test: %x \n",*(cust_firmware->data+i));

}

}

void firmware_test(void)

{

int retval;

printk("test: firmware_test\n");

retval = request_firmware(&cust_firmware, "aa.bin", misc.this_device);

if (retval < 0) {

printk("test: %s: aa.bin request firmware failed(%d)\n", __func__,retval);

} else {

/* check and start upgrade */

devices_upgrade_start();

release_firmware(cust_firmware);

printk("test: release_firmware\n");

}

}

static int test_init(void)

{

int ret;

printk("test: init\n");

//registe misc device

ret = misc_register(&misc);

if(ret < 0)

{

printk("test: can't registe misc device");

return ret;

}

printk("test: misc_register ok\n");

firmware_test();

return 0;

}

static void test_exit(void)

{

misc_deregister(&misc);

printk("test: good bye\n");

}

module_init(test_init);

module_exit(test_exit);

MODULE_LICENSE("GPL");

cp aa.bin /lib/firmware

sudo insmod firmware_test.ko

[11654.046821] test: init

[11654.094990] test: misc_register ok

[11654.094993] test: firmware_test

[11654.095042] misc test: firmware: requesting aa.bin

[11654.214125] test: 31

[11654.214126] test: 32

[11654.214127] test: 33

[11654.214128] test: 34

[11654.214128] test: 35

[11654.214129] test: 36

[11654.214131] test: release_firmware

把固件放到代码中,开机自动下载

make menuconfig

Devices  Drivers  --->  Generic Driver Options  --->   External firmware blobs to build into the kernel binary  增加aa.bin文件就可以了

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值