6.7.1. The b_flashwrapper.s template file

A template board-level assembly code file (b_flashwrapper.s), complete with comments, is shown in Example 6.1.

You might want to rename your version of b_flashwrapper.s file to something more meaningful.

Note

The file b_flashwrapper.s is also available in Application Note 110 Flash Programming with RealView Debugger, which can be found from the Documentation link on the ARM web site http://www.arm.com.

This code is designed to be linked to reside in a contiguous area of RAM on your target. Therefore, you must specify only an RO base in the linker options.

This does not have to be free scratch memory. By default, RealView Debugger saves the contents of affected RAM and restores it after the Flash operation has completed.

Example 6.1. b_flashwrapper.s template

;************************************************************************/
; b_flashwrapper.s
; Sample board level wrapper code for RVD flash algorithms
;
; 27/3/2003 ARM Ltd.
; Revision: A
; Date: 21/03/2003
;
;************************************************************************/
;************************************************************************/
;* DEFINE MACROS AND EQUATES                                            */
;************************************************************************/
P_WIDTH   EQU     NumberofFlashROMs ; number of FlashROMs in parallel across bus.
WIDTH     EQU     FlashWidth        ; Define resultant width of flash.
                                    ; 32bit=4, 16bit=2, byte=1.
;************************************************************************/
;* DEFINE SMALL STACK AREA                                              */
;************************************************************************/
        AREA   FLASH_STACK, CODE
        DCD    0,0,0,0,0,0,0,0,0,0,0,0 ; 12 words for call depth
stack_top
;************************************************************************/
;************************************************************************/
;* FLASH_init - initialize the board (memory access controls, etc).     */
;************************************************************************/
;  This function is exported and called directly by RVD.
;
;  Should contain any board specific initialisation code.
;
;  RVD API register useage as follows
;  In: R1 will contain base of flash
;  Out: R0=status code   (0=OK, else error)
;  Scratch registers available for use in your code: R6,R7,R8.
;************************************************************************/
        AREA    FLASH_TEXT, CODE, READONLY
        EXPORT          FLASH_init
        ENTRY
FLASH_init
        ldr SP, = stack_top
;   ------------------------------------------------------------------- */
;  Your board specific code goes below
;
;  Examples include disabling watchdogs, enabling
;  chip selectors/enables to allow write to this memory, etc.
;   ------------------------------------------------------------------- */
;       not required for ARM Evaluator7T board
;        place_your_code_here
;   ------------------------------------------------------------------- */
;  end of board specific code
;   ------------------------------------------------------------------- */
        ;bl      check_status            ; check Flash status and return in R0
                                         ; not used for SST flash
        b       Local_init              ; finish init, then Stop on breakpoint
;************************************************************************/
;* Include the appropriate Flash algorithm here to do actual work       */
;************************************************************************/
        INCLUDE flash_algorithm_assembly_code ; include appropriate flash algorithm
;************************************************************************/
;* DEFINE BUFFER FOR WRITE/VERIFY                                       */
;************************************************************************/
        AREA BUFFER, NOINIT
buffer  % Size ; define area of RAM for RVD to buffer data in
               ; prior to writing to flash
        END

See also

Copyright © 2002-2007 ARM Limited. All rights reserved.ARM DUI 0182I
Non-Confidential