Hi all Experts,
I'm working to create a custom code where I want a separate bootloader and separate application code memory. So I have defined the memory for Bootloader as well as application memory. My linker file looks like this
-P(CODE)BOOT_MEM=4000-5FFF
-P(CODE)APP_MEM=6000-BFFF
-P(CODE)CODE=4000-FF7F,10000-23FF7
-Z(CODE)CODE_PAD
Here in the linker file, I have defined Booloader memory as 4000-5FFF and for Application memory, it is 6000-BFFF. I'll also attach my code for reference just to get feedback on whether my approach is correct.
One more thing I would like to mention is that for bootloader I'm creating a different project and for application memory, it's a different project itself.
#include <MSP430FR5969.h> #include <stdio.h> #include <stdint.h> #include <stdbool.h> #pragma location="INFOA" int application_memory; #pragma location="COPY" void check_app_flag()@ "COPY" { if(application_memory == 1) { for(int l = 0; l<30; l++) { P1OUT ^= BIT0; __delay_cycles(50000); } } } #pragma location= "APPLICATION_MEMORY" void main( void )@ "APPLICATION_MEMORY" { // Stop watchdog timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD; int l; P1OUT &= ~0x01; P1DIR |= 0x01; PM5CTL0 &= ~LOCKLPM5; check_app_flag(); for(l = 0; l<10; l++) { P1OUT ^= BIT0; __delay_cycles(800000); } for(l=0; l<15; l++) { P1OUT ^= BIT0; __delay_cycles(100000); } application_memory = 1; // Force a Software BOR PMMCTL0 = PMMPW | PMMSWBOR; }
#include <MSP430FR5969.h> #include <stdio.h> #include <stdint.h> #include <stdbool.h> #pragma location="INFOA" int application_memory; #pragma location="COPY" void check_app_flag()@ "COPY" { if(application_memory == 1) { for(int l = 0; l<30; l++) { P1OUT ^= BIT0; __delay_cycles(50000); } } } #pragma location= "APPLICATION_MEMORY" void main( void )@ "APPLICATION_MEMORY" { // Stop watchdog timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD; int l; P1OUT &= ~0x01; P1DIR |= 0x01; PM5CTL0 &= ~LOCKLPM5; check_app_flag(); for(l = 0; l<10; l++) { P1OUT ^= BIT0; __delay_cycles(800000); } for(l=0; l<15; l++) { P1OUT ^= BIT0; __delay_cycles(100000); } application_memory = 1; // Force a Software BOR PMMCTL0 = PMMPW | PMMSWBOR; }