# Anyone using FreeBSD?

**URL:** <https://forum.openwrt.org/t/anyone-using-freebsd/31320>\
**Category:** For Developers\
**Created:** [February 13, 2019, 11:41pm UTC](https://forum.openwrt.org/t/anyone-using-freebsd/31320 "2019-02-13T23:41:16Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![balanga](https://forum.openwrt.org/letter_avatar/balanga/32/6_449c533f586939b6e5f246632a46421f.png) [@balanga](https://forum.openwrt.org/u/balanga)\
**Post date:** [February 13, 2019, 11:41pm UTC](https://forum.openwrt.org/t/anyone-using-freebsd/31320/1 "2019-02-13T23:41:16Z")

</div>

I've put together a OpenWrt build system for FreeBSD, but am not really familiar with how it works.

If anyone is using FreeBSD, would you be able to test my system?

I have a small script which installs it so there is no need to read any instructions.

I will post it here if anyone is interested.

---

<div class="post-metadata">

**Author:** ![anon50098793](https://forum.openwrt.org/letter_avatar/anon50098793/32/6_449c533f586939b6e5f246632a46421f.png) [@anon50098793](https://forum.openwrt.org/u/anon50098793)\
**Post date:** [February 14, 2019, 7:25am UTC](https://forum.openwrt.org/t/anyone-using-freebsd/31320/2 "2019-02-14T07:25:40Z")

</div>

Happy to test for you / us.

---

<div class="post-metadata">

**Author:** ![balanga](https://forum.openwrt.org/letter_avatar/balanga/32/6_449c533f586939b6e5f246632a46421f.png) [@balanga](https://forum.openwrt.org/u/balanga)\
**Post date:** [February 14, 2019, 10:13am UTC](https://forum.openwrt.org/t/anyone-using-freebsd/31320/3 "2019-02-14T10:13:40Z")

</div>

Here is my script - it could do with some refinement but it does create the build system (at least for me)

```
pkg bootstrap -y

# Install required pkgs

cat <<EOF | xargs pkg install -y
git
bash
gmake
gtar
gcc
gawk
ncurses
findutils
patch
wget
getopt
coreutils
EOF

# Build and install GNU time
#
#wget https://ftp.gnu.org/gnu/time/time-1.9.tar.gz
#tar zxf time-1.9.tar.gz
#cd time-1.9
#./configure
#make
#make install
#mv /usr/local/bin/time /usr/local/bin/gtime

# Install OpenWrt Build System

mkdir ~/OpenWrt-BuildSystem
cd ~/OpenWrt-BuildSystem
git clone https://github.com/openwrt/openwrt.git
cd openwrt

# patch mkhash.c

wget 'https://bugs.openwrt.org/index.php?getfile=292' -O patchfile
patch scripts/mkhash.c -i patchfile -o scripts/mkhash.c

# Let's go!!!

./scripts/feeds update -a
./scripts/feeds install -a

make menuconfig

```

Any feedback appreciated.

---

<div class="post-metadata">

**Author:** ![jeff](https://forum.openwrt.org/letter_avatar/jeff/32/6_449c533f586939b6e5f246632a46421f.png) [@jeff](https://forum.openwrt.org/u/jeff)\
**Post date:** [February 14, 2019, 2:00pm UTC](https://forum.openwrt.org/t/anyone-using-freebsd/31320/4 "2019-02-14T14:00:22Z")

</div>

I’d suggest doing it in a jail, as some of the GNU variants can break other operations in unexpected ways.

User will likely need to be running bash, not just in the path.

Some fancy linking will likely be needed to run binutils, dtc, and the like for development work. Same for mounting and manipulation of file systems, especially on FreeBSD 11 and prior.

---

<div class="post-metadata">

**Author:** ![diizzy](https://forum.openwrt.org/letter_avatar/diizzy/32/6_449c533f586939b6e5f246632a46421f.png) [@diizzy](https://forum.openwrt.org/u/diizzy)\
**Post date:** [February 14, 2019, 2:06pm UTC](https://forum.openwrt.org/t/anyone-using-freebsd/31320/5 "2019-02-14T14:06:37Z")

</div>

Agreed, don't mess with /usr/\* dirs at all.  
As jeff points out you'll most likely have more fun down the road...

---

<div class="post-metadata">

**Author:** ![balanga](https://forum.openwrt.org/letter_avatar/balanga/32/6_449c533f586939b6e5f246632a46421f.png) [@balanga](https://forum.openwrt.org/u/balanga)\
**Post date:** [February 14, 2019, 2:18pm UTC](https://forum.openwrt.org/t/anyone-using-freebsd/31320/6 "2019-02-14T14:18:02Z")

</div>

All FreeBSD pkgs get installed under /usr/local, so not really sure what the problem is.

---

<div class="post-metadata">

**Author:** ![jeff](https://forum.openwrt.org/letter_avatar/jeff/32/6_449c533f586939b6e5f246632a46421f.png) [@jeff](https://forum.openwrt.org/u/jeff)\
**Post date:** [February 14, 2019, 2:54pm UTC](https://forum.openwrt.org/t/anyone-using-freebsd/31320/7 "2019-02-14T14:54:04Z")

</div>

Then do yourself a favor in advance and only try this on a throw-away VM or in a dedicated jail. Getting the wrong binary during a system critical operation cal lead you into a world of hurt. `/rescue/` may soon become a familiar place for you.

---

<div class="post-metadata">

**Author:** ![jeff](https://forum.openwrt.org/letter_avatar/jeff/32/6_449c533f586939b6e5f246632a46421f.png) [@jeff](https://forum.openwrt.org/u/jeff)\
**Post date:** [February 14, 2019, 6:25pm UTC](https://forum.openwrt.org/t/anyone-using-freebsd/31320/8 "2019-02-14T18:25:01Z")

</div>

Fails updating packages -- `/bin/sh: mkhash: not found`

```
[jeff@freebsd-12 ~/devel/openwrt]$ freebsd-version 
12.0-RELEASE-p3

```

Unmodified `/etc/pkg/FreeBSD.conf`

OpenWrt `master` branch

> **./scripts/feeds update packages**
>
> ```
> [jeff@freebsd-12 ~/devel/openwrt]$ ./scripts/feeds update packages
> Updating feed 'packages' from 'https://git.openwrt.org/feed/packages.git' ...
> Already up to date.
> Create index file './feeds/packages.index' 
> Checking 'working-make'... ok.
> Checking 'case-sensitive-fs'... ok.
> Checking 'proper-umask'... ok.
> Checking 'gcc'... ok.
> Checking 'working-gcc'... ok.
> Checking 'g++'... ok.
> Checking 'working-g++'... ok.
> Checking 'ncurses'... ok.
> Checking 'perl-thread-queue'... ok.
> Checking 'tar'... ok.
> Checking 'find'... ok.
> Checking 'bash'... ok.
> Checking 'patch'... ok.
> Checking 'diff'... ok.
> Checking 'cp'... ok.
> Checking 'seq'... ok.
> Checking 'awk'... ok.
> Checking 'grep'... ok.
> Checking 'getopt'... ok.
> Checking 'stat'... ok.
> Checking 'unzip'... ok.
> Checking 'bzip2'... ok.
> Checking 'wget'... ok.
> Checking 'perl'... ok.
> Checking 'python'... ok.
> Checking 'git'... ok.
> Checking 'file'... ok.
> Prerequisite check failed. Use FORCE=1 to override.
> gmake: *** [/usr/home/jeff/devel/openwrt/include/toplevel.mk:168: staging_dir/host/.prereq-build] Error 1
> /bin/sh: mkhash: not found
> /bin/sh: mkhash: not found
> 
> ```

---

<div class="post-metadata">

**Author:** ![anon50098793](https://forum.openwrt.org/letter_avatar/anon50098793/32/6_449c533f586939b6e5f246632a46421f.png) [@anon50098793](https://forum.openwrt.org/u/anon50098793)\
**Post date:** [February 14, 2019, 8:34pm UTC](https://forum.openwrt.org/t/anyone-using-freebsd/31320/9 "2019-02-14T20:34:11Z")

</div>

Pretty nasty.... I think we can safely say 11 is out the window....

after mkhash....

xz is broken, xzdec ( websearch stdendian.h ) + is not happy with the automake version!

then some success;

flock \<\> m4macros ( 5ish )

glib iconv errors....

```
gconvert.c:61:2: error: #error GNU libiconv not in use but included iconv.h is from libiconv
 #error GNU libiconv not in use but included iconv.h is from libiconv
  ^ ~~~~
gmake[11]: *** [Makefile:1373: libglib_2_0_la-gconvert.lo] Error 1

```

Your right though.... does get the build system partly going 🙂

frisbee12 might fair better?

---

<div class="post-metadata">

**Author:** ![diizzy](https://forum.openwrt.org/letter_avatar/diizzy/32/6_449c533f586939b6e5f246632a46421f.png) [@diizzy](https://forum.openwrt.org/u/diizzy)\
**Post date:** [February 14, 2019, 11:08pm UTC](https://forum.openwrt.org/t/anyone-using-freebsd/31320/10 "2019-02-14T23:08:40Z")

</div>

...or use bhyve with Debian or Alpine Linux instead 😉  
Alpine feels a lot snappier than Debian but might be placebo.

---

<div class="post-metadata">

**Author:** ![balanga](https://forum.openwrt.org/letter_avatar/balanga/32/6_449c533f586939b6e5f246632a46421f.png) [@balanga](https://forum.openwrt.org/u/balanga)\
**Post date:** [February 14, 2019, 11:16pm UTC](https://forum.openwrt.org/t/anyone-using-freebsd/31320/11 "2019-02-14T23:16:26Z")

</div>

> [@jeff](#):
>
> Fails updating packages -- `/bin/sh: mkhash: not found`

From my script above....

> # patch mkhash.c
> 
> wget '[https://bugs.openwrt.org/index.php?getfile=292](https://bugs.openwrt.org/index.php?getfile=292)' -O patchfile  
> patch scripts/mkhash.c -i patchfile -o scripts/mkhash.c

---

<div class="post-metadata">

**Author:** ![balanga](https://forum.openwrt.org/letter_avatar/balanga/32/6_449c533f586939b6e5f246632a46421f.png) [@balanga](https://forum.openwrt.org/u/balanga)\
**Post date:** [February 14, 2019, 11:18pm UTC](https://forum.openwrt.org/t/anyone-using-freebsd/31320/12 "2019-02-14T23:18:47Z")

</div>

Not sure what you are doing.. it builds fine on 11 here.

Did you run my script?

---

<div class="post-metadata">

**Author:** ![tmomas](https://forum.openwrt.org/letter_avatar/tmomas/32/6_449c533f586939b6e5f246632a46421f.png) [@tmomas](https://forum.openwrt.org/u/tmomas)\
**Post date:** [February 15, 2019, 8:17am UTC](https://forum.openwrt.org/t/anyone-using-freebsd/31320/13 "2019-02-15T08:17:58Z")

</div>

@balanga Please use "Preformatted text \</\>" for logs, scripts, configs and general console output.  
 ![grafik](https://forum.openwrt.org/uploads/default/original/2X/3/3396953c05b720cafad6df6dec38534c63580b9e.png)

---

<div class="post-metadata">

**Author:** ![balanga](https://forum.openwrt.org/letter_avatar/balanga/32/6_449c533f586939b6e5f246632a46421f.png) [@balanga](https://forum.openwrt.org/u/balanga)\
**Post date:** [November 22, 2021, 6:14pm UTC](https://forum.openwrt.org/t/anyone-using-freebsd/31320/14 "2021-11-22T18:14:57Z")

</div>

After getting frustrated with my TP-LINK Archer MR200 v4 being unreliable I thought I'd try installing OpenWrt on it after seeing that an image was available:-

> **[TP-Link Archer MR200 v1](https://openwrt.org/toh/tp-link/archer_mr200?datasrt=%5Efirmware%20openwrt%20install%20url#installation)**
>
> TP-Link Archer MR200 v1 LTE Dual band router with 4 fast (100mbps) ethernet ports. It is similar to Archer C20i and C50 \[Archer MR200 v1\] Supported Versions Hardware Highlights Installation Flash Layout Layer0 raw flash, 8192KiB

Unfortunately I didn't notice that this is only available for v1 of the device, so I'm looking for a v4 image, which I will have to build myself, so I'm checking if my FreeBSD OpenWrt build system still works. It's over 3 years since I last tried so I'm just seeing if it needs updating.

It looks like I no longer need GNU time, although I'm not sure if mkhash.c needs patching.

One error which crept in was the check for 'getopt' failed although it was OK three years ago.

Another error was the check for 'rsync' which passed earlier today but then failed. Not sure if that could have been due to the process running in a jail.

Any comments would be appreciated.

---

<div class="post-metadata">

**Author:** ![balanga](https://forum.openwrt.org/letter_avatar/balanga/32/6_449c533f586939b6e5f246632a46421f.png) [@balanga](https://forum.openwrt.org/u/balanga)\
**Post date:** [November 22, 2021, 6:44pm UTC](https://forum.openwrt.org/t/anyone-using-freebsd/31320/15 "2021-11-22T18:44:06Z")

</div>

Looks like I omitted 'rsync' from my list of required apps. I was under the impression that it was part of the standard FreeBSD installation, but it looks as though I had already installed it previously when I put my script together.

So, as @jeff pointed out, I should have originally tested in a jail environment, which I am now doing.

---

<div class="post-metadata">

**Author:** ![balanga](https://forum.openwrt.org/letter_avatar/balanga/32/6_449c533f586939b6e5f246632a46421f.png) [@balanga](https://forum.openwrt.org/u/balanga)\
**Post date:** [November 23, 2021, 1:10am UTC](https://forum.openwrt.org/t/anyone-using-freebsd/31320/16 "2021-11-23T01:10:50Z")

</div>

Unfortunately I installed Midnight Commander before anything else which pulled in diffutils which is another pkg which ought to be added to the list of pkgs in a pristine environment.

---

<div class="post-metadata">

**Author:** ![p055877632](https://forum.openwrt.org/user_avatar/forum.openwrt.org/p055877632/32/35016_2.png) [@p055877632](https://forum.openwrt.org/u/p055877632)\
**Post date:** [November 23, 2021, 2:35am UTC](https://forum.openwrt.org/t/anyone-using-freebsd/31320/17 "2021-11-23T02:35:51Z")

</div>

why not use linux

---

<div class="post-metadata">

**Author:** ![balanga](https://forum.openwrt.org/letter_avatar/balanga/32/6_449c533f586939b6e5f246632a46421f.png) [@balanga](https://forum.openwrt.org/u/balanga)\
**Post date:** [November 23, 2021, 10:42am UTC](https://forum.openwrt.org/t/anyone-using-freebsd/31320/18 "2021-11-23T10:42:12Z")

</div>

I prefer using FreeBSD whenever I can. Linux is not an OS, it's a distribution of various apps into some flavour, all of which are different from each other without some consistancy as you can see from this list:-

> **[Build system setup](https://openwrt.org/docs/guide-developer/toolchain/install-buildsystem)**
>
> Build system setup \* Assuming a GNU/Linux environment, otherwise see alternative guides. \* Install Git to download the source code, and your distro's default build tools metapackage to do the cross-compilation process. \* You may also need to...

---

<div class="post-metadata">

**Author:** ![balanga](https://forum.openwrt.org/letter_avatar/balanga/32/6_449c533f586939b6e5f246632a46421f.png) [@balanga](https://forum.openwrt.org/u/balanga)\
**Post date:** [December 2, 2021, 1:40am UTC](https://forum.openwrt.org/t/anyone-using-freebsd/31320/19 "2021-12-02T01:40:09Z")

</div>

After revisiting my script and updating FreeBSD to 13.0-RELEASE I am left with one outstanding error, namely

```
Checking 'getopt'... failed.

```

Can anyone suggest why this may be failing?

My updated script consists of:-

```
pkg bootstrap -y

# Install required pkgs

cat <<EOF | xargs pkg install -y
git
rsync
bash
gmake
gtar
gcc
gawk
ncurses
findutils
diffutils
patch
wget
getopt
coreutils
EOF

# Install OpenWrt Build System

mkdir ~/OpenWrt-BuildSystem2
cd ~/OpenWrt-BuildSystem2
git clone https://github.com/openwrt/openwrt.git
cd openwrt

# Let's go!!!

./scripts/feeds update -a
./scripts/feeds install -a

make menuconfig

```

If anyone has access to a FreeBSD system could you check this out?

---

<div class="post-metadata">

**Author:** ![slh](https://forum.openwrt.org/user_avatar/forum.openwrt.org/slh/32/113591_2.png) [@slh](https://forum.openwrt.org/u/slh)\
**Post date:** [December 2, 2021, 1:47am UTC](https://forum.openwrt.org/t/anyone-using-freebsd/31320/20 "2021-12-02T01:47:44Z")

</div>

> <https://github.com/openwrt/openwrt/blob/master/include/prereq-build.mk#L129>

Check if your getopt meets those conditions, or if you have to teach the system about another one (different path ordering).

[Next page](https://forum.openwrt.org/t/anyone-using-freebsd/31320.md?page=2)
