sb_exec.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /**************************************************************************************************
  2. Filename: sb_exec.h
  3. Revised: $Date: 2010-03-10 20:36:55 -0800 (Wed, 10 Mar 2010) $
  4. Revision: $Revision: 21890 $
  5. Description: Serial Bootloader Executive.
  6. Copyright 2009-2010 Texas Instruments Incorporated. All rights reserved.
  7. IMPORTANT: Your use of this Software is limited to those specific rights
  8. granted under the terms of a software license agreement between the user
  9. who downloaded the software, his/her employer (which must be your employer)
  10. and Texas Instruments Incorporated (the "License"). You may not use this
  11. Software unless you agree to abide by the terms of the License. The License
  12. limits your use, and you acknowledge, that the Software may not be modified,
  13. copied or distributed unless embedded on a Texas Instruments microcontroller
  14. or used solely and exclusively in conjunction with a Texas Instruments radio
  15. frequency transceiver, which is integrated into your product. Other than for
  16. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  17. works of, modify, distribute, perform, display or sell this Software and/or
  18. its documentation for any purpose.
  19. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  20. PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  21. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  22. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  23. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  24. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  25. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  26. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  27. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  28. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  29. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  30. Should you have any questions regarding your right to use this Software,
  31. contact Texas Instruments Incorporated at www.TI.com.
  32. **************************************************************************************************/
  33. #ifndef SB_EXEC_H
  34. #define SB_EXEC_H
  35. /* ------------------------------------------------------------------------------------------------
  36. * Includes
  37. * ------------------------------------------------------------------------------------------------
  38. */
  39. #include "hal_types.h"
  40. /* ------------------------------------------------------------------------------------------------
  41. * Constants
  42. * ------------------------------------------------------------------------------------------------
  43. */
  44. #define SB_IMG_OSET (HAL_SB_IMG_ADDR / HAL_FLASH_WORD_SIZE)
  45. // The write-page boundary since the write-address is passed as "actual address / flash word size".
  46. #define SB_WPG_SIZE (HAL_FLASH_PAGE_SIZE / HAL_FLASH_WORD_SIZE)
  47. #define SB_BUF_SIZE 128
  48. #define SB_SOF 0xFE
  49. #define SB_HANDSHAKE 0xFE
  50. #define SB_FORCE_BOOT 0xF8
  51. #define SB_FORCE_RUN (SB_FORCE_BOOT ^ 0xFF)
  52. #define SB_RW_BUF_LEN 64
  53. // Bootloader Serial Interface Subsystem
  54. #define SB_RPC_SYS_BOOT 0x4D
  55. // Commands to Bootloader
  56. #define SB_WRITE_CMD 0x01
  57. #define SB_READ_CMD 0x02
  58. #define SB_ENABLE_CMD 0x03
  59. #define SB_HANDSHAKE_CMD 0x04
  60. // Status codes
  61. #define SB_SUCCESS 0
  62. #define SB_FAILURE 1
  63. #define SB_INVALID_FCS 2
  64. #define SB_INVALID_FILE 3
  65. #define SB_FILESYSTEM_ERROR 4
  66. #define SB_ALREADY_STARTED 5
  67. #define SB_NO_RESPOSNE 6
  68. #define SB_VALIDATE_FAILED 7
  69. #define SB_CANCELED 8
  70. // Serial RX States
  71. #define SB_SOF_STATE 0
  72. #define SB_LEN_STATE 1
  73. #define SB_CMD1_STATE 2
  74. #define SB_CMD2_STATE 3
  75. #define SB_DATA_STATE 4
  76. #define SB_FCS_STATE 5
  77. /* ------------------------------------------------------------------------------------------------
  78. * Functions
  79. * ------------------------------------------------------------------------------------------------
  80. */
  81. /**************************************************************************************************
  82. * @fn sbExec
  83. *
  84. * @brief Boot Loader main executive processing.
  85. *
  86. * input parameters
  87. *
  88. * None.
  89. *
  90. * output parameters
  91. *
  92. * None.
  93. *
  94. * @return TRUE if sbCmnd() returns TRUE, indicating that an SB_ENABLE_CMD succeeded;
  95. * FALSE otherwise.
  96. **************************************************************************************************
  97. */
  98. uint8 sbExec(void);
  99. /**************************************************************************************************
  100. * @fn sbImgValid
  101. *
  102. * @brief Check validity of the run-code image.
  103. *
  104. * input parameters
  105. *
  106. * None.
  107. *
  108. * output parameters
  109. *
  110. * None.
  111. *
  112. * @return TRUE or FALSE for image valid.
  113. **************************************************************************************************
  114. */
  115. uint8 sbImgValid(void);
  116. #endif