Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

How to Create a Ramdisk with Auto-run Demo

From Texas Instruments Wiki
Jump to: navigation, search

This page uses the DM365 showcase demo ramdisk as an example to illustrate how to create a ramdisk which has boot-up auto-run demo application.

Many times when we present demo's in trade shows or customer visits, we hate the complicate setup that hooks up the serial cable to Teraterm or Ethernet cable to NFS server and keyboard typings. It would be great if everything had been flashed to the on-board NAND chip and the demo automatically started right after power on the board.

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


  1. Prepare demo auto-run
  2. Find a PSP base ramdisk & create a tarball from it
  3. Create a bigger empty ramdisk
  4. Copy over the tarball and demo
  5. Test the ramdisk via tftp boot
  6. 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.

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

   ./ || { echo "Error: loadmodules failed"; exit 1; }
   ./encoded.720p -b 3000000 -o $TMPFILE
   ./decoded.720p $TMPFILE &

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

   cd /opt/showcase

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

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

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

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.

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

   cd /tmp
   gunzip baserd.gz
   sudo mount baserd /mnt -o loop

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

   cd ..
   sudo umount /mnt

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
   /sbin/mkfs.ext2 ramdisk
   sudo mount ramdisk /mnt -o loop
   cd /mnt
   sudo tar zxf /tmp/baserd.tar.gz

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
   gzip ramdisk

   cp -a ramdisk.gz /tftpboot

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'
   bootargs='mem=104M console=ttyS0,115200n8 root=/dev/ram0 rw \
            initrd=0x82000000,10M ip=off davinci_capture.device_type=4 \

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

   sudo umount /mnt
   gzip ramdisk

Flash Ramdisk

Now the ramdisk is ready for use. Flash it to the on-board NAND device.

   tftp 0x80700000 uImage
   nand erase 0x400000 0x200000
   nand write 0x80700000 0x400000 0x200000

   tftp 0x82000000 ramdisk.gz
   nand erase 0xC00000 0x430000
   nand write 0x82000000 0xC00000 0x430000

Use the following bootcmd to boot the board from NAND.

   bootcmd='nand read 0x82000000 0xc00000 0x430000; nboot 0x80700000 0 0x400000; bootm'