Why does my MPLAB® Harmony bootloader project build successfully, but with the warning message: …contains code that is located at addresses that do not exist? Should it be ignored?
A PIC32 bootloader application generated with MPLAB Harmony may generate the following warning message, however, it is alright to ignore it.
Warning: "dir"/Demo/firmware/Demo.X/dist/default/debug/Demo.X.debug.elf contains code that is located at addresses that do not exist on the PIC32MZ2048ECH144.
The linker file (btl_mz.ld, generated during the build process) contains a section that fills the memory area 0x1FC14000 - 0x1FC1FFF0 with value 0xFF:
.fill1 : { FILL(0xFF); . = ORIGIN(protected_reg3) + LENGTH(protected_reg3) - 1;}
This generates the warning mentioned. But the memory range filled is valid for the PIC32MZ2048ECH144 microcontroller, so the warning can be ignored.
The bootloaders are configured to only -01 optimization (maximum level enabled for the free compiler version), which, for some bootloaders, will exceed the 80 KB available in each boot flash block.
To resolve this, the linker script treats both 80 KB as one 160 KB block and uses a fill command to block the areas that aren't implemented. However, the hex file contains the fill data, and that is why the error occurs.
You can resolve this in multiple ways:
- Increase optimization, if you have the Pro version of the compiler, remove the fill command, and shrink the boot flash area.
- Change the fill command line in the linker script:
.fill1 (NOLOAD):
That will remove the fill from the hex file and the error should stop. The fix will look like the following:
.fill1 (NOLOAD): // previously just .fill1: { FILL(0xFF); . = ORIGIN(protected_reg3) + LENGTH(protected_reg3) - 1; BYTE(0xFF) } > protected_reg3 }