I encountered an issue when writing firmware via UART on a test system (as the AHB bridge is locked). The argument parsing in the debug_uart driver behaves unexpectedly when using culvert write firmware /dev/ttyUSB0 < image-bmc.
Specifically, it takes firmware as the first argument in ahb *debug_driver_probe and /dev/ttyUSB0 as the second one, causing the driver to fail since argc is 2 instead of the expected 1 or 5.
|
static struct ahb *debug_driver_probe(int argc, char *argv[]) |
|
{ |
|
struct debug *ctx; |
|
int rc; |
|
|
|
ctx = malloc(sizeof(*ctx)); |
|
if (!ctx) { |
|
return NULL; |
|
} |
|
|
|
if (argc == 1) { |
|
/* Local debug interface */ |
|
if ((rc = debug_init(ctx, argv[0])) < 0) { |
|
loge("Failed to initialise local debug interace on %s: %d\n", |
|
argv[0], rc); |
|
goto cleanup_ctx; |
|
} |
|
} else if (argc == 5) { |
I hacked something in so that it is usable again, although I hate it 😄 .
Temporary hack to use it
diff --git a/src/bridge/debug.c b/src/bridge/debug.c
index 68eb41f..2510779 100644
--- a/src/bridge/debug.c
+++ b/src/bridge/debug.c
@@ -525,6 +525,13 @@ static struct ahb *debug_driver_probe(int argc, char *argv[])
return NULL;
}
+ if (argc == 2 && strcmp( argv[0], "firmware" ) == 0) {
+ logi("Hacking argc/argv to remove firmware as first argument\n");
+ argc--;
+ argv++;
+ }
+
+
if (argc == 1) {
/* Local debug interface */
if ((rc = debug_init(ctx, argv[0])) < 0) {
I encountered an issue when writing firmware via UART on a test system (as the AHB bridge is locked). The argument parsing in the
debug_uartdriver behaves unexpectedly when usingculvert write firmware /dev/ttyUSB0 < image-bmc.Specifically, it takes
firmwareas the first argument inahb *debug_driver_probeand/dev/ttyUSB0as the second one, causing the driver to fail sinceargcis 2 instead of the expected 1 or 5.culvert/src/bridge/debug.c
Lines 518 to 535 in 8335227
I hacked something in so that it is usable again, although I hate it 😄 .
Temporary hack to use it