原创 Ramdisk创建总结(DM365)

2010-10-11 21:38 3907 7 7 分类: MCU/ 嵌入式

下面记录来自TI的资料,这里自己做了点笔记,以供个人查询回顾:


 


The following sections use the DM365 showcase demo ramdisk as the example to illustrate how to archive this goal.


 


Procedure:


 


Prepare demo auto-run


Find a PSP base ramdisk & create a tarball from it


Create a bigger empty ramdisk


Copy over the tarball and demo


Test the ramdisk via tftp boot


Flash the ramdisk to the board


 


 


 


Prepare Auto-run


Before create the ramdisk, we have to make the demo automatically run via NFS when power on the board.


 


The showcase demo is installed in /opt/showcase directory in the target filesystem.


 


1创建想要启动运行的脚本


Create a script /opt/showcase/autorun.sh to run the demo.


 


   #!/bin/sh


  


   TMPFILE=/tmp/720P_60.264


  


   ./loadmodules.sh || { echo "Error: loadmodules failed"; exit 1; }


   ./encoded.720p -b 3000000 -o $TMPFILE


   ./decoded.720p $TMPFILE &


 


2把该脚本写入rc.local中,使其能够启动时运行


Create a script /etc/rc.d/rc.local to call /opt/showcase/autorun.sh. /etc/rc.d/rc.local will be automatically executed after the kernel boots up.


 


   #!/bin/sh


  


   cd /opt/showcase


   ./autorun.sh


Do not forget to add the executable attribute to these two scripts.


 


   chmod +x /opt/showcase/autorun.sh


   chmod +x /etc/rc.d/rc.local


Now boot the board from NFS. The demo should automatically start.


 


 


 


3从板级支持包中找到提供的基本的ramdisk,再把其里面内容拷贝成tar包,以方便下一步,把这些内容放入一个空的ramdisk镜像中。


 


Prepare Base Ramdisk


Normally the PSP package provides a ramdisk, which has a minimum set of functionalities . We start from it and add the demo and its dependencies.


 


Make a copy of the PSP ramdisk and create a tarball from it.


 


先把原有的ramdisk.gz改个名字为baserd.gz


   cp -a <path_of_PSP>/ramdisk.gz /tmp/baserd.gz


 


   cd /tmp


解压压缩的baserd.gz镜像


   gunzip baserd.gz


把解压后得到的baserd镜像挂载在/mnt目录下 ,注意mount命令的参数,用loop 代表回环挂载。


   sudo mount baserd /mnt -o loop


 


   cd /mnt


再把镜像中的所有又重新打包成baserd.tar.gz


   sudo tar zcf /tmp/baserd.tar.gz  *


 


   cd ..


   sudo umount /mnt


 


 


4创建一个空的ramdisk镜像,镜像大小按需要决定,这里以10M为例


Create Empty RamDisk


Create a 10MB empty ramdisk. If the size is not big enough, we will face copying errors in next section. Then we have to start over from here with a bigger size.


   cd /tmp


   dd if=/dev/zero of=ramdisk bs=1M count=10  这里可以改大小


用mkfs.ext2穿件镜像文件


   /sbin/mkfs.ext2 ramdisk


把该镜像文件挂载到/mnt


   sudo mount ramdisk /mnt -o loop


   cd /mnt


把上一步从基本的ramdisk中拷贝出来的数据解压至该目录


   sudo tar zxf /tmp/baserd.tar.gz


 


 


5把一些自己要加入的代码,库文件等等放入文件系统相应的目录下


Copy Over Demo Package


Copy over the demo to the new ramdisk. If the ramdisk size is too small to hold the components, go back to the previous step to create a bigger ramdisk.


 


   sudo mkdir -p /mnt/opt


   sudo cp -ar <target_fs>/opt/showcase /mnt/opt


   sudo cp -a <target_fs>/etc/rc.d/rc.local /mnt/etc/rc.d/


 


   cd /tmp


   sudo umount /mnt


把ramdisk 重新打成压缩包生出ramdisk.gz


   gzip ramdisk


 


   cp -a ramdisk.gz /tftpboot


 


 


初步测试下制作的ramdisk是否成功,这里直接把内核镜像,ramdiskl.gz下载到ram中


直接重ram中启动系统。


Test Ramdisk


Set the u-boot env as following and boot the board. The demo should automatically start from ramdisk via tftp.


 


 bootcmd='tftp 0x82000000 ramdisk.gz; tftp 0x80700000 uImage; bootm 0x80700000'


i.e:


 setenv bootcmd 'tftp 0x82000000 ramdisk.gz; tftp 0x80700000 uImage; bootm 0x80700000'


 


 bootargs='mem=104M console=ttyS0,38400n8 root=/dev/ram0 rw initrd=0x82000000,10M  ip=off davinci_capture.device_type=4 dm365_imp.oper_mode=0'


i.e


setenv bootargs 'mem=104M console=ttyS0,38400n8 root=/dev/ram0 rw initrd=0x82000000,20M ip=off davinci_capture.device_type=4 dm365_imp.oper_mode=0'


 


6.启动后在 系统中运行程序时,一般会遇到 没有相应的库文件的错误。而且如果缺乏多个


库文件的话,其只提示遇到的第一个缺少的文件。所以要想把其所有的缺少的库都找出来的话,我一般在用Nfs启动时(有几乎完整的库)用ldd 命令,查看其所有依赖的共享库。


并一一把其拷贝到自己制作的ramdisk的相应目录中。如果已存在则不覆盖。这样比较可靠。


注意拷贝的时候 要用 cp -a 的参数,以免有些连接文件的性质丢失。


 


As expected, you will see some error messages in console, for example some libraries are missing. To find more easily which libraries are missing, you can use ldd command in the NFS filesystem. It will print which shared libraries your demo uses.


 


   ldd < your demo >


Follow the steps below to copy the missing libraries from the full set of NFS target filesystem and re-test the ramdisk until the demo runs successfully.


 


   cd /tftpboot


   gunzip ramdisk.gz


   sudo mount ramdisk /mnt -o loop


 


   sudo cp -a <full_NFS_target_fs>/<missed_files> /mnt/<the lib' ptath>


 


   sudo umount /mnt


   gzip ramdisk


 

PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
我要评论
0
7
关闭 站长推荐上一条 /3 下一条