一、问题描述
有如下log:
RAMDISK: incomplete write (13207 != 32768)
log:
[ 2.9] RAMDISK: incomplete write (13207 != 32768)
[ 2.91] write error
。。。
[ 2.92] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(1,0) ]---
分析uboot启动参数需要添加ramdisk_size=0x4000000参数,修正参数后正常启动
参考例子:
CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/ram0 earlycon=uart8250,mmio,0x21c0500 ramdisk_size=0x4000000"
二、源码分析
static long __init compr_flush(void *window, unsigned long outcnt)
{
long written = kernel_write(out_file, window, outcnt, &out_pos);
if (written != outcnt) {
if (decompress_error == 0)
printk(KERN_ERR
"RAMDISK: incomplete write (%ld != %ld)\n",
written, outcnt);
decompress_error = 1;
return -1;
}
return outcnt;
}
static int __init crd_load(decompress_fn deco)
{
int result;
if (!deco) {
pr_emerg("Invalid ramdisk decompression routine. "
"Select appropriate config option.\n");
panic("Could not decompress initial ramdisk image.");
}
result = deco(NULL, 0, compr_fill, compr_flush, NULL, NULL, error);
if (decompress_error)
result = 1;
return result;
}