diff options
-rw-r--r-- | README | 5 | ||||
-rw-r--r-- | vdmtool.c | 28 |
2 files changed, 30 insertions, 3 deletions
@@ -241,12 +241,15 @@ which is completely self explainatory, but let's expand on it anyway: That's a debug feature... - ^_ 1 Configure the Mac's serial on Primary USB pins. On v3+, this - also isolates the micro-USb connector. On older versions, it + also isolates the micro-USB connector. On older versions, it doesn't, so make sure you don't have anything plugged there. - ^_ 2 Configure the Mac's serial on SBU pins, which is the default. On v3+, this enables the use of the micro-USB connector. +- ^_ ^\ crashes the Central Scrutinizer when in debug mode. This + allows testing the watchdog reset functionnality. + - ^_ ? prints the help message (duh). Finally, the Port 0:/1: lines indicate which I2C/UART combinations the @@ -446,9 +446,11 @@ static void help(struct vdm_context *cxt) "^_ 2 Serial on SBU pins\n"); if (upstream_is_serial()) - cprintf_cont(cxt, "^_ ^@ Send break\n"); + cprintf_cont(cxt, "^_ ^@ Send break\n"); if (PORT(cxt) == 0 && !vdm_contexts[1].hw) - cprintf_cont(cxt, "^_ ^U Switch upstream port USB/Serial\n"); + cprintf_cont(cxt, "^_ ^U Switch upstream port USB/Serial\n"); + if (cxt->verbose) + cprintf_cont(cxt, "^_ ^\\ Crash me now\n"); cprintf_cont(cxt, "^_ ? This message\n"); for (int i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { @@ -550,6 +552,12 @@ static bool serial_handler(struct vdm_context *cxt) cxt->pending = true; evt_disconnect(cxt); break; + case 0x1c: /* ^\ */ + if (cxt->verbose) { + void (*crashme)(void) = NULL - 1; + crashme(); + } + break; case '?': help(cxt); break; @@ -716,6 +724,18 @@ static bool m1_pd_bmc_run_one(struct vdm_context *cxt) return serial_handler(cxt) || cxt->pending; } +/* A tick every second, watchdog fires after 5s */ +#define WDT_PERIOD_MS (5 * 1000) +#define TICK_PERIOD_MS (1 * 1000) +#define TICK_PERIOD_US (TICK_PERIOD_MS * 1000) + +static int64_t tick_cb(alarm_id_t id, void *arg) +{ + watchdog_update(); + + return TICK_PERIOD_US; +} + #define for_each_cxt(___c) \ for (struct vdm_context *___c = &vdm_contexts[0]; \ (___c - vdm_contexts) < CONFIG_USB_PD_PORT_COUNT; \ @@ -724,6 +744,10 @@ static bool m1_pd_bmc_run_one(struct vdm_context *cxt) void m1_pd_bmc_run(void) { + watchdog_enable(WDT_PERIOD_MS, 1); + + add_alarm_in_ms(TICK_PERIOD_MS, tick_cb, NULL, true); + while (1) { bool busy = false; |