<div dir="ltr">Thanks, I'll check it out. <br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 17, 2023 at 10:54 PM Cédric Le Goater <<a href="mailto:clg@kaod.org">clg@kaod.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 3/17/23 17:06, Alex Bennée wrote:<br>
> <br>
> Abhishek Singh Dagur <<a href="mailto:abhishek@drut.io" target="_blank">abhishek@drut.io</a>> writes:<br>
> <br>
> (cc aspeed maintainers)<br>
> <br>
>> Hi all,<br>
>><br>
>> We are using obmc-phosphor-image on an ast2500 board which is trying to communicate with other devices<br>
>> over serial port /dev/ttyS2.<br>
>> As we are trying to emulate the machine on qemu we need to redirect the request to the host machine so<br>
>> that it can handle this request and return appropriately.<br>
>> We tried using QEMU options like -serial ,-chardev but still not the<br>
>> concrete way we get to do it.<br>
> <br>
> Yeah I'm afraid its non-obvious, certainly for built in serial ports.<br>
> Try something like:<br>
> <br>
> ./qemu-system-aarch64 -M ast2500-evb \<br>
> -serial null -serial null -serial chardev:myserial \<br>
> -chardev file,id=myserial,path=output.txt \<br>
> $MORE_OPTIONS<br>
> <br>
> You have to add a -serial for each serial port up to the one you care<br>
> about and then set the chardev for it.<br>
> <br>
> If you where adding a device to the system then you can explicitly set<br>
> the target chardev for it with something like:<br>
> <br>
> -device isa-serial,iobase=nnn,irq=nnn,chardev=ID<br>
> <br>
>> It will be very helpful if you can provide us some guidance on this.<br>
> <br>
> Another quirk for the aspeed boards seems to be the default uart can be<br>
> an arbitrary one depending on the board model:<br>
> <br>
> 334: aspeed_soc_uart_set_chr(s, amc->uart_default, serial_hd(0));<br>
> 336: if (uart == amc->uart_default) {<br>
> 1112: amc->uart_default = ASPEED_DEV_UART5;<br>
> 1407: amc->uart_default = ASPEED_DEV_UART1;<br>
> <br>
> as a result ASPEED_DEV_UART5 will always be the first serial port<br>
> (serial_hd(0)). I don't know how Linux numbers them but worth being<br>
> aware of.<br>
<br>
Yes. UART5 is the general default but it depends on the board definition<br>
and the fuji was the first to require an exception. See commit 5d63d0c76c<br>
("hw/arm/aspeed: Allow machine to set UART default")<br>
<br>
Then, it became more complex with commit d2b3eaefb4 ("aspeed: Refactor<br>
UART init for multi-SoC machines"). That's another topic.<br>
<br>
Abhishek,<br>
<br>
I am afraid, you will need to add a new board to fit what's in the DT.<br>
<br>
Or, here is a little patch adding a machine option to set the default uart.<br>
It was never merged because it is a bit of hack, give it a try and we<br>
will discuss. Use :<br>
<br>
-M ast2500-evb,uart-default=uart2<br>
<br>
<br>
Thanks,<br>
<br>
C.<br>
<br>
From 0d0700ae772fa5236914e96af1be5afcf0d4a994 Mon Sep 17 00:00:00 2001<br>
From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= <<a href="mailto:clg@kaod.org" target="_blank">clg@kaod.org</a>><br>
Date: Fri, 17 Mar 2023 18:21:54 +0100<br>
Subject: [PATCH] aspeed: Add a "uart-default" machine option<br>
MIME-Version: 1.0<br>
Content-Type: text/plain; charset=UTF-8<br>
Content-Transfer-Encoding: 8bit<br>
<br>
Signed-off-by: Cédric Le Goater <<a href="mailto:clg@kaod.org" target="_blank">clg@kaod.org</a>><br>
---<br>
hw/arm/aspeed.c | 31 +++++++++++++++++++++++++++++--<br>
1 file changed, 29 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c<br>
index 806bb10707..e0335cf167 100644<br>
--- a/hw/arm/aspeed.c<br>
+++ b/hw/arm/aspeed.c<br>
@@ -45,6 +45,7 @@ struct AspeedMachineState {<br>
bool mmio_exec;<br>
char *fmc_model;<br>
char *spi_model;<br>
+ uint32_t uart_default;<br>
uint32_t hw_strap1;<br>
};<br>
<br>
@@ -337,10 +338,11 @@ static void connect_serial_hds_to_uarts(AspeedMachineState *bmc)<br>
AspeedMachineClass *amc = ASPEED_MACHINE_GET_CLASS(bmc);<br>
AspeedSoCState *s = &bmc->soc;<br>
AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);<br>
+ int uart_default = bmc->uart_default ? bmc->uart_default : amc->uart_default;<br>
<br>
- aspeed_soc_uart_set_chr(s, amc->uart_default, serial_hd(0));<br>
+ aspeed_soc_uart_set_chr(s, uart_default, serial_hd(0));<br>
for (int i = 1, uart = ASPEED_DEV_UART1; i < sc->uarts_num; i++, uart++) {<br>
- if (uart == amc->uart_default) {<br>
+ if (uart == uart_default) {<br>
continue;<br>
}<br>
aspeed_soc_uart_set_chr(s, uart, serial_hd(i));<br>
@@ -1145,6 +1147,25 @@ static void aspeed_set_spi_model(Object *obj, const char *value, Error **errp)<br>
bmc->spi_model = g_strdup(value);<br>
}<br>
<br>
+const QEnumLookup UartDefault_lookup = {<br>
+ .array =<br>
+ (const char *const[]) {<br>
+ [0] = "none",<br>
+ [1] = "uart1",<br>
+ [2] = "uart2",<br>
+ [3] = "uart3",<br>
+ [4] = "uart4",<br>
+ [5] = "uart5",<br>
+ },<br>
+ .size = 6<br>
+};<br>
+<br>
+static void aspeed_set_uart_default(Object *obj, int val, Error **err)<br>
+{<br>
+ AspeedMachineState *bmc = ASPEED_MACHINE(obj);<br>
+ bmc->uart_default = val + 1;<br>
+}<br>
+<br>
static void aspeed_machine_class_props_init(ObjectClass *oc)<br>
{<br>
object_class_property_add_bool(oc, "execute-in-place",<br>
@@ -1153,6 +1174,12 @@ static void aspeed_machine_class_props_init(ObjectClass *oc)<br>
object_class_property_set_description(oc, "execute-in-place",<br>
"boot directly from CE0 flash device");<br>
<br>
+ object_class_property_add_enum(oc, "uart-default", "UartDefault",<br>
+ &UartDefault_lookup, NULL,<br>
+ aspeed_set_uart_default);<br>
+ object_class_property_set_description(oc, "uart-default",<br>
+ "Change the default UART of the board");<br>
+<br>
object_class_property_add_str(oc, "fmc-model", aspeed_get_fmc_model,<br>
aspeed_set_fmc_model);<br>
object_class_property_set_description(oc, "fmc-model",<br>
-- <br>
2.39.2<br>
<br>
<br>
</blockquote></div>