title: Pointer randomly assigned mysterious values (A5A5A5A5 and FFFFFFFF) on a stm32 using freeRTOS causing hardfault
body: <p>I have a problem with a hardfault that appears at seemingly random times where a pointer is pointing to address A5 or FF (my allowed memory space is far below that at 80000000 and up). It seems to always be the same pointer with these two values.</p>
  
  <p>I'm using an embedded system running a STM32F205RE processor which communicates to a fm/bluetooth/gps chip called cg2900 where this error occurs.</p>
  
  <p>Using a debugger I can see that the pointer is pointing to address A5 and FF respectively during a few testruns. However it seems to happen at random times, sometimes I can run the test for an hour without a failure while other times it crashes 20 seconds in.</p>
  
  <p>I'm running freeRTOS as a scheduler to switch between different tasks (one for radio, one for bluetooth, one for other periodical maintenance) which might interfere somehow.</p>
  
  <p>What can be the cause of this? As it's running custom hardware it can not be ruled out that it's a hardware issue (potentially). Any pointers (no pun intended) on how to approach debugging the issue?</p>
  
  <p>EDIT:</p>
  
  <p>After further investigations it seems that it is very random where it crashes, not just that specific pointer. I used a hardfault handler to get the following values of these registers (all values in hex):</p>
  
  <p>Semi-long run before crash (minutes):</p>
  
  <pre><code>R0 = 1
  R1 = fffffffd
  R2 = 20000400
  R3 = 20007f7c
  R12 = 7
  LR [R14] = 200000c8  subroutine call return address
  PC [R15] = 1010101  program counter
  PSR = 8013d0f
  BFAR = e000ed38
  CFSR = 10000
  HFSR = 40000000
  DFSR = 0
  AFSR = 0
  SCB_SHCSR = 0
  </code></pre>
  
  <p>Very short run before crash (seconds):</p>
  
  <pre><code>R0 = 40026088
  R1 = fffffff1
  R2 = cb3
  R3 = 1
  R12 = 34d
  LR [R14] = 40026088  subroutine call return address
  PC [R15] = a5a5a5a5  program counter
  PSR = fffffffd
  BFAR = e000ed38
  CFSR = 100
  HFSR = 40000000
  DFSR = 0
  AFSR = 0
  SCB_SHCSR = 0
  </code></pre>
  
  <p>Another short one (seconds):</p>
  
  <pre><code>R0 = 0
  R1 = fffffffd
  R2 = 20000400
  R3 = 20007f7c
  R12 = 7
  LR [R14] = 200000c8  subroutine call return address
  PC [R15] = 1010101  program counter
  PSR = 8013d0f
  BFAR = e000ed38
  CFSR = 1
  HFSR = 40000000
  DFSR = 0
  AFSR = 0
  SCB_SHCSR = 0
  </code></pre>
  
  <p>After a very long run (1hour +):<br /></p>
  
  <pre><code>R0 = e80000d0
  R1 = fffffffd
  R2 = 20000400
  R3 = 2000877c
  R12 = 7
  LR [R14] = 200000c8  subroutine call return address
  PC [R15] = 1010101  program counter
  PSR = 8013d0f
  BFAR = 200400d4
  CFSR = 8200
  HFSR = 40000000
  DFSR = 0
  AFSR = 0
  SCB_SHCSR = 0
  </code></pre>
  
  <p>Seems to crash at the same point most of the time. I adjusted the memory according to previous suggestions but I still seem to have the same issue.</p>
  
  <p>Thanks for your time!</p>
  
  <p>Kind regards</p>