Re: Debugging userspace with Nuttx protected build

2023-04-24 Thread Gregory Nutt



On 4/24/2023 7:27 PM, Andrew Dennison wrote:

Are there any examples of a gdb setup to debug a userspace process? One key
issue is to setup the section offsets to match the final application
location once it has been loaded.


You don't describe your build, so I only give you a general answer.

This does not specifically address what you need to do, but might be 
helpful: 
https://cwiki.apache.org/confluence/display/NUTTX/Debugging+ELF+Loadable+Modules


I think the basics would be the same for all builds.

- You need to be able to stop the ELF module (FLAT or KERNEL build) or 
in FLASH program (PROTECTED build).


- Then you can just add the symbol table of the ELF module )or user 
space) to the debugger.



I was actually quite surprised that Nuttx applications are still partially
linked with a protected build and that all sections overlap (start at 0) in
the elf file. I had expected the application would be fully linked to
virtual addresses as per linux and another RTOS I used previously. Is this
something that can be changed relatively easily, or are there some
significant challenges?


That would effect the build logic and the binary loader.  The effort 
would probably be significant.


Are you doing a kernel build?  In that case, all applications are 
partially linked ELF modules as you describe.  Linux positions .bss, 
.data, immediately after .text in the virtual address space.  Heap and 
thread stacks and other things are after that. So Linux applications can 
be fully linked.


NuttX allocates everything from the heap when the module is loaded.  So 
the application must be fully relocatable and address fix-ups are 
needed.  So the ELF module is a partially linked relocatable ELF file.





Re: NuttX PTP Support

2023-04-24 Thread James Dougherty
i’ll take a look at it as soon as I get some free time ; I have a working,
GPS master clock.

On Mon, Apr 24, 2023 at 6:45 AM Alan C. Assis  wrote:

> Could be relevant to this thread:
> https://github.com/apache/nuttx/pull/9084
>
> On 1/30/23, Alan C. Assis  wrote:
> > Hi James,
> >
> > Yes, Espressif is doing a good work adding support to it.
> >
> > I hope in the future others silicon vendors start to contribute as
> > well (hello ST, Microchip, Renesas, ...)
> >
> > Very nice James, I think PTP will be very useful.
> >
> > Please let me know if you want some help with tests, etc.
> >
> > BR,
> >
> > Alan
> >
> > On 1/30/23, James Dougherty  wrote:
> >> wow, it is really well supported!
> >> OK I will start looking at a PTP server implementation and work on
> client
> >> later…
> >>
> >>> On Jan 27, 2023, at 11:36 AM, James Dougherty 
> wrote:
> >>>
> >>> Thanks, I will try it this weekend on one of my boards….
> >>>
>  On Jan 27, 2023, at 11:12 AM, Alan C. Assis 
> wrote:
> 
>  Yes, it is supported: serial and network (ethernet and WiFi).
> 
> >> On 1/27/23, James Dougherty  wrote:
> > Outstanding!
> >
> > Serial and Network…
> >
> > Thank you
> >
> >>> On Jan 27, 2023, at 10:01 AM, Alan C. Assis 
> >>> wrote:
> >>
> >> Hi James,
> >>
> >> ESP32 is supported, which features do you need?
> >>
> >> BR,
> >>
> >> Alan
> >>
> >>> On 1/27/23, James Dougherty  wrote:
> >>> I haven’t looked at it yet, but I am working on ESP32; is WROOM
> >>> supported
> >>> in master or just the S3/C3?
> >>>
> >>>
> >>> On Fri, Jan 27, 2023 at 4:23 AM Robert Alexa
> >>> 
> >>> wrote:
> >>>
>  Hi all,
> 
>  What's the current status of this? I'm also interested in adding
>  PTP
>  support to NuttX, especially on ESP32 if that's possible - I
>  haven't
>  done
>  any research yet regarding the hardware capabilities of ESP32 in
>  this
>  matter.
> 
>  As a first step I was thinking of adding support for the PTP
>  daemon,
>  as
>  Alan suggested.
> 
>  Regards
>  Robert
> 
> > On Fri, 9 Dec 2022 at 07:39, James Dougherty 
> > wrote:
> 
> > Thanks Arie,
> >
> > Yes, very true, it depends on your application!
> >
> > My statement about what makes a good clock is very subjective.
> > This
> > all depends on your application, your measurement and of course
> > your
> > jitter.
> >
> > - For Wireless AV, a 10ms gps clock is fine.
> > - For Wireless Earbuds, a 10us clock is required with 1us phase
> > max
>  drift.
> > - For Photon measurements, you're in the nano/pico domain...
> >
> > Accuracy costs money, how well do you need to measure?
> >
> > So the message is to know your application! Your application will
> > have
> > varying time requirements. The infrastructure and machinery for
> > relaying and exchanging time is all PTP provides as a tool.
> >
> > The 802.1AS spec specifies how to manage that clock across
> > multiple
> > time domains.
> >
> > Related, know your latencies!
> >
> > https://gist.github.com/jboner/2841832
> >
> > Best regards
> > -James
> >
> >
> >
> > On Thu, Dec 8, 2022 at 3:37 AM Arie de Muijnck 
> > wrote:
> >
> >> Beware of that 1PPS signal. A few years ago I bought several GPS
>  modules
> >> and compared the signals. Some differ by exactly 100ns (within
> >> 2ns,
> >> the
> >> accuracy of my scope) from others, and that is not the width of
> >> the
> > pulse,
> >> that is much wider, I compared only the edge that are comes
> close
> >> to
>  the
> >> others. Maybe I will test again, have a 1 GHz LeCroy now, should
> >> be
>  able
> > to
> >> do jitter measurements too.
> >> Oh, and yes, before someone asks: all antenna and scope cables
> >> were
> >> the
> >> same length...  ;-)
> >>
> >> Arie
> >>
> >>
> >> On 2022-12-08 06:33, James Dougherty wrote:
> >>> Related to this, I have a GPS receiver generating PPS
> interrupts
> >>> on
> >> SAME70. It would be a perfect GMC - Atomic clock sync!
> >>> I will look at this when I get a chance. I have a lot of
> >>> upstream
> >> contributions from HW platforms I have done over the last 5
> years
> >> or
> >> so
> >> with myself and others ... I need some time to
> >>> patch m

Debugging userspace with Nuttx protected build

2023-04-24 Thread Andrew Dennison
Are there any examples of a gdb setup to debug a userspace process? One key
issue is to setup the section offsets to match the final application
location once it has been loaded.

I was actually quite surprised that Nuttx applications are still partially
linked with a protected build and that all sections overlap (start at 0) in
the elf file. I had expected the application would be fully linked to
virtual addresses as per linux and another RTOS I used previously. Is this
something that can be changed relatively easily, or are there some
significant challenges?

Kind regards,

Andrew


Re: Telnet broken?

2023-04-24 Thread Nathan Hartman
On Mon, Apr 24, 2023 at 4:54 PM Gregory Nutt  wrote:

>
> > Including the doubling of characters and momentary display of some
> > characters which seem to change rapidly?
>
> That probably comes from NSH.  I think it still sends an escape sequence
> to clear to the end of the line.  So any additional garbage at the end
> after the first four characters would only be present momentarily.
>
> But things are changing rapidly, obviously more rapidly than can be
> tested.  So I would have to studly the nshlib code again to see what it
> is doing today.
>
> So do you think that that last release was too shaky?  Should there be a
> bugfix release for that one?



Unfortunately I wasn't available to test and vote on the most recent
release and I also don't currently know in exactly which commit or PR this
broke, but it is definitely broken now, so if it has been released, then
yes, I think it makes sense to do another release once it's fixed.

I don't know how many people are using the telnet/nsh combination but I
have to do it with this particular board since the only communication port
it has is a network port. When telnet doesn't work correctly it really
messes everything up for me because I can't really interface to it.

Cheers
Nathan


Re: Telnet broken?

2023-04-24 Thread Gregory Nutt




Including the doubling of characters and momentary display of some
characters which seem to change rapidly?


That probably comes from NSH.  I think it still sends an escape sequence 
to clear to the end of the line.  So any additional garbage at the end 
after the first four characters would only be present momentarily.


But things are changing rapidly, obviously more rapidly than can be 
tested.  So I would have to studly the nshlib code again to see what it 
is doing today.


So do you think that that last release was too shaky?  Should there be a 
bugfix release for that one?




Re: Telnet broken?

2023-04-24 Thread Nathan Hartman
On Mon, Apr 24, 2023 at 2:06 PM Gregory Nutt  wrote:
>
>
> > $ ./nuttx
> > login: admin
> > password:
> > User Logged-in!
> > nsh> duk
> > ((o) Duktape 2.5.0 (v2.5.0)
> > duk> hheellpp
> Note that only the characters sent from the remote peer and echoed by
> the driver are corrupted.
> > ReferenceError: identifier 'help' undefined
> >  at [anon] (duktape/src-noline/duktape.c:83732) internal
> >  at global (input:1) preventsyield
> > duk>
> Note that the actual received text is correct, only the echo back is wrong.
> > It was caused by recent carry return modifications.
>
> This seems to be the case.

Including the doubling of characters and momentary display of some
characters which seem to change rapidly?

I noticed that in the past we had a CONFIG_TELNET_CHARACTER_MODE (or
similar name). That doesn't seem to exist anymore. Are we expected to
always be in Character Mode? Line Mode? Which?

Thanks,
Nathan


Re: Telnet broken?

2023-04-24 Thread Gregory Nutt




$ ./nuttx
login: admin
password:
User Logged-in!
nsh> duk
((o) Duktape 2.5.0 (v2.5.0)
duk> hheellpp
Note that only the characters sent from the remote peer and echoed by 
the driver are corrupted.

ReferenceError: identifier 'help' undefined
 at [anon] (duktape/src-noline/duktape.c:83732) internal
 at global (input:1) preventsyield
duk>

Note that the actual received text is correct, only the echo back is wrong.

It was caused by recent carry return modifications.


This seems to be the case.




Re: Telnet broken?

2023-04-24 Thread Alan C. Assis
Hi Nathan,

Yes, same happens to duktape prompt:

$ ./nuttx
login: admin
password:
User Logged-in!
nsh> duk
((o) Duktape 2.5.0 (v2.5.0)
duk> hheellpp

ReferenceError: identifier 'help' undefined
at [anon] (duktape/src-noline/duktape.c:83732) internal
at global (input:1) preventsyield
duk>

It was caused by recent carry return modifications.

BR,

Alan

On 4/24/23, Nathan Hartman  wrote:
> I am having some trouble understanding how NSH_TELNET is supposed to
> work in NuttX now. It used to work for me on real hardware.
>
> I saw that some people had problems because of not synchronized nuttx
> and apps repos, because some PRs were merged at different times. My
> nuttx and apps are both based on latest master.
>
> Recently (last couple of weeks?) there were some PRs in both repos
> related to telnet, CR/LF, CLE, or I don't know what, and the behavior
> changed:
>
> Now, when I type, I see double characters, and they get mixed up, and
> also seem to change with some delay. For example, if I type 'help':
>
> [[[
>
> $ telnet 192.168.10.100
> Trying 192.168.10.100...
> Connected to 192.168.10.100.
> Escape character is '^]'.
>
> NuttShell (NSH)
> nsh> hehehelp
>
> ]]]
>
> Typing 'help' and pressing Return does not work: Momentarily I see ^M
> when I press Return but it is replaced by duplicated characters of
> 'help' and the help does not print.
>
> Typing 'help' followed by Ctrl+J instead of Return does work and the
> help does print, but there is garbage displayed momentarily.
>
> If I change telnet mode to 'line' instead of 'character', it works
> better, but then I see each line of input echoed a second time. For
> example, notice how I type 'help' + Return and I see "helphelp usage"
> on the next line:
>
> [[[
>
> $ telnet 192.168.10.100
> Trying 192.168.10.100...
> Connected to 192.168.10.100.
> Escape character is '^]'.
>
> NuttShell (NSH)
> nsh> ^]
> telnet> mode line
>
> nsh> help
> helphelp usage:  help [-v] []
>
> . basename  ddexit  ifup  nslookup  set
>uname
> [ break delroute  false kill  printfsleep
>umount
> ? cat   dffree  lspssource
>unset
> addroute  cddmesg help  mkdir pwd   test
>uptime
> alias cpecho  hexdump   mkrd  rmtime
>usleep
> unalias   cmp   env   ifconfig  mount rmdir true
>xd
> arp   dirname   exec  ifdownmvroute truncate
>
> Builtin Apps:
> telnetdmorsecode  sh ping   tmutil
> ostest renew  netcat nsh
> nsh>
>
> ]]]
>
> If telnet is working for you, what telnet program are you using and
> what telnet settings do you have?
>
> Thanks,
> Nathan
>


Re: Telnet broken?

2023-04-24 Thread Nathan Hartman
I am having some trouble understanding how NSH_TELNET is supposed to
work in NuttX now. It used to work for me on real hardware.

I saw that some people had problems because of not synchronized nuttx
and apps repos, because some PRs were merged at different times. My
nuttx and apps are both based on latest master.

Recently (last couple of weeks?) there were some PRs in both repos
related to telnet, CR/LF, CLE, or I don't know what, and the behavior
changed:

Now, when I type, I see double characters, and they get mixed up, and
also seem to change with some delay. For example, if I type 'help':

[[[

$ telnet 192.168.10.100
Trying 192.168.10.100...
Connected to 192.168.10.100.
Escape character is '^]'.

NuttShell (NSH)
nsh> hehehelp

]]]

Typing 'help' and pressing Return does not work: Momentarily I see ^M
when I press Return but it is replaced by duplicated characters of
'help' and the help does not print.

Typing 'help' followed by Ctrl+J instead of Return does work and the
help does print, but there is garbage displayed momentarily.

If I change telnet mode to 'line' instead of 'character', it works
better, but then I see each line of input echoed a second time. For
example, notice how I type 'help' + Return and I see "helphelp usage"
on the next line:

[[[

$ telnet 192.168.10.100
Trying 192.168.10.100...
Connected to 192.168.10.100.
Escape character is '^]'.

NuttShell (NSH)
nsh> ^]
telnet> mode line

nsh> help
helphelp usage:  help [-v] []

. basename  ddexit  ifup  nslookup  set
   uname
[ break delroute  false kill  printfsleep
   umount
? cat   dffree  lspssource
   unset
addroute  cddmesg help  mkdir pwd   test
   uptime
alias cpecho  hexdump   mkrd  rmtime
   usleep
unalias   cmp   env   ifconfig  mount rmdir true
   xd
arp   dirname   exec  ifdownmvroute truncate

Builtin Apps:
telnetdmorsecode  sh ping   tmutil
ostest renew  netcat nsh
nsh>

]]]

If telnet is working for you, what telnet program are you using and
what telnet settings do you have?

Thanks,
Nathan


Re: Add g_ prefix to fs file_operations and mountpt_operations

2023-04-24 Thread Gregory Nutt

On 4/24/2023 6:57 AM, Xiang Xiao wrote:

 From https://nuttx.apache.org/docs/latest/contributing/coding_style.html:


-

Global variable prefix. All global variables begin with the prefix g_ to
indicate the scope of variable.

Most global variables follow this guide except a few subsystem, which is
fixed here:
https://github.com/apache/nuttx/pull/9063
https://github.com/apache/nuttx/pull/9033
David suggests asking for consensus before merging, please give your
opinion, thanks.


These were merged two days ago.



Re: NuttX PTP Support

2023-04-24 Thread Alan C. Assis
Could be relevant to this thread: https://github.com/apache/nuttx/pull/9084

On 1/30/23, Alan C. Assis  wrote:
> Hi James,
>
> Yes, Espressif is doing a good work adding support to it.
>
> I hope in the future others silicon vendors start to contribute as
> well (hello ST, Microchip, Renesas, ...)
>
> Very nice James, I think PTP will be very useful.
>
> Please let me know if you want some help with tests, etc.
>
> BR,
>
> Alan
>
> On 1/30/23, James Dougherty  wrote:
>> wow, it is really well supported!
>> OK I will start looking at a PTP server implementation and work on client
>> later…
>>
>>> On Jan 27, 2023, at 11:36 AM, James Dougherty  wrote:
>>>
>>> Thanks, I will try it this weekend on one of my boards….
>>>
 On Jan 27, 2023, at 11:12 AM, Alan C. Assis  wrote:

 Yes, it is supported: serial and network (ethernet and WiFi).

>> On 1/27/23, James Dougherty  wrote:
> Outstanding!
>
> Serial and Network…
>
> Thank you
>
>>> On Jan 27, 2023, at 10:01 AM, Alan C. Assis 
>>> wrote:
>>
>> Hi James,
>>
>> ESP32 is supported, which features do you need?
>>
>> BR,
>>
>> Alan
>>
>>> On 1/27/23, James Dougherty  wrote:
>>> I haven’t looked at it yet, but I am working on ESP32; is WROOM
>>> supported
>>> in master or just the S3/C3?
>>>
>>>
>>> On Fri, Jan 27, 2023 at 4:23 AM Robert Alexa
>>> 
>>> wrote:
>>>
 Hi all,

 What's the current status of this? I'm also interested in adding
 PTP
 support to NuttX, especially on ESP32 if that's possible - I
 haven't
 done
 any research yet regarding the hardware capabilities of ESP32 in
 this
 matter.

 As a first step I was thinking of adding support for the PTP
 daemon,
 as
 Alan suggested.

 Regards
 Robert

> On Fri, 9 Dec 2022 at 07:39, James Dougherty 
> wrote:

> Thanks Arie,
>
> Yes, very true, it depends on your application!
>
> My statement about what makes a good clock is very subjective.
> This
> all depends on your application, your measurement and of course
> your
> jitter.
>
> - For Wireless AV, a 10ms gps clock is fine.
> - For Wireless Earbuds, a 10us clock is required with 1us phase
> max
 drift.
> - For Photon measurements, you're in the nano/pico domain...
>
> Accuracy costs money, how well do you need to measure?
>
> So the message is to know your application! Your application will
> have
> varying time requirements. The infrastructure and machinery for
> relaying and exchanging time is all PTP provides as a tool.
>
> The 802.1AS spec specifies how to manage that clock across
> multiple
> time domains.
>
> Related, know your latencies!
>
> https://gist.github.com/jboner/2841832
>
> Best regards
> -James
>
>
>
> On Thu, Dec 8, 2022 at 3:37 AM Arie de Muijnck 
> wrote:
>
>> Beware of that 1PPS signal. A few years ago I bought several GPS
 modules
>> and compared the signals. Some differ by exactly 100ns (within
>> 2ns,
>> the
>> accuracy of my scope) from others, and that is not the width of
>> the
> pulse,
>> that is much wider, I compared only the edge that are comes close
>> to
 the
>> others. Maybe I will test again, have a 1 GHz LeCroy now, should
>> be
 able
> to
>> do jitter measurements too.
>> Oh, and yes, before someone asks: all antenna and scope cables
>> were
>> the
>> same length...  ;-)
>>
>> Arie
>>
>>
>> On 2022-12-08 06:33, James Dougherty wrote:
>>> Related to this, I have a GPS receiver generating PPS interrupts
>>> on
>> SAME70. It would be a perfect GMC - Atomic clock sync!
>>> I will look at this when I get a chance. I have a lot of
>>> upstream
>> contributions from HW platforms I have done over the last 5 years
>> or
>> so
>> with myself and others ... I need some time to
>>> patch master on upstream -- something for 2023 and now that
>>> NuttX
>>> has
>> graduated! Yay!
>>>
>>
>

>>>
>
>>
>


Re: Add g_ prefix to fs file_operations and mountpt_operations

2023-04-24 Thread Alan C. Assis
On 4/24/23, Xiang Xiao  wrote:
> From https://nuttx.apache.org/docs/latest/contributing/coding_style.html:
>
>
>-
>
>Global variable prefix. All global variables begin with the prefix g_ to
>indicate the scope of variable.
>
> Most global variables follow this guide except a few subsystem, which is
> fixed here:
> https://github.com/apache/nuttx/pull/9063
> https://github.com/apache/nuttx/pull/9033
> David suggests asking for consensus before merging, please give your
> opinion, thanks.
>

I understand that all global variables should include g_ even when
they are defined as static. Not only because it is a rule of the NX
Style, but also because it makes clear that we are handling a global
variable.

BR,

Alan


Add g_ prefix to fs file_operations and mountpt_operations

2023-04-24 Thread Xiang Xiao
>From https://nuttx.apache.org/docs/latest/contributing/coding_style.html:


   -

   Global variable prefix. All global variables begin with the prefix g_ to
   indicate the scope of variable.

Most global variables follow this guide except a few subsystem, which is
fixed here:
https://github.com/apache/nuttx/pull/9063
https://github.com/apache/nuttx/pull/9033
David suggests asking for consensus before merging, please give your
opinion, thanks.