aboutsummaryrefslogtreecommitdiff
path: root/sysutils/u-boot-rpi
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2014-12-11 18:33:19 +0000
committerWarner Losh <imp@FreeBSD.org>2014-12-11 18:33:19 +0000
commit9388dd9bfc8d3e1b1bc63c9522de07d5bc6ebbf9 (patch)
tree5f99f59687c6a25736f628fa1745473cb20e795a /sysutils/u-boot-rpi
parentc2e8b2cfe22f36042ecd69bbfd62c737447c3c43 (diff)
Notes
Diffstat (limited to 'sysutils/u-boot-rpi')
-rw-r--r--sysutils/u-boot-rpi/Makefile52
-rw-r--r--sysutils/u-boot-rpi/distinfo2
-rw-r--r--sysutils/u-boot-rpi/files/imgprefix.bin.gzbin0 -> 147 bytes
-rw-r--r--sysutils/u-boot-rpi/files/patch-api_api.c79
-rw-r--r--sysutils/u-boot-rpi/files/patch-common_cmd__nvedit.c46
-rw-r--r--sysutils/u-boot-rpi/files/patch-common_cmd__test.c19
-rw-r--r--sysutils/u-boot-rpi/files/patch-config.mk11
-rw-r--r--sysutils/u-boot-rpi/files/patch-include_configs_rpi__b.h60
-rw-r--r--sysutils/u-boot-rpi/pkg-descr14
9 files changed, 283 insertions, 0 deletions
diff --git a/sysutils/u-boot-rpi/Makefile b/sysutils/u-boot-rpi/Makefile
new file mode 100644
index 000000000000..619702ea176d
--- /dev/null
+++ b/sysutils/u-boot-rpi/Makefile
@@ -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>
diff --git a/sysutils/u-boot-rpi/distinfo b/sysutils/u-boot-rpi/distinfo
new file mode 100644
index 000000000000..e08c12827292
--- /dev/null
+++ b/sysutils/u-boot-rpi/distinfo
@@ -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
diff --git a/sysutils/u-boot-rpi/files/imgprefix.bin.gz b/sysutils/u-boot-rpi/files/imgprefix.bin.gz
new file mode 100644
index 000000000000..ee4aad9fb806
--- /dev/null
+++ b/sysutils/u-boot-rpi/files/imgprefix.bin.gz
Binary files differ
diff --git a/sysutils/u-boot-rpi/files/patch-api_api.c b/sysutils/u-boot-rpi/files/patch-api_api.c
new file mode 100644
index 000000000000..aac103b5d63c
--- /dev/null
+++ b/sysutils/u-boot-rpi/files/patch-api_api.c
@@ -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;
+ }
+
+ /*
diff --git a/sysutils/u-boot-rpi/files/patch-common_cmd__nvedit.c b/sysutils/u-boot-rpi/files/patch-common_cmd__nvedit.c
new file mode 100644
index 000000000000..fdabe585e567
--- /dev/null
+++ b/sysutils/u-boot-rpi/files/patch-common_cmd__nvedit.c
@@ -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
diff --git a/sysutils/u-boot-rpi/files/patch-common_cmd__test.c b/sysutils/u-boot-rpi/files/patch-common_cmd__test.c
new file mode 100644
index 000000000000..64a4d185dd96
--- /dev/null
+++ b/sysutils/u-boot-rpi/files/patch-common_cmd__test.c
@@ -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
+ {
diff --git a/sysutils/u-boot-rpi/files/patch-config.mk b/sysutils/u-boot-rpi/files/patch-config.mk
new file mode 100644
index 000000000000..320f14b6e9bf
--- /dev/null
+++ b/sysutils/u-boot-rpi/files/patch-config.mk
@@ -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)
diff --git a/sysutils/u-boot-rpi/files/patch-include_configs_rpi__b.h b/sysutils/u-boot-rpi/files/patch-include_configs_rpi__b.h
new file mode 100644
index 000000000000..79c358de84e0
--- /dev/null
+++ b/sysutils/u-boot-rpi/files/patch-include_configs_rpi__b.h
@@ -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
diff --git a/sysutils/u-boot-rpi/pkg-descr b/sysutils/u-boot-rpi/pkg-descr
new file mode 100644
index 000000000000..2a14fdc249d5
--- /dev/null
+++ b/sysutils/u-boot-rpi/pkg-descr
@@ -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