Running FAT16 File Systems and DOS Commands on SHARC® Processors

Total Page:16

File Type:pdf, Size:1020Kb

Running FAT16 File Systems and DOS Commands on SHARC® Processors Engineer-to-Engineer Note EE-329 Technical notes on using Analog Devices DSPs, processors and development tools Visit our Web resources http://www.analog.com/ee-notes and http://www.analog.com/processors or e-mail [email protected] or [email protected] for technical support. a Running FAT16 File Systems and DOS Commands on SHARC® Processors Contributed by Mitesh Moonat, Jagadeesh Rayala and Aseem Vasudev Rev 1 – September 28, 2007 Introduction File Allocation Table 16 (FAT16) is a widely used file format implemented on mid-size memory devices (up to 2GB) such as NAND flash, Multi-Media Card (MMC), and Secure Digital (SD) cards. These memory devices are used mainly to store multimedia content and data. Therefore, it is necessary for media processing software applications to interpret the FAT16 file format in order to access and/or manipulate the content stored on such memory devices. This EE-Note discusses the implementation of various commands similar to Disk Operating System (DOS) commands to access and modify the FAT16 file system on an MMC interfaced to an ADSP-21369 SHARC® processor. This document includes details about dealing with the files stored on MMC. The source code for this interface has been developed and validated on an ADSP-21369 EZ-KIT Lite® evaluation board and is provided with this application note. Although, this document refers to the ADSP-21369 SHARC processor, the same concepts L presented here apply to ADSP-21367, ADSP-21368, and ADSP-2137x SHARC processors. The implementation of basic DOS commands that list files and folders in current directory, create a directory, copy a file, read a file, search a file, navigate through sub-folders in current directory, or delete a file or directory are discussed in detail. The code supports long file names (up to 255 bytes). Other file systems such as FAT12 and FAT32 are briefly discussed and are compared to FAT16 file system. FAT Overview FAT is a partially patented file system developed by Microsoft® for MS-DOS®. It involves the use of a table that centralizes the information about the areas belonging to files. This information helps to identify which areas are free or usable, and where each file is stored on the disk. It also identifies the areas that are unusable. To reduce the management complexity, disk space is allocated to files in contiguous groups of hardware sectors called as clusters. The maximum number of clusters possible that can be addressed by a file system depends on the number of bits being used to identify a cluster in FAT. Currently, there are three types of FAT file systems: FAT12, FAT16, and FAT32. The basic difference between them is the number of bits in the FAT entries on a disk. FAT12 uses 12-bit entries, FAT16 uses 16-bit entries, and FAT32 uses 28-bit entries. The FAT standard has also evolved in several ways, Copyright 2007, Analog Devices, Inc. All rights reserved. Analog Devices assumes no responsibility for customer product design or the use or application of customers’ products or for any infringements of patents or rights of others which may result from Analog Devices assistance. All trademarks and logos are property of their respective holders. Information furnished by Analog Devices applications and development tools engineers is believed to be accurate and reliable, however no responsibility is assumed by Analog Devices regarding technical accuracy and topicality of the content provided in Analog Devices Engineer-to-Engineer Notes. a preserving backward compatibility with existing software. Table 1 shows basic differences between the different FAT file systems. FAT is still a normal file system for removable media (with the exception of CDs and DVDs), with FAT12 used on floppies and FAT16 used on most other removable media (such as flash memory cards for digital cameras, mobile phones, and USB flash drives). Most removable media are not yet large enough to benefit from FAT32, although some larger flash drives such as Secure Digital High-Capacity (SDHC) cards use it. FAT16 is used on these drives for reasons of compatibility and size overhead. FAT12 FAT16 FAT32 Uses Floppies and small hard Small to large hard disk Medium to very large hard disk volumes volumes disk volumes Size of each FAT entry 12 bits 16 bits 28 bits Volume size (maximum) 16 Mbytes 2 Gbytes about 2^41 Table 1. Comparison between various FAT versions FAT16 on a Disk Figure 1 shows the order of structures on a disk or a FAT partition. Boot More reserved File File Root Data Region (for files and directories) sector sectors Allocation Allocation Directory (To end of partition or disk) (optional) Table 1 Table 2 Figure 1. Sections of a disk or partition Reserved Sectors The beginning sectors are reserved sectors. The first sector (sector 0), which is called the Boot Sector (or Partition Boot Record), is mandatory; the others are optional. The boot sector includes an area called the BIOS parameter block that includes the basic file system information (in particular, the FAT type and pointers to the location of the other sections). The total count of reserved sectors is indicated by a field inside the Boot Sector. FAT Region The FAT region contains two copies of FAT. Though rarely used, the second copy is helpful when the default copy gets corrupted. This region contains the mapping details of the data, region indicating the clusters are used and the clusters that are not used. Root Directory Region The root directory region contains a Directory Table that stores information about the files and directories located in the root directory region. This region has a fixed maximum size that is pre-allocated at the time that the volume is formatted. This region is only used for FAT12 and FAT16; FAT32 stores the root directory entries in the data region just as any other sub-directories. Running FAT16 File Systems and DOS Commands on SHARC® Processors (EE-329) Page 2 of 24 a Data Region The data region is the actual region where all files and directories are stored. This region occupies the majority of the partition space. Files and directories stored in this region can be made arbitrarily long simply by adding more clusters in the clusters chain of the FAT. Details of FAT16 Structure The following sections describe the entire FAT16 structure in detail. Boot Sector Table 2 lists the fields in the boot sector. Offset Description Size (bytes) 0x00 Jump code + NOP 3 0x03 OEM name 8 0x0B Bytes per sector 2 0x0D Sectors per cluster 1 0x0E Reserved sectors 2 0x10 Number of copies of FAT 1 0x11 Maximum root directory entries 2 0x13 Number of sectors in partition smaller than 32 Mbytes 2 0x15 Media descriptor (F8H for hard disks) 1 0x16 Sectors per FAT 2 0x18 Sectors per track 2 0x1A Number of heads 2 0x1C Number of hidden sectors in partition 4 0x20 Number of sectors in partition 4 0x24 Logical drive number of partition 2 0x26 Extended signature (29H) 1 0x27 Serial number of partition 4 0x2B Volume name of partition 11 0x36 FAT name (FAT16) 8 0x3E Executable code 448 0xFE Executable marker (0x55 0xAA) 2 l TOTAL 512 Table 2. Boot sector fields Running FAT16 File Systems and DOS Commands on SHARC® Processors (EE-329) Page 3 of 24 a Based on information from the boot sector, the offset locations for all the other regions are calculated as shown in Table 3. Offset Description Start of partition Boot sector Start + number of reserved sectors Fat tables Start + number of reserved sectors+ (number of sectors per FAT * 2) Root directory Start + number of reserved sectors+ (number of sectors per FAT * 2) + Data area (starts with cluster number 2) ((maximum root directory entries * 32) / bytes per sector) Table 3. Offset calculation for various regions of the disk File Allocation Table A partition is divided into identically sized clusters, small blocks of contiguous space. Cluster size may vary, depending upon the size of the partition. Typically, cluster size is between 2 Kbytes and 32 Kbytes. Each file may occupy one or more of these clusters, depending on its size. A file is represented by a chain of these clusters. The clusters in these chains are not necessarily adjacent to one another on the disk's surface and may be fragmented throughout the data region. FAT is a list of entries that map to each cluster on the partition. Each entry records one of the following information listed in Table 4. Sector Number FAT entry Description 1 0x0002 - 0xFFEF Address of the next cluster in a chain. 2 0xFFF8 - 0xFFFF Last cluster of the file (EOF). 3 0xFFF7 Bad cluster 4 0x0001 Reserved cluster 5 0x0000 Unused/Free cluster Table 4. FAT entries Figure 2 shows the mapping of three files using FAT entries. Figure 2. File allocation table Running FAT16 File Systems and DOS Commands on SHARC® Processors (EE-329) Page 4 of 24 a Directory Table A directory table is a special type of file that represents a directory (commonly called a folder). The parameters related to any file or sub-directory are represented by a 32-byte entry in the directory table, corresponding to the parent directory. Each entry records the name, extension, attributes, date and time of creation, address of the first cluster, and the size of the file or directory. The directory table for the root directory is stored in the root directory region location; the directory tables for directories other than the root directory are stored in the data region. Entries with the sub-directory flag set should have a size of 0.
Recommended publications
  • Active@ UNDELETE Documentation
    Active @ UNDELETE Users Guide | Contents | 2 Contents Legal Statement.........................................................................................................5 Active@ UNDELETE Overview............................................................................. 6 Getting Started with Active@ UNDELETE.......................................................... 7 Active@ UNDELETE Views And Windows...................................................................................................... 7 Recovery Explorer View.......................................................................................................................... 8 Logical Drive Scan Result View..............................................................................................................9 Physical Device Scan View......................................................................................................................9 Search Results View...............................................................................................................................11 File Organizer view................................................................................................................................ 12 Application Log...................................................................................................................................... 13 Welcome View........................................................................................................................................14 Using
    [Show full text]
  • Answers to Even- Numbered Exercises 5
    Answers to Even- Numbered Exercises 5 from page 163 1. What does the shell ordinarily do while a command is executing? What should you do if you do not want to wait for a command to finish before running another command? 2. Using sort as a filter, rewrite the following sequence of commands: $ sort list > temp $ lpr temp $ rm temp $ cat list | sort | lpr 3. What is a PID number? Why are they useful when you run processes in the background? 4. Assume that the following files are in the working directory: $ ls intro notesb ref2 section1 section3 section4b notesa ref1 ref3 section2 section4a sentrev Give commands for each of the following, using wildcards to express filenames with as few characters as possible. 1 2 Chapter 5 Answers to Exercises a. List all files that begin with section. $ ls section* b. List the section1, section2, and section3 files only. $ ls section[1-3] c. List the intro file only. $ ls i* d. List the section1, section3, ref1, and ref3 files. $ ls *[13] 5. Refer to the documentation of utilities in Part III or the man pages to determine what commands will a. Output the number of lines in the standard input that contain the word a or A. b. Output only the names of the files in the working directory that contain the pattern $(. c. List the files in the working directory in their reverse alphabetical order. d. Send a list of files in the working directory to the printer, sorted by size. 6. Give a command to a. Redirect the standard output from a sort command into a file named phone_list.
    [Show full text]
  • Openvms: an Introduction
    The Operating System Handbook or, Fake Your Way Through Minis and Mainframes by Bob DuCharme VMS Table of Contents Chapter 7 OpenVMS: An Introduction.............................................................................. 7.1 History..........................................................................................................................2 7.1.1 Today........................................................................................................................3 7.1.1.1 Popular VMS Software..........................................................................................4 7.1.2 VMS, DCL................................................................................................................4 Chapter 8 Getting Started with OpenVMS........................................................................ 8.1 Starting Up...................................................................................................................7 8.1.1 Finishing Your VMS Session...................................................................................7 8.1.1.1 Reconnecting..........................................................................................................7 8.1.2 Entering Commands..................................................................................................8 8.1.2.1 Retrieving Previous Commands............................................................................9 8.1.2.2 Aborting Screen Output.........................................................................................9
    [Show full text]
  • Your Performance Task Summary Explanation
    Lab Report: 11.2.5 Manage Files Your Performance Your Score: 0 of 3 (0%) Pass Status: Not Passed Elapsed Time: 6 seconds Required Score: 100% Task Summary Actions you were required to perform: In Compress the D:\Graphics folderHide Details Set the Compressed attribute Apply the changes to all folders and files In Hide the D:\Finances folder In Set Read-only on filesHide Details Set read-only on 2017report.xlsx Set read-only on 2018report.xlsx Do not set read-only for the 2019report.xlsx file Explanation In this lab, your task is to complete the following: Compress the D:\Graphics folder and all of its contents. Hide the D:\Finances folder. Make the following files Read-only: D:\Finances\2017report.xlsx D:\Finances\2018report.xlsx Complete this lab as follows: 1. Compress a folder as follows: a. From the taskbar, open File Explorer. b. Maximize the window for easier viewing. c. In the left pane, expand This PC. d. Select Data (D:). e. Right-click Graphics and select Properties. f. On the General tab, select Advanced. g. Select Compress contents to save disk space. h. Click OK. i. Click OK. j. Make sure Apply changes to this folder, subfolders and files is selected. k. Click OK. 2. Hide a folder as follows: a. Right-click Finances and select Properties. b. Select Hidden. c. Click OK. 3. Set files to Read-only as follows: a. Double-click Finances to view its contents. b. Right-click 2017report.xlsx and select Properties. c. Select Read-only. d. Click OK. e.
    [Show full text]
  • [JUMP FLOPPY Bios PARAMETER BLOCK—\20
    US 20020026571A1 (19) United States (12) Patent Application Publication (10) Pub. No.: US 2002/0026571 A1 Rickey (43) Pub. Date: Feb. 28, 2002 (54) DUAL USE MASTER BOOT RECORD comprising: a computer usable medium including at least one partition area and a boot sector, With the computer (76) Inventor: Albert E. Rickey, Lake Forest, CA usable medium having computer readable program code (Us) means embodied therein, comprising: ?rst computer read able code means ?xed in the boot sector including a ?rst Correspondence Address: BIOS parameter block for setting parameters for the medium IRELL & MANELLA LLP if inserted in a ?oppy drive of the computer; and second 840 NEWPORT CENTER DRIVE SUITE 400 computer readable code means ?xed in the boot sector NEWPORT BEACH, CA 92660 (US) comprising a Partition Table for organizing the medium to include at least one partition and for designating an active (21) Appl. No.: 09/960,181 partition. In a further embodiment of the invention, the article of manufacture includes: third computer readable (22) Filed: Sep. 20, 2001 code means ?xed in the active partition area on the computer readable medium and including a second BIOS parameter Related US. Application Data block, and DOS boot record code for locating operating system ?les, loading the operating system ?les into the (63) Continuation of application No. 09/163,359, ?led on memory of the computer and causing the computer to Sep. 30, 1998, noW Pat. No. 6,308,264. execute them; and fourth computer readable code means ?xed in the boot sector comprising a master boot record code Publication Classi?cation for loading into the memory of the computer the third computer readable code means comprising the second BIOS (51) Int.
    [Show full text]
  • What Is UNIX? the Directory Structure Basic Commands Find
    What is UNIX? UNIX is an operating system like Windows on our computers. By operating system, we mean the suite of programs which make the computer work. It is a stable, multi-user, multi-tasking system for servers, desktops and laptops. The Directory Structure All the files are grouped together in the directory structure. The file-system is arranged in a hierarchical structure, like an inverted tree. The top of the hierarchy is traditionally called root (written as a slash / ) Basic commands When you first login, your current working directory is your home directory. In UNIX (.) means the current directory and (..) means the parent of the current directory. find command The find command is used to locate files on a Unix or Linux system. find will search any set of directories you specify for files that match the supplied search criteria. The syntax looks like this: find where-to-look criteria what-to-do All arguments to find are optional, and there are defaults for all parts. where-to-look defaults to . (that is, the current working directory), criteria defaults to none (that is, select all files), and what-to-do (known as the find action) defaults to ‑print (that is, display the names of found files to standard output). Examples: find . –name *.txt (finds all the files ending with txt in current directory and subdirectories) find . -mtime 1 (find all the files modified exact 1 day) find . -mtime -1 (find all the files modified less than 1 day) find . -mtime +1 (find all the files modified more than 1 day) find .
    [Show full text]
  • Invalid Class String Error
    Tib4231 July, 2001 TECHNICAL INFORMATION BULLETIN Invalid Class String Error KODAK DC215, KODAK DC240, KODAK DC280, DC3400, and DC5000 Zoom Digital Cameras An Invalid Class String error may occur when you try to launch the camera software for the first time, or the Mounter or Camera Properties software may not operate properly.This error is caused when the program RegSvr32.exe is not located in the C:\Windows\System folder, preventing the DLL files from being registered. Use this document to help you properly locate the RegSvr32.exe program in your system, and if necessary, manually register the DLL files. The instructions in this document assume that you are familiar with copying and moving files in your computer, and installing software. Relocating RegSvr32.exe 1. Go to Start > Find > Files and Folders and search for regsvr32*.* Note the location of the program. 2. In WINDOWS Explorer or My Computer, copy RegSvr32.exe to the C:\Windows\System folder if it is not already there. When the file is in place, go on to Step 3. 3. Uninstall the KODAK software using the KODAK Uninstall application, or go to Start > Settings > Control Panel > Add / Remove Programs. 4. Close all background programs except Explorer and Systray by pressing Ctrl Alt Del, selecting each program one at a time, and clicking End Task after each. 5. Install the KODAK camera software. 6. Start the KODAK Camera Mounter and Camera Properties software for your camera. If the Invalid Class String error appears, manually register the DLL file using the procedure that follows for your camera.
    [Show full text]
  • MS-DOS Basics.Pdf
    MS-DOS Basics The Command Prompt When you first turn on your computer, you will see some cryptic information flash by. MS-DOS displays this information to let you know how it is configuring your computer. You can ignore it for now. When the information stops scrolling past, you'll see the following: C:\> This is called the command prompt or DOS prompt. The flashing underscore next to the command prompt is called the cursor. The cursor shows where the command you type will appear. Type the following command at the command prompt: ver The following message appears on your screen: MS-DOS version 6.22 Viewing the Contents of a Directory To view the contents of a directory 1. Type the following at the command prompt: dir A list similar to the following appears: Changing Directories To change from the root directory to the WINDOWS directory To change directories, you will use the cd command. The cd command stands for "change directory." 1. Type the following at the command prompt: cd windows The command prompt changes. It should now look like the following: C:\WINDOWS> Next, you will use the dir command to view a list of the files in the DOS directory. Viewing the Contents of WINDOWS Directory To view a list of the files in the WINDOWS directory 1. Type the following at the command prompt: dir Changing Back to the Root Directory To change to the root directory 1. Type the following at the command prompt: cd \ Note that the slash you type in this command is a backslash (\), not a forward slash (/).
    [Show full text]
  • MS-DOS Lecture
    MS-DOS 2017 University of Babylon College of Engineering Electrical Department Learning Basics of MS-DOS Assis. Lec. Abeer Abd Alhameed | 1 MS-DOS 2017 Outcomes: By the end of this lecture, students are able to: Define the MS-DOS system Log in MS-DOS commands system Display MS-DOS information on your computer Type basic commands of MS-DOS system (view directory contents, change directory, make directory) Assis. Lec. Abeer Abd Alhameed | 2 MS-DOS 2017 Learning of MS-DOS Basics: Definition - What does Microsoft Disk Operating System (MS- DOS) mean? The Microsoft Disk Operating System (MS-DOS) is an operating system developed for PCs (personal computers) with x86 microprocessors. It was the first widely-installed operating system in personal computers. It is a command-line-based system, where all commands are entered in text form and there is no graphical user interface. The Command Prompt: When you first turn on your computer, you will see some information flash by. MS-DOS displays this information to let you know how it is configuring your computer. You can ignore it for now. When the information stops scrolling past, you'll see the following: C:\> This is called the command prompt or DOS prompt. The flashing underscore next to the command prompt is called the cursor. The cursor shows where the command you type will appear. Typing a Command: This section explains how to type a command at the command prompt and demonstrates the "Bad command or file name" message. • To type a command at the command prompt 1. Type the following at the command prompt (you can type the command in either uppercase or lowercase letters): nul If you make a typing mistake, press the BACKSPACE key to erase the mistake, and then try again.
    [Show full text]
  • CS 103 Lab 1 - Linux and Virtual Machines
    CS 103 Lab 1 - Linux and Virtual Machines 1 Introduction In this lab you will login to your Linux VM and write your first C/C++ program, compile it, and then execute it. 2 What you will learn In this lab you will learn the basic commands and navigation of Linux/Unix, its file system, the GNU C/C++ compiler and a few basic applications such as Gedit. Important: The Linux operating system and environment shares a vast majority of commands and methods with Unix. 3 Background Information and Notes 3.1 Software to Install on your PC Start by following the course virtual machine installation instructions found at the link below. http://cs103.usc.edu/tools-and-links/installing-course-vm/ Below is a list of recommended software you should install that will be helpful over multiple courses in CS and EE. These tools allow you to access remote servers, run GUI apps on those servers, and transfer files between your PC and those servers. For Windows: FileZilla FTP – Available from : https://software.usc.edu/index.aspx XWin-32 – Available from : https://software.usc.edu/index.aspx PuTTY – Available from : https://software.usc.edu/index.aspx For Mac: X Server: http://developer.apple.com/opensource/tools/runningx11.html Fetch FTP – Available from : https://software.usc.edu/index.aspx Reference: http://www.usc.edu/its/unix/ Last Revised: 8/29/2014 1 CS 103 Lab 1 - Linux and Virtual Machines 3.2 Getting Started with Unix1 and Accessing your Account Solaris vs. Unix vs. Linux UNIX was developed by AT&T Bell Labs in 1969.
    [Show full text]
  • Copyrighted Material
    Index Numerics Address Resolution Protocol (ARP), 1052–1053 admin password, SOHO network, 16-bit Windows applications, 771–776, 985, 1011–1012 900, 902 Administrative Tools window, 1081–1083, 32-bit (x86) architecture, 124, 562, 769 1175–1176 64-bit (x64) architecture, 124, 562, 770–771 administrative tools, Windows, 610 administrator account, 1169–1170 A Administrators group, 1171 ADSL (Asynchronous Digital Subscriber Absolute Software LoJack feature, 206 Line), 1120 AC (alternating current), 40 Advanced Attributes window, NTFS AC adapters, 311–312, 461, 468–469 partitions, 692 Accelerated Graphics Port (AGP), 58 Advanced Computing Environment (ACE) accelerated video cards (graphics initiative, 724 accelerator cards), 388 Advanced Confi guration and Power access points, wireless, 996, 1121 Interface (ACPI) standard, 465 access time, hard drive, 226 Advanced Graphics Port (AGP) card, access tokens, 1146–1147 391–392 Account Operators group, 1172 Advanced Graphics Port (AGP) port, 105 ACE (Advanced Computing Environment) Advanced Host Controller Interface (AHCI), initiative, 724 212–213 ACPI (Advanced Confi guration and Power Advanced Micro Devices (AMD), 141–144 Interface) standard, 465 Advanced Packaging Tool (APT), 572 Action Center, 1191–1192 Advanced Power Management (APM) Active Directory Database, 1145–1146, 1183 standard, 465 active heat sink, 150 Advanced Programmable Interrupt active matrix display, LCD (thin-fi lm Controller (APIC), 374 transistor (TFT) display), 470 Advanced RISC Computing Specifi cation active partition, 267,
    [Show full text]
  • Wikipedia: Design of the FAT File System
    Design of the FAT file system A FAT file system is a specific type of computer file system architecture and FAT a family of industry-standard file systems utilizing it. Developer(s) Microsoft, SCP, IBM, [3] The FAT file system is a legacy file system which is simple and robust. It Compaq, Digital offers good performance even in very light-weight implementations, but Research, Novell, cannot deliver the same performance, reliability and scalability as some Caldera modern file systems. It is, however, supported for compatibility reasons by Full name File Allocation Table: nearly all currently developed operating systems for personal computers and FAT12 (12- many home computers, mobile devices and embedded systems, and thus is a bit version), well suited format for data exchange between computers and devices of almost FAT16 (16- any type and age from 1981 through the present. bit versions), Originally designed in 1977 for use on floppy disks, FAT was soon adapted and FAT32 (32-bit version used almost universally on hard disks throughout the DOS and Windows 9x with 28 bits used), eras for two decades. Today, FAT file systems are still commonly found on exFAT (64- floppy disks, USB sticks, flash and other solid-state memory cards and bit versions) modules, and many portable and embedded devices. DCF implements FAT as Introduced 1977 (Standalone the standard file system for digital cameras since 1998.[4] FAT is also utilized Disk BASIC-80) for the EFI system partition (partition type 0xEF) in the boot stage of EFI- FAT12: August 1980 compliant computers. (SCP QDOS) FAT16: August 1984 For floppy disks, FAT has been standardized as ECMA-107[5] and (IBM PC DOS 3.0) ISO/IEC 9293:1994[6] (superseding ISO 9293:1987[7]).
    [Show full text]