Add installboot(8) support for evbarm (and, in the future, other evb*)

boards that use u-boot.  A known board database lists boards and their
respective u-boot packages.  u-boot packages are discovered at run-time
(in /usr/pkg/share/u-boot, by default).  These packages contain board
database overlays that describe u-boot installation procedure that's
specific for that board.

Support this as a native tool and as a host tool.  The native tool
will attempt to determine the running board type using OpenFirmware
calls.  Host tool and native tool alike may also specify a board type
directly using the "-o board=xxx option" or have installboot(8) determine
the board type from a device tree blob using "-o dtb=/path/to/board.dtb".
A "-o media=xxx" option is provided for boards that have different u-boot
binaries and/or installation procedures for different media types (e.g.
SDMMC, eMMC, or USB).

This is trivial to extend to other evb* platforms that use u-boot, even if
they don't use FDT for autoconfiguration.
This commit is contained in:
thorpej 2019-05-07 05:02:41 +00:00
parent e5c09b191b
commit 02d67d1066
15 changed files with 2463 additions and 27 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.1203 2019/04/18 03:50:12 rin Exp $
# $NetBSD: mi,v 1.1204 2019/05/07 05:02:41 thorpej Exp $
#
# Note: Don't delete entries from here - mark them as "obsolete" instead,
# unless otherwise stated below.
@ -3054,6 +3054,9 @@
./usr/share/i18n/iconv base-sysutil-share
./usr/share/i18n/iconv/iconv.dir base-sysutil-share nls
./usr/share/info base-texinfo-share
./usr/share/installboot base-sysutil-share
./usr/share/installboot/evbarm base-sysutil-share
./usr/share/installboot/evbarm/boards.plist base-sysutil-share
./usr/share/keymaps base-sys-share
./usr/share/keymaps/amiga base-sys-share
./usr/share/keymaps/atari base-sys-share

View File

@ -1,4 +1,4 @@
# $NetBSD: NetBSD.dist.base,v 1.196 2019/04/18 03:50:12 rin Exp $
# $NetBSD: NetBSD.dist.base,v 1.197 2019/05/07 05:02:42 thorpej Exp $
# @(#)4.4BSD.dist 8.1 (Berkeley) 6/13/93
# Do not customize this file as it may be overwritten on upgrades.
@ -472,6 +472,8 @@
./usr/share/i18n/esdb/UTF
./usr/share/i18n/iconv
./usr/share/info
./usr/share/installboot
./usr/share/installboot/evbarm
./usr/share/keymaps
./usr/share/keymaps/amiga
./usr/share/keymaps/atari

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.35 2018/06/10 17:55:11 christos Exp $
# $NetBSD: Makefile,v 1.36 2019/05/07 05:02:42 thorpej Exp $
# from @(#)Makefile 8.1 (Berkeley) 6/5/93
# Missing: ms
@ -7,7 +7,7 @@
.if ${MKSHARE} != "no" || \
make(clean) || make(cleandir) || make(distclean) || make(obj)
SUBDIR= dict examples legal man me misc mk \
SUBDIR= dict examples installboot legal man me misc mk \
tabset terminfo tmac wscons xml
.if ${MKGROFF} != "no"

View File

@ -0,0 +1,9 @@
# $NetBSD: Makefile,v 1.1 2019/05/07 05:02:42 thorpej Exp $
.include <bsd.own.mk>
.if ${MKSHARE} != "no"
SUBDIR= evbarm
.endif
.include <bsd.subdir.mk>

View File

@ -0,0 +1,12 @@
# $NetBSD: Makefile,v 1.1 2019/05/07 05:02:42 thorpej Exp $
NOOBJ= # defined
.include <bsd.own.mk>
.if ${MKSHARE} != "no"
FILES= boards.plist
FILESDIR= /usr/share/installboot/evbarm
.endif
.include <bsd.prog.mk>

View File

@ -0,0 +1,337 @@
<!-- $NetBSD: boards.plist,v 1.1 2019/05/07 05:02:42 thorpej Exp $ -->
<!--
Copyright (c) 2019 The NetBSD Foundation, Inc.
All rights reserved.
This code is derived from software contributed to The NetBSD Foundation
by Jason R. Thorpe.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-->
<plist>
<dict>
<!--
-- amlogic boards
-->
<key>hardkernel,odroid-c2</key>
<dict>
<key>description</key>
<string>Hardkernel ODROID-C2</string>
<key>u-boot-pkg</key>
<string>odroid-c2</string>
</dict>
<key>libretech,cc</key>
<dict>
<key>description</key>
<string>Libre Computer Board AML-S905X-CC</string>
<key>u-boot-pkg</key>
<string>libretech-cc</string>
</dict>
<!--
-- exynos boards
-->
<key>hardkernel,odroid-xu3</key>
<dict>
<key>description</key>
<string>Hardkernel Odroid XU3</string>
<key>u-boot-pkg</key>
<string>odroid-xu3</string>
</dict>
<!--
-- rockchip boards
-->
<key>pine64,rockpro64</key>
<dict>
<key>description</key>
<string>Pine64 RockPro64</string>
<key>u-boot-pkg</key>
<string>rockpro64</string>
</dict>
<!--
-- mediatek boards
-->
<key>bananapi,bpi-r2</key>
<dict>
<key>description</key>
<string>Bananapi BPI-R2</string>
<key>u-boot-pkg</key>
<string>bananapi-r2</string>
</dict>
<!--
-- nvidia boards
-->
<key>nvidia,jetson-tk1</key>
<dict>
<key>description</key>
<string>NVIDIA Tegra124 Jetson TK1</string>
<key>u-boot-pkg</key>
<string>jetson-tk1</string>
</dict>
<key>nvidia,p2371-2180</key>
<dict>
<key>description</key>
<string>NVIDIA Jetson TX1 Developer Kit</string>
<key>u-boot-pkg</key>
<string>jetson-tx1</string>
</dict>
<key>nvidia,p2771-0000</key>
<dict>
<key>description</key>
<string>NVIDIA Tegra186 P2771-0000 Development Board</string>
<key>u-boot-pkg</key>
<string>jetson-tx2</string>
</dict>
<!--
-- omap boards
-->
<key>ti,omap3-beagle</key>
<dict>
<key>description</key>
<string>TI OMAP3 BeagleBoard</string>
<key>u-boot-pkg</key>
<string>beagleboard</string>
</dict>
<key>ti,am335x-bone</key>
<dict>
<key>description</key>
<string>TI AM335x BeagleBone</string>
<key>u-boot-pkg</key>
<string>beaglebonewhite</string>
</dict>
<key>ti,am335x-bone-black</key>
<dict>
<key>description</key>
<string>TI AM335x BeagleBone Black</string>
<key>u-boot-pkg</key>
<string>beagleboneblack</string>
</dict>
<!--
-- sunxi boards
-->
<!-- Banana Pi-branded board "compatible" strings are a mess.
We will just keep them all together here. -->
<key>lemaker,bananapi</key>
<dict>
<key>description</key>
<string>LeMaker Banana Pi</string>
<key>u-boot-pkg</key>
<string>bananapi</string>
</dict>
<key>sinovoip,bpi-m3</key>
<dict>
<key>description</key>
<string>Banana Pi BPI-M3</string>
<key>u-boot-pkg</key>
<string>bananapi-m3</string>
</dict>
<key>cubietech,cubieboard2</key>
<dict>
<key>description</key>
<string>Cubietech Cubieboard2</string>
<key>u-boot-pkg</key>
<string>cubieboard2</string>
</dict>
<key>cubietech,a80-cubieboard4</key>
<dict>
<key>description</key>
<string>Cubietech Cubieboard4</string>
<key>u-boot-pkg</key>
<string>cubieboard4</string>
</dict>
<key>cubietech,cubietruck</key>
<dict>
<key>description</key>
<string>Cubietech Cubietruck</string>
<key>u-boot-pkg</key>
<string>cubietruck</string>
</dict>
<key>cubietech,cubietruck-plus</key>
<dict>
<key>description</key>
<string>Cubietech Cubietruck Plus</string>
<key>u-boot-pkg</key>
<string>cubietruck_plus</string>
</dict>
<key>friendlyarm,nanopi-m1</key>
<dict>
<key>description</key>
<string>FriendlyArm NanoPi M1</string>
<key>u-boot-pkg</key>
<string>nanopi-m1</string>
</dict>
<key>friendlyarm,nanopi-neo</key>
<dict>
<key>description</key>
<string>FriendlyARM NanoPi NEO</string>
<key>u-boot-pkg</key>
<string>nanopi-neo</string>
</dict>
<key>friendlyarm,nanopi-neo-plus2</key>
<dict>
<key>description</key>
<string>FriendlyARM NanoPi NEO Plus2</string>
<key>u-boot-pkg</key>
<string>nanopi-neo-plus2</string>
</dict>
<key>friendlyarm,nanopi-neo2</key>
<dict>
<key>description</key>
<string>FriendlyARM NanoPi NEO 2</string>
<key>u-boot-pkg</key>
<string>nanopi-neo2</string>
</dict>
<key>merrii,a31-hummingbird</key>
<dict>
<key>description</key>
<string>Merrii A31 Hummingbird</string>
<key>u-boot-pkg</key>
<string>hummingbird-a31</string>
</dict>
<key>nextthing,chip</key>
<dict>
<key>description</key>
<string>NextThing C.H.I.P.</string>
<key>u-boot-pkg</key>
<string>chip</string>
</dict>
<key>nextthing,pocketchip</key>
<dict>
<key>description</key>
<string>NextThing PocketC.H.I.P.</string>
<key>u-boot-pkg</key>
<string>pocketchip</string>
</dict>
<key>nextthing,chip-pro</key>
<dict>
<key>description</key>
<string>NextThing C.H.I.P. Pro</string>
<key>u-boot-pkg</key>
<string>chip-pro</string>
</dict>
<key>olimex,a10-olinuxino-lime</key>
<dict>
<key>description</key>
<string>Olimex A10-OLinuXino-LIME</string>
<key>u-boot-pkg</key>
<string>a10-olinuxino-lime</string>
</dict>
<key>pine64,pine64-plus</key>
<dict>
<key>description</key>
<string>Pine64+</string>
<key>u-boot-pkg</key>
<string>pine64-plus</string>
</dict>
<key>pine64,pine64</key>
<dict>
<key>description</key>
<string>Pine64</string>
<key>u-boot-pkg</key>
<string>pine64</string>
</dict>
<key>pine64,pinebook</key>
<dict>
<key>description</key>
<string>Pinebook</string>
<key>u-boot-pkg</key>
<string>pinebook</string>
</dict>
<key>pine64,sopine-baseboard</key>
<dict>
<key>description</key>
<string>SoPine with baseboard</string>
<key>u-boot-pkg</key>
<string>sopine-baseboard</string>
</dict>
<key>pine64,pine64-lts</key>
<dict>
<key>description</key>
<string>Pine64 LTS</string>
<!-- Same u-boot as sopine-baseboard. -->
<key>u-boot-pkg</key>
<string>sopine-baseboard</string>
</dict>
<key>pine64,pine-h64</key>
<dict>
<key>description</key>
<string>Pine H64</string>
<key>u-boot-pkg</key>
<string>pine-h64</string>
</dict>
<key>terasic,de0-atlas</key>
<dict>
<key>description</key>
<string>Terasic DE-0(Atlas)</string>
<key>u-boot-pkg</key>
<string>de0-nanosoc</string>
</dict>
<key>xunlong,orangepi-2</key>
<dict>
<key>description</key>
<string>Xunlong Orange Pi 2</string>
<key>u-boot-pkg</key>
<string>orangepi-2</string>
</dict>
<key>xunlong,orangepi-one</key>
<dict>
<key>description</key>
<string>Xunlong Orange Pi One</string>
<key>u-boot-pkg</key>
<string>orangepi-one</string>
</dict>
<key>xunlong,orangepi-plus2e</key>
<dict>
<key>description</key>
<string>Xunlong Orange Pi Plus 2E</string>
<key>u-boot-pkg</key>
<string>orangepi-plus2e</string>
</dict>
<key>xunlong,orangepi-zero</key>
<dict>
<key>description</key>
<string>Xunlong Orange Pi Zero</string>
<key>u-boot-pkg</key>
<string>orangepi-zero</string>
</dict>
<key>xunlong,orangepi-zero-plus</key>
<dict>
<key>description</key>
<string>Xunlong Orange Pi Zero Plus</string>
<key>u-boot-pkg</key>
<string>orangepi-zero-plus</string>
</dict>
</dict>
</plist>

View File

@ -1,11 +1,40 @@
# $NetBSD: Makefile,v 1.11 2011/03/06 18:15:30 bouyer Exp $
# $NetBSD: Makefile,v 1.12 2019/05/07 05:02:42 thorpej Exp $
.include <bsd.hostinit.mk>
HOSTPROGNAME= ${_TOOL_PREFIX}installboot
HOST_SRCDIR= usr.sbin/installboot
LIBPROP_INC= ${.CURDIR}/../../common/include
HOST_CPPFLAGS+= -I${LIBPROP_INC}
HOST_CPPFLAGS+= -I. -I${.CURDIR} -I${.CURDIR}/../mips-elf2ecoff
HOST_CPPFLAGS+= -I${TOOLDIR}/include/nbinclude
HOST_CPPFLAGS+= -DEVBOARDS_PLIST_BASE=\"${TOOLDIR}\"
LIBPROP_OBJ!= cd ${.CURDIR}/../libprop && ${PRINTOBJDIR}
LDADD+= -L${LIBPROP_OBJ} -lprop
SHARE_SRCDIR= ${.CURDIR}/../../share
HOST_SHAREDIR= ${TOOLDIR}/share
BOARDDB_SRCDIR= ${SHARE_SRCDIR}/installboot
BOARDDB_DSTDIR= ${HOST_SHAREDIR}/installboot
BOARDDBS= evbarm
.for _d in ${BOARDDBS}
install: .PHONY install.${_d}.boards.plist
install.${_d}.boards.plist: .PHONY ${BOARDDB_DSTDIR}/${_d}/boards.plist
${BOARDDB_DSTDIR}/${_d}/boards.plist: ${BOARDDB_SRCDIR}/${_d}/boards.plist
${_MKTARGET_INSTALL}
${HOST_INSTALL_DIR} ${HOST_SHAREDIR}
${HOST_INSTALL_DIR} ${BOARDDB_DSTDIR}
${HOST_INSTALL_DIR} ${BOARDDB_DSTDIR}/${_d}
${HOST_INSTALL_FILE} -m ${NONBINMODE} ${.ALLSRC} ${.TARGET}
.endfor
.include "${.CURDIR}/../Makefile.nbincludes"
.include "${.CURDIR}/../Makefile.host"

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.51 2017/01/11 12:19:44 joerg Exp $
# $NetBSD: Makefile,v 1.52 2019/05/07 05:02:42 thorpej Exp $
#
.include <bsd.own.mk>
@ -11,9 +11,17 @@ ARCH_XLAT= amd64-i386.c news68k-news.c newsmips-news.c
ARCH_XLAT+= sun2-sun68k.c sun3-sun68k.c
.if !defined(SMALLPROG) && !defined(ARCH_FILES)
ARCH_FILES= alpha.c amiga.c emips.c ews4800mips.c hp300.c hppa.c i386.c
ARCH_FILES+= landisk.c macppc.c news.c next68k.c pmax.c
ARCH_FILES+= sparc.c sparc64.c sun68k.c vax.c x68k.c
ARCH_FILES= alpha.c amiga.c
ARCH_FILES+= emips.c evbarm.c ews4800mips.c
ARCH_FILES+= hp300.c hppa.c
ARCH_FILES+= i386.c
ARCH_FILES+= landisk.c
ARCH_FILES+= macppc.c
ARCH_FILES+= news.c next68k.c
ARCH_FILES+= pmax.c
ARCH_FILES+= sparc.c sparc64.c sun68k.c
ARCH_FILES+= vax.c
ARCH_FILES+= x68k.c
.else
ARCH_FILES?= ${ARCH_XLAT:M${MACHINE}-*:S/${MACHINE}-//}
.if empty(ARCH_FILES)
@ -23,8 +31,30 @@ ARCH_FILES= ${MACHINE}.c
SRCS+=${ARCH_FILES}
.if !empty(ARCH_FILES:C/(evbarm)/evboard/:Mevboard.c)
SRCS+=evboards.c
.endif
.if !empty(ARCH_FILES:C/(evbarm)/fdt/:Mfdt.c)
FDTDIR= ${.CURDIR}/../../sys/external/bsd/libfdt/dist
.PATH: ${FDTDIR}
CPPFLAGS+= -DSUPPORT_FDT -I${FDTDIR}
SRCS+=fdt.c fdt_ro.c fdt_strerror.c
# XXX libfdt has some sign-comparison issues
COPTS.fdt.c+= -Wno-error=sign-compare
COPTS.fdt_ro.c+= -Wno-error=sign-compare
COPTS.fdt_strerror.c+= -Wno-error=sign-compare
.endif
.if !defined(HOSTPROGNAME)
.if !empty(ARCH_FILES:C/(evbarm)/ofw/:Mofw.c)
CPPFLAGS+= -DSUPPORT_OPENFIRMWARE
.endif
.endif
.if empty(ARCH_FILES:C/(macppc|news|sparc|sun68k|x68k)/stg2/:Mstg2.c)
CPPFLAGS += -DNO_STAGE2
CPPFLAGS+= -DNO_STAGE2
.else
SRCS+= bbinfo.c
@ -47,6 +77,11 @@ CPPFLAGS+= -I${.CURDIR} -I.
COPTS.${f}.c+= -Wno-pointer-sign
.endfor
.if !empty(SRCS:Mevboards.c)
LDADD+= -lprop
DPADD+= ${LIBPROP}
.endif
LDADD+= -lutil
DPADD+= ${LIBUTIL}
.endif

View File

@ -0,0 +1,119 @@
/* $NetBSD: evbarm.c,v 1.1 2019/05/07 05:02:42 thorpej Exp $ */
/*-
* Copyright (c) 2019 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
#include <sys/cdefs.h>
#if !defined(__lint)
__RCSID("$NetBSD: evbarm.c,v 1.1 2019/05/07 05:02:42 thorpej Exp $");
#endif /* !__lint */
#include <err.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include "installboot.h"
#include "evboards.h"
static int evbarm_setboot(ib_params *);
static int evbarm_clearboot(ib_params *);
static int evbarm_editboot(ib_params *);
static void evbarm_usage(ib_params *);
struct ib_mach ib_mach_evbarm = {
.name = "evbarm",
.setboot = evbarm_setboot,
.clearboot = evbarm_clearboot,
.editboot = evbarm_editboot,
.usage = evbarm_usage,
.valid_flags = IB_BOARD | IB_DTB | IB_MEDIA,
.mach_flags = MF_UBOOT,
};
static int
evbarm_setboot(ib_params *params)
{
evb_board board;
int rv = 0;
if (!evb_db_load(params)) {
warnx("Unable to load board db.");
return 0;
}
board = evb_db_get_board(params);
if (board == NULL)
goto out;
rv = evb_uboot_setboot(params, board);
out:
if (params->mach_data) {
prop_object_release(params->mach_data);
params->mach_data = NULL;
}
return rv;
}
static int
evbarm_clearboot(ib_params *params)
{
return no_clearboot(params);
}
static int
evbarm_editboot(ib_params *params)
{
return no_editboot(params);
}
static void
evbarm_usage(ib_params *params)
{
if (!evb_db_load(params)) {
warnx("Unable to load board db.");
return;
}
fprintf(stderr, "Known boards (for -o board=...) are:\n");
evb_db_list_boards(params, stderr);
if (params->mach_data) {
prop_object_release(params->mach_data);
params->mach_data = NULL;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,65 @@
/* $NetBSD: evboards.h,v 1.1 2019/05/07 05:02:42 thorpej Exp $ */
/*-
* Copyright (c) 2019 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef installboot_evboards_h_included
#define installboot_evboards_h_included
#include <stdio.h>
#include <prop/proplib.h>
typedef prop_dictionary_t evb_board;
typedef prop_array_t evb_ubinstall;
typedef prop_object_iterator_t evb_ubsteps;
typedef prop_dictionary_t evb_ubstep;
bool evb_db_load(ib_params *);
evb_board evb_db_get_board(ib_params *);
void evb_db_list_boards(ib_params *, FILE *);
const char * evb_board_get_description(ib_params *, evb_board);
const char * evb_board_get_uboot_pkg(ib_params *, evb_board);
const char * evb_board_get_uboot_path(ib_params *, evb_board);
evb_ubinstall evb_board_get_uboot_install(ib_params *, evb_board);
prop_array_t evb_board_copy_uboot_media(ib_params *, evb_board);
evb_ubsteps evb_ubinstall_get_steps(ib_params *, evb_ubinstall);
evb_ubstep evb_ubsteps_next_step(ib_params *, evb_ubsteps);
const char * evb_ubstep_get_file_name(ib_params *, evb_ubstep);
uint64_t evb_ubstep_get_file_offset(ib_params *, evb_ubstep);
uint64_t evb_ubstep_get_file_size(ib_params *, evb_ubstep);
uint64_t evb_ubstep_get_image_offset(ib_params *, evb_ubstep);
bool evb_ubstep_preserves_partial_block(ib_params *, evb_ubstep);
int evb_uboot_setboot(ib_params *, evb_board);
#endif /* installboot_evboards_h_included */

View File

@ -1,6 +1,6 @@
.\" $NetBSD: installboot.8,v 1.95 2017/08/15 21:21:18 wiz Exp $
.\" $NetBSD: installboot.8,v 1.96 2019/05/07 05:02:42 thorpej Exp $
.\"
.\" Copyright (c) 2002-2017 The NetBSD Foundation, Inc.
.\" Copyright (c) 2002-2019 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd March 14, 2017
.Dd May 5, 2019
.Dt INSTALLBOOT 8
.Os
.Sh NAME
@ -132,6 +132,28 @@ other platforms:
.Sy next68k .
.El
.Pp
Some platforms, typically embedded system platforms, are umbrella platforms
that support many different individual board types, each with their own
boot loader binary and installation procedure requirements.
On these platforms, it may be necessary to provide specific board type
information to
.Nm .
Information about known boards and their requirements is loaded from a
database at run-time.
Sometimes these platforms also require the use of 3rd-party boot loader
software, such as
.Sy U-boot .
To support these platforms,
.Nm
scans known locations for these 3rd-party boot loader packages for
database overlays that contain additional board-specific boot loader
installation information in a file called
.Sq installboot.plist .
.Pp
The following platforms have this requirement and utilize this database
overlay feature:
.Sy evbarm .
.Pp
The options and arguments recognized by
.Nm
are as follows:
@ -202,6 +224,7 @@ The following machines are currently supported by
.Sy alpha ,
.Sy amd64 ,
.Sy amiga ,
.Sy evbarm ,
.Sy ews4800mips ,
.Sy hp300 ,
.Sy hppa ,
@ -250,6 +273,15 @@ to the end of
.Ar filesystem ,
which must be a regular file in this case.
.
.It Sy board=<board name>
.Sy [ evbarm ]
Specify the board type used to determine the correct boot loader image
and installation procedure.
If omitted,
.Nm
will attempt to guess the board type based on system information if run
natively.
.
.It Sy bootconf
.Sy [ amd64 ,
.Sy i386 ]
@ -267,6 +299,18 @@ Modify the default boot command line.
Set the console device, <console name> must be one of:
pc, com0, com1, com2, com3, com0kbd, com1kbd, com2kbd, com3kbd or auto.
.
.It Sy dtb=<path to dtb file>
.Sy [ evbarm ]
Attempt to determine the board type from information in the device tree
blob file at <path to dtb file>.
If both
.Sy board
and
.Sy dtb
optios are specified,
.Sy board
takes precendence.
.
.It Sy ioaddr=<ioaddr>
.Sy [ amd64 ,
.Sy i386 ]
@ -285,6 +329,16 @@ would swap the lowercase letters
and
.Sq z .
.
.It Sy media=<media type>
.Sy [ evbarm ]
Some boards require a different boot loader binary and/or installation
procedure depending on what type of media will be used to boot the system.
For such boards, this option is required, and omitting it will display a
usage message that lists the valid media types for the board.
For boards that do not require special media handling, this option is
not allowed.
Common values: sdmmc, emmc, usb.
.
.It Sy modules
.Sy [ amd64 ,
.Sy i386 ]
@ -418,6 +472,21 @@ uses the following environment variables:
.
.Bl -tag -width "MACHINE"
.
.It Ev INSTALLBOOT_UBOOT_PATHS
A colon-separated list of search paths to scan for
.Sy U-boot
packages with
.Nm installboot
installation overlays.
If multiple overlays are found, overlays from paths closer to the front
of the list take precensence.
If not specified, the default path is
.Pa /usr/pkg/share/u-boot .
This environment variable is only used on platforms that support
using
.Sy U-boot :
.Sy evbarm .
.
.It Ev MACHINE
Default value for
.Ar machine ,
@ -525,6 +594,30 @@ is not found.
.
.El
.
.Ss Nx Ns /evbarm files
The
.Nx Ns /evbarm
platform covers a wide variety of board types, many of which use
.Sy U-boot .
Running
.Nm
with no options will display a list of known boards.
Using the verbose option will also display information about which
.Sy U-boot
package needs to be installed to support that board, and if the required
.Sy U-boot
package is installed, the path at which it is located.
.Bl -tag -width /usr/pkg/share/u-boot
.It Pa /usr/pkg/share/u-boot
The default location scanned for
.Sy U-boot
packages with installation overlays.
.It Pa /usr/share/installboot/evbarm/boards.plist
Base board database, used to provide information about which
.Sy U-boot
package is required for a given board.
.El
.
.Ss Nx Ns /evbmips files
.
The
@ -649,6 +742,27 @@ Modify the command line to change the default from "netbsd -ASn2" to
"netbsd -S":
.Dl Ic installboot -m amiga -o command="netbsd -S" /dev/rsd0a /usr/mdec/bootxx_ffs
.
.Ss Nx Ns /evbarm
Install the
.Sy U-boot
boot loader for a Pinebook into an image that will be written to
an SDMMC card:
.Dl Ic installboot -m evbarm -o board=pine64,pinebook arm64.img
.Pp
Install / update the
.Sy U-boot
boot loader for the current running system on the eMMC device
.Sq ld0
and display verbose information about the procedure:
.Dl Ic installboot -v /dev/rld0c
.Pp
Install a specific
.Sy U-boot
package for a BeagleBone Black into an image that will be written
to an SDMMC card:
.Dl Ic installboot -m evbarm -o board=ti,am335x-bone-black armv7.img \
/path/to/experimental/u-boot/package
.
.Ss Nx Ns /ews4800mips
Install the System V Boot File System primary bootstrap on to disk
.Sq sd0 ,

View File

@ -1,4 +1,4 @@
/* $NetBSD: installboot.c,v 1.39 2015/07/25 10:37:22 mlelstv Exp $ */
/* $NetBSD: installboot.c,v 1.40 2019/05/07 05:02:42 thorpej Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if !defined(__lint)
__RCSID("$NetBSD: installboot.c,v 1.39 2015/07/25 10:37:22 mlelstv Exp $");
__RCSID("$NetBSD: installboot.c,v 1.40 2019/05/07 05:02:42 thorpej Exp $");
#endif /* !__lint */
#include <sys/param.h>
@ -56,6 +56,7 @@ __RCSID("$NetBSD: installboot.c,v 1.39 2015/07/25 10:37:22 mlelstv Exp $");
#endif
#include "installboot.h"
#include "evboards.h"
static void getmachine(ib_params *, const char *, const char *);
static void getfstype(ib_params *, const char *, const char *);
@ -92,6 +93,9 @@ const struct option {
{ "timeout", IB_TIMEOUT, OPT_INT, OFFSET(timeout) },
{ "modules", IB_MODULES, OPT_BOOL, 0 },
{ "bootconf", IB_BOOTCONF, OPT_BOOL, 0 },
{ "board", IB_BOARD, OPT_STRING, OFFSET(board) },
{ "dtb", IB_DTB, OPT_STRING, OFFSET(dtb) },
{ "media", IB_MEDIA, OPT_WORD, OFFSET(media) },
{ .name = NULL },
};
#undef OFFSET
@ -280,16 +284,32 @@ main(int argc, char *argv[])
}
}
assert(params->machine != NULL);
if (argc >= 2) {
if ((params->s1fd = open(argv[1], O_RDONLY, 0600)) == -1)
err(1, "Opening primary bootstrap `%s'", argv[1]);
if (fstat(params->s1fd, &params->s1stat) == -1)
err(1, "Examining primary bootstrap `%s'", argv[1]);
if (!S_ISREG(params->s1stat.st_mode))
errx(1, "`%s' must be a regular file", argv[1]);
if (!S_ISREG(params->s1stat.st_mode)) {
/*
* If the platform uses u-boot, then the stage1
* spec might be the directory where the u-boot
* binaries for the system are located.
*/
if (params->machine->mach_flags & MF_UBOOT) {
if (!S_ISDIR(params->s1stat.st_mode)) {
errx(1, "`%s' must be a regular file "
"or a directory", argv[1]);
}
(void) close(params->s1fd);
params->s1fd = -1;
} else {
errx(1, "`%s' must be a regular file", argv[1]);
}
}
params->stage1 = argv[1];
}
assert(params->machine != NULL);
if (params->flags & IB_VERBOSE) {
printf("File system: %s\n", params->filesystem);
@ -299,9 +319,11 @@ main(int argc, char *argv[])
params->fstype->name, params->fstype->blocksize,
params->fstype->needswap);
if (!(params->flags & IB_EDIT))
printf("Primary bootstrap: %s\n",
printf("Primary bootstrap: %s%s\n",
(params->flags & IB_CLEAR) ? "(to be cleared)"
: params->stage1 ? params->stage1 : "(none)" );
: params->stage1 ? params->stage1 : "(none)",
S_ISDIR(params->s1stat.st_mode) ? " (directory)"
: "");
if (params->stage2 != NULL)
printf("Secondary bootstrap: %s\n", params->stage2);
}
@ -313,9 +335,18 @@ main(int argc, char *argv[])
op = "Clear";
rv = params->machine->clearboot(params);
} else {
if (argc < 2)
errx(EXIT_FAILURE, "Please specify the primary "
"bootstrap file");
if (argc < 2) {
/*
* If the platform uses u-boot, then the stage1 spec is
* optional iff they specified a board (because we can
* infer a default location for u-boot binaries if the
* board type is given).
*/
if (!(params->machine->mach_flags & MF_UBOOT)) {
errx(EXIT_FAILURE,
"Please specify the primary bootstrap file");
}
}
op = "Set";
rv = params->machine->setboot(params);
}
@ -332,7 +363,7 @@ main(int argc, char *argv[])
}
if (close(params->fsfd) == -1)
err(1, "Closing file system `%s'", params->filesystem);
if (argc == 2)
if (params->s1fd != -1)
if (close(params->s1fd) == -1)
err(1, "Closing primary bootstrap `%s'",
params->stage1);
@ -585,5 +616,8 @@ usage(void)
machine_usage();
fstype_usage();
options_usage();
if (installboot_params.machine != NULL &&
installboot_params.machine->usage != NULL)
installboot_params.machine->usage(&installboot_params);
exit(1);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: installboot.h,v 1.39 2014/02/24 07:23:44 skrll Exp $ */
/* $NetBSD: installboot.h,v 1.40 2019/05/07 05:02:42 thorpej Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -67,8 +67,19 @@ typedef enum {
IB_CONSADDR = 1<<20, /* i386 console io address */
IB_MODULES = 1<<21, /* i386: load modules */
IB_BOOTCONF = 1<<22, /* i386: read boot.conf */
IB_BOARD = 1<<23, /* evb*: board specification */
IB_DTB= 1<<24, /* evb*: device tree blob */
/* IB_MEDIA is required for some evb*, but not all. */
IB_MEDIA = 1<<25, /* evb*: boot media type */
} ib_flags;
typedef enum {
MF_UBOOT = 1<<0, /* platform (maybe) uses u-boot */
} m_flags;
typedef struct {
ib_flags flags; /* flags (see above) */
struct ib_mach *machine; /* machine details (see below) */
@ -91,6 +102,12 @@ typedef struct {
const char *password; /* boot password */
int timeout; /* interactive boot timeout */
const char *keymap; /* keyboard translations */
const char *board; /* board specification */
const char *dtb; /* dtb specification */
const char *media; /* boot media type */
/* temporary working data */
void *mach_data; /* platform-specific data */
} ib_params;
typedef struct {
@ -103,7 +120,9 @@ struct ib_mach {
int (*setboot) (ib_params *);
int (*clearboot) (ib_params *);
int (*editboot) (ib_params *);
void (*usage) (ib_params *);
ib_flags valid_flags;
m_flags mach_flags;
};
struct ib_fs {
@ -165,6 +184,7 @@ int ext2fs_findstage2(ib_params *, uint32_t *, ib_block *);
extern struct ib_mach ib_mach_alpha;
extern struct ib_mach ib_mach_amd64;
extern struct ib_mach ib_mach_amiga;
extern struct ib_mach ib_mach_evbarm;
extern struct ib_mach ib_mach_ews4800mips;
extern struct ib_mach ib_mach_hp300;
extern struct ib_mach ib_mach_hppa;

View File

@ -1,4 +1,4 @@
/* $NetBSD: machines.c,v 1.39 2014/02/24 07:23:44 skrll Exp $ */
/* $NetBSD: machines.c,v 1.40 2019/05/07 05:02:42 thorpej Exp $ */
/*-
* Copyright (c) 2002-2005 The NetBSD Foundation, Inc.
@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if !defined(__lint)
__RCSID("$NetBSD: machines.c,v 1.39 2014/02/24 07:23:44 skrll Exp $");
__RCSID("$NetBSD: machines.c,v 1.40 2019/05/07 05:02:42 thorpej Exp $");
#endif /* !__lint */
#include <sys/types.h>
@ -51,6 +51,7 @@ struct ib_mach
ib_mach_amd64,
ib_mach_amiga,
ib_mach_emips,
ib_mach_evbarm,
ib_mach_ews4800mips,
ib_mach_hp300,
ib_mach_hppa,
@ -73,6 +74,7 @@ struct ib_mach * const machines[] = {
&ib_mach_amd64,
&ib_mach_amiga,
&ib_mach_emips,
&ib_mach_evbarm,
&ib_mach_ews4800mips,
&ib_mach_hp300,
&ib_mach_hppa,