You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by Sara da Cunha Monteiro de Souza <sa...@gmail.com> on 2021/02/10 14:35:14 UTC
What to be perfomed in up_earlyserialinit?
Hi all,
I've been working in the serial driver.
And I've got a little confused about what is to be performed in
*up_earlyserialinit. *
I've been looking at other chips and I noticed that the
*<chip>_lowsetup *function performs
almost the same of this function and the latter is called earlier than the
former in* <chip>_start*.*c*.
So, I am not sure what to do in *up_earlyserialinit.*
Besides it*, *I also noticed that the *setup* ioctl seems not to be
performed for the console.
Instead of this function, the console setup is done in the *<chip>_lowsetup
*function.
However, both have the same responsibilities, right?
Thanks in advance,
Sara
Re: What to be perfomed in up_earlyserialinit?
Posted by Gregory Nutt <sp...@gmail.com>.
The primary purpose of xyz_earlyserialinit() is to make the serial
console available for low level debug output before the serial driver is
initialized. That happens much later. That is helpful mostly for
debugging. Without early initialization of the serial console, there
will be no output until nx_start() and up_initialize() are called.
By the way, the naming up_earlyserialinit() is incorrect. That should
be called esp32_earlyserialinit() or maybe esp32_early_serialinit().
The up_ prefix is reserved and should be used ONLY for functions called
from the OS. All functions called internally without esp32 logic should
begin with esp32_ (or xtensa or lx6 as appropriate for the scope of the
function). See
https://cwiki.apache.org/confluence/display/NUTTX/Naming+of+Architecture%2C+MCU%2C+and+Board+Interfaces
for a more complete explanation.
up_initialize() is properly named because it is called from the OS.
up_earlyserialinit() is not called from the OS and is not correctly named.
On 2/10/2021 8:35 AM, Sara da Cunha Monteiro de Souza wrote:
> Hi all,
>
> I've been working in the serial driver.
> And I've got a little confused about what is to be performed in
> *up_earlyserialinit. *
> I've been looking at other chips and I noticed that the
> *<chip>_lowsetup *function performs
> almost the same of this function and the latter is called earlier than the
> former in* <chip>_start*.*c*.
>
> So, I am not sure what to do in *up_earlyserialinit.*
> Besides it*, *I also noticed that the *setup* ioctl seems not to be
> performed for the console.
> Instead of this function, the console setup is done in the *<chip>_lowsetup
> *function.
> However, both have the same responsibilities, right?
>
> Thanks in advance,
>
> Sara
>
Re: What to be perfomed in up_earlyserialinit?
Posted by Sara da Cunha Monteiro de Souza <sa...@gmail.com>.
Hum.. ok.
Running "git grep lowsetup" I just found it on UART peripheral code.
And in the case of ESP32, for example, although there is a comment
mentioning "esp32_lowsetup()"
it was not actually implemented.
Em qui., 11 de mar. de 2021 às 13:13, Gregory Nutt <sp...@gmail.com>
escreveu:
> No, xyz_earlyearlyinit() initializes the serial driver to support a
> serial console device (stdin, stdout, stderr). xyz_lowsetup() may
> initialize any hardware, not necessarily UART. It has nothing to do
> with the serial driver. It initializes whatever hardware in necessary to
> start the system. That normally includes the hardware UART that will be
> used later for the console.
>
> On 3/11/2021 8:59 AM, Sara da Cunha Monteiro de Souza wrote:
> > Hi Mr Nutt,
> >
> > I am so sorry for delaying my answer.
> > I went into vacation and missed this conversation.
> >
> > So, I came up to the conclusion that the *<chip>_lowsetup *function that
> > I've seen in many chips
> > is a standard deviation and it is actually playing the role of the
> > *xyz_earlyserialinit().*
> > Am I right?
> >
> > Thanks too much for the detailed explanation.
> >
> > Em qua., 10 de fev. de 2021 às 12:33, Gregory Nutt <sp...@gmail.com>
> > escreveu:
> >
> >> As I said, the early serial initialization is needed for boot-up debug
> >> output. Here is a little more detail:
> >>
> >> If the serial is not initialized, then up_putc will not work. In fact,
> >> any calls to up_putc() could hang. If the serial console is the syslog
> >> debug channel, then up_putc is called from syslog under certain
> conditions:
> >>
> >> * Syslog output from an interrupt handler
> >> * Syslog() is called with LOG_EMERG
> >> * Syslog() is called early in the initialization (while using the
> >> g_default_channel)
> >>
> >> up_putc is also used in most very low level startup logic in the
> >> PROGRESS macro that outputs the ABCDEF that you see when booting most
> >> NuttX systems.
> >>
> >> What happens if the serial device used by up_putc is not initialized?
> >> It will certainly fail to ouput anything but could also hang on a busy
> >> wait polling an uninitialized device.
> >>
> >>
> >>
>
>
Re: What to be perfomed in up_earlyserialinit?
Posted by Gregory Nutt <sp...@gmail.com>.
No, xyz_earlyearlyinit() initializes the serial driver to support a
serial console device (stdin, stdout, stderr). xyz_lowsetup() may
initialize any hardware, not necessarily UART. It has nothing to do
with the serial driver. It initializes whatever hardware in necessary to
start the system. That normally includes the hardware UART that will be
used later for the console.
On 3/11/2021 8:59 AM, Sara da Cunha Monteiro de Souza wrote:
> Hi Mr Nutt,
>
> I am so sorry for delaying my answer.
> I went into vacation and missed this conversation.
>
> So, I came up to the conclusion that the *<chip>_lowsetup *function that
> I've seen in many chips
> is a standard deviation and it is actually playing the role of the
> *xyz_earlyserialinit().*
> Am I right?
>
> Thanks too much for the detailed explanation.
>
> Em qua., 10 de fev. de 2021 às 12:33, Gregory Nutt <sp...@gmail.com>
> escreveu:
>
>> As I said, the early serial initialization is needed for boot-up debug
>> output. Here is a little more detail:
>>
>> If the serial is not initialized, then up_putc will not work. In fact,
>> any calls to up_putc() could hang. If the serial console is the syslog
>> debug channel, then up_putc is called from syslog under certain conditions:
>>
>> * Syslog output from an interrupt handler
>> * Syslog() is called with LOG_EMERG
>> * Syslog() is called early in the initialization (while using the
>> g_default_channel)
>>
>> up_putc is also used in most very low level startup logic in the
>> PROGRESS macro that outputs the ABCDEF that you see when booting most
>> NuttX systems.
>>
>> What happens if the serial device used by up_putc is not initialized?
>> It will certainly fail to ouput anything but could also hang on a busy
>> wait polling an uninitialized device.
>>
>>
>>
Re: What to be perfomed in up_earlyserialinit?
Posted by Sara da Cunha Monteiro de Souza <sa...@gmail.com>.
Hi Mr Nutt,
I am so sorry for delaying my answer.
I went into vacation and missed this conversation.
So, I came up to the conclusion that the *<chip>_lowsetup *function that
I've seen in many chips
is a standard deviation and it is actually playing the role of the
*xyz_earlyserialinit().*
Am I right?
Thanks too much for the detailed explanation.
Em qua., 10 de fev. de 2021 às 12:33, Gregory Nutt <sp...@gmail.com>
escreveu:
> As I said, the early serial initialization is needed for boot-up debug
> output. Here is a little more detail:
>
> If the serial is not initialized, then up_putc will not work. In fact,
> any calls to up_putc() could hang. If the serial console is the syslog
> debug channel, then up_putc is called from syslog under certain conditions:
>
> * Syslog output from an interrupt handler
> * Syslog() is called with LOG_EMERG
> * Syslog() is called early in the initialization (while using the
> g_default_channel)
>
> up_putc is also used in most very low level startup logic in the
> PROGRESS macro that outputs the ABCDEF that you see when booting most
> NuttX systems.
>
> What happens if the serial device used by up_putc is not initialized?
> It will certainly fail to ouput anything but could also hang on a busy
> wait polling an uninitialized device.
>
>
>
Re: What to be perfomed in up_earlyserialinit?
Posted by Gregory Nutt <sp...@gmail.com>.
As I said, the early serial initialization is needed for boot-up debug
output. Here is a little more detail:
If the serial is not initialized, then up_putc will not work. In fact,
any calls to up_putc() could hang. If the serial console is the syslog
debug channel, then up_putc is called from syslog under certain conditions:
* Syslog output from an interrupt handler
* Syslog() is called with LOG_EMERG
* Syslog() is called early in the initialization (while using the
g_default_channel)
up_putc is also used in most very low level startup logic in the
PROGRESS macro that outputs the ABCDEF that you see when booting most
NuttX systems.
What happens if the serial device used by up_putc is not initialized?
It will certainly fail to ouput anything but could also hang on a busy
wait polling an uninitialized device.