Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Dec 2014 18:33:20 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r374545 - in head/sysutils/u-boot-rpi: . files
Message-ID:  <201412111833.sBBIXK6S097553@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Thu Dec 11 18:33:19 2014
New Revision: 374545
URL: https://svnweb.freebsd.org/changeset/ports/374545
QAT: https://qat.redports.org/buildarchive/r374545/

Log:
  Customized version of uboot for RPi, with extra files for boot
  images.
  
  Submitted by: ian@

Added:
  head/sysutils/u-boot-rpi/
  head/sysutils/u-boot-rpi/Makefile   (contents, props changed)
  head/sysutils/u-boot-rpi/distinfo   (contents, props changed)
  head/sysutils/u-boot-rpi/files/
  head/sysutils/u-boot-rpi/files/imgprefix.bin.gz   (contents, props changed)
  head/sysutils/u-boot-rpi/files/patch-api_api.c   (contents, props changed)
  head/sysutils/u-boot-rpi/files/patch-common_cmd__nvedit.c   (contents, props changed)
  head/sysutils/u-boot-rpi/files/patch-common_cmd__test.c   (contents, props changed)
  head/sysutils/u-boot-rpi/files/patch-config.mk   (contents, props changed)
  head/sysutils/u-boot-rpi/files/patch-include_configs_rpi__b.h   (contents, props changed)
  head/sysutils/u-boot-rpi/pkg-descr   (contents, props changed)

Added: head/sysutils/u-boot-rpi/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/u-boot-rpi/Makefile	Thu Dec 11 18:33:19 2014	(r374545)
@@ -0,0 +1,52 @@
+# $FreeBSD$
+
+PORTNAME=	u-boot
+PORTVERSION=	2013.01
+CATEGORIES=	sysutils
+PKGNAMESUFFIX=	-rpi
+DISTNAME=	u-boot-${PORTVERSION}-${GH_ACCOUNT}-${GH_PROJECT}
+
+MAINTAINER=	ian@FreeBSD.org
+COMMENT=	Cross-build U-Boot loader for Raspberry Pi
+
+LICENSE=	GPLv2
+
+BUILD_DEPENDS=  arm-none-eabi-gcc:${PORTSDIR}/devel/arm-none-eabi-gcc \
+		gsed:${PORTSDIR}/textproc/gsed
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	gonzoua
+GH_PROJECT=	u-boot-pi
+GH_COMMIT=	6709570
+GH_TAGNAME=	${GH_COMMIT}
+
+NO_ARCH=	yes
+
+WRKSRC=		${WRKDIR}/${GH_ACCOUNT}-${GH_PROJECT}-${GH_TAGNAME}
+USES=		gmake
+SSP_UNSAFE=	yes # cross-build static linking dies with -fstack-protector
+
+U_BOOT_DIR=	share/u-boot/${PORTNAME}${PKGNAMESUFFIX}
+PLIST_DIRS=	${U_BOOT_DIR} share/u-boot
+PLIST_FILES=	${U_BOOT_DIR}/uboot.img \
+		${U_BOOT_DIR}/README
+
+MAKE_ARGS+=	ARCH=arm \
+		CROSS_COMPILE=arm-none-eabi- \
+		HOSTCC=cc \
+		SED=gsed
+
+do-configure:
+	(cd ${WRKSRC}; ${GMAKE} ${MAKE_ARGS} rpi_b_config)
+
+# The output of the u-boot build process is u-boot.bin.  We have to put a
+# standard (for the RPi) image header on the front of it, and the resulting
+# file is named uboot.img (without a dash for historical reasons).
+IMGFILE=${STAGEDIR}/${PREFIX}/${U_BOOT_DIR}/uboot.img
+do-install:
+	${MKDIR} ${STAGEDIR}/${PREFIX}/${U_BOOT_DIR}
+	${GZCAT} ${FILESDIR}/imgprefix.bin.gz >${IMGFILE}
+	${CAT} ${WRKSRC}/u-boot.bin >>${IMGFILE}
+	${CP} ${.CURDIR}/pkg-descr ${STAGEDIR}/${PREFIX}/${U_BOOT_DIR}/README
+
+.include <bsd.port.mk>

Added: head/sysutils/u-boot-rpi/distinfo
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/u-boot-rpi/distinfo	Thu Dec 11 18:33:19 2014	(r374545)
@@ -0,0 +1,2 @@
+SHA256 (u-boot-2013.01-gonzoua-u-boot-pi.tar.gz) = 29a0d6ffa952483adf37d066bc1823f5f0d62e6534829d6190e9880ef9354f42
+SIZE (u-boot-2013.01-gonzoua-u-boot-pi.tar.gz) = 13850640

Added: head/sysutils/u-boot-rpi/files/imgprefix.bin.gz
==============================================================================
Binary file. No diff available.

Added: head/sysutils/u-boot-rpi/files/patch-api_api.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/u-boot-rpi/files/patch-api_api.c	Thu Dec 11 18:33:19 2014	(r374545)
@@ -0,0 +1,79 @@
+--- api/api.c.orig	2012-11-28 01:28:06 UTC
++++ api/api.c
+@@ -512,45 +512,47 @@ static int API_env_set(va_list ap)
+  */
+ static int API_env_enum(va_list ap)
+ {
+-	int i, n;
+-	char *last, **next;
++	int i;
++	char *last, **next, *s;
++	ENTRY *match, search;
++	static char *buf;
+ 
+ 	last = (char *)va_arg(ap, u_int32_t);
+ 
+ 	if ((next = (char **)va_arg(ap, u_int32_t)) == NULL)
+ 		return API_EINVAL;
+ 
+-	if (last == NULL)
+-		/* start over */
+-		*next = ((char *)env_get_addr(0));
+-	else {
+-		*next = last;
+-
+-		for (i = 0; env_get_char(i) != '\0'; i = n + 1) {
+-			for (n = i; env_get_char(n) != '\0'; ++n) {
+-				if (n >= CONFIG_ENV_SIZE) {
+-					/* XXX shouldn't we set *next = NULL?? */
+-					return 0;
+-				}
+-			}
+-
+-			if (envmatch((uchar *)last, i) < 0)
+-				continue;
+-
+-			/* try to get next name */
+-			i = n + 1;
+-			if (env_get_char(i) == '\0') {
+-				/* no more left */
+-				*next = NULL;
+-				return 0;
+-			}
+-
+-			*next = ((char *)env_get_addr(i));
+-			return 0;
++	/*
++	 * This leverages realloc's behavior of growing but never shrinking the
++	 * existing buffer.
++	 */
++	if (last == NULL) {
++		i = 0;
++		buf = realloc(buf, 512); /* Start with reasonable size buf. */
++	} else {
++		buf = realloc(buf, strlen(last) + 1);
++		strcpy(buf, last);
++		if ((s = strchr(buf, '=')) != NULL)
++		     *s = 0;
++		search.key = buf;
++		if ((i = hsearch_r(search, FIND, &match, &env_htab)) == 0) {
++			i = API_EINVAL;
++			goto done;
+ 		}
+ 	}
+ 
++	/* hmatch on empty string is effectively "get next entry after i". */
++	if ((i = hmatch_r("", i, &match, &env_htab)) == 0)
++		goto done;
++	buf = realloc(buf, strlen(match->key) + strlen(match->data) + 2);
++	snprintf(buf, buflen, "%s=%s", match->key, match->data);
++	*next = buf;
+ 	return 0;
++done:
++	free(buf);
++	buf = NULL;
++	*next = NULL;
++	return i;
+ }
+ 
+ /*

Added: head/sysutils/u-boot-rpi/files/patch-common_cmd__nvedit.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/u-boot-rpi/files/patch-common_cmd__nvedit.c	Thu Dec 11 18:33:19 2014	(r374545)
@@ -0,0 +1,46 @@
+--- common/cmd_nvedit.c.orig	2012-11-28 01:28:06 UTC
++++ common/cmd_nvedit.c
+@@ -966,6 +966,23 @@ sep_err:
+ }
+ #endif
+ 
++#if defined(CONFIG_CMD_ENV_EXISTS)
++static int do_env_exists(cmd_tbl_t *cmdtp, int flag, int argc,
++		       char * const argv[])
++{
++	ENTRY e, *ep;
++
++	if (argc < 2)
++		return CMD_RET_USAGE;
++
++	e.key = argv[1];
++	e.data = NULL;
++	hsearch_r(e, FIND, &ep, &env_htab);
++
++	return (ep == NULL) ? 1 : 0;
++}
++#endif
++
+ /*
+  * New command line interface: "env" command with subcommands
+  */
+@@ -995,6 +1012,9 @@ static cmd_tbl_t cmd_env_sub[] = {
+ 	U_BOOT_CMD_MKENT(save, 1, 0, do_env_save, "", ""),
+ #endif
+ 	U_BOOT_CMD_MKENT(set, CONFIG_SYS_MAXARGS, 0, do_env_set, "", ""),
++#if defined(CONFIG_CMD_ENV_EXISTS)
++	U_BOOT_CMD_MKENT(exists, 2, 0, do_env_exists, "", ""),
++#endif
+ };
+ 
+ #if defined(CONFIG_NEEDS_MANUAL_RELOC)
+@@ -1033,6 +1053,9 @@ static char env_help_text[] =
+ #if defined(CONFIG_CMD_EDITENV)
+ 	"env edit name - edit environment variable\n"
+ #endif
++#if defined(CONFIG_CMD_ENV_EXISTS)
++	"env exists name - tests for existence of variable\n"
++#endif
+ #if defined(CONFIG_CMD_EXPORTENV)
+ 	"env export [-t | -b | -c] [-s size] addr [var ...] - export environment\n"
+ #endif

Added: head/sysutils/u-boot-rpi/files/patch-common_cmd__test.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/u-boot-rpi/files/patch-common_cmd__test.c	Thu Dec 11 18:33:19 2014	(r374545)
@@ -0,0 +1,19 @@
+--- common/cmd_test.c.orig	2012-11-28 01:28:06 UTC
++++ common/cmd_test.c
+@@ -29,9 +29,14 @@ static int do_test(cmd_tbl_t *cmdtp, int
+ 	char * const *ap;
+ 	int left, adv, expr, last_expr, neg, last_cmp;
+ 
+-	/* args? */
+-	if (argc < 3)
++	/*
++	 * If no args, that's bogus, return false.
++	 * If op is -z and no other args, answer is Yes, string is empty.
++	 */
++	if (argc < 2)
+ 		return 1;
++	else if (argc == 2)
++		return !(strcmp(argv[1], "-z") == 0);
+ 
+ #ifdef DEBUG
+ 	{

Added: head/sysutils/u-boot-rpi/files/patch-config.mk
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/u-boot-rpi/files/patch-config.mk	Thu Dec 11 18:33:19 2014	(r374545)
@@ -0,0 +1,11 @@
+--- config.mk.orig	2012-11-28 01:28:06 UTC
++++ config.mk
+@@ -90,7 +90,7 @@ HOSTCC		 = $(call os_x_before, 10, 5, "c
+ HOSTCFLAGS	+= $(call os_x_before, 10, 4, "-traditional-cpp")
+ HOSTLDFLAGS	+= $(call os_x_before, 10, 5, "-multiply_defined suppress")
+ else
+-HOSTCC		= gcc
++HOSTCC		?= gcc
+ endif
+ 
+ ifeq ($(HOSTOS),cygwin)

Added: head/sysutils/u-boot-rpi/files/patch-include_configs_rpi__b.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/u-boot-rpi/files/patch-include_configs_rpi__b.h	Thu Dec 11 18:33:19 2014	(r374545)
@@ -0,0 +1,60 @@
+--- include/configs/rpi_b.h.orig	2012-11-28 01:28:06 UTC
++++ include/configs/rpi_b.h
+@@ -183,4 +183,57 @@
+ #define CONFIG_INITRD_TAG
+ #define CONFIG_CMD_BMP
+ 
++/*****************************************************************************
++ * FreeBSD customizations from here down.
++ ****************************************************************************/
++
++//#define CONFIG_API
++//#define CONFIG_CMD_ELF
++#define CONFIG_CMD_ENV_EXISTS
++#define CONFIG_EFI_PARTITION
++#define CONFIG_PREBOOT
++
++/* Save the env to the fat partition. */
++#undef  CONFIG_ENV_IS_NOWHERE
++#define CONFIG_ENV_IS_IN_FAT
++#define CONFIG_FAT_WRITE
++#define FAT_ENV_INTERFACE	"mmc"
++#define FAT_ENV_DEVICE		0
++#define FAT_ENV_PART		1
++#define FAT_ENV_FILE		"uboot.env"
++#define CONFIG_CMD_SAVEENV
++
++/* Create a small(ish) boot environment for FreeBSD. */
++#undef  CONFIG_EXTRA_ENV_SETTINGS
++#define CONFIG_EXTRA_ENV_SETTINGS \
++	"bootfile=ubldr\0" \
++	"fatdev=mmc 0:1\0" \
++	"loaderdev=disk\0" \
++	"stdin=serial\0" \
++	"stderr=serial,lcd\0" \
++	"stdout=serial,lcd\0" \
++	"uenv_file=uEnv.txt\0" \
++	\
++	"fatboot=" \
++	  "env exists user_fatboot && run user_fatboot; " \
++	  "fatload ${fatdev} ${loadaddr} ${bootfile} && bootelf; " \
++	"\0" \
++	"netboot=" \
++	  "env exists ethact || usb start; " \
++	  "env exists user_netboot && run user_netboot; " \
++	  "dhcp ${loadaddr} ${bootfile} && bootelf; " \
++	"\0" \
++	"preboot=" \
++	  "fdt addr 0x100; " \
++	  "env exists uenv_import && run uenv_import; " \
++	  "env exists user_preboot && run user_preboot; " \
++	"\0" \
++	"uenv_import=" \
++	  "fatload ${fatdev} ${loadaddr} ${uenv_file} && " \
++	    "env import -t ${loadaddr} ${filesize}; " \
++	"\0"
++
++#undef  CONFIG_BOOTCOMMAND
++#define CONFIG_BOOTCOMMAND "run fatboot"
++
+ #endif

Added: head/sysutils/u-boot-rpi/pkg-descr
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/u-boot-rpi/pkg-descr	Thu Dec 11 18:33:19 2014	(r374545)
@@ -0,0 +1,14 @@
+U-Boot loader for Raspberry Pi
+
+To install this bootloader, copy the file uboot.img to the FAT parition
+on an SD card.  Other files (not part of this package) are also required.
+
+This version is patched so that:
+ * ELF and API features are enabled.
+ * The default environment is trimmed to just what's needed to boot.
+ * The saveenv command writes to the file uboot.env on the FAT partition.
+
+For information about running FreeBSD on RaspberryPi, see
+WWW: http://wiki.freebsd.org/FreeBSD/arm/Raspberry%20Pi
+
+For general information about U-Boot see WWW: http://www.denx.de/wiki/U-Boot



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201412111833.sBBIXK6S097553>