Skip to content

Commit

Permalink
fel: add list-socs command
Browse files Browse the repository at this point in the history
As over time we gain support for more and more SoCs, it would be
convenient to know which SoCs a particular build actually supports.

Add a "list-socs" command, that just iterates over the soc_info table
and outputs the SoC ID and the name for each entry.

Signed-off-by: Andre Przywara <[email protected]>
  • Loading branch information
apritzel authored and paulkocialkowski committed Oct 25, 2023
1 parent 34c3150 commit 91f9ccf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions fel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,7 @@ void usage(const char *cmd) {
" -l, --list Enumerate all (USB) FEL devices and exit\n"
" -d, --dev bus:devnum Use specific USB bus and device number\n"
" --sid SID Select device by SID key (exact match)\n"
" --list-socs Print a list of all supported SoCs\n"
"\n"
" spl file Load and execute U-Boot SPL\n"
" If file additionally contains a main U-Boot binary\n"
Expand Down Expand Up @@ -1297,6 +1298,7 @@ int main(int argc, char **argv)
bool uboot_autostart = false; /* flag for "uboot" command = U-Boot autostart */
bool pflag_active = false; /* -p switch, causing "write" to output progress */
bool device_list = false; /* -l switch, prints device list and exits */
bool socs_list = false; /* list all supported SoCs and exit */
feldev_handle *handle;
int busnum = -1, devnum = -1;
char *sid_arg = NULL;
Expand All @@ -1315,6 +1317,9 @@ int main(int argc, char **argv)
else if (strcmp(argv[1], "--list") == 0 || strcmp(argv[1], "-l") == 0
|| strcmp(argv[1], "list") == 0)
device_list = true;
else if (strcmp(argv[1], "--list-socs") == 0 ||
strcmp(argv[1], "list-socs") == 0)
socs_list = true;
else if (strncmp(argv[1], "--dev", 5) == 0 || strncmp(argv[1], "-d", 2) == 0) {
char *dev_arg = argv[1];
dev_arg += strspn(dev_arg, "-dev="); /* skip option chars, ignore '=' */
Expand Down Expand Up @@ -1353,6 +1358,14 @@ int main(int argc, char **argv)
/* Process options that don't require a FEL device handle */
if (device_list)
felusb_list_devices(); /* and exit program afterwards */
if (socs_list) {
const soc_info_t *soc_info = NULL;

printf("SoCID name\n");
while ((soc_info = get_next_soc(soc_info)) != NULL)
printf("%04x: %s\n", soc_info->soc_id, soc_info->name);
return 0;
}
if (sid_arg) {
/* try to set busnum and devnum according to "--sid" option */
select_by_sid(sid_arg, &busnum, &devnum);
Expand Down
5 changes: 5 additions & 0 deletions sunxi-fel.1
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ Enable verbose logging.
Enumerate all (USB) FEL devices and exit.
.RE
.sp
.B \-\-list-socs
.RS 4
Print a list of all supported SoCs and exit.
.RE
.sp
.B \-d, \-\-dev bus:devnum
.RS 4
Use specific USB bus and device number
Expand Down

0 comments on commit 91f9ccf

Please sign in to comment.