ME11B Sample Code in Maxim Integrated Team
Dependencies: BMI160 max32630hsp3 MemoryLCD USBDevice
Fork of Host_Software_MAX32664GWEB_HR_EXTENDED by
bootloader/bootldrAPI.h@3:b8989dab0f88, 2019-03-25 (annotated)
- Committer:
- seyhmuscacina
- Date:
- Mon Mar 25 07:40:37 2019 +0000
- Revision:
- 3:b8989dab0f88
- Parent:
- 0:ac4dea3e2894
Fork the repository
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
seyhmus.cacina | 0:ac4dea3e2894 | 1 | /* |
seyhmus.cacina | 0:ac4dea3e2894 | 2 | * bootldrInterface.h |
seyhmus.cacina | 0:ac4dea3e2894 | 3 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 4 | * Created on: Feb 7, 2019 |
seyhmus.cacina | 0:ac4dea3e2894 | 5 | * Author: Yagmur.Gok |
seyhmus.cacina | 0:ac4dea3e2894 | 6 | */ |
seyhmus.cacina | 0:ac4dea3e2894 | 7 | |
seyhmus.cacina | 0:ac4dea3e2894 | 8 | #ifndef SOURCE_CMDUI_BOOTLDRINTERFACE_H_ |
seyhmus.cacina | 0:ac4dea3e2894 | 9 | #define SOURCE_CMDUI_BOOTLDRINTERFACE_H_ |
seyhmus.cacina | 0:ac4dea3e2894 | 10 | |
seyhmus.cacina | 0:ac4dea3e2894 | 11 | typedef int (*cmdExecFunc)( const char*); // typedef void (*cmdExecFunc)( const void*); |
seyhmus.cacina | 0:ac4dea3e2894 | 12 | |
seyhmus.cacina | 0:ac4dea3e2894 | 13 | typedef struct { |
seyhmus.cacina | 0:ac4dea3e2894 | 14 | char const* cmdStr; |
seyhmus.cacina | 0:ac4dea3e2894 | 15 | cmdExecFunc execute; |
seyhmus.cacina | 0:ac4dea3e2894 | 16 | char const *help; |
seyhmus.cacina | 0:ac4dea3e2894 | 17 | }cmd_interface_tb; |
seyhmus.cacina | 0:ac4dea3e2894 | 18 | |
seyhmus.cacina | 0:ac4dea3e2894 | 19 | #define FLASH_ERR_GENERAL -1 |
seyhmus.cacina | 0:ac4dea3e2894 | 20 | #define FLASH_ERR_CHECKSUM -2 |
seyhmus.cacina | 0:ac4dea3e2894 | 21 | #define FLASH_ERR_AUTH -3 |
seyhmus.cacina | 0:ac4dea3e2894 | 22 | |
seyhmus.cacina | 0:ac4dea3e2894 | 23 | /** |
seyhmus.cacina | 0:ac4dea3e2894 | 24 | * @brief sets the SENSOR HUB to Bootloader Mode for Firmware update. Prints status info on command console |
seyhmus.cacina | 0:ac4dea3e2894 | 25 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 26 | * @param[in] null_arg : NULL string, just to match the form of command table function pointer type |
seyhmus.cacina | 0:ac4dea3e2894 | 27 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 28 | * @return status info, 0x00 on success. |
seyhmus.cacina | 0:ac4dea3e2894 | 29 | **/ |
seyhmus.cacina | 0:ac4dea3e2894 | 30 | int SH_BOOTLDR_enter_blmode(const char *null_arg); |
seyhmus.cacina | 0:ac4dea3e2894 | 31 | |
seyhmus.cacina | 0:ac4dea3e2894 | 32 | /** |
seyhmus.cacina | 0:ac4dea3e2894 | 33 | * @brief exits the SENSOR HUB from Bootloader Mode to Application Mode. Prints status info on command console |
seyhmus.cacina | 0:ac4dea3e2894 | 34 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 35 | * @param[in] null_arg : NULL string, just to match the form of command table function pointer type |
seyhmus.cacina | 0:ac4dea3e2894 | 36 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 37 | * @return status info, 0x00 on success. |
seyhmus.cacina | 0:ac4dea3e2894 | 38 | **/ |
seyhmus.cacina | 0:ac4dea3e2894 | 39 | int SH_BOOTLDR_exit_blmode(const char *null_arg); |
seyhmus.cacina | 0:ac4dea3e2894 | 40 | |
seyhmus.cacina | 0:ac4dea3e2894 | 41 | /** |
seyhmus.cacina | 0:ac4dea3e2894 | 42 | * @brief gets the page size of bootloader within SENSOR HUB. Prints status info and page size value on command console |
seyhmus.cacina | 0:ac4dea3e2894 | 43 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 44 | * @param[in] null_arg : NULL string, just to match the form of command table function pointer type |
seyhmus.cacina | 0:ac4dea3e2894 | 45 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 46 | * @return status info, 0x00 on success. |
seyhmus.cacina | 0:ac4dea3e2894 | 47 | **/ |
seyhmus.cacina | 0:ac4dea3e2894 | 48 | int SH_BOOTLDR_get_pagesz(const char *null_arg); |
seyhmus.cacina | 0:ac4dea3e2894 | 49 | |
seyhmus.cacina | 0:ac4dea3e2894 | 50 | /** |
seyhmus.cacina | 0:ac4dea3e2894 | 51 | * @brief sets the totatl page count for MSBL file to be uploaded to SENSOR HUB. Prints status info on command console |
seyhmus.cacina | 0:ac4dea3e2894 | 52 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 53 | * @param[in] arg : byte string including command followed by page size value extracted from header of MSBL file in DECIMAL format! |
seyhmus.cacina | 0:ac4dea3e2894 | 54 | * "num_pages 24" |
seyhmus.cacina | 0:ac4dea3e2894 | 55 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 56 | * @return status info, 0x00 on success. |
seyhmus.cacina | 0:ac4dea3e2894 | 57 | **/ |
seyhmus.cacina | 0:ac4dea3e2894 | 58 | int SH_BOOTLDR_set_pagecount(const char *arg); |
seyhmus.cacina | 0:ac4dea3e2894 | 59 | |
seyhmus.cacina | 0:ac4dea3e2894 | 60 | /** |
seyhmus.cacina | 0:ac4dea3e2894 | 61 | * @brief sets the IV vector of MSBL file to be uploaded to SENSOR HUB. Prints status info on command console |
seyhmus.cacina | 0:ac4dea3e2894 | 62 | * IV vector is 22 bytes of data extracted from header of MSBL file. |
seyhmus.cacina | 0:ac4dea3e2894 | 63 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 64 | * @param[in] arg : byte string including command followed by 22 byte IV value in HEXADECIMAL format! do no preceed IV bytes wirh 0x !!!! |
seyhmus.cacina | 0:ac4dea3e2894 | 65 | "set_iv 1234567891234567891234" |
seyhmus.cacina | 0:ac4dea3e2894 | 66 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 67 | * @return status info, 0x00 on success. |
seyhmus.cacina | 0:ac4dea3e2894 | 68 | **/ |
seyhmus.cacina | 0:ac4dea3e2894 | 69 | int SH_BOOTLDR_set_iv(const char *arg); |
seyhmus.cacina | 0:ac4dea3e2894 | 70 | |
seyhmus.cacina | 0:ac4dea3e2894 | 71 | /** |
seyhmus.cacina | 0:ac4dea3e2894 | 72 | * @brief sets the Authentication vector of MSBL file to be uploaded to SENSOR HUB. Prints status info on command console |
seyhmus.cacina | 0:ac4dea3e2894 | 73 | * Authentication vector is 36 bytes of data extracted from header of MSBL file. |
seyhmus.cacina | 0:ac4dea3e2894 | 74 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 75 | * @param[in] arg : byte string including command followed by 22 byte IV value in HEXADECIMAL format! do no preceed IV bytes wirh 0x !!!! |
seyhmus.cacina | 0:ac4dea3e2894 | 76 | "set_auth 12345678912345678912345678912345" |
seyhmus.cacina | 0:ac4dea3e2894 | 77 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 78 | * @return status info, 0x00 on success. |
seyhmus.cacina | 0:ac4dea3e2894 | 79 | **/ |
seyhmus.cacina | 0:ac4dea3e2894 | 80 | int SH_BOOTLDR_set_authentication(const char *arg); |
seyhmus.cacina | 0:ac4dea3e2894 | 81 | |
seyhmus.cacina | 0:ac4dea3e2894 | 82 | /** |
seyhmus.cacina | 0:ac4dea3e2894 | 83 | * @brief erases application code of SENSOR HUB. Prints status info on command console |
seyhmus.cacina | 0:ac4dea3e2894 | 84 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 85 | * @param[in] null_arg : NULL string, just to match the form of command table function pointer type |
seyhmus.cacina | 0:ac4dea3e2894 | 86 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 87 | * @return status info, 0x00 on success. |
seyhmus.cacina | 0:ac4dea3e2894 | 88 | **/ |
seyhmus.cacina | 0:ac4dea3e2894 | 89 | int SH_BOOTLDR_eraseflash(const char *null_arg); |
seyhmus.cacina | 0:ac4dea3e2894 | 90 | |
seyhmus.cacina | 0:ac4dea3e2894 | 91 | /** |
seyhmus.cacina | 0:ac4dea3e2894 | 92 | * @brief puts the SENSOR HUB to the state of waiting for MSBL application code pages from serial command interface. |
seyhmus.cacina | 0:ac4dea3e2894 | 93 | * Prints status info on command console upon flashing of every page. |
seyhmus.cacina | 0:ac4dea3e2894 | 94 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 95 | * @param[in] null_arg : NULL string, just to match the form of command table function pointer type |
seyhmus.cacina | 0:ac4dea3e2894 | 96 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 97 | * @return status info, 0x00 on success. |
seyhmus.cacina | 0:ac4dea3e2894 | 98 | **/ |
seyhmus.cacina | 0:ac4dea3e2894 | 99 | int SH_BOOTLDR_flash(const char *null_arg); |
seyhmus.cacina | 0:ac4dea3e2894 | 100 | |
seyhmus.cacina | 0:ac4dea3e2894 | 101 | /** |
seyhmus.cacina | 0:ac4dea3e2894 | 102 | * @brief sets the SENSOR HUB to the bootloader state where application image pages are first stored into HOST ram and will be flashed |
seyhmus.cacina | 0:ac4dea3e2894 | 103 | * at once. Prints status info on command console. |
seyhmus.cacina | 0:ac4dea3e2894 | 104 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 105 | * @param[in] arg : byte string including command followed by 1 byte omage on ram flag in DECIMAL format |
seyhmus.cacina | 0:ac4dea3e2894 | 106 | * "image_on_ram 0/1" 0: for classic mode where pages are downloaded form PC over serial command console and |
seyhmus.cacina | 0:ac4dea3e2894 | 107 | * flashed to SENSOR HUB 1 by 1. 1: for image on ram mode. |
seyhmus.cacina | 0:ac4dea3e2894 | 108 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 109 | * @return status info, 0x00 on success. |
seyhmus.cacina | 0:ac4dea3e2894 | 110 | **/ |
seyhmus.cacina | 0:ac4dea3e2894 | 111 | int SH_BOOTLOADER_image_on_ram( const char *arg ); |
seyhmus.cacina | 0:ac4dea3e2894 | 112 | |
seyhmus.cacina | 0:ac4dea3e2894 | 113 | /** |
seyhmus.cacina | 0:ac4dea3e2894 | 114 | * @brief flashes pages in HOST Ram to Sensor Hub. |
seyhmus.cacina | 0:ac4dea3e2894 | 115 | * USE ONLY IN IMAGE_ON_RAM MODE !!!! |
seyhmus.cacina | 0:ac4dea3e2894 | 116 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 117 | * @param[in] null_arg : NULL string, just to match the form of command table function pointer type |
seyhmus.cacina | 0:ac4dea3e2894 | 118 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 119 | * @return status info, 0x00 on success. |
seyhmus.cacina | 0:ac4dea3e2894 | 120 | **/ |
seyhmus.cacina | 0:ac4dea3e2894 | 121 | int SH_BOOTLDR_flash_appimage_from_ram(const char *null_arg); |
seyhmus.cacina | 0:ac4dea3e2894 | 122 | |
seyhmus.cacina | 0:ac4dea3e2894 | 123 | /** |
seyhmus.cacina | 0:ac4dea3e2894 | 124 | * @brief set the delay factor multipler for Bootloader wait durations in commands and between flashing of pages |
seyhmus.cacina | 0:ac4dea3e2894 | 125 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 126 | * @param[in] arg : byte string including command followed by delay factor in DECIMAL format |
seyhmus.cacina | 0:ac4dea3e2894 | 127 | * "set_cfg host cdf 1" to "set_cfg host cdf 4" practical range. 1 is default. |
seyhmus.cacina | 0:ac4dea3e2894 | 128 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 129 | * @return status info, 0x00 on success. |
seyhmus.cacina | 0:ac4dea3e2894 | 130 | **/ |
seyhmus.cacina | 0:ac4dea3e2894 | 131 | int SH_BOOTLDR_set_host_bootcmds_delay_factor( const char *arg); |
seyhmus.cacina | 0:ac4dea3e2894 | 132 | |
seyhmus.cacina | 0:ac4dea3e2894 | 133 | /** |
seyhmus.cacina | 0:ac4dea3e2894 | 134 | * @brief get the delay factor multipler for Bootloader wait durations in commands and between flashing of pages. |
seyhmus.cacina | 0:ac4dea3e2894 | 135 | * Prints delay factor multipler value on command console. |
seyhmus.cacina | 0:ac4dea3e2894 | 136 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 137 | * @param[in] null_arg : NULL string, just to match the form of command table function pointer type |
seyhmus.cacina | 0:ac4dea3e2894 | 138 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 139 | * @return status info, 0x00 on success. |
seyhmus.cacina | 0:ac4dea3e2894 | 140 | **/ |
seyhmus.cacina | 0:ac4dea3e2894 | 141 | int SH_BOOTLDR_get_host_bootcmds_delay_factor( const char *null_arg); |
seyhmus.cacina | 0:ac4dea3e2894 | 142 | |
seyhmus.cacina | 0:ac4dea3e2894 | 143 | /** |
seyhmus.cacina | 0:ac4dea3e2894 | 144 | * @brief sets the resetting method of SENSOR HUB between command based and GPIO based resets. Default is GPIO based reset.ie 1. |
seyhmus.cacina | 0:ac4dea3e2894 | 145 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 146 | * @param[in] arg : byte string including command followed by ebl mode in DECIMAL format |
seyhmus.cacina | 0:ac4dea3e2894 | 147 | * "set_cfg host ebl 1/0" . 0 for command based reset; 1 for GPIO based reset which is default and preferred option. |
seyhmus.cacina | 0:ac4dea3e2894 | 148 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 149 | * @return status info, 0x00 on success. |
seyhmus.cacina | 0:ac4dea3e2894 | 150 | **/ |
seyhmus.cacina | 0:ac4dea3e2894 | 151 | int SH_BOOTLDR_set_host_ebl_mode(const char *arg); |
seyhmus.cacina | 0:ac4dea3e2894 | 152 | |
seyhmus.cacina | 0:ac4dea3e2894 | 153 | /** |
seyhmus.cacina | 0:ac4dea3e2894 | 154 | * @brief gets the resetting method of SENSOR HUB between command based and GPIO based resets. |
seyhmus.cacina | 0:ac4dea3e2894 | 155 | * Prints delay factor multipler value on command console. |
seyhmus.cacina | 0:ac4dea3e2894 | 156 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 157 | * @param[in] null_arg : NULL string, just to match the form of command table function pointer type |
seyhmus.cacina | 0:ac4dea3e2894 | 158 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 159 | * @return status info, 0x00 on success. |
seyhmus.cacina | 0:ac4dea3e2894 | 160 | **/ |
seyhmus.cacina | 0:ac4dea3e2894 | 161 | int SH_BOOTLDR_get_host_ebl_mode(const char *null_arg); |
seyhmus.cacina | 0:ac4dea3e2894 | 162 | |
seyhmus.cacina | 0:ac4dea3e2894 | 163 | /** |
seyhmus.cacina | 0:ac4dea3e2894 | 164 | * @brief gets the struct keeping state information about bootloading steps required at HOST side. |
seyhmus.cacina | 0:ac4dea3e2894 | 165 | * Prints struct data fields and state flags; ie. is_iv_set? page_size acquired from hub etc. |
seyhmus.cacina | 0:ac4dea3e2894 | 166 | * If all steps are not done, flashing operation do not take place and informs user on command |
seyhmus.cacina | 0:ac4dea3e2894 | 167 | * console |
seyhmus.cacina | 0:ac4dea3e2894 | 168 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 169 | * @param[in] null_arg : NULL string, just to match the form of command table function pointer type |
seyhmus.cacina | 0:ac4dea3e2894 | 170 | * |
seyhmus.cacina | 0:ac4dea3e2894 | 171 | * @return status info, 0x00 on success. |
seyhmus.cacina | 0:ac4dea3e2894 | 172 | **/ |
seyhmus.cacina | 0:ac4dea3e2894 | 173 | int BOOTLDR_get_host_bootloader_state(const char *null_arg); |
seyhmus.cacina | 0:ac4dea3e2894 | 174 | |
seyhmus.cacina | 0:ac4dea3e2894 | 175 | |
seyhmus.cacina | 0:ac4dea3e2894 | 176 | #define NUMCMDSBOOTLDRAPI (15) |
seyhmus.cacina | 0:ac4dea3e2894 | 177 | |
seyhmus.cacina | 0:ac4dea3e2894 | 178 | const cmd_interface_tb CMDTABLEBOOTLDR[] = { |
seyhmus.cacina | 0:ac4dea3e2894 | 179 | |
seyhmus.cacina | 0:ac4dea3e2894 | 180 | { "bootldr" , SH_BOOTLDR_enter_blmode , "resets and puts sensor hub to bootloader mode " }, |
seyhmus.cacina | 0:ac4dea3e2894 | 181 | { "exit" , SH_BOOTLDR_exit_blmode , "exits sensor hub from bootloader mode to app mode" }, |
seyhmus.cacina | 0:ac4dea3e2894 | 182 | { "page_size" , SH_BOOTLDR_get_pagesz , "returns sensor hub bootloader page size for app data pages" }, |
seyhmus.cacina | 0:ac4dea3e2894 | 183 | { "num_pages" , SH_BOOTLDR_set_pagecount , "sets sensor hub bootloader app image pages, uasge: num_pages PAGES" }, |
seyhmus.cacina | 0:ac4dea3e2894 | 184 | { "set_iv" , SH_BOOTLDR_set_iv , "sets sensor hub bootloader initial vector bytes, usage: set_iv XXXXXXXXXXX (11 hex chrs)" }, |
seyhmus.cacina | 0:ac4dea3e2894 | 185 | { "set_auth" , SH_BOOTLDR_set_authentication , "sets sensor hub bootloader authentication bytes, usage: set_iv XXXXXXXXXXXXXXXX (16 hex chrs)" }, |
seyhmus.cacina | 0:ac4dea3e2894 | 186 | { "erase" , SH_BOOTLDR_eraseflash , "erases sesn hub application flash memory" }, |
seyhmus.cacina | 0:ac4dea3e2894 | 187 | { "image_on_ram" , SH_BOOTLOADER_image_on_ram , "selects pagBypage download-flash / block download-flash options" }, |
seyhmus.cacina | 0:ac4dea3e2894 | 188 | { "flash" , SH_BOOTLDR_flash , "flash image to hub/dowload pages from PC based on image_on_ram selection" }, |
seyhmus.cacina | 0:ac4dea3e2894 | 189 | { "image_flash" , SH_BOOTLDR_flash_appimage_from_ram , "flashes app image in ram to sensor hub, call after flash cmd in image_on_ram mode" }, |
seyhmus.cacina | 0:ac4dea3e2894 | 190 | { "set_cfg host cdf" , SH_BOOTLDR_set_host_bootcmds_delay_factor , "sets delay factor for bootoader cmd waits default 1, usage: set_cfg host cdf FACTOR" }, |
seyhmus.cacina | 0:ac4dea3e2894 | 191 | { "set_cfg host ebl" , SH_BOOTLDR_set_host_ebl_mode , "sets GPIO/CMD reset for reset hub to bootoader mode. default GPIO, usage: set_cfg host ebl 1/0, 1 for GPIO" }, |
seyhmus.cacina | 0:ac4dea3e2894 | 192 | { "get_cfg host cdf" , SH_BOOTLDR_get_host_bootcmds_delay_factor , "sets delay factor for bootoader cmd waits default 1, usage: set_cfg host cdf FACTOR" }, |
seyhmus.cacina | 0:ac4dea3e2894 | 193 | { "get_cfg host ebl" , SH_BOOTLDR_get_host_ebl_mode , "sets GPIO/CMD reset for reset hub to bootoader mode. default GPIO, usage: set_cfg host ebl 1/0, 1 for GPIO" }, |
seyhmus.cacina | 0:ac4dea3e2894 | 194 | { "get_host_boot_state_info" , BOOTLDR_get_host_bootloader_state , "gets boot state keeping struct of host" }, |
seyhmus.cacina | 0:ac4dea3e2894 | 195 | |
seyhmus.cacina | 0:ac4dea3e2894 | 196 | |
seyhmus.cacina | 0:ac4dea3e2894 | 197 | }; |
seyhmus.cacina | 0:ac4dea3e2894 | 198 | |
seyhmus.cacina | 0:ac4dea3e2894 | 199 | #endif /* SOURCE_CMDUI_BOOTLDRINTERFACE_H_ */ |
seyhmus.cacina | 0:ac4dea3e2894 | 200 |