This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

scatter_load lead to Usage Fault (Unaligned access) due to the PAD data missing in the generated Hex/binary

hi all,

I am experiencing Usage Fault (Unaligned access) during scatter_load upon powered-on. After investigation it is found that when the PAD is applied at the end of the memory, the PAD data will be ignored in the generated HEX file (Scenario1). But if is no PAD applied at the end of memory (but applied before end of memory), the applied PAD will be kept (scenario 2).

it seem like there is issue with Linker. Can somebody advice on this topic? thank you so much!

Scenario 1:
          ➜ PAD is applied at the end of the memory:
          0x20000320 0x00000d24 0x00000001 Data RW 41 .data.TIMER_main.pwmDutyTiming timer.o
          0x20000321 0x00000d25 0x00000003 PAD

          ➜ PAD data is ignored in the generated HEX file. data 20, PAD none
          :100D0000180800000020024000D00240000002400D
          :100D100000093D000090024000A0024000B00240E7
          :050D200000C0024002CA

Scenario 2:   
          ➜ PAD is NOT applied at the end of the memory: 
          0x20000320 0x00000d70 0x00000001 Data RW 41 .data.TIMER_main.pwmDutyTiming timer.o
          0x20000321 0x00000d71 0x00000003 PAD
          0x20000324 0x00000d74 0x00000004 Data RW 42 .data.TIMER_main.pwmDutyTiming1 timer.o


          ➜ PAD data is in the generated HEX file. data 20, PAD 000000
          :100D50000020024000D002400000024000093D0097
          :100D60000090024000A0024000B0024000C00240DB
          :080D7000020000000200000077

  • Hi SimonYew.

    Padding should not matter in general, that is why linker is inserting padding where it thinks it would be better to do so.

    You could look into why that is a problem in your situation, which access really triggers the fault and why.
    Also, you can change the size of your pwmDutyTiming and make it 4 byte so there will be no necessity for the padding in that particular instance.