I can run (execv) i2c from hello πŸ™‚

works!!!!!

Now Gustavo can you this TIP to make work the PCA/PCF GPIO extender πŸ™‚

Thanks!!!!!!!!!!!!!!!!!

nsh> hello
Executing 1 /bin/i2c
Usage: i2c <cmd> [arguments]
Where <cmd> is one of:

  Show help     : ?
  List buses    : bus
  List devices  : dev [OPTIONS] <first> <last>
  Read register : get [OPTIONS] [<repetitions>]
  Dump register : dump [OPTIONS] [<num bytes>]
  Show help     : help
nsh>   Write register: set [OPTIONS] <value> [<repetitions>]
  Verify access : verf [OPTIONS] [<value>] [<repetitions>]

Where common "sticky" OPTIONS include:
  [-a addr] is the I2C device address (hex).  Default: 03 Current: 03
  [-b bus] is the I2C bus number (decimal).  Default: 0 Current: 0
  [-w width] is the data width (8 or 16 decimal).  Default: 8 Current: 8
  [-s|n], send/don't send start between command and data.  Default: -n Current: 
-n
  [-i|j], Auto increment|don't increment regaddr on repetitions.  Default: NO 
Current: NO
  [-f freq] I2C frequency.  Default: 400000 Current: 400000

Special non-sticky options:
  [-r regaddr] is the I2C device register index (hex).  Default: not used/sent

NOTES:
o An environment variable like $PATH may be used for any argument.
o Arguments are "sticky". For example, once the I2C address is
  specified, that address will be re-used until it is changed.

WARNING:
o The I2C dev command may have bad side effects on your I2C devices.
  Use only at your own risk.


nsh> hello
Executing 1 /bin/i2c
Usage: i2c <cmd> [arguments]
Where <cmd> is one of:

  Show help     : ?
  List buses    : bus
  List devices  : dev [OPTIONS] <first> <last>
  Read register : get [OPTIONS] [<repetitions>]
  Dump register : dump [OPTIONS] [<num bytes>]
  Show help     : help
nsh>   Write register: set [OPTIONS] <value> [<repetitions>]
  Verify access : verf [OPTIONS] [<value>] [<repetitions>]

Where common "sticky" OPTIONS include:
  [-a addr] is the I2C device address (hex).  Default: 03 Current: 03
  [-b bus] is the I2C bus number (decimal).  Default: 0 Current: 0
  [-w width] is the data width (8 or 16 decimal).  Default: 8 Current: 8
  [-s|n], send/don't send start between command and data.  Default: -n Current: 
-n
  [-i|j], Auto increment|don't increment regaddr on repetitions.  Default: NO 
Current: NO
  [-f freq] I2C frequency.  Default: 400000 Current: 400000

Special non-sticky options:
  [-r regaddr] is the I2C device register index (hex).  Default: not used/sent

NOTES:
o An environment variable like $PATH may be used for any argument.
o Arguments are "sticky". For example, once the I2C address is
  specified, that address will be re-used until it is changed.

WARNING:
o The I2C dev command may have bad side effects on your I2C devices.
  Use only at your own risk.
________________________________
De: Alan C. Assis <acas...@gmail.com>
Enviado: quinta-feira, 12 de outubro de 2023 20:05
Para: dev@nuttx.apache.org <dev@nuttx.apache.org>
Assunto: Re: execv obsolet ?

Ah ok, I tested using the original code with "ls" instead "/bin/ls"
and the result as similar to NuttX: didn't print anything.

I discovered the issue: ls is not a buildin program, you need to call
a builtin program to get it working.

I modified apps/examples/null to print an incentive message !

/****************************************************************************
 * Name: null_main
 ****************************************************************************/

int main(int argc, char *argv[])
{
  printf("We did it, not because it is easy! But because we thought it
was easy!\n");
  return 0;
}

And modified hello to call this null application:

int main(int argc, char *argv[])
{
  int ret;

  if (argc < 2)
    {
      static char * const args[2] =
      {
        "null",
        NULL
      };

      ret = execv(args[0], args);
      if (ret < 0)
        {
          printf("Error: execv failed: %d\n", ret);
        }
    }
}

See the result:

NuttShell (NSH) NuttX-12.3.0-RC0
nsh> ?
help usage:  help [-v] [<cmd>]

    .           cd          exit        mount       source      uptime
    [           cp          false       mv          test        usleep
    ?           cmp         help        printf      time        xd
    alias       dirname     hexdump     pwd         true
    unalias     dd          kill        rm          truncate
    basename    dmesg       ls          rmdir       uname
    break       echo        mkdir       set         umount
    cat         exec        mkrd        sleep       unset

Builtin Apps:
    hello    nsh      null     sh
nsh> hello
We did it, not because it is easy! But because we thought it was easy!
nsh>

Just used the DEBUG to find-out the issue, the debug binary loader
said exactly what was the issue.

BR,

Alan

On 10/12/23, MIGUEL ALEXANDRE WISINTAINER <tcpipc...@hotmail.com> wrote:
>  1 hour ago, not 1 year agoπŸ™‚
> ________________________________
> De: MIGUEL ALEXANDRE WISINTAINER <tcpipc...@hotmail.com>
> Enviado: quinta-feira, 12 de outubro de 2023 19:07
> Para: dev@nuttx.apache.org <dev@nuttx.apache.org>
> Assunto: RE: execv obsolet ?
>
> yes, i already had done that 1 year ago
>
> ubuntu@DESKTOP-GRCNLV8:~$ nano hello_main.c
> ubuntu@DESKTOP-GRCNLV8:~$ gcc hello_main.c -o hello_main
> ubuntu@DESKTOP-GRCNLV8:~$ ./hello_main
> Executing 1 /bin/ls
> Espruino                      esp                  kitware-archive.sh.1
> nuttx    mbed    rust   esp-adf
> RIOT                          esp-va-sdk           kitware-archive.sh.2
> tinygo  thread-os freertos
> a.out                         esp32_binary_merger  lora-modem-abz-1.2.5
> tinygo_0.26.0_amd64.deb
> blink                         go                   lora-modem-abz-1.2.5.zip
> zephyr-sdk-0.15.0   embedded-os-beta-esp32c
> cmake-3.21.1-Linux-x86_64.sh  hello_main           loramac-node
> zephyr-sdk-0.15.0_linux-x86_64.tar.gz
> drogue-device                 hello_main.c         minicom.log
> zephyr-sdk-0.15.1_linux-x86_64.tar.gz
> embassy                       kitware-archive.sh   mynewt
>
> On linux works
>
> On nuttx not...i tried  the path to...but...the problem is where is the path
> of ls
>
> "/ls"
>
> if (argc < 2)
> {
>         static char * const args[2] =
>         {
>                 "/bin/ls",
>                 NULL
>         };
>         printf("Executing 1 %s \n", args[0]);
>         execv(args[0], args);
> }
>
> ________________________________
> De: Alan C. Assis <acas...@gmail.com>
> Enviado: quinta-feira, 12 de outubro de 2023 18:48
> Para: dev@nuttx.apache.org <dev@nuttx.apache.org>
> Assunto: Re: execv obsolet ?
>
> Hi Miguel,
>
> I suggest you to try first in the Linux.
>
> NuttX should give you the same result ;-)
>
> BR,
>
> Alan
>
> On 10/12/23, MIGUEL ALEXANDRE WISINTAINER <tcpipc...@hotmail.com> wrote:
>> Now compiles πŸ™‚
>>
>> in theory should show the files got from ls on terminal ?
>>
>> Builtin Apps:
>>     i2c      sh       hello    nsh
>> nsh> hello
>> nsh>
>>
>> =============
>>
>> #include <nuttx/config.h>
>> #include <stdio.h>
>> #include <stdlib.h>
>> #include <unistd.h>
>>
>>
>> #ifdef CONFIG_BUILD_KERNEL
>> int main(int argc, FAR char *argv[])
>> #else
>> int hello_main(int argc, char *argv[])
>> #endif
>> {
>>
>> if (argc < 2)
>> {
>>       static char * const args[2] =
>>       {
>>             "ls",
>>             NULL
>>       };
>>
>>       execv(args[0], args);
>> }
>> De: Xiang Xiao <xiaoxiang781...@gmail.com>
>> Enviado: quinta-feira, 12 de outubro de 2023 18:08
>> Para: dev@nuttx.apache.org <dev@nuttx.apache.org>
>> Assunto: Re: execv obsolet ?
>>
>> you need enable CONFIG_LIBC_EXECFUNCS:
>> https://github.com/apache/nuttx/blob/master/libs/libc/unistd/lib_execv.c#L29
>>
>> On Fri, Oct 13, 2023 at 1:59β€―AM MIGUEL ALEXANDRE WISINTAINER <
>> tcpipc...@hotmail.com> wrote:
>>
>>> #include <nuttx/config.h>
>>> #include <stdio.h>
>>> #include <stdlib.h>
>>> #include <unistd.h>
>>>
>>> #ifdef CONFIG_BUILD_KERNEL
>>> int main(int argc, FAR char *argv[])
>>> #else
>>> int hello_main(int argc, char *argv[])
>>> #endif
>>> {
>>>
>>> if (argc < 2)
>>> {
>>> static char * const args[2] =
>>> {
>>> "/bin/ls",
>>> NULL
>>> };
>>>
>>> execv(args[0], args);
>>> }
>>>
>>> else
>>> {
>>> int i;
>>>
>>> for (i = 1; i < argc; i++)
>>> {
>>> static char * const args[3] =
>>> {
>>> "/bin/ls",
>>> NULL,
>>> NULL
>>> };
>>> args[1] = argv[i];
>>> execv(args[0], args);
>>> }
>>> }
>>> return EXIT_SUCCESS;
>>> }
>>>
>>> hello_main.c:(.text.hello_main+0xe): undefined reference to `execv'
>>> xtensa-esp32-elf-ld: hello_main.c:(.text.hello_main+0x20): undefined
>>> reference to `execv'
>>> make[1]: *** [Makefile:173: nuttx] Error 1
>>> make: *** [tools/Unix.mk:537: nuttx] Error 2
>>>
>>
>

Reply via email to