2.3.106. READFILE

Reads a file into target memory.


READFILE ,obj [,nowarn] filename [[=]address]

READFILE ,{raw|raw8|raw16|raw32} [,nowarn] filename [=]address

READFILE ,ascii[,opts] [,nowarn] filename [[=]address|address-range]



The file is an executable file in the standard target format. For ARM targets, this is ARM-ELF.


Read the file as raw data, using the most efficient access size for the target.


Use this option in situations where the length of data is not a multiple of the specified access size.


Read the file as raw data, one byte for each byte of memory.


Read the file as raw data, 16 bits for each 16 bits of memory.


Read the file as raw data, 32 bits for each 32 bits of memory.


You must specify an address with all raw qualifiers.


The file is a stream of ASCII digits separated by whitespace. The interpretation of the digits is specified by other qualifiers (see the opts qualifier). The starting address of the file must be specified in a one line header in one of the following ways:


The start address.


The start address, a comma, and the end address.


The start address, a comma, and the length.


The start address, a comma, the end address, a comma, and the size of each value (8, 16, or 32 bits). This is the format used by the WRITEFILE command.

If the size of the items in the file is not specified, the debugger determines the size by examining the number of white-space separated significant digits in the first data value. For example, if the first data value is 00A0, the size is set to 16-bits.


Optional qualifiers available for use with the ascii qualifier:


The file is a stream of 8-bit values that are written to target memory without extra interpretation.

half_word | word

The file is a stream of 16-bit values.


The file is a stream of 32-bit values.


Suppress the display of the large file warning messages, such as:

Downloading n bytes can take a long time. (Hint: Choosing a larger access size may reduce this time) Do it anyway?


The name of the file to be read. The file can be one that you have written with the WRITEFILE command.

The filename must be enclosed in either single or double quotation marks if a pathname is specified, and the pathname must already exist on your system. You can include one or more environment variables in the filename. For example, if MYPATH defines the location C:\Myfiles, you can specify:

readfile,raw '$MYPATH\myfile.dat' 0x8000

The starting address in target memory for the load.


For an ascii file type, the address range to be loaded. The load terminates when the end of the address range is reached.


For targets that support the TrustZone technology, you can prefix the address or address range with S: or N: to indicate Secure World or Normal World addresses.


The READFILE command reads a file, performs a format conversion on its contents if required, and loads the resulting information into target memory.

The types of file and file formats supported depend on the target processor and any loaded DLLs. The type of memory assumed depends on the target processor. For example, ARM architecture-based processors have byte addressable memory.


The following examples show how to use READFILE:

readfile ,obj 'c:\temp\file.exe'

Reads the contents of the named executable file into memory at its specified start address.

readfile ,ascii,long "c:\temp\file.txt" =0xA000

Reads the contents of the named text file to address 0xA000 in memory. Values are written as words using the target endianness to translate values in the file into bytes in target memory. The file contents can look, for example, like this:

E28F8090 E898000F E0800008 E0811008 
E0822008 E0833008 E240B001 E242C001 
E1500001 0A00000E E8B00070 E1540005

See also

Copyright © 2002-2011 ARM. All rights reserved.ARM DUI 0175N