芯片解密|单片机解密|IC解密|芯片破解|芯片复制| PCB抄板|软件开发

飞芯科技-芯片解密|单片机解密|IC解密|芯片破解|芯片复制| PCB抄板|软件开发

NXP LPC1758 Bootloader 使用串口芯片破解

芯片破解NXP LPC1758 Bootloader 使用串口0 支持xmodem1k协议,可以使用超级终端将应用程序上传到FLASH实现IAP程序升级

芯片破解单片机源程序如下:
  1. #include "LPC17xx.h"   /* LPC17xx外设寄存器            */
  2. #include "../UART/uart.h"
  3. #include "../IAP/iap.h"
  4. #include "../CRC/crc.h"
  5. #include "../XMODEM1K/xmodem1k.h"
  6. #include <string.h>

  7. extern uint32_t SystemFrequency;
  8. /*
  9. * Define flash memory address at which user application is located
  10. */
  11. #define APP_START_ADDR                                                0x00010000UL
  12. #define APP_END_ADDR                                                0x00080000UL                /* LPC1766 256K Flash           */

  13. /*
  14. * Define the flash sectors used by the application
  15. */
  16. #define APP_START_SECTOR                                        16
  17. #define APP_END_SECTOR                                                29                            /* LPC1766 256K Flash           */

  18. volatile uint32_t IAPFlagTimeOut;

  19. static uint32_t u32InvalidateApp(void);
  20. void ExceuteApplication(void);
  21. static void vBootLoader_Task(void);
  22. static uint32_t u32BootLoader_AppPresent(void);
  23. static uint32_t u32Bootloader_WriteCRC(uint16_t u16CRC);
  24. static uint32_t u32BootLoader_ProgramFlash(uint8_t *pu8Data, uint16_t u16Len);

  25. /*********************************************************************************************************
  26. ** Function name:       Timer0_Init
  27. ** Descriptions:        定时器0初始化程序
  28. ** input parameters:    无
  29. ** output parameters:   无
  30. ** Returned value:      无
  31. *********************************************************************************************************/
  32. void  Timer0_Init (uint32_t ulsec)
  33. {
  34.     LPC_TIM0->TCR  = 0x02;
  35.     LPC_TIM0->IR   = 0x01;
  36.     LPC_TIM0->CTCR = 0;
  37.     LPC_TIM0->TC   = 0;
  38.     LPC_TIM0->PR   = 0;
  39.     LPC_TIM0->MR0  = (SystemFrequency/4)*ulsec;                         /* nS中断1次                    */
  40.     LPC_TIM0->MCR  = 0x05;                                              /* 匹配后产生中断               */
  41.     LPC_TIM0->TCR  = 0x01;                                              /* 启动定时器                   */
  42. }

  43. /*********************************************************************************************************
  44. ** Function name:       JMP_Boot
  45. ** Descriptions:        跳转到应用程序
  46. ** input parameters:    address 应用程序地址
  47. ** output parameters:   无
  48. ** Returned value:      无
  49. *********************************************************************************************************/
  50. __asm void JMP_Boot( uint32_t address ){
  51.    LDR SP, [R0]                ;Load new stack pointer address
  52.    LDR PC, [R0, #4]        ;Load new program counter address
  53. }

  54. /*********************************************************************************************************
  55. ** Function name:       Boot
  56. ** Descriptions:        跳转到应用程序
  57. ** input parameters:    无
  58. ** output parameters:   无
  59. ** Returned value:      无
  60. *********************************************************************************************************/
  61. void Boot( void )
  62. {
  63.         SCB->VTOR = APP_START_ADDR & 0x1FFFFF80;        //修改中断向量表
  64.         //SCB->VTOR = APP_START_ADDR;
  65.         JMP_Boot(APP_START_ADDR);
  66. }

  67. /*********************************************************************************************************
  68. ** Function name:       main
  69. ** Descriptions:        Bootloader控制循环
  70. ** input parameters:    无
  71. ** output parameters:   无
  72. ** Returned value:      无
  73. *********************************************************************************************************/
  74. int main(void)
  75. {
  76.         uint8_t uartBuffer[16], len;
  77.         SystemInit();
  78.     vUARTInit(BAUD_RATE); //P0.2,P0.3对就串口0,115200
  79.     vUARTSend((uint8_t *)("\r\nLPC1700 Ready For Updates >"), strlen("\r\nLPC1700 Ready For Updates >"));   
  80.     Timer0_Init (10);
  81.     len = 0;
  82.         //获取IAP升级命令IAP
  83.     while (1)
  84.         {
  85.         if ((LPC_TIM0->IR & 0x01) == 0x01)
  86.                 {
  87.              LPC_TIM0->IR   = 0x01;                                     /* 清除中断标志                 */
  88.              IAPFlagTimeOut = 1;                                                                                /* 等待升级命令超时             */
  89.              vUARTSend((uint8_t *)("\r\nTimeout waiting for the upgrade command!\r\n"), strlen("\r\nTimeout waiting for the upgrade command!\r\n"));
  90.              break;
  91.         }
  92.                 //等待置信IAP字例 入IAP升级,超进退出。
  93.         if (u8UARTReceive(uartBuffer) > 0)
  94.                 {                                    /* 判断升级命令 IAP             */
  95.             
  96.             vUARTSend(uartBuffer, 1);
  97.             if (uartBuffer[0] == 'I')
  98.                         {
  99.                 len = 1;
  100.             }
  101.             if (uartBuffer[0] == 'A')
  102.                         {
  103.                 if (len == 1)
  104.                                 {
  105.                     len = 2;
  106.                 }
  107.                                 else
  108.                                 {
  109.                     len = 0;
  110.                 }
  111.             }
  112.             if (uartBuffer[0] == 'P')
  113.                         {
  114.                 if (len == 2)
  115.                                 {
  116.                     len = 3;
  117.                 }
  118.                                 else
  119.                                 {
  120.                     len = 0;
  121.                 }
  122.             }
  123.         }
  124.         if (len == 3)
  125.                 {
  126.                 IAPFlagTimeOut = 0;
  127.                 vUARTSend((uint8_t *)("\r\nReceiving a successful upgrade command!\r\n"), strlen("\r\nReceiving a successful upgrade command!\r\n"));
  128.                 break;
  129.         }
  130.     }



联系方式

地址:石家庄市新华区民族路77号华强广场D座2009
电话:0311-88816616/87087811
手机:13315190088
传真:0311-67901001
联系人:张工
网址:www.feixindz.com
邮箱:feixindz@163.com
微信:xinpianjiemi
QQ:527263666/568069805

在线客服
热线电话

企业微信