Tanushree,
Couple notes to get you going here.  First off you really want to
avoid editing the .config file directly and instead use menuconfig so
that the dependencies are handled correctly.  You can use "/" to
search for config settings.
I tweaked the nsh config like this and was able to make it work.  The
error you were seeing is unrelated to elf, it has to do with the NSH
script support, which is also using romfs.  The two images are
overwriting each other during the build.
I did notice what looks like a bug to me, the elf relocation seems to
have an issue with the 64bit build, so this config you will notice I
set CONFIG_SIM_M32.  I will open a bug on that.

❯ diff boards/sim/sim/sim/configs/elf/defconfig
boards/sim/sim/sim/configs/nsh/defconfig
16d15
< CONFIG_BOARDCTL_ROMDISK=y
23,26d21
< CONFIG_ELF=y
< CONFIG_EXAMPLES_ELF=y
< CONFIG_EXAMPLES_ELF_DEVMINOR=6
< CONFIG_EXAMPLES_ELF_DEVPATH="/dev/ram6"
28,29d22
< CONFIG_EXECFUNCS_HAVE_SYMTAB=y
< CONFIG_EXECFUNCS_SYSTEM_SYMTAB=y
33a27
> CONFIG_FS_BINFS=y
37a32
> CONFIG_LIBC_EXECFUNCS=y
41a37
> CONFIG_NSH_ARCHROMFS=y
42a39,40
> CONFIG_NSH_CONSOLE_LOGIN=y
> CONFIG_NSH_FATDEVNO=2
46a45,46
> CONFIG_NSH_ROMFSDEVNO=1
> CONFIG_NSH_ROMFSETC=y
54d53
< CONFIG_SIM_M32=y

---------------------------------------------------------------------------------------
NuttShell (NSH) NuttX-10.0.1
MOTD: username=admin password=Administrator
nsh> ?
help usage:  help [-v] [<cmd>]

  .         cd        echo      hexdump   mkfatfs   poweroff  sleep
 umount
  [         cp        exec      kill      mkrd      ps        source
 unset
  ?         cmp       exit      losetup   mh        pwd       test
 usleep
  basename  dirname   false     ls        mount     rm        time
 xd
  break     dd        free      mb        mv        rmdir     true
  cat       df        help      mkdir     mw        set       uname

Builtin Apps:
  elf    hello  nsh    sh
nsh> elf
Initial memory usage: 1124560
Registering romdisk at /dev/ram6

Memory Usage after romdisk_register:
  Before:  1124560 After:  1124640 Change:       80
Mounting ROMFS filesystem at target=/mnt/romfs with source=/dev/ram6

Memory Usage after mount:
  Before:  1124640 After:  1124784 Change:      144

****************************************************************************
* Executing errno
****************************************************************************


Memory Usage after exec:
  Before:  1124784 After:  1192000 Change:    67216
Wait a bit for test completion
Hello, World on stdout
Hello, World on stderr
We failed to open "aflav-sautga-ay!" errno is 2

Memory Usage after program execution:
  Before:  1192000 After:  1190560 Change:    -1440



<-------snip------->
nsh> /mnt/romfs/hello
Getting ready to say "Hello, world"

Hello, world!
It has been said.

argc    = 1
argv    = 0x0xf3e3bb30
argv[0]    = (0x0xf3e3bb38) "/mnt/romfs/hello"
argv[1]    = 0x0
Goodbye, world!

On Sun, Apr 11, 2021 at 9:24 PM Tanushree Baindur
<tanushree.bain...@gmail.com> wrote:
>
> Hi,
>
> I am trying to run the hello world example in
> /apps/examples/elf/tests/hello in the simulator. I cleared the existing
> configuration using make distclean and then regenerated the .config file
> for sim:nsh configuration. I have added the following lines to the end of
> the .config file:
>
>   CONFIG_LIBC_ARCH_ELF=y
>   CONFIG_ELF=y
>   CONFIG_EXAMPLES_ELF=y
>   CONFIG_EXAMPLES_ELF_ROMFS=y
>   CONFIG_EXAMPLES_ELF_DEVPATH="/dev/ram6"
>   CONFIG_EXAMPLES_ELF_DEVMINOR=6
>   CONFIG_ELF_SYMBOL_CACHECOUNT=256
>   CONFIG_ELF_RELOCATION_BUFFERCOUNT=256
>   CONFIG_LIBC_ARCH_ELF_64BIT=y
>
> When I run the simulator after a make I get the following error:
> nsh: init: fopen failed: 2
>
> Could you please let me know if I am missing more configuration settings?
>
> Thanks,
> Tanushree

Reply via email to