cybtldr_utils.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*******************************************************************************
  2. * Copyright 2011-2012, Cypress Semiconductor Corporation. All rights reserved.
  3. * You may use this file only in accordance with the license, terms, conditions,
  4. * disclaimers, and limitations in the end user license agreement accompanying
  5. * the software package with which this file was provided.
  6. ********************************************************************************/
  7. #ifndef __CYBTLDR_UTILS_H__
  8. #define __CYBTLDR_UTILS_H__
  9. #include <stdio.h>
  10. // NB: These items are toolchain specific that will need to be updated
  11. // depending on the environment being used.
  12. #ifdef WIN32
  13. #define EXTERN extern __declspec(dllexport)
  14. #else
  15. #define EXTERN extern
  16. #endif
  17. /******************************************************************************
  18. * HOST ERROR CODES
  19. ******************************************************************************
  20. *
  21. * Different return codes from the bootloader host. Functions are not
  22. * limited to these values, but are encuraged to use them when returning
  23. * standard error values.
  24. *
  25. * 0 is successful, all other values indicate a failure.
  26. *****************************************************************************/
  27. /* Completed successfully */
  28. #define CYRET_SUCCESS 0x00
  29. /* File is not accessable */
  30. #define CYRET_ERR_FILE 0x01
  31. /* Reached the end of the file */
  32. #define CYRET_ERR_EOF 0x02
  33. /* The amount of data available is outside the expected range */
  34. #define CYRET_ERR_LENGTH 0x03
  35. /* The data is not of the proper form */
  36. #define CYRET_ERR_DATA 0x04
  37. /* The command is not recognized */
  38. #define CYRET_ERR_CMD 0x05
  39. /* The expected device does not match the detected device */
  40. #define CYRET_ERR_DEVICE 0x06
  41. /* The bootloader version detected is not supported */
  42. #define CYRET_ERR_VERSION 0x07
  43. /* The checksum does not match the expected value */
  44. #define CYRET_ERR_CHECKSUM 0x08
  45. /* The flash array is not valid */
  46. #define CYRET_ERR_ARRAY 0x09
  47. /* The flash row is not valid */
  48. #define CYRET_ERR_ROW 0x0A
  49. /* The bootloader is not ready to process data */
  50. #define CYRET_ERR_BTLDR 0x0B
  51. /* The application is currently marked as active */
  52. #define CYRET_ERR_ACTIVE 0x0C
  53. /* An unknown error occured */
  54. #define CYRET_ERR_UNK 0x0F
  55. /* The operation was aborted */
  56. #define CYRET_ABORT 0xFF
  57. /* The communications object reported an error */
  58. #define CYRET_ERR_COMM_MASK 0x2000
  59. /* The bootloader reported an error */
  60. #define CYRET_ERR_BTLDR_MASK 0x4000
  61. /******************************************************************************
  62. * BOOTLOADER STATUS CODES
  63. ******************************************************************************
  64. *
  65. * Different return status codes from the bootloader.
  66. *
  67. * 0 is successful, all other values indicate a failure.
  68. *****************************************************************************/
  69. /* Completed successfully */
  70. #define CYBTLDR_STAT_SUCCESS 0x00
  71. /* The provided key does not match the expected value */
  72. #define CYBTLDR_STAT_ERR_KEY 0x01
  73. /* The verification of flash failed */
  74. #define CYBTLDR_STAT_ERR_VERIFY 0x02
  75. /* The amount of data available is outside the expected range */
  76. #define CYBTLDR_STAT_ERR_LENGTH 0x03
  77. /* The data is not of the proper form */
  78. #define CYBTLDR_STAT_ERR_DATA 0x04
  79. /* The command is not recognized */
  80. #define CYBTLDR_STAT_ERR_CMD 0x05
  81. /* The expected device does not match the detected device */
  82. #define CYBTLDR_STAT_ERR_DEVICE 0x06
  83. /* The bootloader version detected is not supported */
  84. #define CYBTLDR_STAT_ERR_VERSION 0x07
  85. /* The checksum does not match the expected value */
  86. #define CYBTLDR_STAT_ERR_CHECKSUM 0x08
  87. /* The flash array is not valid */
  88. #define CYBTLDR_STAT_ERR_ARRAY 0x09
  89. /* The flash row is not valid */
  90. #define CYBTLDR_STAT_ERR_ROW 0x0A
  91. /* The flash row is protected and can not be programmed */
  92. #define CYBTLDR_STAT_ERR_PROTECT 0x0B
  93. /* The application is not valid and cannot be set as active */
  94. #define CYBTLDR_STAT_ERR_APP 0x0C
  95. /* The application is currently marked as active */
  96. #define CYBTLDR_STAT_ERR_ACTIVE 0x0D
  97. /* An unknown error occured */
  98. #define CYBTLDR_STAT_ERR_UNK 0x0F
  99. /******************************************************************************
  100. * VERSION INFORMATION
  101. ******************************************************************************
  102. *
  103. * Major – Used to indicate binary compatibility. If a change is incompatible
  104. * in any way with the prior release, the major version number will be
  105. * updated.
  106. * Minor – Used to indicate feature set. If a new feature or functionality is
  107. * added beyond what was available in a prior release, the this number
  108. * will be updated.
  109. * Patch – Used to indicate very minor fixes. If the code was modified to fix
  110. * a defect or to improve the quality in any way that does not add new
  111. * functionality or change APIs this version number will be updated.
  112. *
  113. * 1.0 - Original (PSoC Creator 1.0 Beta 5)
  114. * 1.1 - Add checksum option (PSoC Creator 1.0 Production)
  115. * 1.2 - Add support for Multi Application Bootloaders
  116. *
  117. *****************************************************************************/
  118. #define VERSION_MAJOR 0x01
  119. #define VERSION_MINOR 0x02
  120. #define VERSION_PATCH 0x00
  121. #endif