The hdd demo is found in the folder Home > Blackfin > demos > hdd
This demo program will check if the sda1 partition is mounted to /mnt and then will create a test file on the hard drive. You will need to prepare the hard drive for this demo by following the preparation text file.
This is only a simple demo, just to show you that files can be written to the hard drive and basic debugging can be performed.
The demo comes with the customised Ubuntu ISO and can be found in the folder /home/Blackfin/demos. Alternatively it is already installed on the demo uClinux image (demo-uclinux.img) that you can get on ADSP-BF548 EZ-KIT Quick Start: Booting uClinux.
If you just want to download the demos on their own and get their source code you can download the compressed archive (demos-R1.tar.gz) here bf548-quick-start .
root:/> cd /demos/hdd
root:/> fdisk /dev/sda The number of cylinders for this disk is set to 4864. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): p Disk /dev/sda: 40.0 GB, 40007761920 bytes 255 heads, 63 sectors/track, 4864 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 1 4864 39070048+ b Win95 FAT32 Command (m for help): q root:/> mkfs.ext2 /dev/sda1 mke2fs 1.41.12 (17-May-2010) ext2fs_check_if_mount: Can't check if filesystem is mounted due to missing mtab file while determining whether /dev/sda1 is mounted. Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 2444624 inodes, 9767512 blocks 488375 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=0 299 block groups 32768 blocks per group, 32768 fragments per group 8176 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624 Writing inode tables: done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 30 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
Note: If your partition table doesn't look like this when you ran the p command
Device Boot Start End Blocks Id System /dev/sda1 1 4864 39070048+ b Win95 FAT32
Then you may have to delete some partitions etc. Research the fdisk command here http://tldp.org/HOWTO/Partition/fdisk_partitioning.html to learn how to do this.
root:/> mount /dev/sda1 /mnt
root:/> ./hddtest
root:/> ls /mnt lost+found test_file.txt root:/> cat /mnt/test_file.txt This is a test file that should be saved on to the hard drive!
For other alternatives and ways to utilise the hdd (once it is mounted) look up File I/O programming. Anything available in standard C will most likely be available to perform on the Blackfin.
Make sure your vendor staging install is complete (ADSP-BF548 EZ-KIT Quick Start: Compiling uClinux).
root:/> make vendor_staging_install
Run the following compile command in the same directory as the source code:
root:/> bfin-linux-uclibc-gcc -O2 hddtest.c -o hddtest
What this compile command is doing is it is calling the uclibc cross compiler that is set up from the Blackfin toolchains to compile our application.
The final parameters match up to standard gcc compiling, “hddtest.c” is the source file and ”-o hddtest” indicates the output file is “hddtest”.
A standard make file is accompanies this demo and you can run that by simply calling
root:/> make hddtest
The ATAPI controller is discussed on the Blackfin On-Chip ATAPI Controller page.
You can look up file operations for programming with C to see examples such as binary file io.