title: AOSP Kernel debugging
body: <p>We are building a custom android board based on an imx6 SoC. the android version used is quite old (KitKat 4.4.2), and so is the kernel (3.0.35).
  We are dealing with an issue that we haven't figured out yet.</p>
  
  <p>Usually, when everything works fine, the reboot of the board takes 5-6 second top. But sometimes, the reboot of the board takes a <strong>long</strong> time, ranging anywhere from 1.30 minute up to 2.30 minutes.</p>
  
  <p>What we would like to know is, first, which module / function is the kernel stuck in. </p>
  
  <p>We suspect this could be an eMMC problem, but this is a longshot guess and we really have no clue of what is going on at this point.</p>
  
  <p>Do you guys know of ways to make the kernel extra verbose ? like print every function call ? Could kgdb or similar debugging tools help us at this point ?</p>
  
  <p>Thanks,</p>
  
  <p>Regards,</p>
  
  <p>Vauteck</p>
  
  <p>EDIT:
  So we made progress in the search of the problem. Turns out the kernel is stuck in the arm_machine_restart() function in arch/arm/kernel/process.c.
  Specifically, it's stuck after the call to cpu_proc_fin() function, which for our board is defined as cpu_v7_proc_init in arch/arm/mm/proc-v7.S. The code of this function is in assembly : </p>
  
  <pre><code>mrc p15, 0, r0, c1, c0, 0       @ ctrl register
  bic r0, r0, #0x1000         @ ...i............
  bic r0, r0, #0x0006         @ .............ca.
  mcr p15, 0, r0, c1, c0, 0       @ disable caches
  mov pc, lr
  </code></pre>
  
  <p>We are not the only ones that encountered this issue. (<a href="https://community.nxp.com/thread/321274" rel="nofollow noreferrer">thread on NXP forum here</a>)
  We tried commenting out the line</p>
  
  <pre><code>// bic  r0, r0, #0x0006         @ .............ca.
  </code></pre>
  
  <p>Now the function never blocks but sometimes the board still doesn't reboot immediately.
  We are still looking for insights and suggestions at this point. 
  Thanks for reading guys.</p>