@@ -1906,11 +1906,12 @@ static void print_fw_part_line(const char *tag,
19061906 if (!inf )
19071907 return ;
19081908
1909- printf (" %-4s\tVersion: %-8s\tCRC: %08lx\t%4s%11s%s\n" ,
1909+ printf (" %-4s\tVersion: %-8s\tCRC: %08lx\t%4s%11s%s%s \n" ,
19101910 tag , inf -> version , inf -> image_crc ,
19111911 inf -> read_only ? "(RO)" : "" ,
19121912 inf -> running ? " (Running)" : "" ,
1913- inf -> valid ? "" : " (Invalid)" );
1913+ inf -> valid ? "" : " (Invalid)" ,
1914+ inf -> redundant ? " (Redundant)" : "" );
19141915}
19151916
19161917static int print_fw_part_info (struct switchtec_dev * dev )
@@ -2177,7 +2178,7 @@ static int fw_toggle(int argc, char **argv)
21772178 "are not supported by Gen3 switches\n" );
21782179 return 1 ;
21792180 } else if (cfg .riotcore && switchtec_is_gen4 (cfg .dev )){
2180- fprintf (stderr , "Firmware type RIOTCORE is not supported by Gen4 switchtes \n" );
2181+ fprintf (stderr , "Firmware type RIOTCORE is not supported by Gen4 switches \n" );
21812182 return 1 ;
21822183 } else {
21832184 ret = switchtec_fw_toggle_active_partition (cfg .dev ,
@@ -2205,6 +2206,69 @@ static int fw_toggle(int argc, char **argv)
22052206 return ret ;
22062207}
22072208
2209+ #define CMD_DESC_FW_REDUNDANT "Set an image partition to redundant"
2210+ static int fw_redundant (int argc , char * * argv )
2211+ {
2212+
2213+ int ret = 0 ;
2214+
2215+ static struct {
2216+ struct switchtec_dev * dev ;
2217+ int bl2 ;
2218+ int key ;
2219+ int firmware ;
2220+ int config ;
2221+ int riotcore ;
2222+ int redundant ;
2223+ } cfg = {
2224+ .redundant = 1 ,
2225+ };
2226+ const struct argconfig_options opts [] = {
2227+ DEVICE_OPTION ,
2228+ {"bl2" , 'b' , "" , CFG_NONE , & cfg .bl2 , no_argument ,
2229+ "Set redundancy flag for bl2 partition" },
2230+ {"key" , 'k' , "" , CFG_NONE , & cfg .key , no_argument ,
2231+ "Set redundancy flag for Key manifest partition" },
2232+ {"firmware" , 'f' , "" , CFG_NONE , & cfg .firmware , no_argument ,
2233+ "Set redundancy flag for main FW image partition" },
2234+ {"config" , 'c' , "" , CFG_NONE , & cfg .config , no_argument ,
2235+ "Set redundancy flag for data CFG partition" },
2236+ {"riotcore" , 'r' , "" , CFG_NONE , & cfg .riotcore , no_argument ,
2237+ "Set redundancy flag for RIOTCORE partition" },
2238+ {"redundant" , 'R' , "unset - 0 / set - 1" , CFG_INT , & cfg .redundant , required_argument ,
2239+ "Set the redundant flag for the selected image type(s). If left blank will set (1)" },
2240+ {NULL }};
2241+
2242+ argconfig_parse (argc , argv , CMD_DESC_FW_REDUNDANT , opts , & cfg , sizeof (cfg ));
2243+
2244+ if (!switchtec_is_gen5 (cfg .dev )) {
2245+ fprintf (stderr , "Setting the redundant flag is only supported on Gen5 switches\n" );
2246+ return 1 ;
2247+ }
2248+ if (!cfg .bl2 && !cfg .key && !cfg .firmware && !cfg .config && !cfg .riotcore ) {
2249+ fprintf (stderr , "Not setting image partition(s) as redundant since no partition type was specified\n" );
2250+ return 1 ;
2251+ }
2252+ if (cfg .redundant > 1 ) {
2253+ fprintf (stderr , "Set redundant flag to either set - 1 or unset - 0\n" );
2254+ return 1 ;
2255+ }
2256+
2257+ ret = switchtec_fw_set_redundant_flag (cfg .dev , cfg .key ,
2258+ cfg .riotcore , cfg .bl2 ,
2259+ cfg .config , cfg .firmware ,
2260+ cfg .redundant );
2261+ if (ret )
2262+ switchtec_perror ("set redundant flag" );
2263+
2264+ ret = print_fw_part_info (cfg .dev );
2265+ if (ret )
2266+ switchtec_perror ("print fw info" );
2267+
2268+ printf ("\n" );
2269+ return ret ;
2270+ }
2271+
22082272#define CMD_DESC_FW_READ "read a firmware image from flash"
22092273
22102274static int fw_read (int argc , char * * argv )
@@ -2781,6 +2845,7 @@ static const struct cmd commands[] = {
27812845 CMD (fw_update , CMD_DESC_FW_UPDATE ),
27822846 CMD (fw_info , CMD_DESC_FW_INFO ),
27832847 CMD (fw_toggle , CMD_DESC_FW_TOGGLE ),
2848+ CMD (fw_redundant , CMD_DESC_FW_REDUNDANT ),
27842849 CMD (fw_read , CMD_DESC_FW_READ ),
27852850 CMD (fw_img_info , CMD_DESC_FW_IMG_INFO ),
27862851 CMD (evcntr , CMD_DESC_EVCNTR ),
0 commit comments