User`s manual

64 rabbit.com The System Identification and User Blocks
7.2.2 Reserved Flash Space
The macro MAX_USERBLOCK_SIZE (default 0x8000) in the BIOS tells the Dynamic C compiler how
much flash at the top of the primary flash is excluded from use by the compiler for xmem functions. For
any application, whether compiled to a single target board or for multiple target boards, the
MAX_USERBLOCK_SIZE macro value defined in RabbitBios.c must not be lower than the amount
of flash required for the
System ID/User blocks on the target board with the largest requirement. Note that
in the case of mirrored combined ID/User blocks (version 3 and up), the amount of flash that must be
reserved is double the size of one combined ID/User block image. For example, if a target board has mir-
rored combined ID/User blocks and the size of one image is 16 KB (0x4000 bytes), then the minimum
value defined for the MAX_USERBLOCK_SIZE macro is 32 KB (0x8000 bytes).
All of the default MAX_USERBLOCK_SIZE reserved space is not necessarily needed by the System ID
and User blocks, but reserving this much space maximizes forward binary compatibility should a product
switch to any of various huge, non-uniform sector flash types. Some of these types have sectors of 8 KB, 8
KB and 16 KB at the top, and the mirrored design of the User block requires that these 3 sectors be used. If
you do not need the User block and are not concerned with forward binary compatibility, the
MAX_USERBLOCK_SIZE macro value could be safely lowered (protecting the sector containing the ID
block) to as little as 0x4000 (16 KB), but only if the System ID block is rewritten to set the User block size
to zero (i.e., no run-time flash writes can occur, such as to the User block or to a flash file system).
Reducing the MAX_USERBLOCK_SIZE macro value will only increase available xmem code space, not
root code space which is generally in shorter supply. To increase available xmem code space, the following
general procedure should be followed:
1. Determine that binary forward compatibility with large sector flash types as described above is not an
issue. This means that the application will only ever run on target boards equipped with small sector
flash (i.e., uniform sectors of a size no larger than 4 KB).
2. Determine the application's minimum User block size requirement. If the application does not write to
the User block, this size is zero.
3. If the target board has factory calibration constants stored in the User block, add the size reserved for
these constants. Consult your hardware manual for the reserved size required.
4. Add the size of the System ID block, which is 132 bytes for versions 2 through 4.
5. Round this total size up to the next higher 4 KB block boundary.
6. If using mirrored combined (version 3 or 4) ID/User blocks, double the size.
7. Calculate the number of 4 KB blocks required for the total size.
8. Edit the write_idblock.c utility to set the required number of 4 KB blocks, and write a new ID
block onto the target board.
9. Repeat the previous steps for every board which is to be programmed with the application(s) compiled
using the updated MAX_USERBLOCK_SIZE macro value.
10.Edit the RabbitBios.c file to update the MAX_USERBLOCK_SIZE macro value.
Note that it is especially difficult to effectively reduce the MAX_USERBLOCK_SIZE macro value below
0x4000 (16 KB) for the BL20xx or BL21xx board families, which have their combined ID/User blocks
size hard-coded in the FLASHWR.LIB and IDBLOCK.LIB libraries because their stored calibration con-
stants are in a nonstandard place. For this reason, Rabbit strongly recommends not attempting to make
System ID/User block changes on these board families.