Skip to content

Commit

Permalink
shell: device_service: print DT metadata
Browse files Browse the repository at this point in the history
Example output on qemu_cortex_m3:

  devices:
  - uart@4000e000 (READY)
    DT node labels: uart2
  - uart@4000d000 (READY)
    DT node labels: uart1
  - uart@4000c000 (READY)
    DT node labels: uart0
  - gpio@40026000 (READY)
    DT node labels: gpio6
  - gpio@40025000 (READY)
    DT node labels: gpio5
  - gpio@40024000 (READY)
    DT node labels: gpio4
  - gpio@40007000 (READY)
    DT node labels: gpio3
  - gpio@40006000 (READY)
    DT node labels: gpio2
  - gpio@40005000 (READY)
    DT node labels: gpio1
  - gpio@40004000 (READY)
    DT node labels: gpio0

Signed-off-by: Martí Bolívar <[email protected]>
  • Loading branch information
mbolivar-ampere authored and aescolar committed Jun 12, 2024
1 parent 48a14dc commit b93fe6a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions subsys/shell/modules/device_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ static int cmd_device_list(const struct shell *sh,
(void)device_required_foreach(dev, cmd_device_list_visitor, &ctx);
}
#endif /* CONFIG_DEVICE_DEPS */

#ifdef CONFIG_DEVICE_DT_METADATA
const struct device_dt_nodelabels *nl = device_get_dt_nodelabels(dev);

if (nl->num_nodelabels > 0) {
shell_fprintf(sh, SHELL_NORMAL, " DT node labels:");
for (size_t j = 0; j < nl->num_nodelabels; j++) {
const char *nodelabel = nl->nodelabels[j];

shell_fprintf(sh, SHELL_NORMAL, " %s", nodelabel);
}
shell_fprintf(sh, SHELL_NORMAL, "\n");
}
#endif /* CONFIG_DEVICE_DT_METADATAa */
}

return 0;
Expand Down

0 comments on commit b93fe6a

Please sign in to comment.