The --FILL driver option allows you to fill the unused program memory with a known value.
You can access this option in the MPLAB® X IDE > XC8 Project Properties > XC8 Linker > Fill Flash Memory selection in the drop-down menu; and then enter the appropriate argument in the Fill field.
This option utilizes the Hexmate application to fill unused locations, thus it will only work for HEX files — it will not fill unused locations in binary file outputs.
The usage of the driver option is:
--FILL=[const_width:]fill_expr[@address[:end_address]]
Example:
Executing the following command will fill the unused locations in hex file with 0x3FFF
hexmate.exe Code.hex --fill=0x3FFF
fill_expr can use the syntax (where const and increment are n-byte constants):
- const fill memory with a repeating constant.
For example: --FILL=0xBEEF becomes 0xBEEF, 0xBEEF, 0xBEEF, 0xBEEF
- const+=increment fill memory with an incrementing constant.
For example: --fill=0xBEEF+=1 becomes 0xBEEF, 0xBEF0, 0xBEF1, 0xBEF2
- const-=increment fill memory with a decrementing constant.
For example: --fill=0xBEEF-=0x10 becomes 0xBEEF, 0xBEDF, 0xBECF, 0xBEBF
- const,const,…,const fill memory with a list of repeating constants.
For example: --FILL=0xDEAD,0xBEEF becomes 0xDEAD,0xBEEF,0xDEAD,0xBEEF
The options following fill_expr result in the following behavior:
- @unused (or nothing) fill all unused memory with fill_expr.
For example: --FILL=0xBEEF@unused fills all unused memory with 0xBEEF.
- @address fill a specific address with fill_expr.
For example: --FILL=0xBEEF@0x1000 puts 0xBEEF at address 1000h
- @address:end_address fill a range of memory with fill_expr.
For example: --FILL=0xBEEF@0:0xFF puts 0xBEEF in unused addresses between 0 and 255