最近在调试鸿蒙的qemu项目,对于鸿蒙官方给出的qemu构建指导,对一些疑点做了些了解,记录下来避免后续反复产生疑问。
sudo modprobe mtdram total_size=65536 erase_size=256
sudo mtdpart add /dev/mtd0 kernel 0 10223616
sudo mtdpart add /dev/mtd0 kernel 10223616 10485760
sudo mtdpart add /dev/mtd0 root 10485760 56623104
sudo nandwrite -p /dev/mtd1 out/qemu_arm_virt_ca7/OHOS_Image.bin
echo -e “bootargs=root=cfi-flash fstype=jffs2 rootaddr=0xA00000 rootsize=27Mx0” | sudo nandwrite -p /dev/mtd2 -
sudo nandwrite -p /dev/mtd3 out/qemu_arm_virt_ca7/rootfs_jffs2.img
sudo dd if=/dev/mtd0 of=flash.img
sudo chown USERNAME flash.img
sudo rmmod mtdram
以上摘自Qemu ARM Virt 教程
对于modprobe, mtdpart, nandwrite, rmmod四个命令的解释:
modprobe用来加载内核模块,如mtdram模块。mtdram模块加载完成后,会生成一个mtd设备/dev/mtd0。
mtdpart maguangyao@ubuntu-15:~/workspace/code$ mtdpart --helpUsage: mtdpart add [OPTION] <MTD_DEVICE> <PART_NAME> <START> <SIZE> mtdpart del [OPTION] <MTD_DEVICE> <PART_NUMBER>Adds a partition to an MTD device, or remove an existing partition from it. -h, --help Display this help and exit --version Output version information and exitSTART location and SIZE of the partition are in bytes. They should align oneraseblock size.mtdpart用于给mtd设备添加分区或者删除分区。add的情况下,生成的/dev/mtd1,/dev/mtd2…
nandwrite maguangyao@ubuntu-15:~/workspace/code$ nandwrite --helpUsage: nandwrite [OPTION] MTD_DEVICE [INPUTFILE|-]Writes to the specified MTD device. -a, --autoplace Use auto OOB layout -m, --wxdblbad Mark blocks bad if write fails -n, --noecc Write without ecc -N, --noskipbad Write without bad block skipping -o, --oob Input contains oob data -O, --onlyoob Input contains oob data and only write the oob part -s addr, --start=addr Set output start address (default is 0) -p, --pad Pad writes to page size -b, --blockalign=1|2|4 Set multiple of eraseblocks to align to --input-skip=length Skip |length| bytes of the input file --input-size=length Only read |length| bytes of the input file -q, --quiet Don't display progress messages -h, --help Display this help and exit --version Output version information and exit写分区,可以是上述添加分区后的设备名,如/dev/mtd1。
rmmod maguangyao@ubuntu-15:~/workspace/code$ rmmod --helpUsage: rmmod [options] modulename ...Options: -f, --force forces a module unload and may crash your machine. This requires Forced Module Removal option in your kernel. DANGEROUS -s, --syslog print to syslog, not stderr -v, --verbose enables more messages -V, --version show version -h, --help show this help删除内核模块,如mtdram,同时删除/dev/mtd0及其范围内的所有分区。