Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Jul 2016 15:06:14 +0000 (UTC)
From:      Pawel Pekala <pawel@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r418324 - in head/sysutils: . u-boot-olimex-a20-som-evb u-boot-olimex-a20-som-evb/files
Message-ID:  <201607101506.u6AF6E2O002355@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pawel
Date: Sun Jul 10 15:06:14 2016
New Revision: 418324
URL: https://svnweb.freebsd.org/changeset/ports/418324

Log:
  U-Boot loader for Olimex A20 SOM EVB.
  
  To install this bootloader, follow the instructions in
   http://linux-sunxi.org/Bootable_SD_card#Bootloader
  
  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 u-boot.env on the FAT partition.
   * The DTB file name is chosen based on the board model and passed to ubldr.bin
     using the fdtfile env variable. ubldr.bin loads the DTB from /boot/dtb/ on
     the FreeBSD partition.
   * By default, it loads PIE ubldr.bin from file ubldr.bin on the FAT partition
     to address 0x42000000, and launches it.
  
  For information about running FreeBSD on Cubieboard, see
   https://wiki.freebsd.org/FreeBSD/arm/Allwinner
  
  For general information about U-Boot see WWW: http://www.denx.de/wiki/U-Boot
  
  PR:		210625
  Submitted by:	manu

Added:
  head/sysutils/u-boot-olimex-a20-som-evb/
  head/sysutils/u-boot-olimex-a20-som-evb/Makefile   (contents, props changed)
  head/sysutils/u-boot-olimex-a20-som-evb/distinfo   (contents, props changed)
  head/sysutils/u-boot-olimex-a20-som-evb/files/
  head/sysutils/u-boot-olimex-a20-som-evb/files/patch-api_api.c   (contents, props changed)
  head/sysutils/u-boot-olimex-a20-som-evb/files/patch-api_api__net.c   (contents, props changed)
  head/sysutils/u-boot-olimex-a20-som-evb/files/patch-cmd_elf.c   (contents, props changed)
  head/sysutils/u-boot-olimex-a20-som-evb/files/patch-cmd_test.c   (contents, props changed)
  head/sysutils/u-boot-olimex-a20-som-evb/files/patch-include_configs_sunxi-common.h   (contents, props changed)
  head/sysutils/u-boot-olimex-a20-som-evb/pkg-descr   (contents, props changed)
Modified:
  head/sysutils/Makefile

Modified: head/sysutils/Makefile
==============================================================================
--- head/sysutils/Makefile	Sun Jul 10 14:48:57 2016	(r418323)
+++ head/sysutils/Makefile	Sun Jul 10 15:06:14 2016	(r418324)
@@ -1092,6 +1092,7 @@
     SUBDIR += u-boot-cubieboard2
     SUBDIR += u-boot-cubox-hummingboard
     SUBDIR += u-boot-duovero
+    SUBDIR += u-boot-olimex-a20-som-evb
     SUBDIR += u-boot-pandaboard
     SUBDIR += u-boot-pine64
     SUBDIR += u-boot-rpi

Added: head/sysutils/u-boot-olimex-a20-som-evb/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/u-boot-olimex-a20-som-evb/Makefile	Sun Jul 10 15:06:14 2016	(r418324)
@@ -0,0 +1,58 @@
+# $FreeBSD$
+
+PORTNAME=	u-boot
+PORTVERSION=	${UBOOT_VERSION}
+CATEGORIES=	sysutils
+MASTER_SITES=	ftp://ftp.denx.de/pub/u-boot/
+PKGNAMESUFFIX?=	-${MODEL}
+
+MAINTAINER=	manu@FreeBSD.org
+COMMENT=	Cross-build U-Boot loader for olimex-a20-som-evb
+
+LICENSE=	GPLv2
+
+BUILD_DEPENDS=	arm-none-eabi-gcc:devel/arm-none-eabi-gcc
+
+UBOOT_VERSION?=	2016.05
+BOARD_CONFIG?=	A20-Olimex-SOM-EVB_defconfig
+MODEL?=		olimex-a20-som-evb
+
+NO_ARCH=	yes
+
+WRKSRC=		${WRKDIR}/u-boot-${DISTVERSION}
+USES=		gmake tar:bzip2
+SSP_UNSAFE=	yes # cross-LD does not support -fstack-protector
+
+U_BOOT_DIR=	share/u-boot/${PORTNAME}${PKGNAMESUFFIX}
+PLIST_FILES=	${U_BOOT_DIR}/u-boot.img \
+		${U_BOOT_DIR}/u-boot-sunxi-with-spl.bin \
+		${U_BOOT_DIR}/sunxi-spl.bin \
+		${U_BOOT_DIR}/README
+
+MAKE_ARGS+=	ARCH=arm \
+		CROSS_COMPILE=arm-none-eabi-
+
+.include <bsd.port.pre.mk>
+
+.if ${OSVERSION} < 1100000
+IGNORE=		requires FreeBSD 11 or later
+.endif
+
+post-patch:
+	@${REINPLACE_CMD} -e "s,%%MODEL%%,${MODEL}," \
+		${WRKSRC}/include/configs/sunxi-common.h
+
+do-configure:
+	(cd ${WRKSRC}; ${MAKE_CMD} ${BOARD_CONFIG})
+
+do-install:
+	${MKDIR} ${STAGEDIR}/${PREFIX}/${U_BOOT_DIR}
+	${INSTALL_DATA} ${WRKSRC}/u-boot.img ${STAGEDIR}/${PREFIX}/${U_BOOT_DIR}
+	${INSTALL_DATA} ${WRKSRC}/u-boot-sunxi-with-spl.bin \
+		${STAGEDIR}/${PREFIX}/${U_BOOT_DIR}
+	${INSTALL_DATA} ${WRKSRC}/spl/sunxi-spl.bin \
+		${STAGEDIR}/${PREFIX}/${U_BOOT_DIR}
+	${INSTALL_DATA} ${.CURDIR}/pkg-descr \
+		${STAGEDIR}/${PREFIX}/${U_BOOT_DIR}/README
+
+.include <bsd.port.post.mk>

Added: head/sysutils/u-boot-olimex-a20-som-evb/distinfo
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/u-boot-olimex-a20-som-evb/distinfo	Sun Jul 10 15:06:14 2016	(r418324)
@@ -0,0 +1,3 @@
+TIMESTAMP = 1466239765
+SHA256 (u-boot-2016.05.tar.bz2) = 87d02275615aaf0cd007b54cbe9fbadceef2bee7c79e6c323ea1ae8956dcb171
+SIZE (u-boot-2016.05.tar.bz2) = 11325053

Added: head/sysutils/u-boot-olimex-a20-som-evb/files/patch-api_api.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/u-boot-olimex-a20-som-evb/files/patch-api_api.c	Sun Jul 10 15:06:14 2016	(r418324)
@@ -0,0 +1,95 @@
+--- api/api.c.orig	2016-05-16 14:40:32 UTC
++++ api/api.c
+@@ -290,6 +290,14 @@ static int API_dev_close(va_list ap)
+ 	if (!err)
+ 		di->state = DEV_STA_CLOSED;
+ 
++	/*
++	 * FreeBSD loader(8) just loaded code to some random location that may
++	 * contain stale icache entries.  Now that the device is closed it's
++	 * about to run that code, so clean the caches.
++	 */
++	flush_dcache_all();
++	invalidate_icache_all();
++
+ 	return err;
+ }
+ 
+@@ -495,45 +503,48 @@ static int API_env_set(va_list ap)
+  */
+ static int API_env_enum(va_list ap)
+ {
+-	int i, n;
+-	char *last, **next;
++	int i, buflen;
++	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)) == 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;
++	buflen = strlen(match->key) + strlen(match->data) + 2;
++	buf = realloc(buf, buflen);
++	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-olimex-a20-som-evb/files/patch-api_api__net.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/u-boot-olimex-a20-som-evb/files/patch-api_api__net.c	Sun Jul 10 15:06:14 2016	(r418324)
@@ -0,0 +1,11 @@
+--- api/api_net.c.orig	2016-05-16 14:40:32 UTC
++++ api/api_net.c
+@@ -25,7 +25,7 @@ DECLARE_GLOBAL_DATA_PTR;
+ 
+ #define errf(fmt, args...) do { printf("ERROR @ %s(): ", __func__); printf(fmt, ##args); } while (0)
+ 
+-#ifdef CONFIG_CMD_NET
++#if defined(CONFIG_CMD_NET) && !defined(CONFIG_DM_ETH)
+ 
+ static int dev_valid_net(void *cookie)
+ {

Added: head/sysutils/u-boot-olimex-a20-som-evb/files/patch-cmd_elf.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/u-boot-olimex-a20-som-evb/files/patch-cmd_elf.c	Sun Jul 10 15:06:14 2016	(r418324)
@@ -0,0 +1,29 @@
+--- cmd/elf.c.orig	2016-05-16 14:40:32 UTC
++++ cmd/elf.c
+@@ -110,22 +110,12 @@ static unsigned long do_bootelf_exec(ulo
+ 	unsigned long ret;
+ 
+ 	/*
+-	 * QNX images require the data cache is disabled.
+-	 * Data cache is already flushed, so just turn it off.
+-	 */
+-	int dcache = dcache_status();
+-	if (dcache)
+-		dcache_disable();
+-
+-	/*
+-	 * pass address parameter as argv[0] (aka command name),
+-	 * and all remaining args
++	 * FreeBSD wants the caches enabled while ubldr runs, and as of r276397
++	 * the kernel can tolerate being entered with internal (but not external
++	 * PL310) caches enabled on armv6/7 systems.  So don't disable caches
++	 * here, just launch the program directly.
+ 	 */
+ 	ret = entry(argc, argv);
+-
+-	if (dcache)
+-		dcache_enable();
+-
+ 	return ret;
+ }
+ 

Added: head/sysutils/u-boot-olimex-a20-som-evb/files/patch-cmd_test.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/u-boot-olimex-a20-som-evb/files/patch-cmd_test.c	Sun Jul 10 15:06:14 2016	(r418324)
@@ -0,0 +1,19 @@
+--- cmd/test.c.orig	2016-05-16 14:40:32 UTC
++++ cmd/test.c
+@@ -56,9 +56,14 @@ static int do_test(cmd_tbl_t *cmdtp, int
+ 	char * const *ap;
+ 	int i, op, left, adv, expr, last_expr, last_unop, last_binop;
+ 
+-	/* 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-olimex-a20-som-evb/files/patch-include_configs_sunxi-common.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/u-boot-olimex-a20-som-evb/files/patch-include_configs_sunxi-common.h	Sun Jul 10 15:06:14 2016	(r418324)
@@ -0,0 +1,72 @@
+--- include/configs/sunxi-common.h.orig	2016-05-16 14:40:32 UTC
++++ include/configs/sunxi-common.h
+@@ -513,4 +513,69 @@ extern int soft_i2c_gpio_scl;
+ #define CONFIG_EXTRA_ENV_SETTINGS
+ #endif
+ 
++/*****************************************************************************
++ * FreeBSD customizations from here down.
++ ****************************************************************************/
++
++/* Add the API and ELF features needed for ubldr. */
++#ifndef CONFIG_SPL_BUILD
++#define CONFIG_API
++#define CONFIG_EFI_PARTITION
++#endif
++
++/* Turn off dcache. */
++#ifndef CONFIG_SPL_BUILD
++#define CONFIG_SYS_DCACHE_OFF
++#define CONFIG_CMD_CACHE
++#endif
++
++/* Save the env to the fat partition. */
++#ifndef CONFIG_SPL_BUILD
++#undef  CONFIG_ENV_IS_NOWHERE
++#undef  CONFIG_ENV_IS_IN_NAND
++#undef  CONFIG_ENV_IS_IN_MMC
++#undef  CONFIG_ENV_IS_IN_SPI_FLASH
++#define CONFIG_ENV_IS_IN_FAT
++#define CONFIG_FAT_WRITE
++#define CONFIG_SYS_MMC_MAX_DEVICE	4
++#define FAT_ENV_INTERFACE		"mmc"
++#define FAT_ENV_DEVICE_AND_PART		"0:1"
++#define FAT_ENV_FILE			"u-boot.env"
++#endif
++
++/* Create a small(ish) boot environment for FreeBSD. */
++#ifndef CONFIG_SPL_BUILD
++#undef  CONFIG_EXTRA_ENV_SETTINGS
++#define CONFIG_EXTRA_ENV_SETTINGS \
++	MEM_LAYOUT_ENV_SETTINGS \
++	CONSOLE_STDOUT_SETTINGS \
++	"stdin=serial,usbkbd\0" \
++	"fdtfile=%%MODEL%%.dtb\0" \
++	"console=ttyS0,115200\0" \
++	"Fatboot=" \
++	  "env exists loaderdev || env set loaderdev ${fatdev}; " \
++	  "env exists UserFatboot && run UserFatboot; " \
++	  "echo Booting from: ${fatdev} ${bootfile}; " \
++	  "fatload ${fatdev} ${kernel_addr_r} ${bootfile} && bootelf || go ${kernel_addr_r}; " \
++	"\0" \
++	"Netboot=" \
++	  "env exists loaderdev || env set loaderdev net; " \
++	  "env exists UserNetboot && run UserNetboot; " \
++	  "dhcp ${kernel_addr_r} ${bootfile} && bootelf; " \
++	"\0" \
++	"preboot=usb start; " \
++	  "env exists bootfile || env set bootfile ubldr.bin; " \
++	  "env exists SetupFatdev && run SetupFatdev; " \
++	  "env exists UserPreboot && run UserPreboot; " \
++	"\0" \
++	"SetupFatdev=" \
++	  "env exists fatdev || env set fatdev 'mmc 0'; " \
++	"\0"
++
++#undef  CONFIG_BOOTCOMMAND
++#define CONFIG_BOOTCOMMAND	"run Fatboot"
++#undef  CONFIG_PREBOOT
++#define CONFIG_PREBOOT		"run preboot"
++#endif
++
+ #endif /* _SUNXI_COMMON_CONFIG_H */

Added: head/sysutils/u-boot-olimex-a20-som-evb/pkg-descr
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/u-boot-olimex-a20-som-evb/pkg-descr	Sun Jul 10 15:06:14 2016	(r418324)
@@ -0,0 +1,19 @@
+U-Boot loader for Olimex A20 SOM EVB.
+
+To install this bootloader, follow the instructions in
+ http://linux-sunxi.org/Bootable_SD_card#Bootloader
+
+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 u-boot.env on the FAT partition.
+ * The DTB file name is chosen based on the board model and passed to ubldr.bin
+   using the fdtfile env variable. ubldr.bin loads the DTB from /boot/dtb/ on
+   the FreeBSD partition.
+ * By default, it loads PIE ubldr.bin from file ubldr.bin on the FAT partition
+   to address 0x42000000, and launches it.
+
+For information about running FreeBSD on Cubieboard, see
+ https://wiki.freebsd.org/FreeBSD/arm/Allwinner
+
+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?201607101506.u6AF6E2O002355>