Linux 通过 /dev/mtd 更新内核
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7977555/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
kernel update via /dev/mtd
提问by Bartlomiej Grzeskowiak
I'm working on embedded device where kernel image is stored inside /dev/mtd4 part of flash. I would like to update this kernel without Uboot.
我正在研究内核映像存储在闪存的 /dev/mtd4 部分的嵌入式设备。我想在没有 Uboot 的情况下更新这个内核。
How is it possible ? I was trying to call:
这怎么可能 ?我试图打电话:
echo ./kernel.bin > /dev/mtdblock4
but it doesn't work. Stored data are not recognized as kernel in next boot.
但它不起作用。存储的数据在下次启动时不会被识别为内核。
采纳答案by Basile Starynkevitch
It should at least be cat kernel.bin > /dev/mtdblock4
but that probably won't work neither.
至少应该是,cat kernel.bin > /dev/mtdblock4
但这可能也行不通。
And it depends upon how your kernel is actually loaded (what is the bootloader).
这取决于您的内核是如何实际加载的(引导加载程序是什么)。
回答by shodanex
You should use the mtdutilstool flashcp :
您应该使用mtdutils工具 flashcp :
flashcp -v ./kernel.bin /dev/mtd4
flashcp will take care of the erasing, writing, and verifying which cat won't do. Note that is works with the char driver and not the block driver. -v is for verbose operation
flashcp 将负责擦除、写入和验证哪只猫不会这样做。请注意,它适用于字符驱动程序而不是块驱动程序。-v 用于详细操作
回答by Luke Postema
I've never used flashcp. Where can I get it? I use flash_erase or flash_eraseall and then nandwrite. If you don't have these utilities, you can get the source hereand build them for your target.
我从来没有用过 flashcp。我在哪里可以得到它?我使用 flash_erase 或 flash_eraseall,然后使用 nandwrite。如果您没有这些实用程序,您可以在此处获取源代码并为您的目标构建它们。
To update my system, I use:
要更新我的系统,我使用:
# /usr/bin/flash_erase /dev/mtd3
# /usr/bin/nandwrite -m -p /dev/mtd3 /uImage
Is this NAND flash? If so, I don't think that echo or cat are going to properly skip bad blocks for you.
这是NAND闪存吗?如果是这样,我认为 echo 或 cat 不会为您正确跳过坏块。
回答by nomoney29
To update the different mtd blocks, I use following routine:
要更新不同的 mtd 块,我使用以下例程:
# flash_eraseall /dev/mtd3 # dd if="kernel.bin" of=/dev/mtd3 bs=16k conv=sync
回答by KBell
I also have a device where I update the kernel image and use uBoot. My workflow is:
我还有一个设备,我可以在其中更新内核映像并使用 uBoot。我的工作流程是:
- I transfer the new imagefile to the devices tmp directory
I erase the flash mtd directory:
flash_eraseall /dev/mtd3
then I copy from tmp to flash directory (/tmp/ --> /dev/mtd3)
flashcp /tmp/uImage /dev/mtd3
- 我将新的图像文件传输到设备 tmp 目录
我擦除了 flash mtd 目录:
flash_eraseall /dev/mtd3
然后我从 tmp 复制到 flash 目录 (/tmp/ --> /dev/mtd3)
flashcp /tmp/uImage /dev/mtd3
I hope this helps, regards
我希望这有帮助,问候