Skip to content

Commit 09bdb3b

Browse files
committed
add command option for riotcore
Add the requested feature to toggle the riotcore partition option, add as part of the existing fw-toggle command. As part of these changes a new 8bit field to toggle the riotcore is included to the toggle MRPC cmd. FW partition line prints RIOT as inactive or active in sections of the fw_info command and fw_toggle command where approriate.
1 parent f4fe1db commit 09bdb3b

3 files changed

Lines changed: 28 additions & 7 deletions

File tree

cli/main.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,6 +1799,8 @@ static int print_fw_part_info(struct switchtec_dev *dev)
17991799
print_fw_part_line("BOOT", sum->boot.active);
18001800
print_fw_part_line("MAP", sum->map.active);
18011801
print_fw_part_line("KEY", sum->key.active);
1802+
if (switchtec_is_gen5(dev))
1803+
print_fw_part_line("RIOT", sum->riot.active);
18021804
print_fw_part_line("BL2", sum->bl2.active);
18031805
print_fw_part_line("IMG", sum->img.active);
18041806
print_fw_part_line("CFG", sum->cfg.active);
@@ -1809,6 +1811,8 @@ static int print_fw_part_info(struct switchtec_dev *dev)
18091811
printf("Inactive Partitions:\n");
18101812
print_fw_part_line("MAP", sum->map.inactive);
18111813
print_fw_part_line("KEY", sum->key.inactive);
1814+
if (switchtec_is_gen5(dev))
1815+
print_fw_part_line("RIOT", sum->riot.inactive);
18121816
print_fw_part_line("BL2", sum->bl2.inactive);
18131817
print_fw_part_line("IMG", sum->img.inactive);
18141818
print_fw_part_line("CFG", sum->cfg.inactive);
@@ -2019,6 +2023,7 @@ static int fw_toggle(int argc, char **argv)
20192023
int key;
20202024
int firmware;
20212025
int config;
2026+
int riotcore;
20222027
} cfg = {};
20232028
const struct argconfig_options opts[] = {
20242029
DEVICE_OPTION,
@@ -2030,23 +2035,29 @@ static int fw_toggle(int argc, char **argv)
20302035
"toggle IMG firmware"},
20312036
{"config", 'c', "", CFG_NONE, &cfg.config, no_argument,
20322037
"toggle CFG data"},
2038+
{"riotcore", 'r', "", CFG_NONE, &cfg.riotcore, no_argument,
2039+
"toggle RIOTCORE - Gen5 switch only"},
20332040
{NULL}};
20342041

20352042
argconfig_parse(argc, argv, CMD_DESC_FW_TOGGLE, opts, &cfg, sizeof(cfg));
20362043

2037-
if (!cfg.bl2 && !cfg.key && !cfg.firmware && !cfg.config) {
2044+
if (!cfg.bl2 && !cfg.key && !cfg.firmware && !cfg.config && !cfg.riotcore) {
20382045
fprintf(stderr, "NOTE: Not toggling images as no "
20392046
"partition type options were specified\n\n");
2040-
} else if ((cfg.bl2 || cfg.key) && switchtec_is_gen3(cfg.dev)) {
2041-
fprintf(stderr, "Firmware type BL2 and Key manifest"
2047+
} else if ((cfg.bl2 || cfg.key || cfg.riotcore) && switchtec_is_gen3(cfg.dev)) {
2048+
fprintf(stderr, "Firmware type BL2, Key manifest, or RIORCORE "
20422049
"are not supported by Gen3 switches\n");
20432050
return 1;
2051+
} else if (cfg.riotcore && switchtec_is_gen4(cfg.dev)){
2052+
fprintf(stderr, "Firmware type RIOTCORE is not supported by Gen4 switchtes\n");
2053+
return 1;
20442054
} else {
20452055
ret = switchtec_fw_toggle_active_partition(cfg.dev,
20462056
cfg.bl2,
20472057
cfg.key,
20482058
cfg.firmware,
2049-
cfg.config);
2059+
cfg.config,
2060+
cfg.riotcore);
20502061
if (ret)
20512062
err = errno;
20522063
}

inc/switchtec/switchtec.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,8 @@ enum switchtec_fw_ro {
843843

844844
int switchtec_fw_toggle_active_partition(struct switchtec_dev *dev,
845845
int toggle_bl2, int toggle_key,
846-
int toggle_fw, int toggle_cfg);
846+
int toggle_fw, int toggle_cfg,
847+
int toggle_riotcore);
847848
int switchtec_fw_write_fd(struct switchtec_dev *dev, int img_fd,
848849
int dont_activate, int force,
849850
void (*progress_callback)(int cur, int tot));

lib/fw.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,18 @@ static int switchtec_fw_wait(struct switchtec_dev *dev,
247247
*/
248248
int switchtec_fw_toggle_active_partition(struct switchtec_dev *dev,
249249
int toggle_bl2, int toggle_key,
250-
int toggle_fw, int toggle_cfg)
250+
int toggle_fw, int toggle_cfg,
251+
int toggle_riotcore)
251252
{
252253
uint32_t cmd_id;
254+
size_t cmd_size;
253255
struct {
254256
uint8_t subcmd;
255257
uint8_t toggle_fw;
256258
uint8_t toggle_cfg;
257259
uint8_t toggle_bl2;
258260
uint8_t toggle_key;
261+
uint8_t toggle_riotcore;
259262
} cmd;
260263

261264
if (switchtec_boot_phase(dev) == SWITCHTEC_BOOT_PHASE_BL2) {
@@ -270,8 +273,14 @@ int switchtec_fw_toggle_active_partition(struct switchtec_dev *dev,
270273
cmd.toggle_key = !!toggle_key;
271274
cmd.toggle_fw = !!toggle_fw;
272275
cmd.toggle_cfg = !!toggle_cfg;
276+
if (switchtec_is_gen5(dev)) {
277+
cmd.toggle_riotcore = !!toggle_riotcore;
278+
cmd_size = sizeof(cmd);
279+
} else {
280+
cmd_size = sizeof(cmd) - 1;
281+
}
273282

274-
return switchtec_cmd(dev, cmd_id, &cmd, sizeof(cmd),
283+
return switchtec_cmd(dev, cmd_id, &cmd, cmd_size,
275284
NULL, 0);
276285
}
277286

0 commit comments

Comments
 (0)