Sparc-elf-mkprom User's Manual v1.0.7
Contents
Introduction
sparc-elf-mkprom
utility program creates boot-images for programs compiled with the BCC
cross-compiler. It encapsulates the application in a loader
suitable to be placed in a boot prom. The application is compressed
with a modified LZSS algorithm, typically achieving a compression
factor of 2. The loader operates in the following steps:
- The register files of IU and FPU (if present) are initialized.
- The LEON control, waitstate and memory configuration registers are set according to the specified options.
- The application is decompressed and installed into RAM
- Finally, the application is started, setting the stack pointer to the top of ram.
The created boot-prom will run on
both LEON2 or LEON3 systems.
NOTE:
this version of MkProm can only generate boot proms for LEON2 and LEON3
processors. Other SPARC processors like TSC691 or TSC695 (ERC32) are not supported.
Usage
sparc-elf-mkprom is a command line utility that takes a number of options and files to encapsulate:
sparc-elf-mkprom [options] files
To generate a boot-prom for a typical system, do:
sparc-elf-mkprom -v -rmw -ramsize 1024 hello
LEON3 MKPROM boot-prom builder for BCC v1.0.6
Copyright Gaisler Research 2004, all rights reserved.
loading hello:
section: .text at 0x40000000, size 15744 bytes
Uncoded stream length: 15744 bytes
Coded stream length: 7794 bytes
Compression Ratio: 2.020
section: .data at 0x40003d80, size 2016 bytes
Uncoded stream length: 2016 bytes
Coded stream length: 691 bytes
Compression Ratio: 2.918
section: .jcr at 0x400045c4, size 4 bytes
Uncoded stream length: 4 bytes
Coded stream length: 4 bytes
Compression Ratio: 1.000
creating LEON boot prom: prom.out
When executed, the prom prints a configuration message at start-up:
tsim> run
MkProm LEON boot loader v1.2
Copyright Gaisler Research - all right reserved
system clock : 50.0 MHz
baud rate : 19171 baud
prom : 512 K, (2/2) ws (r/w)
sram : 1024 K, 1 bank(s), 0/0 ws (r/w)
decompressing .text
decompressing .data
decompressing .jcr
starting hello
Hello world!
Creating applications that run in prom
Mkprom
can also create applications that run in prom, and have data and stack
in ram. A prom application is created in two steps:
1. Compile the application into on or more object file, but do not link:
sparc-elf-gcc -msoft-float -c -g -O2 hello.c
2. Create final prom image with mkprom, listing all object files on the command line:
sparc-elf-mkprom -freq 40 -rmw hello.o -msoft-float
A prom application has it code (.text segment) in prom, and data
(.data & .bss) in ram. At start-up, the .data segment is copied
from the prom to the ram, and the .bss segment is cleared. A prom
application is linked to start from address 0x0. The data segment is by
default linked to 0x40000000, but can be
changed by giving the -Tdata=<address> option of gcc to mkprom.
Note that if no FPU is present, the -msoft-float option must also be
given to mkprom in this case since it is needed during the final
linking.
When debugging prom applications with GRMON or gdb, only
hardware breakpoints (hbreak command) can be used. Applications running from prom cannot be compressed.
Mkprom General Options
-baud baudrate
Set rate of UART A to baudrate. Default value is 19200.
-bdinit
The
user can optionally call two user-defined routines, bdinit1() and
bdinit2(), during the boot process. bdinit1() is called after the
LEON registers have been initialized but before the memory has been
cleared. bdinit2() is called after the memory has been initialized but
before the application is loaded. Note that when bdinit1() is called,
the stack has not been setup meaning that bdinit1() must be a leaf
routine and not allocate any stack space (no local variables). When
-bdinit is used, a file called bdinit.o must exist in the current
directory, containing the two routines.
-dump
The
intermediate assembly code with the compressed application and the LEON
register values is put in dump.s (only for debugging of mkprom).
-freq system_clock
Defines
the system clock in MHz. This value is used to calculate the divider
value for the baud rate generator and the real-time clock. Default is
50 for LEON.
-noinit
Suppress
all code which initializes on-chip peripherals such as uarts, timers
and memory controllers. This option requires -bdinit to add custom
initialisation code, or the boot process will fail.
-nomsg
Suppress the boot message.
-nocomp
Don't compress application. Decreases loading time on the expense of rom size.
-o outfile
Put the resulting image in outfile, rather then prom.out (default).
-stack addr
Sets the initial stack pointer to addr. If not specified, the stack starts at top-of-ram.
-v
Be verbose; reports compression statistics and compile commands
input_files
The
input files must be in aout or elf32 format. If more than one file is
specified, all files are loaded by the loader and control is
transferred to the first segment of the first file.
Mkprom options for the LEON2 memory controller
-cas delay
Set the SDRAM CAS delay. Allowed values are 2 and 3, 2 is default.
-col bits
Set the number of SDRAM column bits. Allowed values are 8 - 11, 9 is default.
-nosram
Disables the static RAM and maps SDRAM at address 0x40000000.
-ramsize size
Defines
the total available RAM. Used to initialize the in the memory
configuration register(s). The default value is 2048 (2 Mbyte).
-ramcs chip_selects
Set the number of ram banks to chip_selects. Default is 1.
-ramws ws
Set the number of waitstates during ram reads and writes to ws. Default is 0.
-ramrws ws
Set the number of waitstates during ram reads to ws. Default is 0.
-ramwws ws
Set the number of waitstates during ram writes to ws. Default is 0.
-romws ws
Set the number of rom waitstates during read and write to ws. Default is 2.
-romrws ws
Set the number of rom waitstates during read to ws. Default is 2.
-romwws ws
Set the number of rom waitstates during write to ws. Default is 2.
-ramwidth width
Set the data bus width to 8, 16 or 32-bits, default is 32. The prom width is set through the PIO[1:0] ports.
-rmw
Perform read-modify-write cycles during byte and halfword writes.
-sdram size
The amount of attached SDRAM in Mbyte. 0 by default
-sdrambanks num_banks
Set the number of populated SDRAM banks (default is 1).
-trfc delay
Set the SDRAM tRFC parameter (in ns). Default is 66 ns.
-trp delay
Set the SDRAM tRP parameter (in ns). Default is 20 ns.
-refresh delay
Set the SDRAM refresh period (in us). Default is 7.8 us, although many SDRAMS actually use 15.6 us.
Mkprom options for LEON3
-memc <addr>
Set the address of the memory controller registers. Default is 0x80000000.
-gpt <addr>
Set the address of the timer unit control registers. Default is 0x80000300.
-uart <addr>
Set the address of the UART control registers. Default is 0x80000100.
Jiri Gaisler.
Copyright 2004 Gaisler Research. Comments or bug reports to jiri@gaisler.com.
Permission is granted to make and
distribute verbatim copies of this manual provided the copyright notice
and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided also that
the entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions.