Skip to content

Commit

Permalink
Using streamer for cli_dump_address and exposing it in sysfs
Browse files Browse the repository at this point in the history
  • Loading branch information
ncasaril committed Sep 3, 2020
1 parent 6eaa85e commit 851eb84
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
14 changes: 7 additions & 7 deletions hw/drivers/uwb/uwb_dw1000/src/dw1000_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,17 @@ dw1000_cli_dump_registers(struct _dw1000_dev_instance_t * inst, struct streamer
}

void
dw1000_dump_address(struct _dw1000_dev_instance_t * inst, uint32_t addr, uint16_t length)
dw1000_cli_dump_address(struct _dw1000_dev_instance_t * inst, uint32_t addr, uint16_t length, struct streamer *streamer)
{
int i, step = 16;
uint8_t b[step];
console_printf("Dump starting at %06"PRIX32":\n", addr);
#define DUMP_STEP (16)
int i, step = DUMP_STEP;
uint8_t b[DUMP_STEP];
streamer_printf(streamer, "Dump starting at %06"PRIX32":\n", addr);
for (i=0;i<length;i+=step) {
memset(b,0,sizeof(b));
dw1000_read(inst, addr, i, b, step);

console_printf("%04X: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n",
streamer_printf(streamer, "%04X: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n",
i, b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7],
b[8], b[9], b[10], b[11], b[12], b[13], b[14], b[15]);
}
Expand All @@ -196,7 +197,6 @@ dw1000_cli_dump_event_counters(struct _dw1000_dev_instance_t * inst, struct stre
streamer_printf(streamer, " TXFRS: %6d # tx frames sent\n", cnt.ev4s.count_txfrs);
streamer_printf(streamer, " HPWARN: %6d # half period warn\n", cnt.ev5s.count_hpwarn);
streamer_printf(streamer, " TPW: %6d # tx pwr-up warn\n", cnt.ev5s_1000.count_tpwarn);
streamer_printf(streamer, " RXPREJ: %6d # rx prem rejects\n", cnt.ev6s.count_rxprej);
}
#endif

Expand Down Expand Up @@ -584,7 +584,7 @@ dw1000_cli_cmd(const struct shell_cmd *cmd, int argc, char **argv, struct stream
length = strtol(argv[4], NULL, 0);
}
inst = hal_dw1000_inst(inst_n);
dw1000_dump_address(inst, addr, length);
dw1000_cli_dump_address(inst, addr, length, streamer);
} else if (!strcmp(argv[1], "cw")) {
if (argc<3) {
inst_n=0;
Expand Down
1 change: 1 addition & 0 deletions hw/drivers/uwb/uwb_dw1000/src/dw1000_cli_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

void dw1000_cli_dump_registers(struct _dw1000_dev_instance_t * inst, struct streamer *streamer);
void dw1000_cli_dump_event_counters(struct _dw1000_dev_instance_t * inst, struct streamer *streamer);
void dw1000_cli_dump_address(struct _dw1000_dev_instance_t * inst, uint32_t addr, uint16_t length, struct streamer *streamer);
void dw1000_cli_backtrace(struct _dw1000_dev_instance_t * inst, uint16_t verbose, struct streamer *streamer);
void dw1000_cli_spi_backtrace(struct _dw1000_dev_instance_t * inst, uint16_t verbose, struct streamer *streamer);
void dw1000_cli_interrupt_backtrace(struct _dw1000_dev_instance_t * inst, uint16_t verbose, struct streamer *streamer);
Expand Down
27 changes: 27 additions & 0 deletions hw/drivers/uwb/uwb_dw1000/src/dw1000_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ struct debug_cmd {

static struct dentry *dir = 0;
static struct seq_file *seq_file = 0;
static uint32_t da_addr = 0x11;
static uint32_t da_length = 128;

static int
debugfs_vprintf(struct streamer *streamer,
Expand Down Expand Up @@ -89,6 +91,10 @@ static int cmd_dump(struct seq_file *s, void *data)
if (!strcmp(cmd->fn, "ev")) {
dw1000_cli_dump_event_counters(inst, &streamer_debugfs);
}
if (!strcmp(cmd->fn, "da")) {
if (da_addr > 0x3F) da_addr = 0x3F;
dw1000_cli_dump_address(inst, da_addr, da_length, &streamer_debugfs);
}
#if MYNEWT_VAL(DW1000_SYS_STATUS_BACKTRACE_LEN)
if (!strcmp(cmd->fn, "ibt")) {
dw1000_cli_interrupt_backtrace(inst, 1, &streamer_debugfs);
Expand Down Expand Up @@ -116,11 +122,26 @@ static const struct file_operations clk_dump_fops = {
.release = single_release,
};

static int debugfs_u32_set(void *data, u64 val)
{
*(u32 *)data = val;
return 0;
}

static int debugfs_u32_get(void *data, u64 *val)
{
*val = *(u32 *)data;
return 0;
}

DEFINE_SIMPLE_ATTRIBUTE(fops_u32, debugfs_u32_get, debugfs_u32_set, "%llu\n");

static char* cmd_names[] = {
"dump",
"ev",
"ibt",
"bt",
"da",
0
};

Expand Down Expand Up @@ -160,6 +181,12 @@ void dw1000_debugfs_init(void)
return;
}
}
if (!debugfs_create_file("da_addr", 0644, dir, &da_addr, &fops_u32)) {
pr_err("failed to add da_addr\n");
}
if (!debugfs_create_file("da_length", 0644, dir, &da_length, &fops_u32)) {
pr_err("failed to add da_length\n");
}
}
}

Expand Down

0 comments on commit 851eb84

Please sign in to comment.