hal_oad.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /**************************************************************************************************
  2. Filename: hal_oad.h
  3. Revised: $Date:$
  4. Revision: $Revision:$
  5. Description: This module defines optionally-compiled Boot Code parameters for the CC2x3x.
  6. Copyright 2008-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 HAL_OAD_H
  34. #define HAL_OAD_H
  35. /*********************************************************************
  36. * INCLUDES
  37. */
  38. #include "hal_board_cfg.h"
  39. #include "hal_types.h"
  40. /*********************************************************************
  41. * MACROS
  42. */
  43. #if !defined HAL_OAD_BOOT_CODE
  44. #define HAL_OAD_BOOT_CODE FALSE
  45. #endif
  46. // MSP430 needs to explicitly pack OAD data structures - 8051 is automatic with byte alignment.
  47. #define PACK_1
  48. /*********************************************************************
  49. * CONSTANTS
  50. */
  51. // Placement controlled by oad.xcl.
  52. #define HAL_OAD_RC_START 0x0800
  53. #define HAL_OAD_CRC_ADDR 0x0888
  54. #define HAL_OAD_CRC_OSET (HAL_OAD_CRC_ADDR - HAL_OAD_RC_START)
  55. /* Note that corresponding changes must be made to oad.xcl when changing the source of Xtra-NV.
  56. * When using internal flash for XNV, (HAL_OAD_BOOT_PG_CNT + HAL_NV_PAGE_CNT) must be even.
  57. */
  58. #define HAL_OAD_XNV_IS_INT TRUE
  59. #define HAL_OAD_XNV_IS_SPI !HAL_OAD_XNV_IS_INT
  60. /* The oad/oad-boot.xcl files only need 1 page of boot code (located on the first flash page),
  61. * but the Lock Bits Page is lost with OAD since it is not programmable.
  62. * So discard it here by faking that boot needs 2 pages.
  63. */
  64. #define HAL_OAD_BOOT_PG_CNT 2
  65. /* To reduce the binary image size due to padding un-used code space, reduce HAL_OAD_DL_SIZE
  66. * to the minimum required for your Application and make the corresponding changes to oad_app.xcl.
  67. * This size must be an even multiple of HAL_FLASH_PAGE_SIZE.
  68. */
  69. #if HAL_OAD_XNV_IS_SPI && !defined HAL_BOARD_CC2530EB_REV13
  70. #define HAL_OAD_DL_MAX 0x40000
  71. #define HAL_OAD_DL_SIZE (0x40000 - ((HAL_NV_PAGE_CNT+HAL_OAD_BOOT_PG_CNT)*HAL_FLASH_PAGE_SIZE))
  72. #define HAL_OAD_DL_OSET 0x0 // Configurable offset into an external NV.
  73. #else
  74. #define HAL_OAD_DL_MAX (0x40000 - ((HAL_NV_PAGE_CNT+HAL_OAD_BOOT_PG_CNT)*HAL_FLASH_PAGE_SIZE))
  75. #define HAL_OAD_DL_SIZE (HAL_OAD_DL_MAX / 2)
  76. #define HAL_OAD_DL_OSET (HAL_OAD_DL_MAX / 2)
  77. #endif
  78. // To run OAD with the legacy ZOAD.exe PC tool, place the preamble in this legacy location.
  79. #define PREAMBLE_OFFSET 0x8C
  80. #if HAL_OAD_XNV_IS_INT
  81. #define VDD_MIN_OAD VDD_MIN_NV
  82. #else
  83. #error CC2531 OAD by external NV not characterized.
  84. #endif
  85. /*********************************************************************
  86. * TYPEDEFS
  87. */
  88. typedef enum {
  89. HAL_OAD_RC, /* Run code / active image. */
  90. HAL_OAD_DL /* Downloaded code to be activated later. */
  91. } image_t;
  92. typedef struct {
  93. uint8 magic[2];
  94. uint32 len;
  95. uint16 vers;
  96. uint16 manu;
  97. uint16 prod;
  98. } preamble_t;
  99. /*********************************************************************
  100. * FUNCTIONS
  101. */
  102. uint8 HalOADChkDL(uint8 dlImagePreambleOffset);
  103. void HalOADInvRC(void);
  104. uint32 HalOADAvail(void);
  105. void HalOADRead(uint32 oset, uint8 *pBuf, uint16 len, image_t type);
  106. void HalOADWrite(uint32 oset, uint8 *pBuf, uint16 len, image_t type);
  107. #endif