Upcoming maintenance
Dear Customers and Partners.
This website will be undergoing scheduled maintenance on June 14, 2023. Please be aware there may be disruption to the developer portal website and associated services during the scheduled maintenance period.
This upgrade is essential to ensure the continued performance, reliability, and security of Developer World.
We apologize for any inconvenience.
Build and flash custom app from CLI in another directory
-
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 usingmkappsdir
andmkcmd
.
The documentation does not explain the rest.
My directory is not in spresense repository (besidesdk/
) 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
andTOPDIR
are not defined.
From the sdk directory,config
can'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. -
I'm not entirely sure I understood the whole problem, but some pointers here that can help:
- Yes, you always should run commands inside the sdk folder.
- Did you follow the steps in https://developer.sony.com/develop/spresense/docs/sdk_set_up_en.html#_adding_a_user_application ?
- 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. - 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.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.
-
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 besidespresense/
for instance. After usemkappsdir.py
andmkcmd.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. -
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_directoryThe 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