If semihosting is disabled, then the user has no debugger attached, and will not see any messages. Don't create a serial device in this instance, to (hopefully) fall back on another working serial device.
Signed-off-by: Sean Anderson <sean.ander...@seco.com> --- Changes in v2: - New drivers/serial/serial_semihosting.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/serial/serial_semihosting.c b/drivers/serial/serial_semihosting.c index b43683c6f1..706c1aabe1 100644 --- a/drivers/serial/serial_semihosting.c +++ b/drivers/serial/serial_semihosting.c @@ -25,9 +25,17 @@ static const struct dm_serial_ops smh_serial_ops = { .getc = smh_serial_getc, }; +static int smh_serial_bind(struct udevice *dev) +{ + if (semihosting_enabled()) + return 0; + return -ENOENT; +} + U_BOOT_DRIVER(smh_serial) = { .name = "serial_semihosting", .id = UCLASS_SERIAL, + .bind = smh_serial_bind, .ops = &smh_serial_ops, .flags = DM_FLAG_PRE_RELOC, }; @@ -83,7 +91,8 @@ struct serial_device serial_smh_device = { void smh_serial_initialize(void) { - serial_register(&serial_smh_device); + if (semihosting_enabled()) + serial_register(&serial_smh_device); } __weak struct serial_device *default_serial_console(void) -- 2.25.1