MSYS2

238 views
Skip to first unread message

patacongo

unread,
Jun 1, 2018, 10:07:55 AM6/1/18
to NuttX
I have been playing with the MSYS2 development environment under Windows:  https://www.msys2.org/

If anyone is interested in the POSIX development environment for Windows that lighter weight than Cygwin and better integrated with windows than the Ubuntu Bash shell under windows, then perhaps this is what you are looking for.

It does have a few quirks (as do all environments) like:  It does not support symbolic links and it does not permit spaces in the PATH variable. It does not support any kind of graphics (light weight, remember?)  Otherwise is works pretty slick and gives you a nice, integrated NuttX development environment.

Everything I know about it is the top-level NuttX README.txt file.

Greg

ma...@makr.zone

unread,
Jun 27, 2018, 4:50:00 PM6/27/18
to NuttX
Hi Greg

First I'd like to express my admiration for this great project!

I'm trying to get started with MSYS2.

First I was stuck with the symbolic link issue. I've seen the readme.txt section about Make.defs but I don't understand how and where to apply it, as this seems to be a hen-egg problem with the

tools/configure.sh <board-name>/<config-dir>

already failing.

Then I tried with MSYS=winsymlinks:nativestrict -> see
https://sourceforge.net/p/msys2/tickets/41/#6622

This worked for the tools/configure.sh

Then I tried to do a buildroot. Needed to add

pacman -S libtool
pacman -S texinfo
pacman -S msys/gmp-devel
pacman -S msys/mpfr-devel
pacman -S msys/mpc-devel

in addition to the readme.txt list.

The build seems to work mostly but eventually it fails with this:

# Make sure we have 'cc'.
if [ ! -e /home/Markus/nuttxspace/buildroot/build_arm_hf/staging_dir/bin/arm-nuttx-eabi-cc ] ; then \
ln -snf arm-nuttx-eabi-gcc \
/home/Markus/nuttxspace/buildroot/build_arm_hf/staging_dir/bin/arm-nuttx-eabi-cc ; \
fi;
if [ ! -e /home/Markus/nuttxspace/buildroot/build_arm_hf/staging_dir/arm-nuttx-eabi/bin/cc ] ; then \
ln -snf gcc /home/Markus/nuttxspace/buildroot/build_arm_hf/staging_dir/arm-nuttx-eabi/bin/cc ; \
fi;
ln: failed to create symbolic link '/home/Markus/nuttxspace/buildroot/build_arm_hf/staging_dir/arm-nuttx-eabi/bin/cc': No such file or directory
make: *** [toolchain/gcc/gcc-nuttx-4.x.mk:146: /home/Markus/nuttxspace/buildroot/toolchain_build_arm_hf/gcc-7.3.0-build/.installed] Error 1


I'm completely at a loss of how to fix that. I guess this means some finishing steps are missing?

I just tried to make nuttx anyway and after figuring out I had the add the

...buildroot/build_arm_hf/staging_dir/bin

to the PATH manually and setting the FPU to [*] to match the cortexm4f-eabi-defconfig-7.3.0 it compiled.


So these are the questions:

1. Is MSYS supposed to work without the MSYS=winsymlinks:nativestrict hack?

2. How does one add the Make.defs DIRLINK DIRUNLINK exactly, so that tools/configure.sh works?

3. Do I really need to add the buildroot/build_arm_hf/staging_dir/bin to PATH manually even if I chose the correct option in make menuconfig?

4. is there a fix for the above error? (With or without the MSYS=winsymlinks:nativestrict)


Thanks a lot for all your help and for making all this available!

_Mark

patacongo

unread,
Jun 27, 2018, 5:05:08 PM6/27/18
to NuttX

I'm trying to get started with MSYS2.

I have it on my laptop and have used it only a little.  But it worked just fine for me.


First I was stuck with the symbolic link issue. I've seen the readme.txt section about Make.defs but I don't understand how and where to apply it, as this seems to be a hen-egg problem with the

  tools/configure.sh <board-name>/<config-dir>

First, mistake.  You left out and almost-required argument".  Look at the output from:

tools/configure.sh -h

You are missing the -g option.  Try again with :

tools/configure.sh -g <board-name>/<config-dir>

The other things you tried are meandering into the unkown and I don't have any feedback.

Then I tried to do a buildroot. Needed to add

I don't know if you can build the buildroot toolchain with MinGW.  I wouldn't was a lot of time trying that.  I use the ARM Embedded Toolchain for Windows that you can get here:  https://developer.arm.com/open-source/gnu-toolchain/gnu-rm

This is a windows native toolchain so you need to do 'make menuconfig' on the configuration BEFORE doing 'make'.  No there are two steps:

tools/configure.sh -g <board-name>/<config-dir>
make menconfig -> Change to the Generic GNU EABI toolchain for Windows


1. Is MSYS supposed to work without the MSYS=winsymlinks:nativestrict hack?

Yes.  I don't event know that is.


2. How does one add the Make.defs DIRLINK DIRUNLINK exactly, so that tools/configure.sh works?

You add the -g option to configure.sh

3. Do I really need to add the buildroot/build_arm_hf/staging_dir/bin to PATH manually even if I chose the correct option in make menuconfig?

Don't bother trying to build the buildroot toolchain under MSYS2.  Then, if you do that, you will be the first and no one can give you advice there.

4. is there a fix for the above error? (With or without the MSYS=winsymlinks:nativestrict)

I think so.  I don't think anything is broken.

Greg

ma...@makr.zone

unread,
Jun 28, 2018, 3:09:36 AM6/28/18
to NuttX
Thank you very much. Will try that.
_Mark

ma...@makr.zone

unread,
Jun 29, 2018, 5:22:24 AM6/29/18
to NuttX
Hi

tanks again for helping, I tried your suggestion. Prep:

  1. I deleted the nuttx apps tools directories 
  2. closed MSYS2
  3. deactivated the symbolic link hack (no more MSYS=winsymlinks:nativestrict)
  4. restarted MSYS2
  5. got the nuttx apps tools fresh by git

Tried as you suggested:
 
tools/configure.sh -g <board-name>/<config-dir>

 
Markus@VANTAGE MSYS ~/nuttxspace/nuttx/tools
$ ./configure.sh –g nucleo-l496zg/nsh
 
<board/config> defined twice
 
 
USAGE: ./configure.sh [-d] [-l|m|c|u|g|n] [-a <app-dir>] <board-name>/<config-name>
 
Where:
  -l selects the Linux (l) host environment.
  -m selects the macOS (m) host environment.
  -c selects the Windows host and Cygwin (c) environment.
  -u selects the Windows host and Ubuntu under Windows 10 (u) environment.
  -g selects the Windows host and MinGW/MSYS environment.
  -n selects the Windows host and Windows native (n) environment.
  Default: Use host setup in the defconfig file
  Default Windows: Cygwin
  <board-name> is the name of the board in the configs directory
  <config-name> is the name of the board configuration sub-directory
  <app-dir> is the path to the apps/ directory, relative to the nuttx
     directory

 

Don't know enough about bash to understand why, the code in configure.sh seems correct to me(?)


However guessing it might help, I tried with the -g at the end

 

$ ./configure.sh nucleo-l496zg/nsh -g
  Copy files
  Select CONFIG_HOST_WINDOWS=y
  Select CONFIG_WINDOWS_MSYS=y
  Refreshing...
make: *** [tools/Makefile.unix:361: clean_context] Error 1


At the given line 361 it uses DIRUNLINK and therefore tools/unlink.sh


I tried to make distclean:

 

include/arch/board already exists but is not a symbolic link
make: *** [tools/Makefile.unix:361: clean_context] Error 1


So I looked at tools/unlink.sh doing step by step what it does, I found out that MSYS2 does not seem to create the .fakelnk marker.



Markus@VANTAGE MSYS ~/nuttxspace/nuttx
$ test -h include/arch/board
 
Markus@VANTAGE MSYS ~/nuttxspace/nuttx
$ echo $?
1
 
Markus@VANTAGE MSYS ~/nuttxspace/nuttx
$ test -d include/arch/board
 
Markus@VANTAGE MSYS ~/nuttxspace/nuttx
$ echo $?
0

Markus@VANTAGE MSYS ~/nuttxspace/nuttx
$ test -f include/arch/board/.fakelnk
 
Markus@VANTAGE MSYS ~/nuttxspace/nuttx
$ echo $?
1


So link.sh needs to add it. A google search later I saw that I am not the first one to stumble (because it only survived in the Google Cache, I created an archive link)


I fixed the syntax error discussed in the newsgroup post and now all seems to work. I can configure and build for the first time.


 tools/link.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
diff --git a/tools/link.sh b/tools/link.sh
index f14e9e5abb..d3672b771d 100755
--- a/tools/link.sh
+++ b/tools/link.sh
@@ -94,3 +94,11 @@ fi
 
 ln -s "${src}" "${dest}" || \
  { echo "Failed to create link: $dest" ; exit 1 ; }
+
+# sebastien lorquet 20140528 for msys, ln will not create a symlink, but a copy
+# so fake the link instead
+os=`shell uname -o`
+if [ "x${os}" == "xMsys" ]; then
+ touch ${dest}/.fakelnk
+fi
+



Do you need a pull request?


_Mark


patacongo

unread,
Jun 29, 2018, 8:51:46 AM6/29/18
to NuttX

However guessing it might help, I tried with the -g at the end

 

$ ./configure.sh nucleo-l496zg/nsh -g
  Copy files
  Select CONFIG_HOST_WINDOWS=y
  Select CONFIG_WINDOWS_MSYS=y
  Refreshing...
make: *** [tools/Makefile.unix:361: clean_context] Error 1

In the top-level README.txt, it says that you need to add this to the Make.defs file:

    ifeq ($(CONFIG_WINDOWS_MSYS),y)
      DIRLINK = $(TOPDIR)/tools/copydir.sh
      DIRUNLINK = $(TOPDIR)/tools/unlink.sh
    endif

Using copydir.sh instead of 'ln' will avoid using the MSYS 'ln' command when creating the link.  Instead, the link will be created as it is for Cygwin using an explicit 'cp -a' and the .fakelnk will be touched.

I don't think your change to link.sh is necessary if you follow the README.txt (certainly not if you use copydir.sh instead), but it also seems like a reasonable.thing to add so that people won't have to change their Make.defs file.

Greg

patacongo

unread,
Jun 29, 2018, 9:39:04 AM6/29/18
to NuttX

Tried as you suggested:
 
tools/configure.sh -g <board-name>/<config-dir>

 
Markus@VANTAGE MSYS ~/nuttxspace/nuttx/tools
$ ./configure.sh –g nucleo-l496zg/nsh
 
<board/config> defined twice

Odd.  That works fine for me using.

spuda@DESKTOP-7AO5MJM MSYS ~/projects/nuttx/master/nuttx
$ tools/configure.sh -g nucleo-l496zg/nsh

  Copy files
  Select CONFIG_HOST_WINDOWS=y
  Select CONFIG_WINDOWS_MSYS=y
  Refreshing...

spuda@DESKTOP-7AO5MJM MSYS ~/projects/nuttx/master/nuttx
$
 
include/arch/board already exists but is not a symbolic link
make: *** [tools/Makefile.unix:361: clean_context] Error 1

I committed a change to link.sh based on your recommendation that resolves this.  I did not check for uname -o == Msys, instead I added a check after the 'ln'.  If a directory was created instead of a symbolic link, then the .fakelnk was added.  Should be the same thing, but independent of environment.,

Thanks,

Greg

ma...@makr.zone

unread,
Jun 29, 2018, 9:51:57 AM6/29/18
to NuttX
Thanks for the reply.

The problem is that Make.defs is not yet there when configuring. And if I add it later, it is too late, the (faulty) links have already been made.

Markus@VANTAGE MSYS ~/nuttxspace

$ mv nuttx nuttx.bak

 

Markus@VANTAGE MSYS ~/nuttxspace

$ git clone https://bitbucket.org/nuttx/nuttx

Cloning into 'nuttx'...

remote: Counting objects: 375710, done.

remote: Compressing objects:  16% (13201/82505)

remote: Compressing objects: 100% (82505/82505), done.

fsReceiving objects:   8% (30057/375710), 5.25 MiB | 1.74 MiB/s

remote: Total 375710 (delta 292905), reused 355348 (delta 277815)

Receiving objects: 100% (375710/375710), 89.03 MiB | 3.12 MiB/s, done.

Resolving deltas: 100% (292905/292905), done.

Checking out files: 100% (10068/10068), done.

 

Markus@VANTAGE MSYS ~/nuttxspace

$ cd nuttx

 

Markus@VANTAGE MSYS ~/nuttxspace/nuttx

$ ls Make.defs

ls: cannot access 'Make.defs': No such file or directory


I really tried to read both nuttx/readme.txt and nuttx/tools/readme.txt and they only discuss the matter as if the Make.defs is there already.

I tried creating a Make.defs myself - doesn't work.

Markus@VANTAGE MSYS ~/nuttxspace/nuttx

$ git clean -fXd

Removing .config

Removing Make.defs

Removing arch/arm/src/board/

Removing configs/dummy/Kconfig

Removing include/arch/

 

Markus@VANTAGE MSYS ~/nuttxspace/nuttx

$ echo " DIRLINK = /home/Markus/nuttxspace/nuttx/tools/copydir.sh" > Make.defs

 

Markus@VANTAGE MSYS ~/nuttxspace/nuttx

$ tools/configure.sh nucleo-l496zg/nsh -g

  Copy files

  Select CONFIG_HOST_WINDOWS=y

  Select CONFIG_WINDOWS_MSYS=y

  Refreshing...

make[2]: board: Command not found

make[2]: *** [Makefile:119: board] Error 127

make[1]: *** [Makefile:115: dirlinks] Error 2

make: *** [tools/Makefile.unix:335: dirlinks] Error 2


I tried setting it as an environment variable: same result.

Need advice.

_Mark

ma...@makr.zone

unread,
Jun 29, 2018, 9:57:54 AM6/29/18
to NuttX
Ah I see my last response just crossed yours.

I committed a change to link.sh based on your recommendation that resolves this.  I did not check for uname -o == Msys, instead I added a check after the 'ln'.  If a directory was created instead of a symbolic link, then the .fakelnk was added.  Should be the same thing, but independent of environment.,


Very good, many thanks!

_Mark

patacongo

unread,
Jun 29, 2018, 10:02:16 AM6/29/18
to NuttX


The problem is that Make.defs is not yet there when configuring. And if I add it later, it is too late, the (faulty) links have already been made.

I don't see any problem with modifying the Make.defs BEFORE configuring to support new features.  That is what is is for.  You would need only to provide a patch to incorporate the change upstream.

ma...@makr.zone

unread,
Jun 29, 2018, 10:28:35 AM6/29/18
to NuttX
The problem is solved by your change:


Very good!

The Chicken-and-Egg problem that the Make.defs is actually created by the tools/configure.sh so it can obviously not be modified beforehand, does not apply any more.

Again, many thanks, this issue is SOLVED.

_Mark
Reply all
Reply to author
Forward
0 new messages