This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSPM0L1306-Q1: Reading from NVM (Flash) gives me a Hard Fault

Part Number: MSPM0L1306-Q1
Other Parts Discussed in Thread: MSPM0L1306

This is how my linker cmd file looks like

-uinterruptVectors
--stack_size=256

MEMORY
{
   FLASH           (RX)  : origin = 0x00000000, length = 0x0000F4F7
   SEN_CFG         (RW)  : origin = 0x0000F4F8, length = 0x00000A80 
   SRAM            (RWX) : origin = 0x20000000, length = 0x00001000
   BCR_CONFIG      (R)   : origin = 0x41C00000, length = 0x00000080
   BSL_CONFIG      (R)   : origin = 0x41C00100, length = 0x00000080
}

SECTIONS
{
    .intvecs:   > 0x00000000
    .text   : palign(8) {} > FLASH
    .const  : palign(8) {} > FLASH
    .cinit  : palign(8) {} > FLASH
    .pinit  : palign(8) {} > FLASH
    .rodata : palign(8) {} > FLASH
    .ARM.exidx    : palign(8) {} > FLASH
    .init_array   : palign(8) {} > FLASH
    .binit        : palign(8) {} > FLASH
    .TI.ramfunc   : load = FLASH, palign(8), run=SRAM, table(BINIT)

    .vtable :   > SRAM
    .args   :   > SRAM
    .data   :   > SRAM
    .bss    :   > SRAM
    .sysmem :   > SRAM
    .stack  :   > SRAM (HIGH)

    .SENCFG     : {} > SEN_CFG
    .BCRConfig  : {} > BCR_CONFIG
    .BSLConfig  : {} > BSL_CONFIG
}


As can be seen, I have defined a new section to store (and load) configuration data starting from 0x0000F4F8 spanning 0xA80 bytes. I've reduced the size of the section called 'FLASH' too. My new section is away from the last 8 bytes as mentioned in the manual. I was able to write to one of the locations in this region. However it will occasionally fail here too. It worked a couple of times and now I get a hard fault while writing to the same location. Previously, I was able to write to it but I faced this issue while reading from it.

I'd like to know if I need to do anything more than this aka defining a separate memory section and then directly using an address from within that section as part of code?

To identify the exception, I modified all exceptions and interrupts so that it breaks as suggested by  here. Now it shows that I am getting a 'Hard Fault'. I am not sure why. Does anything here suggest that I may be accessing illegal memory? What could cause a hard fault in a case like mine? 


  • Hi Aj,

    How do you write the flash? I am not sure is this used for data or code area. We provide example code in SDK to call the flash controller to program flash, and you can refer to "flashctl_multiple_size_write_LP_MSPM0L1306_nortos_ticlang".

    If it is used for code, or to save the data by compiler, please share how you do. Then maybe I can take a try and figure out what happen.

    B.R.

    Sal

  • Hello Sal

    Apparently, I was NOT unprotecting the sector before attempting the (failing) write. I don't know anything besides that I was doing differently than what the example code in the SDK does. SO I need to watch out for it.

    Will keep you updated

  • Hi Aj,

    Sure, I will keep the post open and wait your feedback.

    B.R.

    Sal