Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions cli/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1799,6 +1799,8 @@ static int print_fw_part_info(struct switchtec_dev *dev)
print_fw_part_line("BOOT", sum->boot.active);
print_fw_part_line("MAP", sum->map.active);
print_fw_part_line("KEY", sum->key.active);
if (switchtec_is_gen5(dev))
print_fw_part_line("RIOT", sum->riot.active);
print_fw_part_line("BL2", sum->bl2.active);
print_fw_part_line("IMG", sum->img.active);
print_fw_part_line("CFG", sum->cfg.active);
Expand All @@ -1809,6 +1811,8 @@ static int print_fw_part_info(struct switchtec_dev *dev)
printf("Inactive Partitions:\n");
print_fw_part_line("MAP", sum->map.inactive);
print_fw_part_line("KEY", sum->key.inactive);
if (switchtec_is_gen5(dev))
print_fw_part_line("RIOT", sum->riot.inactive);
print_fw_part_line("BL2", sum->bl2.inactive);
print_fw_part_line("IMG", sum->img.inactive);
print_fw_part_line("CFG", sum->cfg.inactive);
Expand Down Expand Up @@ -2019,6 +2023,7 @@ static int fw_toggle(int argc, char **argv)
int key;
int firmware;
int config;
int riotcore;
} cfg = {};
const struct argconfig_options opts[] = {
DEVICE_OPTION,
Expand All @@ -2030,23 +2035,29 @@ static int fw_toggle(int argc, char **argv)
"toggle IMG firmware"},
{"config", 'c', "", CFG_NONE, &cfg.config, no_argument,
"toggle CFG data"},
{"riotcore", 'r', "", CFG_NONE, &cfg.riotcore, no_argument,
"toggle RIOTCORE - Gen5 switch only"},
{NULL}};

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

if (!cfg.bl2 && !cfg.key && !cfg.firmware && !cfg.config) {
if (!cfg.bl2 && !cfg.key && !cfg.firmware && !cfg.config && !cfg.riotcore) {
fprintf(stderr, "NOTE: Not toggling images as no "
"partition type options were specified\n\n");
} else if ((cfg.bl2 || cfg.key) && switchtec_is_gen3(cfg.dev)) {
fprintf(stderr, "Firmware type BL2 and Key manifest"
} else if ((cfg.bl2 || cfg.key || cfg.riotcore) && switchtec_is_gen3(cfg.dev)) {
fprintf(stderr, "Firmware type BL2, Key manifest, or RIORCORE "
"are not supported by Gen3 switches\n");
return 1;
} else if (cfg.riotcore && switchtec_is_gen4(cfg.dev)){
fprintf(stderr, "Firmware type RIOTCORE is not supported by Gen4 switchtes\n");
return 1;
} else {
ret = switchtec_fw_toggle_active_partition(cfg.dev,
cfg.bl2,
cfg.key,
cfg.firmware,
cfg.config);
cfg.config,
cfg.riotcore);
if (ret)
err = errno;
}
Expand Down
3 changes: 2 additions & 1 deletion inc/switchtec/switchtec.h
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,8 @@ enum switchtec_fw_ro {

int switchtec_fw_toggle_active_partition(struct switchtec_dev *dev,
int toggle_bl2, int toggle_key,
int toggle_fw, int toggle_cfg);
int toggle_fw, int toggle_cfg,
int toggle_riotcore);
int switchtec_fw_write_fd(struct switchtec_dev *dev, int img_fd,
int dont_activate, int force,
void (*progress_callback)(int cur, int tot));
Expand Down
13 changes: 11 additions & 2 deletions lib/fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,18 @@ static int switchtec_fw_wait(struct switchtec_dev *dev,
*/
int switchtec_fw_toggle_active_partition(struct switchtec_dev *dev,
int toggle_bl2, int toggle_key,
int toggle_fw, int toggle_cfg)
int toggle_fw, int toggle_cfg,
int toggle_riotcore)
{
uint32_t cmd_id;
size_t cmd_size;
struct {
uint8_t subcmd;
uint8_t toggle_fw;
uint8_t toggle_cfg;
uint8_t toggle_bl2;
uint8_t toggle_key;
uint8_t toggle_riotcore;
} cmd;

if (switchtec_boot_phase(dev) == SWITCHTEC_BOOT_PHASE_BL2) {
Expand All @@ -270,8 +273,14 @@ int switchtec_fw_toggle_active_partition(struct switchtec_dev *dev,
cmd.toggle_key = !!toggle_key;
cmd.toggle_fw = !!toggle_fw;
cmd.toggle_cfg = !!toggle_cfg;
if (switchtec_is_gen5(dev)) {
cmd.toggle_riotcore = !!toggle_riotcore;
cmd_size = sizeof(cmd);
} else {
cmd_size = sizeof(cmd) - 1;
}

return switchtec_cmd(dev, cmd_id, &cmd, sizeof(cmd),
return switchtec_cmd(dev, cmd_id, &cmd, cmd_size,
NULL, 0);
}

Expand Down