apache / nuttx

Apache NuttX is a mature, real-time embedded operating system (RTOS)
https://nuttx.apache.org/
Apache License 2.0
2.82k stars 1.17k forks source link

Should the makefile warn if there isn't a valid APPDIR? #844

Open cmorganBE opened 4 years ago

cmorganBE commented 4 years ago

If you run the ./tools/configure.sh script without a ../apps folder or without setting APPDIR you get errors like below without any helpful reason what is going on. It took several minutes to figure it out.

nuttx$ ./tools/configure.sh olimex-stm32-e407:nsh
  Copy files
  Select CONFIG_HOST_LINUX=y
  Refreshing...
make: the '-C' option requires a non-empty string argument
Usage: make [options] [target] ...
Options:
...

Thoughts on having the Makefile check for this folder to provide reasonable warning/error messages?

patacongo commented 4 years ago

It should be possible to build NuttX without any apps/ directory. So this would be a bug.

cmorganBE commented 4 years ago

@patacongo steps to reproduce here on Ubuntu 20.04 amd64:

mkdir nuttx_build_test
cd nuttx_build_test/
git clone git@github.com:apache/incubator-nuttx.git
cd incubator-nuttx/
./tools/configure.sh nucleo-h743zi:nsh

At this point I get:

 ./tools/configure.sh nucleo-h743zi:nsh
  Copy files
  Select CONFIG_HOST_LINUX=y
  Refreshing...
make: the '-C' option requires a non-empty string argument
Usage: make [options] [target] ...
Options:
  -b, -m                      Ignored for compatibility.
  -B, --always-make           Unconditionally make all targets.
  -C DIRECTORY, --directory=DIRECTORY
                              Change to DIRECTORY before doing anything.
  -d                          Print lots of debugging information.
  --debug[=FLAGS]             Print various types of debugging information.
  -e, --environment-overrides
                              Environment variables override makefiles.
  --eval=STRING               Evaluate STRING as a makefile statement.
  -f FILE, --file=FILE, --makefile=FILE
                              Read FILE as a makefile.
  -h, --help                  Print this message and exit.
  -i, --ignore-errors         Ignore errors from recipes.
  -I DIRECTORY, --include-dir=DIRECTORY
                              Search DIRECTORY for included makefiles.
  -j [N], --jobs[=N]          Allow N jobs at once; infinite jobs with no arg.
  -k, --keep-going            Keep going when some targets can't be made.
  -l [N], --load-average[=N], --max-load[=N]
                              Don't start multiple jobs unless load is below N.
  -L, --check-symlink-times   Use the latest mtime between symlinks and target.
  -n, --just-print, --dry-run, --recon
                              Don't actually run any recipe; just print them.
  -o FILE, --old-file=FILE, --assume-old=FILE
                              Consider FILE to be very old and don't remake it.
  -O[TYPE], --output-sync[=TYPE]
                              Synchronize output of parallel jobs by TYPE.
  -p, --print-data-base       Print make's internal database.
  -q, --question              Run no recipe; exit status says if up to date.
  -r, --no-builtin-rules      Disable the built-in implicit rules.
  -R, --no-builtin-variables  Disable the built-in variable settings.
  -s, --silent, --quiet       Don't echo recipes.
  -S, --no-keep-going, --stop
                              Turns off -k.
  -t, --touch                 Touch targets instead of remaking them.
  --trace                     Print tracing information.
  -v, --version               Print the version number of make and exit.
  -w, --print-directory       Print the current directory.
  --no-print-directory        Turn off -w, even if it was turned on implicitly.
  -W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE
                              Consider FILE to be infinitely new.
  --warn-undefined-variables  Warn when an undefined variable is referenced.

This program built for x86_64-pc-linux-gnu
Report bugs to <bug-make@gnu.org>
make: *** [tools/Makefile.unix:364: dirlinks] Error 2
ERROR: failed to refresh
RockySong commented 3 years ago

After I cloned https://github.com/apache/incubator-nuttx-apps and moved+renamed it to ../apps, I got other problems. rs@DESKTOP-UG5S1LM:~/nuttx/incubator-nuttx$ ./tools/configure.sh ubw32:nsh Copy files Select CONFIG_HOST_LINUX=y Refreshing... make[1]: Entering directory '/home/rs/nuttx/incubator-nuttx' make[2]: Entering directory '/home/rs/nuttx/incubator-nuttx/boards' make[2]: Leaving directory '/home/rs/nuttx/incubator-nuttx/boards' make[2]: Entering directory '/home/rs/nuttx/apps' make[3]: Entering directory '/home/rs/nuttx/apps/platform' make[3]: Leaving directory '/home/rs/nuttx/apps/platform' make[3]: Entering directory '/home/rs/nuttx/apps/builtin' make[3]: Leaving directory '/home/rs/nuttx/apps/builtin' make[2]: Leaving directory '/home/rs/nuttx/apps' make[2]: Entering directory '/home/rs/nuttx/incubator-nuttx/graphics' make[3]: Entering directory '/home/rs/nuttx/incubator-nuttx/graphics/nxglib' make[3]: Leaving directory '/home/rs/nuttx/incubator-nuttx/graphics/nxglib' make[3]: Entering directory '/home/rs/nuttx/incubator-nuttx/graphics/nxglib' make[3]: Leaving directory '/home/rs/nuttx/incubator-nuttx/graphics/nxglib' make[3]: Entering directory '/home/rs/nuttx/incubator-nuttx/graphics/nxglib' make[3]: Leaving directory '/home/rs/nuttx/incubator-nuttx/graphics/nxglib' make[2]: Leaving directory '/home/rs/nuttx/incubator-nuttx/graphics' make[2]: Entering directory '/home/rs/nuttx/incubator-nuttx/arch/mips/src' make[2]: Nothing to be done for 'clean_context'. make[2]: Leaving directory '/home/rs/nuttx/incubator-nuttx/arch/mips/src' make[1]: Leaving directory '/home/rs/nuttx/incubator-nuttx' LN: include/arch to arch/mips/include LN: include/arch/board to /home/rs/nuttx/incubator-nuttx/boards/mips/pic32mx/ubw32/include LN: include/arch/chip to arch/mips/include/pic32mx LN: arch/mips/src/board to /home/rs/nuttx/incubator-nuttx/boards/mips/pic32mx/ubw32/src LN: arch/mips/src/chip to arch/mips/src/pic32mx LN: /home/rs/nuttx/incubator-nuttx/drivers/platform to /home/rs/nuttx/incubator-nuttx/drivers/dummy make[1]: Entering directory '/home/rs/nuttx/incubator-nuttx/libs/libxx' make[1]: Nothing to be done for 'dirlinks'. make[1]: Leaving directory '/home/rs/nuttx/incubator-nuttx/libs/libxx' make[1]: Entering directory '/home/rs/nuttx/incubator-nuttx/boards' make[1]: Leaving directory '/home/rs/nuttx/incubator-nuttx/boards' make[1]: Entering directory '/home/rs/nuttx/incubator-nuttx/openamp' make[1]: Nothing to be done for 'dirlinks'. make[1]: Leaving directory '/home/rs/nuttx/incubator-nuttx/openamp' make[1]: Entering directory '/home/rs/nuttx/apps' make[2]: Entering directory '/home/rs/nuttx/apps/platform' LN: platform/board to /home/rs/nuttx/apps/platform/dummy make[2]: Leaving directory '/home/rs/nuttx/apps/platform' make[1]: Leaving directory '/home/rs/nuttx/apps' make[1]: Entering directory '/home/rs/nuttx/apps' make[2]: Entering directory '/home/rs/nuttx/apps/examples' /bin/sh: /home/rs/nuttx/apps/tools/mkkconfig.sh: Permission denied make[2]: [/home/rs/nuttx/apps/Directory.mk:60: preconfig] Error 126 make[2]: Leaving directory '/home/rs/nuttx/apps/examples' make[1]: [Makefile:167: Kconfig] Error 2 make[1]: Leaving directory '/home/rs/nuttx/apps' make: *** [tools/Makefile.unix:604: apps_preconfig] Error 2 ERROR: failed to refresh

acassis commented 3 years ago

Hi @RockySong the issue appears related to issues on your file system, could you please confirm that this file has execution permission, like mine:

$ ls -l apps/tools/mkkconfig.sh
-rwxrwxr-x 1 alan alan 2806 May  7  2020 apps/tools/mkkconfig.sh
RockySong commented 3 years ago

[solved on my side, thanks @acassis, the results are appended at last]

Hi @acassis Noted with thanks for your reply! Later I downloaded the 9.1.0 release from Nuttx official site and deleted the git cloned version, and 9.1.0 release worked normally. I checked permission and got below:

rs@DESKTOP-UG5S1LM:~/nuttx/nuttx_910$ ls -l apps/tools/mkkconfig.sh -rwxr-xr-x 1 rs rs 2806 Jul 8 08:06 apps/tools/mkkconfig.sh

However, to verify the execution permission matters, then I cloned the git cloned back the app, and found it also has execution permission!

rs@DESKTOP-UG5S1LM:~/nuttx$ ls -l incubator-nuttx-apps/tools/mkkconfig.sh -rwxr-xr-x 1 rs rs 2806 Nov 21 09:23 incubator-nuttx-apps/tools/mkkconfig.sh

It looks there are some other causes to this problem?

By the way, I use ubuntu under WSL2 with Windows 10, sometimes I use tar -xf / unzip, even sometimes may use windows tools to extract packages, maybe the execution permission can get lost with tar -xf / unzip / windows tools?

------- 10 minutes later [solution on my side]----------- This time I did git clone all the packages under WSL2 + ubuntu, with the ../apps/ folder, the configure.sh worked normally. So, the keys are:

  1. has ../apps folder relative to nuttx tree , one can clone incubator-nuttx-apps and rename it to apps
  2. ./apps/tools/mkkconfig.sh must have execution permission.
Robokishan commented 3 years ago

I am having same problem on ubuntu and mac over nuttx git version i am just following documents as @RockySong mentioned may be there are some issues with git version

btashton commented 3 years ago

@Robokishan I'm trying to understand what is going on here since we run all these builds against Ubuntu and Windows multiple times a day so I don't think git is broken.

There clearly is an issue if two people have run into to the same issue so I want to get to the root of it.

If you clone directly to app git clone https://github.com/apache/incubator-nuttx-apps apps do you have an issue. This would eliminate something funny happening when you are moving things around (I don't see how that could cause an issue either).

The configure.sh script can also take a path to the apps folder so you do not have to rename it.

Also what version of Ubuntu are you using?

Robokishan commented 3 years ago

@btashton i am just following nuttx docs https://nuttx.apache.org/docs/latest/quickstart/quickstart.html

and then i am having this same errors on ./tools/configure.sh -m nucleo-h743zi:nsh

at first when i got this errors i thought i am the first having this then i saw this issue on nuttx so i am pretty much sure there is something wrong or the thing is not in the docs let me try one more time what you have suggested

Robokishan commented 3 years ago

After clonning it into app i am getting errors

  Copy files
  Select CONFIG_HOST_MACOS=y
  Refreshing...
make[2]: Nothing to be done for `clean_context'.
LN: include/arch to arch/arm/include
LN: include/arch/board to /Users/kishan/Documents/Github/nuttx/nuttx/boards/arm/stm32h7/nucleo-h743zi/include
LN: include/arch/chip to arch/arm/include/stm32h7
LN: arch/arm/src/board to /Users/kishan/Documents/Github/nuttx/nuttx/boards/arm/stm32h7/nucleo-h743zi/src
LN: arch/arm/src/chip to arch/arm/src/stm32h7
LN: /Users/kishan/Documents/Github/nuttx/nuttx/drivers/platform to /Users/kishan/Documents/Github/nuttx/nuttx/drivers/dummy
make[1]: Nothing to be done for `dirlinks'.
make[1]: Nothing to be done for `dirlinks'.
LN: platform/board to /Users/kishan/Documents/Github/nuttx/apps/platform/dummy
mkkconfig in /Users/kishan/Documents/Github/nuttx/apps/canutils
mkkconfig in /Users/kishan/Documents/Github/nuttx/apps/examples
mkkconfig in /Users/kishan/Documents/Github/nuttx/apps/fsutils
mkkconfig in /Users/kishan/Documents/Github/nuttx/apps/gpsutils
mkkconfig in /Users/kishan/Documents/Github/nuttx/apps/graphics
mkkconfig in /Users/kishan/Documents/Github/nuttx/apps/industry
mkkconfig in /Users/kishan/Documents/Github/nuttx/apps/interpreters
mkkconfig in /Users/kishan/Documents/Github/nuttx/apps/netutils
mkkconfig in /Users/kishan/Documents/Github/nuttx/apps/system/libuv
mkkconfig in /Users/kishan/Documents/Github/nuttx/apps/system
mkkconfig in /Users/kishan/Documents/Github/nuttx/apps/testing
mkkconfig in /Users/kishan/Documents/Github/nuttx/apps/wireless/bluetooth
mkkconfig in /Users/kishan/Documents/Github/nuttx/apps/wireless/ieee802154
mkkconfig in /Users/kishan/Documents/Github/nuttx/apps/wireless
mkkconfig in /Users/kishan/Documents/Github/nuttx/apps
arch/arm/src/imxrt/Kconfig:1220: syntax error
arch/arm/src/imxrt/Kconfig:1219: invalid option
arch/arm/src/stm32l4/Kconfig:5236: syntax error
arch/arm/src/stm32l4/Kconfig:5185: missing end statement for this entry
arch/arm/src/stm32l4/Kconfig:5053: missing end statement for this entry
arch/arm/src/stm32l4/Kconfig:8: missing end statement for this entry
arch/arm/Kconfig:1017: missing end statement for this entry
arch/arm/Kconfig:7: missing end statement for this entry
Kconfig:1809: missing end statement for this entry
arch/arm/src/stm32l4/Kconfig:5235: invalid statement
arch/arm/src/stm32l4/Kconfig:5245: unexpected end statement
arch/arm/src/stm32l4/Kconfig:5248: syntax error
arch/arm/src/stm32l4/Kconfig:5247: invalid statement
arch/arm/src/stm32l4/Kconfig:5257: unexpected end statement
arch/arm/src/stm32l4/Kconfig:5260: syntax error
arch/arm/src/stm32l4/Kconfig:5259: invalid statement
arch/arm/src/stm32l4/Kconfig:5269: unexpected end statement
arch/arm/src/stm32l4/Kconfig:5271: unexpected end statement
arch/arm/src/stm32l4/Kconfig:5273: unexpected end statement
arch/arm/src/stm32l4/Kconfig:6097: unexpected end statement
arch/arm/Kconfig:1018: unexpected end statement
arch/arm/Kconfig:1032: unexpected end statement
Kconfig:1811: unexpected end statement
boards/sim/sim/sim/Kconfig:53: syntax error
boards/sim/sim/sim/Kconfig:52: invalid option
drivers/note/Kconfig:62: syntax error
drivers/note/Kconfig:61: invalid option
drivers/sensors/Kconfig:227: syntax error
drivers/sensors/Kconfig:226: invalid option
make: *** [olddefconfig] Error 1
ERROR: failed to refresh
Robokishan commented 3 years ago

and i checkout both nuttx-apps and nuttx to tag/nuttx-9.1.0 after that following errors

  Copy files
  Select CONFIG_HOST_MACOS=y
  Refreshing...
arch/arm/src/imxrt/Kconfig:1096: syntax error
arch/arm/src/imxrt/Kconfig:1095: invalid option
make: *** [olddefconfig] Error 1
ERROR: failed to refresh
btashton commented 3 years ago

@Robokishan see https://github.com/apache/incubator-nuttx/issues/2405 I am still not clear on what the issue was. But I think it was resolved using the kconfig that I pointed him at.

btashton commented 3 years ago

I suspect you are somehow using an old version of kconfig when you run which kconfig do you get the version you built?

Robokishan commented 3 years ago

Yes that's resolve the problem thanks for help!!!... i install it from brew since i didn't wanted to install using sudo make install. and its kinda very old the version is 3.xx something. now i installed kconfig using make install now it is working....

btashton commented 3 years ago

Great! You can install kconfig to a local path by passing --prefix= to ./configure.sh which is what we do in the CI script here ./configure --prefix=$prebuilt/kconfig-frontends

Also just as a note 10.0.0 has been released (I need to send the announcement and update the site today).

btashton commented 3 years ago

@v01d maybe we should add a note to the docs warning people about the brew version of kconfig-fronteneds for macOS?

Robokishan commented 3 years ago

Sure will checkout that also. thanks for the help $prebuilt whould work ?

btashton commented 3 years ago

Sure will checkout that also. thanks for the help $prebuilt whould work ?

$prebuilt is a directory that we define at the top and then make sure $prebuilt/bin is in the PATH. For my local development I tend to use prefix=$HOME/.local/ and then export PATH=$PATH:$HOME/.local/bin but everyone has there own way of managing local paths, so this is just an example.

Link should have been https://github.com/apache/incubator-nuttx-testing/blob/24de04a72985ad92bb8b165dc9890074e92d2239/cibuild.sh#L115

protobits commented 3 years ago

@v01d maybe we should add a note to the docs warning people about the brew version of kconfig-fronteneds for macOS?

So the issue was there was already a system installed version? Maybe we need to add a message asking to uninstall that before a locally built one is used.

Robokishan commented 3 years ago

@btashton not working it still trying to install it into the sytem. ./configure --prefix=$prebuilt/kconfig-frontends --enable-mconf --disable-shared --enable-static --disable-gconf --disable-qconf --disable-nconf

without those options which are from docs.. it's giving me lots of errors so i added those options .

btashton commented 3 years ago

Yeah sorry you do need to supply all the of those especially for local development. Just make sure $prebuilt/kconfig-frontends point to where you want it installed for when you run make install

Robokishan commented 3 years ago

same as yours i just want to install it to the $HOME/.local/bin so i exported it and then 1. export prefix=$HOME/.local/ 2. ./configure --prefix=$prebuilt/kconfig-frontends --enable-mconf --disable-shared --enable-static --disable-gconf --disable-qconf --disable-nconf 3. make install is there anything else i can add to make it work ?

btashton commented 3 years ago

You should use --prefix=$HOME/.local/ instead of --prefix=$prebuilt/kconfig-frontends then you will see the kconfig binaries in $HOME/.local/bin/ after make install export PATH=$HOME/.local/bin:$PATH to make sure they are part of your path for the current bash session

My ~/.bashrc has this export PATH=$HOME/.local/bin:$PATH it is is always configured but how you manage this is up to you. This is not NuttX specific.

Robokishan commented 3 years ago

yes yes that's for sure.. now it is working thanks for the help that was the thing i was looking for i always use .local for the installation since sudo is too risky for anything.

Thanks for the help!

Now i can build nuttx thanks for the great help