Advertisement
Guest User

Untitled

a guest
Apr 26th, 2012
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. diff --git a/bootloader/rk27xx.c b/bootloader/rk27xx.c
  2. index dfba970..44f0724 100644
  3. --- a/bootloader/rk27xx.c
  4. +++ b/bootloader/rk27xx.c
  5. @@ -24,6 +24,45 @@
  6.  
  7. extern void show_logo( void );
  8.  
  9. +static void enter_dfu(void)
  10. +{
  11. + asm volatile (
  12. + /* turn off cache */
  13. + "ldr r0, =0xefff0000 \n"
  14. + "ldrh r1, [r0] \n"
  15. + "strh r1, [r0] \n"
  16. +
  17. + /* turn off interrupts */
  18. + "mrs r0, cpsr \n"
  19. + "bic r0, r0, #0x1f \n"
  20. + "orr r0, r0, #0xd3 \n"
  21. + "msr cpsr, r0 \n"
  22. +
  23. + /* disable iram remap */
  24. + "mov r0, #0x18000000 \n"
  25. + "add r0, r0, #0x1c000 \n"
  26. + "mov r1, #0 \n"
  27. + "str r1, [r0, #4] \n"
  28. +
  29. + /* setup stacks in unmapped
  30. + * iram just as rom will do
  31. + */
  32. + "msr cpsr, #0xd2 \n"
  33. + "ldr r1, =0x18200274 \n"
  34. + "add r1, r1, #0x200 \n"
  35. + "mov sp, r1 \n"
  36. + "msr cpsr, #0xd3 \n"
  37. + "add r1, r1, #0x400 \n"
  38. + "mov sp, r1 \n"
  39. +
  40. + /* jump to main() in rom
  41. + * just before dfu handler
  42. + */
  43. + "ldr r0, =0xec0 \n"
  44. + "bx r0 \n"
  45. + );
  46. +}
  47. +
  48. void main(void) NORETURN_ATTR;
  49. void main(void)
  50. {
  51. @@ -102,8 +141,9 @@ void main(void)
  52. kernel_entry();
  53.  
  54. printf("ERR: Failed to boot");
  55. + printf("Entering rockchip DFU mode");
  56. sleep(5*HZ);
  57. - power_off();
  58. + enter_dfu();
  59.  
  60. /* hang */
  61. while(1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement