Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output a list of supported SoCs #190

Merged
merged 2 commits into from
Oct 25, 2023
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
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
27 changes: 27 additions & 0 deletions soc_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,33 @@ soc_info_t *get_soc_info_from_version(struct aw_fel_version *buf)
return get_soc_info_from_id(buf->soc_id);
}

/*
* Iterate through all supported SoCs. The first call will take NULL as
* an argument, subsequent calls pass in the pointer returned by the
* previous call. When we reach the end of the list, the function
* returns NULL.
*/
const soc_info_t *get_next_soc(const soc_info_t *prev)
{
const soc_info_t *soc;

if (prev == NULL)
return &soc_info_table[0];

for (soc = soc_info_table; soc->swap_buffers; soc++) {
if (soc != prev)
continue;

soc++;
if (!soc->swap_buffers) /* end of list? */
return NULL;

return soc;
}

return NULL; /* prev entry not found */
}

void get_soc_name_from_id(soc_name_t buffer, uint32_t soc_id)
{
soc_info_t *soc;
Expand Down
1 change: 1 addition & 0 deletions soc_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,6 @@ typedef struct {
void get_soc_name_from_id(soc_name_t buffer, uint32_t soc_id);
soc_info_t *get_soc_info_from_id(uint32_t soc_id);
soc_info_t *get_soc_info_from_version(struct aw_fel_version *buf);
const soc_info_t *get_next_soc(const soc_info_t *prev);

#endif /* _SUNXI_TOOLS_SOC_INFO_H */
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
Loading