Hi Alan,

I think we should have "int main(int argc, const char * argv[])" (added
'const' for argv). Maybe should grep for all instances of main in our code
and docs and add const? I'm willing to do that.

Let me know,
Nathan

On Sun, Jul 21, 2024 at 1:03 PM Alan C. Assis <acas...@gmail.com> wrote:

> Hi Nathan,
>
> I think this is a nice improvement. We need to improve our Kconfig
> "--help--".
>
> Actually the original documentation was using "argc" and "argv", mine was
> different (with "int main(void)") because I just created a simple main from
> scratch.
>
> The main (no pun intended) issue in the original documentation was because
> it wasn't creating a main function for custom hello:
>
>
> https://github.com/apache/nuttx/commit/a1a0315b9cb6cca373f70ae32b9b1ec3cff526d3
>
> BR,
>
> Alan
>
> On Sun, Jul 21, 2024 at 1:00 PM Nathan Hartman <hartman.nat...@gmail.com>
> wrote:
>
> > Hi all,
> >
> > I have opened pull request PR-12742 [1] to improve the "---help---"
> > text of this Kconfig and hopefully help others avoid this same issue:
> >
> > [1] https://github.com/apache/nuttx/pull/12742
> >
> > Cheers,
> > Nathan
> >
> > On Sat, Jul 20, 2024 at 8:40 AM Linotte Justin ...
> > <lutinjisno...@gmail.com> wrote:
> > >
> > > hello, i'm happy you resolved the issue and that you also helped me
> > > progress in my projects !
> > > have a nice day.
> > >
> > > Justin Linotte
> > >
> > > Le 19-07-24 à 23:48, Alan C. Assis a écrit :
> > > > PR submitted: https://github.com/apache/nuttx/pull/12736
> > > >
> > > > Thank you Justin for finding this issue!!!
> > > >
> > > > You helped to improve our system!
> > > >
> > > > BR,
> > > >
> > > > Alan
> > > >
> > > > On Fri, Jul 19, 2024 at 6:21 PM Alan C. Assis <acas...@gmail.com>
> > wrote:
> > > >
> > > >> Hi Justin,
> > > >>
> > > >> I was assuming you were planning to run it from "nsh>" that is
> working
> > > >> fine:
> > > >>
> > > >> nsh> ?
> > > >> help usage:  help [-v] [<cmd>]
> > > >>
> > > >>      .           cp          exec        ls          reboot
> > truncate
> > > >>
> > > >>      [           cmp         exit        mkdir       rm
> uname
> > > >>
> > > >>      ?           dirname     expr        mkrd        rmdir
> >  umount
> > > >>
> > > >>      alias       date        false       mount       set
>  unset
> > > >>
> > > >>      unalias     dd          fdinfo      mv          sleep
> >  uptime
> > > >>
> > > >>      basename    df          free        pidof       source
> > usleep
> > > >>
> > > >>      break       dmesg       help        printf      test        xd
> > > >>
> > > >>      cat         echo        hexdump     ps          time
> > > >>      cd          env         kill        pwd         true
> > > >>
> > > >> Builtin Apps:
> > > >>
> > > >>      custom_hello    hello           ostest
> > > >>
> > > >>      getprime        nsh             sh
> > > >>
> > > >> nsh> custom_hello
> > > >>
> > > >> Custom Hello
> > > >>
> > > >> nsh>
> > > >>
> > > >> So, probably you forgot to go: make menuconfig => Applications
> > > >> Configuration -> Custom Apps -> [*] Custom Hello.
> > > >>
> > > >> However I found an intriguing fact, when I use
> > > >> CONFIG_INIT_ENTRYPOINT="hello_main" I get it working fine and I see
> > in the
> > > >> minicom:
> > > >>
> > > >> Hello, World!!
> > > >>
> > > >> But, when I changed to CONFIG_INIT_ENTRYPOINT="custom_hello_main" I
> > get
> > > >> this compilation error:
> > > >>
> > > >> $ make
> > > >> CC:  CustomHello.c <command-line>: error: conflicting types for
> > > >> 'custom_hello_main'
> > > >> CustomHello.c:3:5: note: in expansion of macro 'main'
> > > >>      3 | int main(void)
> > > >>        |     ^~~~
> > > >> In file included from
> /home/alan/nuttxspace/nuttx/include/stdio.h:28,
> > > >>                   from CustomHello.c:1:
> > > >> /home/alan/nuttxspace/nuttx/include/sys/types.h:337:5: note:
> previous
> > > >> declaration of 'custom_hello_main' was here
> > > >>    337 | int CONFIG_INIT_ENTRYPOINT(int argc, FAR char *argv[]);
> > > >>        |     ^~~~~~~~~~~~~~~~~~~~~~
> > > >> make[2]: *** [/home/alan/nuttxspace/apps/Application.mk:289:
> > > >> CustomHello.c.home.alan.nuttxspace.apps.CustomApps.CustomHello.o]
> > Error 1
> > > >> make[1]: *** [Makefile:51:
> > > >> /home/alan/nuttxspace/apps/CustomApps/CustomHello_all] Error 2
> > > >> make: *** [tools/LibTargets.mk:232:
> > /home/alan/nuttxspace/apps/libapps.a]
> > > >> Error 2
> > > >>
> > > >>
> > > >>
> > > >> After some investigation I found the root cause, the main was
> defined
> > this
> > > >> way:
> > > >>
> > > >> int main(void)
> > > >> {
> > > >>    printf("Custom Hello\n");
> > > >>    return 0;
> > > >> }
> > > >>
> > > >> So, it was generation conflict, then after changing to:
> > > >>
> > > >> int main(int argc, FAR char *argv[])
> > > >> {
> > > >>    printf("Custom Hello\n");
> > > >>    return 0;
> > > >> }
> > > >>
> > > >> Everything worked as expected and I got it on minicom:
> > > >>
> > > >> Custom Hello
> > > >>
> > > >> I will submit a patch to fix this example, thank you very much!
> > > >>
> > > >> BR,
> > > >>
> > > >> Alan
> > > >>
> > > >> On Fri, Jul 19, 2024 at 4:37 PM Linotte Justin ... <
> > > >> lutinjisno...@gmail.com> wrote:
> > > >>
> > > >>> thanks you for helping me find the solution, i replaced my custom
> > apps
> > > >>> dir with your to try, but the same problem happen, i think there
> may
> > be
> > > >>> a problem with my configuration.
> > > >>> How do i know what name should i type in "*Application entry
> point"*
> > so
> > > >>> that it point to the custom hello main (from CustomHello.c) and
> that
> > > >>> nuttx start with my "custom hello" program where i can do what i
> want
> > > >>> into ?
> > > >>> The menuconfig window where i find *"Application entry point"* :
> > > >>> -------------------
> > > >>> (Top) → RTOS Features → Tasks and Scheduling
> > > >>> ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ NuttX/$ARCH Configuration
> > > >>> [ ] Enable multi handler sharing a IRQ
> > > >>>       Initialization Task (Via application entry)  --->
> > > >>> ()  Application argument list
> > > >>> (2048) Main thread stack size
> > > >>> (100) init thread priority
> > > >>> *(CustomHello) Application entry point*
> > > >>> (CustomHello) Application entry name
> > > >>> (200) Round robin timeslice (MSEC)
> > > >>> [ ] Support sporadic scheduling
> > > >>> (31) Maximum task name size
> > > >>> [ ] Support parent/child task relationships
> > > >>> [*] Enable waitpid() API
> > > >>>       ↓↓↓↓↓↓↓↓↓↓↓↓↓↓
> > > >>> [Space/Enter] Toggle/enter  [ESC] Leave menu           [S] Save
> > > >>> [O] Load                    [?] Symbol info            [/] Jump to
> > symbol
> > > >>> [F] Toggle show-help mode   [C] Toggle show-name mode  [A] Toggle
> > > >>> show-all mode
> > > >>> [Q] Quit (prompts for save) [D] Save minimal config (advanced)
> > > >>>
> > > >>> Thanks you in advance,
> > > >>> Justin Linotte
> > > >>>
> > > >>> Le 18-07-24 à 20:52, Alan C. Assis a écrit :
> > > >>>> Hi Linotte,
> > > >>>>
> > > >>>> Thanks for testing our tutorials, it is important to validate and
> > find
> > > >>>> issues.
> > > >>>>
> > > >>>> I followed the tutorial here (this is the first time I do it) and
> it
> > > >>> worked
> > > >>>> fine (although copying the text from page removes the comments #)
> > > >>>>
> > > >>>> I compressed by CustomApps and shared it:
> > > >>>>
> > > >>>>
> > > >>>
> >
> https://u.pcloud.link/publink/show?code=XZPzJP0Zh3fACWyHaOHTdsEA8Glg5VmGFwy7
> > > >>>> Extract it and use some diff tool like meld to compare files and
> to
> > > >>>> discover what you did wrong.
> > > >>>>
> > > >>>> BR,
> > > >>>>
> > > >>>> Alan
> > > >>>>
> > > >>>> On Thu, Jul 18, 2024 at 3:01 PM Linotte Justin ...<
> > > >>> lutinjisno...@gmail.com>
> > > >>>> wrote:
> > > >>>>
> > > >>>>> hello, i hope my question doesn't bother you, i'm an amateur, not
> > a pro
> > > >>>>> with 40y of experience so it may be dumb for you. i'm also an
> > amateur
> > > >>> in
> > > >>>>> english btw
> > > >>>>>
> > > >>>>> when i do make like advised here :
> > > >>>>>
> > > >>>>>
> > > >>>
> >
> https://nuttx.apache.org/docs/latest/quickstart/compiling_make.html#build-nuttx
> > > >>>>> i get this :
> > > >>>>>
> > > >>>>> :~/pico/nuttx/nuttx$ make
> > > >>>>> Create version.h
> > > >>>>> LN: platform/board to
> /home/default/pico/nuttx/apps/platform/dummy
> > > >>>>> Register: custom_hello
> > > >>>>> Register: hello
> > > >>>>> Register: nsh
> > > >>>>> Register: sh
> > > >>>>> Register: getprime
> > > >>>>> Register: ostest
> > > >>>>> CPP:
> > > >>>>>
> > > >>>
> >
> /home/default/pico/nuttx/nuttx/boards/arm/rp2040/raspberrypi-pico/scripts/raspberrypi-pico-flash.ld->
> > > >>>>>
> > > >>>
> > /home/default/pico/nuttx/nuttx/boards/arm/rp2040/raspberrypi-pico/scrLD:
> > > >>>>> nuttx
> > > >>>>> arm-none-eabi-ld:
> > > >>>>>
> > > >>>
> >
> /home/default/pico/nuttx/nuttx/staging/libapps.a(builtin_list.c.home.default.pico.nuttx.apps.builtin_1.o):(.rodata.g_builtins+0xc):
> > > >>>>> undefined reference to `custom_hello_main'
> > > >>>>> make[1]: *** [Makefile:197: nuttx] Error 1
> > > >>>>> make: *** [tools/Unix.mk:546: nuttx] Error 2
> > > >>>>>
> > > >>>>> i try to "Extend the apps/ directory to include a new custom
> > directory"
> > > >>>>> to use my own code into nuttx :
> > > >>>>>
> > > >>>>>
> > > >>>
> >
> https://nuttx.apache.org/docs/latest/guides/customapps.html#extend-the-apps-directory-to-include-a-new-custom-directory
> > > >>>>> i've configured with menuconfig
> > > >>>>> rtos features>tasks and scheduling>application entry point to
> > > >>>>> custom_hello (not custom_hello_main)
> > > >>>>> application configuration>Custom Apps>[*]Custom Hello App
> > > >>>>>          >program Name is set to custom_hello
> > > >>>>>
> > > >>>>> I don't know how i can know the real name of the entrypoint and
> > also
> > > >>> how
> > > >>>>> i can resolve the error when building withmake. i also followed
> > that :
> > > >>>>>
> > > >>>>>
> > > >>>
> >
> https://nuttx.apache.org/docs/latest/faq/index.html#how-to-start-directly-my-application-instead-starting-nsh
> > > >>>>> this doesn't explain how you know the ENTRYPOINT name
> > > >>>>> i'm a bit confused on what to do (maybe you are too because of
> how
> > i
> > > >>> write)
> > > >>>>> thank you if you can help !
> > > >>>>>
> > > >>>>>
> > > >>
> >
>

Reply via email to