# EMC2/LinuxCNC Port Or Package



## fbn (Mar 25, 2012)

FreeBSD'ers,

*H*ow far has anybody gotten with porting LinuxCNC (used to be EMC2) to FreeBSD? *C*urrently it's 'pre-packaged' with Ubuntu. *I* like PC-BSD/FreeBSD better! 

Have A Nice Day!


----------



## trasz@ (Jun 26, 2016)

I'm working on it.  It's running fine, although in simulation-only mode for now.  I'm slowly pushing my changes to the upstream, and will follow up with a proper port soon.


----------



## Phishfry (Aug 25, 2016)

trasz@
Had a chance to test the cad/linuxcnc-devel port tonight and it loaded to the configuration selector. Looks Good. Build took quite a while.
You know the next question. When do we get more than simulaton..
Actually porting over the realtime stuff must have been fun.

Great Job. When I get a chance I want to test this on ARM. Will it build??

Dell E6430/3612QM/16GB/128GB SSD/FreeBSD11-RC1-amd64


----------



## SirDice (Aug 25, 2016)

Phishfry said:


> When I get a chance I want to test this on ARM. Will it build??


Not sure, not tested it myself, but looking at the dependencies I see no reason why it shouldn't build.


----------



## trasz@ (Aug 26, 2016)

Not sure, I'm afraid; other stuff in life took precedence.  Yeah, I think it should work on ARM.


----------



## Phishfry (Aug 26, 2016)

I see on LinuxCNC forums where people are overclocking their Raspberry Pi to get it to perform better. So it is scraping on the low end of hardware requirements. I will stick with x86.

Would be nice to get this working with FreeBSD GPIO's.


----------



## Phishfry (Aug 27, 2016)

Well I fired off a `make install clean` tonight on a RaspberryPi2. It took over 1 hour on a Ivy Bridge quad. So I am guessing 20-30 hours on Arm.

I am just discovering SSH's flexibility and it is great.


----------



## Phishfry (Aug 28, 2016)

Well it failed after 8 hours compiling on RPi2. Was worth a try.


```
getarch_2nd.c:47:37: error: use of undeclared identifier
  'DGEMM_DEFAULT_UNROLL_N'
  printf("ZGEMM3M_UNROLL_N=%d\n", DGEMM_DEFAULT_UNROLL_N);
  ^
12 errors generated.
gmake[10]: *** [Makefile.prebuild:46: getarch_2nd] Error 1
Makefile:127: *** OpenBLAS: Detecting CPU failed. Please set TARGET explicitly,  e.g. make TARGET=your_cpu_target. Please read README for the detail..  Stop.
gmake[10]: Leaving directory '/usr/ports/math/openblas/work/OpenBLAS-0.2.18'
*** Error code 2

Stop.
make[9]: stopped in /usr/ports/math/openblas
*** Error code 1

Stop.
make[8]: stopped in /usr/ports/math/openblas
*** Error code 1

Stop.
make[7]: stopped in /usr/ports/math/suitesparse
*** Error code 1

Stop.
make[6]: stopped in /usr/ports/math/suitesparse
*** Error code 1

Stop.
make[5]: stopped in /usr/ports/math/py-numpy
*** Error code 1

Stop.
make[4]: stopped in /usr/ports/math/py-numpy
*** Error code 1

Stop.
make[3]: stopped in /usr/ports/graphics/py-PyOpenGL
*** Error code 1

Stop.
make[2]: stopped in /usr/ports/graphics/py-PyOpenGL
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/x11-toolkits/py-gtkglext
*** Error code 1

Stop.
make: stopped in /usr/ports/cad/linuxcnc-devel
```


----------



## Phishfry (Aug 28, 2016)

I tried using TARGET=ARMV6 in the math/openblas makefile. It appears the makefile uses a "DYNAMIC_ARCH" structure.


----------



## Phishfry (Aug 28, 2016)

Oh my bad. Instead  of adding TARGET=ARMV6 to the Makefile,
It needed `make TARGET=ARMV6 BINARY=32`

https://github.com/xianyi/OpenBLAS/blob/develop/TargetList.txt


----------



## Phishfry (Aug 28, 2016)

I give up on building this on Arm. Was worth a shot.


```
../kernel/arm/iamax_vfp.S../kernel/arm/iamax_vfp.S::339339::26../kernel/arm/iamax_vf  p.S: :339:26: error: error: unknown directive
unknown directive
  ..aarrmm ; . g;l o.bgalolb asmax_lk  s;m i.nf_ukn c;  s.mfauxn_k ;smc smin_27k : ;  serror: min_k:
  unknown directive
  a.xa  _ k :
 ^
  ^
rm ; .global samax_k ; .func samax_k ;samax_k:
  ^
gmake[3]: *** [Makefile.L1:538: smax_k.o] Error 1
gmake[3]: *** Waiting for unfinished jobs....
gmake[3]: *** [Makefile.L1:549: smin_k.o] Error 1
gmake[3]: *** [Makefile.L1:498: samax_k.o] Error 1
../kernel/arm/iamax_vfp.S:339:27: error: unknown directive
 .arm ; .global samin_k ; .func samin_k ;samin_k:
  ^
gmake[3]: *** [Makefile.L1:518: samin_k.o] Error 1
gmake[3]: Leaving directory '/usr/ports/math/openblas/work/OpenBLAS-0.2.18/kernel'
gmake[2]: *** [Makefile:138: libs] Error 1
gmake[2]: Leaving directory '/usr/ports/math/openblas/work/OpenBLAS-0.2.18'
*** Error code 2

Stop.
make[1]: stopped in /usr/ports/math/openblas
*** Error code 1

Stop.
make: stopped in /usr/ports/math/openblas
root@rpi2:/usr/ports/math/openblas #
```


----------



## acheron (Aug 28, 2016)

If I remember correctly you need lang/gcc to build openblas on armv6.


----------



## Phishfry (Aug 28, 2016)

How does this look?

```
root@rpi2:/usr/ports/math/openblas/work # gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc48/gcc/armv6-portbld-freebsd11.0/4.8.5/lto-wrapper
Target: armv6-portbld-freebsd11.0
Configured with: /usr/ports/lang/gcc/work/gcc-4.8.5/configure --disable-multilib --disable-bootstrap --disable-nls --enable-gnu-indirect-function --libdir=/usr/local/lib/gcc48 --libexecdir=/usr/local/libexec/gcc48 --program-suffix=48 --with-as=/usr/local/bin/as --with-gmp=/usr/local --with-gxx-include-dir=/usr/local/lib/gcc48/include/c++/ --with-ld=/usr/local/bin/ld --with-pkgversion='FreeBSD Ports Collection' --with-system-zlib --disable-libgcj --enable-languages=c,c++,objc,fortran --prefix=/usr/local --localstatedir=/var --mandir=/usr/local/man --infodir=/usr/local/info/gcc48 --build=armv6-portbld-freebsd11.0
Thread model: posix
gcc version 4.8.5 (FreeBSD Ports Collection)
```


----------



## Phishfry (Aug 28, 2016)

I have plenty of 3 COM port x86 platforms to run this on. They would be more appropriate anyway.
Lets not waste any more time on it.

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=207287


----------

