2.3.160. WRITEFILE

Writes the contents of memory to a file, performing a format conversion if necessary.

Syntax

WRITEFILE ,{obj|raw|raw8|raw16|raw32} [,nowarn] filename [=]address-range

WRITEFILE ,ascii[,opts] [,nowarn] filename [=]address-range

Note

You must specify an address range with all type qualifiers.

where:

obj

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

Note

It is only valid to use obj if the area of target memory contains an executable image. If no executable image is present, subsequent behavior is undefined.

raw

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

raw8

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

raw16

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

raw32

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

ascii

Write the file as a stream of ASCII digits separated by whitespace. The exact format is specified by other qualifiers (see the opts qualifier). The file has a one line header that is compatible withthe READFILE and VERIFYFILE commands. This header has the following format:

[start,end,size]

where:

  • start and end specifies the address range that is written

  • size indicates the size of each value (8, 16, or 32 bits).

opts

Optional qualifiers available for use with the ascii qualifier:

byte

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

half_word | word

The file is a stream of 16-bit values.

long

The file is a stream of 32-bit hexadecimal values.

nowarn

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?

This also suppresses the warning if the file you are writing to already exists. In this case, the existing file is overwritten.

filename

The name of the file to be written.

You can include one or more environment variables in the filename. For example, if MYPATH defines the location C:\Myfiles, you can specify:

writefile,raw "$MYPATH\\myfile.dat" 0x8000..0x8100
address-range

The address range in target memory to write to the file. Specify an address range as:

  • start_addr..end_addr, for example 0x8000..0x8FFF

  • start_addr..+length, for example 0x8000..+0x1000.

Note

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

Description

The WRITEFILE command writes the contents of memory to a file, performing a format conversion if necessary.

The type of memory assumed depends on the target processor. For example, ARM processors have byte addressable memory.

Examples

The following examples show how to use WRITEFILE:

writefile ,raw 'c:\temp\file.dat' =0x8000..0x8FFF

Write the contents of the 4KB memory page at 0x8000 to the file c:\temp\file.dat, storing the data in raw, uninterpreted, form.

writefile ,ascii,long "c:\temp\file.txt" =0x8000..+0x1000

Write the contents of the 4KB memory page at 0x8000 to the file c:\temp\file.dat, storing it as 32-bit values in target memory endianness. For example, the file might look similar to this:

[0x8000,0x8FFF,32]
E28F8090 E898000F E0800008 E0811008 
E0822008 E0833008 E240B001 E242C001 
E1500001 0A00000E E8B00070 E1540005
...

Note

By writing a file as long values and reading it back as long values on a different target, you can convert the endianness of the data in the file.

See also

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