1.14 Bootloader Linker and Build Options
Compiler, Linker and Post Build Options for the Bootloader and Application Projects
Since the bootloader often requires specialized build features, extra build options are often required. These settings are automatically enabled in the most recent versions of MPLABx.
- Basic Verification Linker Settings
-
If the user is not enabling any Code Protect or Codeguard settings, then no linker command line changes are required and the user can skip to the Application Post Build Options below
- Code Protect / Code Guard settings
-
When the user selected Code Protect Bootloader, the device is configured to use Codeguard. This feature requires special linker options to place the code in the correct place. The three added features are listed below along with the command line that needs to be added to the project
- Bootloader Project Linker Settings
-
-
–add-flags-code=boot Forces all code in this project placed in the boot section.
-
–add-flags-const=boot Forces all constants in this project placed in the boot section.
-
-D__USE_BFA Allows the boot section to be placed according to the security mode and not default to normal system map.
This linker command should automatically be added to the project for the user. However, they can be added manually by following the below steps.
-
Go to Project Properties
-
Go to XC16->xc16-ld
-
Under additional options add the following: –add-flags-code=boot,–add-flags-const=boot,-D__USE_BFA
-
- Application Project Linker Settings
-
The application also has an extra linker setting and it should be added automatically and is shown below.
-
-D__USE_BFA Allows the project to use the best fit settings for the code.
These changes should automatically be added to the project for the user. However, they can be added manually by following the below steps.
-
Goto Project Properties
-
Goto XC16->xc16-ld
-
Under additional options add the following: -D__USE_BFA
-
- ECDSA Verification with Code Protect / Code Guard settings
-
When the user selected Code Protect Bootloader, the device is configured to use Codeguard. This feature requires special linker options to place the code in the correct place. Below are the linker settings for both the bootloader and applications.
- Bootloader Project Linker Settings
-
–add-flags-code=boot,–add-flags-const=boot,-D__USE_BFA
The steps needed to change this are shown below.-
Goto Project Properties
-
Goto XC16->xc16-ld
-
Under additional options add the following: –add-flags-code=boot,–add-flags-const=boot,-D__USE_BFA
-
- Application Project Linker Settings
-
Application Linker Settings -D__USE_BFA
-
Go to Project Properties
-
Go to XC16->xc16-ld
-
Under additional options add the following: -D__USE_BFA
-
- Application Project Post Build Settings
-
As the final part of the build process, the application code needs to be signed and converted to a hex format to download. This process is the same for all verification methods and is shown below.
Windows Post Build Command
cd mcc_generated_files/boot && postBuild.bat $(MP_CC_DIR) $(ProjectDir) $(ImageDir) $(ImageName) $(IsDebug)
Linux Post Build Command
cd mcc_generated_files/boot && ./postBuild.sh $(MP_CC_DIR) $(ProjectDir) $(ImageDir) $(ImageName) $(IsDebug)
- Adding Post Build step to Application Project
-
-
Go to Project Properties
-
Select the 'Building' left navigation node.
-
Check the box next to 'Execute this line after the build'.
-