From 200e88a964b6bb479f40bdf1dc398e8ead8c3700 Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Mon, 28 Nov 2022 22:04:12 +0000 Subject: [PATCH] fel: add list-socs command 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 --- fel.c | 13 +++++++++++++ sunxi-fel.1 | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/fel.c b/fel.c index 2e4c33648..79a7c24d0 100644 --- a/fel.c +++ b/fel.c @@ -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" @@ -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; @@ -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 '=' */ @@ -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); diff --git a/sunxi-fel.1 b/sunxi-fel.1 index 42aed744c..3923bc0e2 100644 --- a/sunxi-fel.1 +++ b/sunxi-fel.1 @@ -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