Skip to content

Commit fac7027

Browse files
committed
zephyr/shell: fix module_list and clock_status output
Three fixes: - module_list: search for TEXT segment by type flag instead of assuming segment[0] is always TEXT (built-in modules have no loaded segments so segment[0].length is 0) - module_list: raise CONFIG_SHELL_PRINTF_BUFF_SIZE to 256 in shell_overlay.conf (was 30, causing mid-line truncation) - module_list: add k_msleep(5) between module entries to allow the snd_sof_serial TX FIFO to drain (prevents byte loss on fast output) - clock_status: replace %.1f (unsupported by Zephyr shell printf) with integer MHz whole + tenth using integer arithmetic
1 parent a844610 commit fac7027

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

app/shell_overlay.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ CONFIG_SOF_SHELL_CORE_POWER=y
2525

2626
# Disable REBOOT since qemu_xtensa does not implement sys_arch_reboot
2727
CONFIG_REBOOT=n
28+
CONFIG_SHELL_PRINTF_BUFF_SIZE=256

zephyr/sof_shell.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,11 @@ __cold static int cmd_sof_clock_status(const struct shell *sh,
384384

385385
for (i = 0; i < NUM_CLOCKS; i++) {
386386
uint32_t freq = clocks[i].freqs[clocks[i].current_freq_idx].freq;
387+
uint32_t mhz_whole = freq / 1000000;
388+
uint32_t mhz_tenth = (freq % 1000000) / 100000;
387389

388-
shell_print(sh, "%-6d %-12u %.1f",
389-
i, freq, (double)freq / 1000000.0);
390+
shell_print(sh, "%-6d %-12u %u.%u",
391+
i, freq, mhz_whole, mhz_tenth);
390392
}
391393

392394
return 0;
@@ -420,8 +422,9 @@ __cold static void print_manifest_modules(const struct shell *sh,
420422
for (i = 0; i < (int)desc->header.num_module_entries; i++) {
421423
const struct sof_man_module *mod;
422424
const struct sof_man_mod_config *cfg = NULL;
423-
uint32_t text_sz, bss_sz;
425+
uint32_t text_sz = 0, bss_sz;
424426
char name[SOF_MAN_MOD_NAME_LEN + 1];
427+
int s;
425428

426429
mod = (const struct sof_man_module *)
427430
((const uint8_t *)desc + SOF_MAN_MODULE_OFFSET(i));
@@ -433,8 +436,15 @@ __cold static void print_manifest_modules(const struct shell *sh,
433436
if (mod->cfg_count > 0)
434437
cfg = cfg_base + mod->cfg_offset;
435438

436-
text_sz = (uint32_t)mod->segment[0].flags.r.length * _SHELL_MOD_PAGE_SZ;
437-
bss_sz = (uint32_t)mod->instance_bss_size * _SHELL_MOD_PAGE_SZ;
439+
/* find TEXT segment by type — index 0 is not always TEXT for built-ins */
440+
for (s = 0; s < 3; s++) {
441+
if (mod->segment[s].flags.r.type == SOF_MAN_SEGMENT_TEXT) {
442+
text_sz = (uint32_t)mod->segment[s].flags.r.length
443+
* _SHELL_MOD_PAGE_SZ;
444+
break;
445+
}
446+
}
447+
bss_sz = (uint32_t)mod->instance_bss_size * _SHELL_MOD_PAGE_SZ;
438448

439449
shell_print(sh,
440450
"[%d:%d] %-8s"
@@ -456,6 +466,9 @@ __cold static void print_manifest_modules(const struct shell *sh,
456466
cfg->cpc, cfg->cps, cfg->ibs, cfg->obs);
457467
else
458468
shell_print(sh, " cpc:N/A");
469+
470+
/* yield between entries so the serial driver can drain its TX FIFO */
471+
k_msleep(5);
459472
}
460473
}
461474
#endif /* CONFIG_IPC4_BASE_FW_INTEL */

0 commit comments

Comments
 (0)