Sony's Developer World forum

    • Home
    • Forum guidelines

    Build and flash custom app from CLI in another directory

    Spresense
    2
    4
    147
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      RomainPC 0 1 1 1 1 1 1 last edited by

      Hi,

      I am able to create and run my own app into the VSCode IDE.
      However I can't use only CLI.
      So far I have created a new app directory with a new app inside using mkappsdir and mkcmd.
      The documentation does not explain the rest.
      My directory is not in spresense repository (beside sdk/) but beside it.

      In my app there is a SDK config file inside a directory (with IDE it is global to workspace). There is this time a Kconfig, what is the purpose of this file since IDE's apps can run without it ?

      From my new app directory, makefiles are not working, Application.mk doesn't exist. APPDIR, SDKDIR and TOPDIRare not defined.
      From the sdk directory, configcan't find the default config inside my app dir.

      Is there a commands chain to simply build and flash a stand-alone app ? Do I always need to enter commands from sdk folder ? Also, can the compilation time be reduced ?

      Thanks in advance.
      Romain.

      C 1 Reply Last reply Reply Quote
      • C
        CamilaSouza DeveloperWorld @RomainPC 0 1 1 1 1 1 1 last edited by CamilaSouza

        Hey, @RomainPC-0-1-1-1-1-1-1

        I'm not entirely sure I understood the whole problem, but some pointers here that can help:

        1. Yes, you always should run commands inside the sdk folder.
        2. Did you follow the steps in https://developer.sony.com/develop/spresense/docs/sdk_set_up_en.html#_adding_a_user_application ?
        3. Compilation time can be reduced using the -j flag in the make command. "make -j"
          This will make allow infinite parallel jobs. However, if it doesn’t work correctly due to lack of PC resources, try to limit the number of jobs like make -j2.
        4. Explanation about the Kconfig file:

        The KConfig file defines any configurations that you want to create for your example.
        Let's look at the Hello example:

        config EXAMPLES_HELLO
        	tristate "\"Hello, World!\" example"
        	default n
        	---help---
        		Enable the \"Hello, World!\" example
        
        if EXAMPLES_HELLO
        
        config EXAMPLES_HELLO_PROGNAME
        	string "Program name"
        	default "hello"
        	---help---
        		This is the name of the program that will be used when the NSH ELF
        		program is installed.
        
        config EXAMPLES_HELLO_PRIORITY
        	int "Hello task priority"
        	default 100
        
        config EXAMPLES_HELLO_STACKSIZE
        	int "Hello stack size"
        	default DEFAULT_TASK_STACKSIZE
        
        endif
        

        config EXAMPLES_HELLO is the one you can toggle on and off to decide if this example will be available on the NuttShell terminal on your board.
        Then, you state that if this example is enabled, you want the rest of these configuration options to be present in your config menu.
        You see.. now under "Hello, World!" example you see the three config options that I stated in the KConfig file: Program name, Hello task priority and Hello stack size.

        b4f0f871-b9e5-4cf2-bf28-b24e70cc682a-image.png

        If you want to be able to add other configuration options to your custom example, you can do that in the KConfig. It's also the file where you choose the name of the example and the text that will appear in the menu along with your example.

        I hope this helped and the explanation was clear.

        1 Reply Last reply Reply Quote
        • R
          RomainPC 0 1 1 1 1 1 1 last edited by

          Hi @CamilaSouza ,
          Thank you for your quick answer.

          If I understand correctly, every app, in order to be build or flash, must be declared into the sdk directory ? And the flashed kernel is always somewhere in the sdk folder ? That is why if I change sdk config from IDE it change config for CLI make.

          I managed to flash my own application, only in a directory beside sdk/. Not in a directory beside spresense/ for instance. After use mkappsdir.py and mkcmd.py i cleaned sdk then make it again. My app appears in the menuconfig into "Application Configuration > Spresense SDK > My apps"
          Then ./tools/flash.sh -c /dev/ttyUSB0 nuttx.spk works.

          I looked at the code of the VSCode extension, indeed it seems to cd to the sdk directory. And then it compiles. Is the extension following the same procedure ? Because I do not see the Kconfig, I suppose that IDE's apps are not examples but real stand-alone apps. But may be it also declares the app to the kernel ?

          To return to the make, compiling takes 10-30s with VSCode IDE, without clean after modifications. Does the quantity of examples have an impact ? Do you think it is possible to optimize the compilation? most of the time make goes in and out of directories and prints "nothing to do".

          Thanks,
          Romain.

          C 1 Reply Last reply Reply Quote
          • C
            CamilaSouza DeveloperWorld @RomainPC 0 1 1 1 1 1 1 last edited by CamilaSouza

            Hey, @RomainPC-0-1-1-1-1-1-1
            Let's see if I can answer everything.

            It's actually possible to store the application outside of the sdk repository.
            Here is a link on how to do that:
            https://developer.sony.com/develop/spresense/docs/sdk_set_up_en.html#_add_to_a_different_directory

            The flashed kernel is always inside the sdk folder, yes. And it's called nuttx.spk.

            About not seeing the Kconfig in the IDE apps:
            We don't need a Kconfig file on the IDE because the whole point of this file is that we can see the configurations associated with our example once we open the configuration menu in the CLI.
            In the IDE, this configurations are chosen for you by default in the application.mk file.
            If you want to change the default values, you can go to your application Makefile and input the values you want. But if you notice, in the bottom of the Makefile of an application created with vscode, you have an include to .vscode/application.mk.

            About compilation time:
            I don't think the amount of examples have that big of an impact, since going in and out of directories is pretty fast. What I can recommend to improve compilation time in the VSCode IDE is going to .vscode/build.sh and changing adding -j after the make command.

            Before:

            cd ${SDK_PATH}/sdk
              make
            

            After:

            cd ${SDK_PATH}/sdk
              make -j
            
            1 Reply Last reply Reply Quote
            • First post
              Last post
            Developer World
            Copyright © 2021 Sony Group Corporation. All rights reserved.
            • Contact us
            • Legal