# "Bad system call" while building release



## tuaris (Oct 13, 2020)

I'm trying to create an image for the Orange Pi One by following the tutorial on how to build images for arm devices using FreeBSD's release building infrastructure.  The host system is: 


```
12.1-RELEASE-p10 FreeBSD 12.1-RELEASE-p10 GENERIC  amd64
```

The sources under /usr/src


```
svn info
Path: .
Working Copy Root Path: /usr/src
URL: https://svn.freebsd.org/base/releng/12.1
Relative URL: ^/releng/12.1
Repository Root: https://svn.freebsd.org/base
Repository UUID: ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Revision: 366623
Node Kind: directory
Schedule: normal
Last Changed Author: gordon
Last Changed Rev: 365782
Last Changed Date: 2020-09-15 17:48:24 -0400 (Tue, 15 Sep 2020)
```

My configuration file is /usr/src/release/arm/ORANGEPI-ONE.conf and contains the following:


```
#!/bin/sh
#
# $FreeBSD: releng/12.1/release/arm/ORANGEPI-ONE.conf 336998 2018-07-31 19:12:31Z manu $
#

EMBEDDED_TARGET_ARCH="armv7"
EMBEDDED_TARGET="arm"
EMBEDDEDBUILD=1
EMBEDDEDPORTS="sysutils/u-boot-orangepi-one"
FAT_SIZE="50m -b 1m"
FAT_TYPE="16"
IMAGE_SIZE="3072M"
KERNEL="GENERIC-NODEBUG"
MD_ARGS="-x 63 -y 255"
NODOC=1
PART_SCHEME="MBR"
export BOARDNAME="ORANGEPI-ONE"
SRCBRANCH="base/releng/12.1@366623"

arm_install_uboot() {
    UBOOT_DIR="/usr/local/share/u-boot/u-boot-orangepi-one"
    UBOOT_FILES="u-boot-sunxi-with-spl.bin"
    chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/${UBOOT_FILES} \
        of=/dev/${mddev} bs=1k seek=8 conv=sync

    return 0
}
```

I have the corresponding sysutils/u-boot-orangepi-one package installed on the host:


```
pkg info u-boot-orangepi-one
u-boot-orangepi-one-2020.07
Name           : u-boot-orangepi-one
Version        : 2020.07
Installed on   : Sun Oct 11 01:34:56 2020 EDT
Origin         : sysutils/u-boot-orangepi-one
Architecture   : FreeBSD:12:*
Prefix         : /usr/local
Categories     : sysutils
Licenses       : GPLv2
Maintainer     : uboot@FreeBSD.org
WWW            : https://www.denx.de/wiki/U-Boot
Comment        : Cross-build das u-boot for model orangepi-one
Annotations    :
Flat size      : 892KiB
Description    :
U-Boot loader for OrangePi One.
```

I start the build using sh release.sh -c arm/ORANGEPI-ONE.conf and it starts checking out a copy of the sources under /scratch/usr/src:


```
svn info
Path: .
Working Copy Root Path: /scratch/usr/src
URL: svn://svn.freebsd.org/base/releng/12.1
Relative URL: ^/releng/12.1
Repository Root: svn://svn.freebsd.org/base
Repository UUID: ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Revision: 366623
Node Kind: directory
Schedule: normal
Last Changed Author: gordon
Last Changed Rev: 365782
Last Changed Date: 2020-09-15 17:48:24 -0400 (Tue, 15 Sep 2020)
```

It appears to be building correctly, but few hours later it fails with a "Bad system call" error:


```
...
===> usr.sbin/wlandebug (installconfig)
--- installconfig_subdir_usr.sbin/wpa ---
===> usr.sbin/wpa (installconfig)
--- installconfig_subdir_usr.sbin/wpa/wpa_supplicant ---
===> usr.sbin/wpa/wpa_supplicant (installconfig)
--- installconfig_subdir_usr.sbin/wpa/wpa_cli ---
===> usr.sbin/wpa/wpa_cli (installconfig)
--- installconfig_subdir_usr.sbin/wpa/wpa_passphrase ---
===> usr.sbin/wpa/wpa_passphrase (installconfig)
--- installconfig_subdir_usr.sbin/wpa/hostapd ---
===> usr.sbin/wpa/hostapd (installconfig)
--- installconfig_subdir_usr.sbin/wpa/hostapd_cli ---
===> usr.sbin/wpa/hostapd_cli (installconfig)
--- installconfig_subdir_usr.sbin/wpa/ndis_events ---
===> usr.sbin/wpa/ndis_events (installconfig)
ELF ldconfig path: /lib /usr/lib /usr/lib/compat
32-bit compatibility ldconfig path: /usr/lib32
===>  Deinstalling for u-boot-orangepi-one
/bin/sh: /usr/local/sbin/pkg-static: not found
===>   u-boot-orangepi-one not installed, skipping
===>  License GPLv2 accepted by the user
===>   u-boot-orangepi-one-2020.07 depends on file: /usr/local/sbin/pkg - not found
===>  Installing for pkg-1.15.10
===>   Registering installation for pkg-1.15.10
pkg-static: Warning: Major OS version upgrade detected.  Running "pkg bootstrap -f" recommended
Child process pid=98664 terminated abnormally: Bad system call
*** Error code 140

Stop.
make[2]: stopped in /usr/ports/ports-mgmt/pkg
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/ports-mgmt/pkg
*** Error code 1

Stop.
make: stopped in /usr/ports/sysutils/u-boot-orangepi-one
```

I used this same system to sucesfully build an image using Crotchet (with some tweaks), but that tool appears to be no longer maintained. Which is why I would like to be able to build using the release building infrastructure.


----------

