Compact flash are often used in Digital Signage applications and hard-disks used in both signage application and IP set-top-box to play high definition videos. However, sometimes the performance of those devices and the performance limitations of embedded systems may make the task difficult especially for higher bit-rate videos.
- Choosing the right file system
Once of the easiest way to improve performance is to select an appropriate file system. The best performance is achieved by ext-2, followed by ext-3, fat 32 and ntfs on the embedded system I worked with at least (e.g. Sigma Designs EM8620 and SMP8630 series). Basically, if your CF card/HDD is not supposed to be taken out of your device, then ext-2 is the obvious choice. However, if your user for whatever reasons need to take the devie out and connect it to a Windows PC FAT 32 or NTFS might be a better choice, although it would still be possible to install a ext2 driver such as Ext2 FS in Windows to be able to read/write ext-2 partition. If you are never going to use file over 2GB, then FAT32 is the best choice* otherwise you’ll have to go for NTFS.
*Unless you use commercial NTFS solution as discussed a previous post.
- Using appropriate format parameters.
Once you get the file systems fpr your needs, you are ready to format your device. In case, you’ll store large files the best is to use the largest block size as possible, as this would improve performance although you’ll lose some space due to the slack (e.g. a 1KB file would still use 64KB if the block size is 64KB).
For ext-2/ext-3, specify the block size as follows:
mkfs.ext2 -b 65536 /dev/hda
You may also need a kernel patch to support 64KB block for ext-2 depending on the kernel version used.
For NTFS or FAT32 , if you use Windows to format your disk, go to the command line and type:
format /FS:NTFS /A:64K F:
format /FS:FAT32 /A:64K F:
- Adjusting the IDE parameters with hdparm
Once you’ve done the easy part, you can also use hdparm (part of busybox or the full version to have more options).
First you can check the current settings:
hdparm /dev/hda
1 2 3 4 5 6 7 8 9 10 |
<span><span style="font-family: monospace;"> multcount = 0 (off) I/O support = 0 (default 16-bit) unmaskirq = 0 (off) using_dma = 0 (off) keepsettings = 0 (off) nowerr = 0 (off) readonly = 0 (off) readahead = 256 (on) geometry = 1870/255/63, sectors = 30043440, start = 0 </span></span> |
For more information you can use hdparm -I /dev/hda
If your system support it you should enable DMA, multicount, enable unmaskirq (to allow Linux to unmask other interrupts) and adjust the read ahead value.
For example below, we’ll set the read ahead value to 512, enable DMA, set multicount to 16 and enable unmaskirq:
hdparm -a512 -d1 -m16 -u1 /dev/hda
Basically you have to do some trial an error on you system and test the performance using tools using as hdparm (hdparm -tT /dev/hda) or bonnie64.
- Using 80 conductor pin cable – Enabling udma5
If you use the wrong cable or your hardware is configured that it will use the default 40-pin configuration, limiting the Ultra-DMA mode that can be used to UDMA2. To make use of better mode UDMA3/4/5, you’ll need a 80 conductor pin cable (That actually only have 40 wires caring data) or rework your hardware so that pin 34 of the IDE connector is pulled low.
Some have noticed major performance enhancement by enabling UDMA5. In our case we also got major improvement for the hdparm "Timing buffered disk reads" (16 to 23mb/s) but
Bonnie test did not show any improvement, and video playback very little. Maybe this depends on the hard disk model used.
If your system support it you should enable DMA, multicount, enable unmaskirq (to allow Linux to unmask other interrupts) and adjust the read ahead value.
For example below, we’ll set the read ahead value to 512, enable DMA, set multicount to 16 and enable unmaskirq:
hdparm -a512 -d1 -m16 -u1 /dev/hda
Basically you have to do some trial an error on you system and test the performance using tools using as hdparm (hdparm -tT /dev/hda) or bonnie64.In one of our hardware platforms and for some specific CF cards, DMA was not working properly, so we had to disable DMA to improve the performance, we just set pio mode to 4: hdparm -p4 /dev/hda and the performance was significantly improved.
Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.
Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress