Skip to content

Commit 88de751

Browse files
aiwyatt787davidflowers
authored andcommitted
Pull request #97: Fix the entry address for CC16BOOT-8527 and CC16BOOT-8526
Merge in MCU16CE/dspic33-dsc-bootloader-code-examples from ~C74569/dspic33-dsc-bootloader-code-examples:bugfix/CC16BOOT-8528-fix-address to develop * commit '58a46e330241b56c282ecd94d6f05746f3818a9a': Fix MISRA violations and add comments Fix MISRA violation and add comments for required violations Fix MISRA violation and add comments for required violations Fix the entry address for CC16BOOT-8527 and CC16BOOT-8526
2 parents b5bc71c + 58a46e3 commit 88de751

File tree

6 files changed

+39
-17
lines changed

6 files changed

+39
-17
lines changed

.main-meta/main.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"content": {
55
"metaDataVersion": "1.3.0",
66
"name": "com.microchip.mplabx.project.dspic33-dsc-bootloader-code-examples",
7-
"version": "1.2.3",
7+
"version": "1.2.4",
88
"displayName": "dsPIC33 DSC Bootloader Code Examples",
99
"projectName": "dspic33-dsc-bootloader-code-examples",
1010
"shortDescription": "dsPIC33 DSC Bootloader Code Examples",

changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# dsPIC33 DSC Bootloader Code Examples v1.2.4
2+
### Release Highlights
3+
* Corrected application/executable entry address in dspic33a_bootloader_and_firmware_upgrade_demo and dspic33a_secure_boot.
4+
5+
### Features Added\Updated
6+
* Corrected application/executable entry address in dspic33a_bootloader_and_firmware_upgrade_demo and dspic33a_secure_boot.
7+
18
# dsPIC33 DSC Bootloader Code Examples v1.2.3
29
### Release Highlights
310
* Updated instances of "dsPIC33a" to "dsPIC33A".

dspic33a_bootloader_and_firmware_upgrade_demo/.main-meta/main.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"content": {
55
"metaDataVersion": "1.3.0",
66
"name": "com.microchip.mplabx.project.dspic33a-bootloader-and-firmware-upgrade-demo",
7-
"version": "1.2.3",
7+
"version": "1.2.4",
88
"displayName": "dsPIC33A Bootloader and Firmware Upgrade Demo",
99
"projectName": "dspic33a-bootloader-and-firmware-upgrade-demo",
1010
"shortDescription": "This MPLAB® X IDE example demonstrates how to perform secure boot authentication and firmware upgrade via UART with Microchip Device Firmware Update Protocol (M-DFU) and CRC32 verification within MCC Melody.",

dspic33a_bootloader_and_firmware_upgrade_demo/boot.X/mdfu/mdfu_firmware_update.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,27 @@ bool MDFU_FirmwareUpdateVerifyImage(void)
9393
}
9494

9595
void MDFU_FirmwareUpdateStartApplication(void)
96-
{
97-
int (*user_application)(void);
96+
{
97+
/*
98+
* Declare a file-scoped, constant, volatile function pointer named
99+
* 'user_application'. This pointer is set to the program memory (flash)
100+
* address defined by MDFU_CONFIG_APPLICATION_RESET_ADDRESS, which is the
101+
* entry point (reset vector) of the user application.
102+
* The 'space(prog)' attribute specifies that the pointer refers to program
103+
* memory (flash), not data memory (RAM).
104+
* The 'noload' attribute instructs the linker not to initialize this
105+
* variable at startup.
106+
*
107+
* By calling 'user_application()', the bootloader transfers execution to the
108+
* user application.
109+
*/
110+
static void (* volatile const user_application)(void) __attribute__((address(MDFU_CONFIG_APPLICATION_RESET_ADDRESS), space(prog), noload));
98111

99112
/* This is probably being replaced at some point by __builtin__setIVTBASE() but is not currently supported */
100113
/* This also assumes that the first block of memory in the application is the reset/ivt table which may not always be true if there is an application header */
101114
PACCON1bits.IVTBASEWR = 1;
102115
IVTBASE = MDFU_CONFIG_APPLICATION_RESET_ADDRESS;
103116
PACCON1bits.IVTBASEWR = 0;
104117

105-
user_application = (int(*)(void))MDFU_CONFIG_APPLICATION_RESET_ADDRESS;
106-
user_application();
118+
user_application();
107119
}

dspic33a_secure_boot/.main-meta/main.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"content": {
55
"metaDataVersion": "1.3.0",
66
"name": "com.microchip.mplabx.project.dspic33a-secure-boot-and-secure-firmware-upgrade-demo",
7-
"version": "1.2.3",
7+
"version": "1.2.4",
88
"displayName": "dsPIC33A Secure Boot and Secure Firmware Upgrade Demo",
99
"projectName": "dspic33a-secure-boot-and-secure-firmware-upgrade-demo",
1010
"shortDescription": "This MPLAB® X IDE example demonstrates how to perform secure boot authentication and secure firmware upgrade via UART with Microchip Device Firmware Update Protocol (M-DFU) and ECDSA with P-384 verification within MCC Melody.",

dspic33a_secure_boot/boot.X/mdfu/mdfu_partition_executable.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ static void CacheInvalidate(void)
210210
*/
211211
static enum MDFU_PARTITION_STATUS Run(void)
212212
{
213-
/* NOTE: Before starting the executable, all interrupts used
213+
/* NOTE: Before starting the executable, all interrupts used
214214
* by the bootloader must be disabled. Add code here to return
215215
* the peripherals/interrupts to the reset state before starting
216216
* the executable code. */
@@ -226,17 +226,20 @@ static enum MDFU_PARTITION_STATUS Run(void)
226226
IVTBASE = MDFU_CONFIG_EXECUTABLE_DATA_ORIGIN;
227227
PACCON1bits.IVTBASEWR = 0;
228228

229-
/* cppcheck-suppress misra-c2012-11.6
229+
/*
230+
* Declare a file-scoped, constant, volatile function pointer named
231+
* 'user_executable'. This pointer is set to the program memory (flash)
232+
* address defined by MDFU_CONFIG_EXECUTABLE_DATA_ORIGIN, which is the entry
233+
* point of the executable partition.
234+
* The 'space(prog)' attribute specifies that the pointer refers to program
235+
* memory (flash), not data memory (RAM).
236+
* The 'noload' attribute instructs the linker not to initialize this
237+
* variable at startup.
230238
*
231-
* (Rule 11.6) REQUIRED: Required: A cast shall not be performed between
232-
* pointer to void and an arithmetic type
233-
*
234-
* Reasoning: This function represents a jump between the boot code and the
235-
* user code. Because the address of the jump lives outside of boot space,
236-
* there is no way to create an object at that address to references so
237-
* an integer address is used for the pre-defined executable entry point.
239+
* By calling 'user_executable()', the bootloader transfers execution to the
240+
* user application.
238241
*/
239-
void (*user_executable)(void) = (void(*)(void))MDFU_CONFIG_EXECUTABLE_DATA_ORIGIN;
242+
static void (* volatile const user_executable)(void) __attribute__((address(MDFU_CONFIG_EXECUTABLE_DATA_ORIGIN), space(prog), noload));
240243

241244
/* Disable IRT access before transferring control to the executable.
242245
*

0 commit comments

Comments
 (0)