10.5.1. Building the ROM image

Follow this procedure to build the ROM image:

  1. Compile the C file ex.c with the following command.

    armcc -c ex.c  (ARM)

    tcc -c ex.c    (Thumb)



    tells the compiler not to link.

  2. Assemble the initialization code init.s.

    armasm init.s

    or, for Thumb:

    armasm -PD "THUMB SETL {TRUE}" init.s

  3. Build the ROM image using armlink.

    armlink -o ram0.axf -ro-base 0xf0000000 -rw-base  0x10000000 
    -first init.o(Init) -map -info Sizes init.o ex.o 

    or, for Thumb:

    armlink -o tram0.axf -ro-base 0xf0000000 -ro-base 0x10000000
    -First init.o(Init) -map -info Sizes init.o ex.o

    The only difference between this and the command used in Example 1 is that here you use -ro 0xf0000000 to specify the ROM base address.

  4. Run the fromELF utility to produce a plain binary version of the image:

    fromelf -nozeropad ram0.axf -bin ram0.bin    (ARM)

    fromelf -nozeropad tram0.axf -bin tram0.bin  (Thumb)

  5. Load and execute the ROM image under ARMulator by starting armsd, ADW, or ADU, then type the following on the command line:

    getfile ram0.bin 0xf0000000   (ARM)

    getfile tram0.bin 0xf0000000    (Thumb)

    This tells armsd to load the file ram0 at address 0xf0000000 in the ARMulator memory map.

  6. Check that the ROM has been loaded correctly by disassembling its first section:

    list 0xf0000000

    Sample output is shown in Sample disassembly below.

  7. Set the program counter to the base of the ROM image, then run it:


    This produces the following output:

    'factory_id' is at address 10000000, contents = AA55AA55
    'display' is at address 10000004

Copyright © 1997, 1998 ARM Limited. All rights reserved.ARM DUI 0040D