Mailing List Archive

sbsa_uart domU baremetal driver
Hi,

I'm trying to write a baremetal domU application on arm64 and I'm
having some troubles making it print on the vpl011 serial.

The application works fine if I use the UART driver of the board I'm
using (XUARTPS on Xilinx ZCU104), but as soon as I try to use the
virtual console, then I get no output at all. I'm using a custom pl011
driver that works on other (real) consoles. I'm not trying to have it
read chars, just print them, so the driver is quite simple.

If I try to do something 'wrong' with the virtual UART, I have Xen
complaining of unaligned access to the vpl011 driver, so Xen is able
to see that I'm trying to use the console. But as soon as I correctly
(I think) write to the data output region of the driver, my
application writes exactly 369 characters before crashing or freezing.
Note that I don't see those bytes, I just know that the `putchar`
function gets called 369 times, even when I try to print more than 369
characters.

My understanding is that the under the hood vpl011 uses the ring
buffer, which by default should be emptied at max every time it gets
half-full, so I'm not sure why I'm allowed to write only 369 bytes.

The memory region mapped for the uart is uncached, so it shouldn't be
a problem of dirty cache.

I'm afraid I'm missing something stupid, so here's my setup:

Xen version 4.13
on the .cfg file I have `vuart = "sbsa_uart"`
I start the domU with `xl create -c baremetal.cfg`

There I expect to see my output, but nothing. Also `xl dmesg` doesn't
show useful information.
Any ideas?

Thanks,
Angelo
Re: sbsa_uart domU baremetal driver [ In reply to ]
On 14/10/2020 23:28, Angelo Ruocco wrote:
> Hi,

Hello,

>
> I'm trying to write a baremetal domU application on arm64 and I'm
> having some troubles making it print on the vpl011 serial.
>
> The application works fine if I use the UART driver of the board I'm
> using (XUARTPS on Xilinx ZCU104), but as soon as I try to use the
> virtual console, then I get no output at all. I'm using a custom pl011
> driver that works on other (real) consoles. I'm not trying to have it
> read chars, just print them, so the driver is quite simple.
>
> If I try to do something 'wrong' with the virtual UART, I have Xen
> complaining of unaligned access to the vpl011 driver, so Xen is able
> to see that I'm trying to use the console. But as soon as I correctly
> (I think) write to the data output region of the driver, my
> application writes exactly 369 characters before crashing or freezing.
> Note that I don't see those bytes, I just know that the `putchar`
> function gets called 369 times, even when I try to print more than 369
> characters.
>
> My understanding is that the under the hood vpl011 uses the ring
> buffer, which by default should be emptied at max every time it gets
> half-full, so I'm not sure why I'm allowed to write only 369 bytes.
>
> The memory region mapped for the uart is uncached, so it shouldn't be
> a problem of dirty cache.
>
> I'm afraid I'm missing something stupid, so here's my setup:
>
> Xen version 4.13
> on the .cfg file I have `vuart = "sbsa_uart"`
> I start the domU with `xl create -c baremetal.cfg`

There are multiple console available to the guest (e.g. PV, SBSA). The
option -c will open the console


>
> There I expect to see my output, but nothing. Also `xl dmesg` doesn't
> show useful information.
> Any ideas?
>
> Thanks,
> Angelo
>

--
Julien Grall
Re: sbsa_uart domU baremetal driver [ In reply to ]
Hi,

Sorry, I pressed sent by mistake.

On 20/10/2020 10:48, Julien Grall wrote:
>
>
> On 14/10/2020 23:28, Angelo Ruocco wrote:
>> Hi,
>
> Hello,
>
>>
>> I'm trying to write a baremetal domU application on arm64 and I'm
>> having some troubles making it print on the vpl011 serial.
>>
>> The application works fine if I use the UART driver of the board I'm
>> using (XUARTPS on Xilinx ZCU104), but as soon as I try to use the
>> virtual console, then I get no output at all. I'm using a custom pl011
>> driver that works on other (real) consoles. I'm not trying to have it
>> read chars, just print them, so the driver is quite simple.
>>
>> If I try to do something 'wrong' with the virtual UART, I have Xen
>> complaining of unaligned access to the vpl011 driver, so Xen is able
>> to see that I'm trying to use the console. But as soon as I correctly
>> (I think) write to the data output region of the driver, my
>> application writes exactly 369 characters before crashing or freezing.
>> Note that I don't see those bytes, I just know that the `putchar`
>> function gets called 369 times, even when I try to print more than 369
>> characters.
>>
>> My understanding is that the under the hood vpl011 uses the ring
>> buffer, which by default should be emptied at max every time it gets
>> half-full, so I'm not sure why I'm allowed to write only 369 bytes.
>>
>> The memory region mapped for the uart is uncached, so it shouldn't be
>> a problem of dirty cache.
>>
>> I'm afraid I'm missing something stupid, so here's my setup:
>>
>> Xen version 4.13
>> on the .cfg file I have `vuart = "sbsa_uart"`
>> I start the domU with `xl create -c baremetal.cfg`
>
> There are multiple console available to the guest (e.g. PV, SBSA).

The option -c will open the PV console. In this case, you will want to
use "xl console -t vuart <domain>".

Best regards,

--
Julien Grall
Re: sbsa_uart domU baremetal driver [ In reply to ]
On 20/10/2020, Julien Grall <julien@xen.org> wrote:
> Hi,
>
> Sorry, I pressed sent by mistake.
>
> On 20/10/2020 10:48, Julien Grall wrote:
>>
>>
>> On 14/10/2020 23:28, Angelo Ruocco wrote:
>>> Hi,
>>
>> Hello,
>>
>>>
>>> I'm trying to write a baremetal domU application on arm64 and I'm
>>> having some troubles making it print on the vpl011 serial.
>>>
>>> The application works fine if I use the UART driver of the board I'm
>>> using (XUARTPS on Xilinx ZCU104), but as soon as I try to use the
>>> virtual console, then I get no output at all. I'm using a custom pl011
>>> driver that works on other (real) consoles. I'm not trying to have it
>>> read chars, just print them, so the driver is quite simple.
>>>
>>> If I try to do something 'wrong' with the virtual UART, I have Xen
>>> complaining of unaligned access to the vpl011 driver, so Xen is able
>>> to see that I'm trying to use the console. But as soon as I correctly
>>> (I think) write to the data output region of the driver, my
>>> application writes exactly 369 characters before crashing or freezing.
>>> Note that I don't see those bytes, I just know that the `putchar`
>>> function gets called 369 times, even when I try to print more than 369
>>> characters.
>>>
>>> My understanding is that the under the hood vpl011 uses the ring
>>> buffer, which by default should be emptied at max every time it gets
>>> half-full, so I'm not sure why I'm allowed to write only 369 bytes.
>>>
>>> The memory region mapped for the uart is uncached, so it shouldn't be
>>> a problem of dirty cache.
>>>
>>> I'm afraid I'm missing something stupid, so here's my setup:
>>>
>>> Xen version 4.13
>>> on the .cfg file I have `vuart = "sbsa_uart"`
>>> I start the domU with `xl create -c baremetal.cfg`
>>
>> There are multiple console available to the guest (e.g. PV, SBSA).
>
> The option -c will open the PV console. In this case, you will want to
> use "xl console -t vuart <domain>".

Ah. Yeah, I missed that, thank you.

Still, no luck with the output, what I get from that is:

`xenconsole: Could not read tty from store: No such file or directory`

Some other trivial mistake I could be making?
Yes, `xenconsoled` and `xenstored` are running.

Thank you,
Angelo

>
> Best regards,
>
> --
> Julien Grall
>
Re: sbsa_uart domU baremetal driver [ In reply to ]
Hi,

On 20/10/2020 20:44, Angelo Ruocco wrote:
> Still, no luck with the output, what I get from that is:
>
> `xenconsole: Could not read tty from store: No such file or directory`
>
> Some other trivial mistake I could be making?
> Yes, `xenconsoled` and `xenstored` are running.

I am wondering if this is related to [1]. Would you mind to give it a try?

Cheers,

[1]
https://lore.kernel.org/xen-devel/alpine.DEB.2.21.2010291704180.12247@sstabellini-ThinkPad-T480s/

--
Julien Grall
Re: sbsa_uart domU baremetal driver [ In reply to ]
On 30/10/2020, Julien Grall <julien@xen.org> wrote:
> Hi,
>
> On 20/10/2020 20:44, Angelo Ruocco wrote:
>> Still, no luck with the output, what I get from that is:
>>
>> `xenconsole: Could not read tty from store: No such file or directory`
>>
>> Some other trivial mistake I could be making?
>> Yes, `xenconsoled` and `xenstored` are running.
>
> I am wondering if this is related to [1]. Would you mind to give it a try?

I finally found the time to give that patch a try and it works perfectly :)

Thank you for your help,
Angelo

> Cheers,
>
> [1]
> https://lore.kernel.org/xen-devel/alpine.DEB.2.21.2010291704180.12247@sstabellini-ThinkPad-T480s/
>
> --
> Julien Grall
>


--
Angelo