shell: device_service: print DT metadata

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 <mbolivar@amperecomputing.com>
This commit is contained in:
Martí Bolívar 2024-04-25 02:05:58 -06:00 committed by Alberto Escolar
commit b93fe6ad2d

View file

@ -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;