YOSHIHISA TABUCHI / Mbed OS Host_Software_MAX32664GWEB_HR_EXTENDEDtest

Dependencies:   BMI160 max32630hsp3 MemoryLCD USBDevice

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers bootldrAPI.h Source File

bootldrAPI.h

00001 /*
00002  * bootldrInterface.h
00003  *
00004  *  Created on: Feb 7, 2019
00005  *      Author: Yagmur.Gok
00006  */
00007 
00008 #ifndef SOURCE_CMDUI_BOOTLDRINTERFACE_H_
00009 #define SOURCE_CMDUI_BOOTLDRINTERFACE_H_
00010 
00011 typedef int (*cmdExecFunc)( const char*); // typedef void (*cmdExecFunc)( const void*);
00012 
00013 typedef struct {
00014     char const* cmdStr;
00015     cmdExecFunc execute;
00016     char const *help;
00017 }cmd_interface_tb;
00018 
00019 #define FLASH_ERR_GENERAL   -1
00020 #define FLASH_ERR_CHECKSUM  -2
00021 #define FLASH_ERR_AUTH      -3
00022 
00023 /**
00024 * @brief      sets the SENSOR HUB to Bootloader Mode for Firmware update. Prints status info on command console
00025 *
00026 * @param[in]  null_arg : NULL string, just to match the form of command table function pointer type
00027 *
00028 * @return status info, 0x00 on success.
00029 **/
00030 int SH_BOOTLDR_enter_blmode(const char *null_arg);
00031 
00032 /**
00033 * @brief      exits the SENSOR HUB from Bootloader Mode to Application Mode. Prints status info on command console
00034 *
00035 * @param[in]  null_arg : NULL string, just to match the form of command table function pointer type
00036 *
00037 * @return status info, 0x00 on success.
00038 **/
00039 int SH_BOOTLDR_exit_blmode(const char *null_arg);
00040 
00041 /**
00042 * @brief      gets the page size of bootloader within SENSOR HUB. Prints status info and page size value on command console
00043 *
00044 * @param[in]  null_arg : NULL string, just to match the form of command table function pointer type
00045 *
00046 * @return status info, 0x00 on success.
00047 **/
00048 int SH_BOOTLDR_get_pagesz(const char *null_arg);
00049 
00050 /**
00051 * @brief      sets the totatl page count for MSBL file to be uploaded to SENSOR HUB. Prints status info on command console
00052 *
00053 * @param[in]  arg : byte string including command followed by page size value extracted from header of MSBL file in DECIMAL format!
00054 *                   "num_pages 24"
00055 *
00056 * @return status info, 0x00 on success.
00057 **/
00058 int SH_BOOTLDR_set_pagecount(const char *arg);
00059 
00060 /**
00061 * @brief      sets the IV vector of  MSBL file to be uploaded to SENSOR HUB. Prints status info on command console
00062 *             IV vector is 22 bytes of data extracted from header of MSBL file.
00063 *
00064 * @param[in]  arg : byte string including command followed by 22 byte IV value in HEXADECIMAL format! do no preceed IV bytes wirh 0x !!!!
00065                     "set_iv 1234567891234567891234"
00066 *
00067 * @return status info, 0x00 on success.
00068 **/
00069 int SH_BOOTLDR_set_iv(const char *arg);
00070 
00071 /**
00072 * @brief      sets the Authentication vector of  MSBL file to be uploaded to SENSOR HUB. Prints status info on command console
00073 *             Authentication vector is 36 bytes of data extracted from header of MSBL file.
00074 *
00075 * @param[in]  arg : byte string including command followed by 22 byte IV value in HEXADECIMAL format! do no preceed IV bytes wirh 0x !!!!
00076                     "set_auth 12345678912345678912345678912345"
00077 *
00078 * @return status info, 0x00 on success.
00079 **/
00080 int SH_BOOTLDR_set_authentication(const char *arg);
00081 
00082 /**
00083 * @brief      erases application code of SENSOR HUB. Prints status info on command console
00084 *
00085 * @param[in]  null_arg : NULL string, just to match the form of command table function pointer type
00086 *
00087 * @return status info, 0x00 on success.
00088 **/
00089 int SH_BOOTLDR_eraseflash(const char *null_arg);
00090 
00091 /**
00092 * @brief      puts the SENSOR HUB to the state of waiting for MSBL application code pages from serial command interface.
00093 *             Prints status info on command console upon flashing of every page.
00094 *
00095 * @param[in]  null_arg : NULL string, just to match the form of command table function pointer type
00096 *
00097 * @return status info, 0x00 on success.
00098 **/
00099 int SH_BOOTLDR_flash(const char *null_arg);
00100 
00101 /**
00102 * @brief      sets the SENSOR HUB to the bootloader state where application image pages are first stored into HOST ram and will be flashed
00103 *             at once. Prints status info on command console.
00104 *
00105 * @param[in]  arg : byte string including command followed by 1 byte omage on ram flag in DECIMAL format
00106 *                   "image_on_ram 0/1"  0: for classic mode where pages are downloaded form PC over serial command console and
00107 *                    flashed to SENSOR HUB 1 by 1. 1: for image on ram mode.
00108 *
00109 * @return status info, 0x00 on success.
00110 **/
00111 int SH_BOOTLOADER_image_on_ram( const char *arg );
00112 
00113 /**
00114 * @brief      flashes pages in HOST Ram to Sensor Hub.
00115 *             USE ONLY IN IMAGE_ON_RAM MODE !!!!
00116 *
00117 * @param[in]  null_arg : NULL string, just to match the form of command table function pointer type
00118 *
00119 * @return status info, 0x00 on success.
00120 **/
00121 int SH_BOOTLDR_flash_appimage_from_ram(const char *null_arg);
00122 
00123 /**
00124 * @brief      set the delay factor multipler for Bootloader wait durations in commands and between flashing of pages
00125 *
00126 * @param[in]  arg : byte string including command followed by delay factor in DECIMAL format
00127 *                   "set_cfg host cdf 1" to "set_cfg host cdf 4" practical range. 1 is default.
00128 *
00129 * @return status info, 0x00 on success.
00130 **/
00131 int SH_BOOTLDR_set_host_bootcmds_delay_factor( const char *arg);
00132 
00133 /**
00134 * @brief      get the delay factor multipler for Bootloader wait durations in commands and between flashing of pages.
00135 *             Prints delay factor multipler value on command console.
00136 *
00137 * @param[in]  null_arg : NULL string, just to match the form of command table function pointer type
00138 *
00139 * @return status info, 0x00 on success.
00140 **/
00141 int SH_BOOTLDR_get_host_bootcmds_delay_factor( const char *null_arg);
00142 
00143 /**
00144 * @brief      sets the resetting method of SENSOR HUB between command based and GPIO based resets. Default is GPIO based reset.ie 1.
00145 *
00146 * @param[in]  arg : byte string including command followed by ebl mode in DECIMAL format
00147 *                   "set_cfg host ebl 1/0" . 0 for command based reset; 1 for GPIO based reset which is default and preferred option.
00148 *
00149 * @return status info, 0x00 on success.
00150 **/
00151 int SH_BOOTLDR_set_host_ebl_mode(const char *arg);
00152 
00153 /**
00154 * @brief      gets the resetting method of SENSOR HUB between command based and GPIO based resets.
00155 *             Prints delay factor multipler value on command console.
00156 *
00157 * @param[in]  null_arg : NULL string, just to match the form of command table function pointer type
00158 *
00159 * @return status info, 0x00 on success.
00160 **/
00161 int SH_BOOTLDR_get_host_ebl_mode(const char *null_arg);
00162 
00163 /**
00164 * @brief      gets the struct keeping state information about bootloading steps required at HOST side.
00165 *             Prints struct data fields and state flags; ie. is_iv_set? page_size acquired from hub etc.
00166 *             If all steps are not done, flashing operation do not take place and informs user on command
00167 *             console
00168 *
00169 * @param[in]  null_arg : NULL string, just to match the form of command table function pointer type
00170 *
00171 * @return status info, 0x00 on success.
00172 **/
00173 int BOOTLDR_get_host_bootloader_state(const char *null_arg);
00174 
00175 
00176 #define NUMCMDSBOOTLDRAPI (15)
00177 
00178 const cmd_interface_tb CMDTABLEBOOTLDR[] = {
00179 
00180         {  "bootldr"          , SH_BOOTLDR_enter_blmode                   , "resets and puts sensor hub to bootloader mode "                                                                },
00181         {  "exit"             , SH_BOOTLDR_exit_blmode                    , "exits sensor hub from bootloader mode to app mode"                                                             },
00182         {  "page_size"        , SH_BOOTLDR_get_pagesz                     , "returns sensor hub bootloader page size for app data pages"                                                    },
00183         {  "num_pages"        , SH_BOOTLDR_set_pagecount                  , "sets sensor hub bootloader app image pages, uasge: num_pages PAGES"                                            },
00184         {  "set_iv"           , SH_BOOTLDR_set_iv                         , "sets sensor hub bootloader initial vector bytes, usage: set_iv XXXXXXXXXXX (11 hex chrs)"                      },
00185         {  "set_auth"         , SH_BOOTLDR_set_authentication             , "sets sensor hub bootloader authentication bytes, usage: set_iv XXXXXXXXXXXXXXXX (16 hex chrs)"                 },
00186         {  "erase"            , SH_BOOTLDR_eraseflash                     , "erases sesn hub application flash memory"                                                                      },
00187         {  "image_on_ram"     , SH_BOOTLOADER_image_on_ram                , "selects pagBypage download-flash / block download-flash options"                                               },
00188         {  "flash"            , SH_BOOTLDR_flash                          ,  "flash image to hub/dowload pages from PC based on image_on_ram selection"                                     },
00189         {  "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"                             },
00190         {  "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"                           },
00191         {  "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"   },
00192         {  "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"                           },
00193         {  "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"   },
00194         {  "get_host_boot_state_info" , BOOTLDR_get_host_bootloader_state , "gets boot state keeping struct of host"                                                                        },
00195 
00196 
00197 };
00198 
00199 #endif /* SOURCE_CMDUI_BOOTLDRINTERFACE_H_ */
00200