nuttx icon indicating copy to clipboard operation
nuttx copied to clipboard

Failed to Build with Custom Apps Directory

Open j-couch opened this issue 2 years ago • 3 comments

I am trying to build with a custom apps directory following this guide: https://nuttx.apache.org/docs/latest/guides/customapps.html#custom-apps-how-to

Using NuttX Release 12.3.0 in WSL (Linux version 5.15.133.1-microsoft-standard-WSL2), I created the example files listed in the guide and try to build

> ./tools/configure.sh -E -a ../CustomApps sim:nsh runs fine > make has a build error:

/usr/bin/ld: nuttx.rel: warning: relocation against `g_builtins' in read-only section `.text.builtin_for_index'
/usr/bin/ld: nuttx.rel: in function `builtin_for_index':
/nuttx/libs/libc/builtin/lib_builtin_forindex.c:54: undefined reference to `g_builtin_count'
/usr/bin/ld: /nuttx/libs/libc/builtin/lib_builtin_forindex.c:56: undefined reference to `g_builtins'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status

Looking in normal Apps directory g_builtin_count and g_builtins are defined in builtin/builtin_list.c, does this or something similar need to be added to custom apps directory as well? Or maybe I have a configuration issue unnecessarily requiring g_builtin_count and g_builtins?

Also just tested with latest master @ 804f713 and see the same issue

j-couch avatar Dec 23 '23 18:12 j-couch

@j-couch I was able to get it working following the second option "2. Extend the apps/ directory to include a new custom directory" of the Custom Apps guide, with the following modifications:

Make.defs should be replaced to include CONFIGURED_APPS when CONFIG_CUSTOM_APPS_CUSTOM_HELLO is enabled in the menuconfig! This way:

ifneq ($(CONFIG_CUSTOM_APPS_CUSTOM_HELLO),)
CONFIGURED_APPS += $(APPDIR)/CustomApps
endif

In CustomHello.c the function name should be "main" instead of "custom_hello" otherwise it will report that "custom_hello_main" is missing.

This is the result:

$ ./nuttx 
login: admin
password: 
User Logged-in!
nsh> ?
help usage:  help [-v] [<cmd>]

    .           cp          exit        ls          ps          time        
    [           cmp         false       mkdir       pwd         true        
    ?           dirname     fdinfo      mkfatfs     readlink    truncate    
    alias       dd          free        mkrd        rm          uname       
    unalias     df          help        mount       rmdir       umount      
    basename    dmesg       hexdump     mv          set         unset       
    break       echo        kill        pidof       sleep       uptime      
    cat         env         losetup     poweroff    source      usleep      
    cd          exec        ln          printf      test        xd          

Builtin Apps:
    custom_hello    gpio            nsh             
    dumpstack       hello           sh              
nsh> custom_hello
Hello, Custom World!!
nsh> poweroff

Note, doing this way if you move CustomApps to outside of apps/ and just create a symbolic link to it, also will work.

For your convenience just find attached the example: CustomApps.tar.gz

@TimJTi please take a look, I think we need to update the guide. Also it should be nice if the Makefile text could be copied keeping the format including TAB, etc. Currently even the lines with comment "#" are copied as lines without asterisk.

acassis avatar Dec 24 '23 20:12 acassis

@acassis thank you for the quick response! I was originally trying to recreate the "1. Replace The Apps/ Directory Completely" method but was able to duplicate your steps here, compile and run, and believe the symbolic link method should work okay for my purposes instead. Maybe the "Replace" section should be removed from the guide?

j-couch avatar Dec 27 '23 02:12 j-couch

The # issue not copying is some peculiarity of the way the pages are rendered. They copy fine when editing the files and previewing and there is no way of "escaping" that I know of. They are in code blocks. Perhaps someone who knows rst and or the way the NuttX web server renders it can advise.

Not sure why I used "custom_hello rather than "main" - I know I tested it all so either something in NuttX has changed, or I edited the names in the text prior to submission and didn't check again.

Solution 1) should probably be zapped - not having access to the existing nuttx-apps would, I think, leave NuttX severly lacking in features.

Perhaps @j-couch or @acassis could do the PR for these changes.

TimJTi avatar Dec 27 '23 11:12 TimJTi