Index: head/sysutils/u-boot-rpi/Makefile =================================================================== --- head/sysutils/u-boot-rpi/Makefile (revision 409215) +++ head/sysutils/u-boot-rpi/Makefile (revision 409216) @@ -1,54 +1,54 @@ # $FreeBSD$ PORTNAME= u-boot -PORTVERSION= 2015.10 +PORTVERSION= 2016.01 CATEGORIES= sysutils MASTER_SITES= ftp://ftp.denx.de/pub/u-boot/ \ LOCAL/ian/:bootfiles PKGNAMESUFFIX= -rpi DISTFILES= ${DISTNAME}${EXTRACT_SUFX} \ - rpi-boot-files-2014.10_2.tar.bz2:bootfiles + rpi-boot-files-2016.01.tar.bz2:bootfiles 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 NO_ARCH= yes USES= gmake tar:bzip2 SSP_UNSAFE= yes # cross-LD does not support -fstack-protector WRK_BOOTFILES= ${WRKDIR}/rpi-boot-files U_BOOT_DIR= share/u-boot/${PORTNAME}${PKGNAMESUFFIX} PLIST_FILES= ${U_BOOT_DIR}/u-boot.img \ ${U_BOOT_DIR}/LICENCE.broadcom \ - ${U_BOOT_DIR}/README \ + ${U_BOOT_DIR}/README-BootDetails \ ${U_BOOT_DIR}/bootcode.bin \ ${U_BOOT_DIR}/config.txt \ ${U_BOOT_DIR}/fixup.dat \ ${U_BOOT_DIR}/fixup_cd.dat \ ${U_BOOT_DIR}/start.elf \ ${U_BOOT_DIR}/start_cd.elf MAKE_ARGS+= ARCH=arm \ CROSS_COMPILE=arm-none-eabi- do-configure: (cd ${WRKSRC}; ${GMAKE} rpi_defconfig) # 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 u-boot.img. Also copy the entire contents of the bootfiles # distribution (these are proprietary binary files required to boot). IMGFILE=${STAGEDIR}/${PREFIX}/${U_BOOT_DIR}/u-boot.img do-install: ${MKDIR} ${STAGEDIR}/${PREFIX}/${U_BOOT_DIR} ${GZCAT} ${FILESDIR}/imgprefix.bin.gz >${IMGFILE} ${CAT} ${WRKSRC}/u-boot.bin >>${IMGFILE} ${CP} ${WRK_BOOTFILES}/* ${STAGEDIR}/${PREFIX}/${U_BOOT_DIR}/ .include Index: head/sysutils/u-boot-rpi/distinfo =================================================================== --- head/sysutils/u-boot-rpi/distinfo (revision 409215) +++ head/sysutils/u-boot-rpi/distinfo (revision 409216) @@ -1,4 +1,4 @@ -SHA256 (u-boot-2015.10.tar.bz2) = bdc68d5f9455ad933b059c735d983f2c8b6b552dafb062e5ff1444f623021955 -SIZE (u-boot-2015.10.tar.bz2) = 10416503 -SHA256 (rpi-boot-files-2014.10_2.tar.bz2) = bcaa493d3585151fde755245bee44b7d30d0e9c7ec9cc7f4dccdad57caf18cdc -SIZE (rpi-boot-files-2014.10_2.tar.bz2) = 1893216 +SHA256 (u-boot-2016.01.tar.bz2) = e5792fba9399d9804aa2ef667f14ff771e2cdece72367d340250265bf095a5d5 +SIZE (u-boot-2016.01.tar.bz2) = 10602974 +SHA256 (rpi-boot-files-2016.01.tar.bz2) = d912abb1e91a1f38f7fa62cbf2202e8279a832106b15a76c30989ce36a04aea7 +SIZE (rpi-boot-files-2016.01.tar.bz2) = 2006903 Index: head/sysutils/u-boot-rpi/files/patch-api_api.c =================================================================== --- head/sysutils/u-boot-rpi/files/patch-api_api.c (revision 409215) +++ head/sysutils/u-boot-rpi/files/patch-api_api.c (revision 409216) @@ -1,79 +1,94 @@ ---- api/api.c.orig 2015-10-19 23:59:38 UTC +--- api/api.c.orig 2015-08-05 16:53:17 UTC +++ api/api.c -@@ -495,45 +495,47 @@ static int API_env_set(va_list ap) +@@ -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,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)) == 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; } /* Index: head/sysutils/u-boot-rpi/files/patch-common_cmd__elf.c =================================================================== --- head/sysutils/u-boot-rpi/files/patch-common_cmd__elf.c (revision 409215) +++ head/sysutils/u-boot-rpi/files/patch-common_cmd__elf.c (revision 409216) @@ -1,32 +1,32 @@ ---- common/cmd_elf.c.orig 2015-10-19 23:59:38 UTC +--- common/cmd_elf.c.orig 2016-01-12 14:06:54 UTC +++ common/cmd_elf.c -@@ -35,22 +35,15 @@ static unsigned long do_bootelf_exec(ulo +@@ -110,22 +110,15 @@ 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 invalidate the icache (because we DMA'd new data into that + * memory recently) and launch the program directly. */ + flush_dcache_all(); + invalidate_icache_all(); ret = entry(argc, argv); - - if (dcache) - dcache_enable(); - return ret; } Index: head/sysutils/u-boot-rpi/files/patch-include_configs_rpi-common.h =================================================================== --- head/sysutils/u-boot-rpi/files/patch-include_configs_rpi-common.h (revision 409215) +++ head/sysutils/u-boot-rpi/files/patch-include_configs_rpi-common.h (revision 409216) @@ -1,59 +1,58 @@ ---- include/configs/rpi-common.h.orig 2015-10-19 23:59:38 UTC +--- include/configs/rpi-common.h.orig 2016-01-12 14:06:54 UTC +++ include/configs/rpi-common.h -@@ -183,4 +183,56 @@ +@@ -182,4 +182,55 @@ #define CONFIG_BOOTDELAY 2 +/***************************************************************************** + * FreeBSD customizations from here down. + ****************************************************************************/ + +#define CONFIG_API -+#define CONFIG_CMD_ELF +#define CONFIG_EFI_PARTITION +#define CONFIG_PREBOOT + +#define CONFIG_SYS_MMC_MAX_DEVICE 1 + +/* Create a small(ish) boot environment for FreeBSD. */ +#undef CONFIG_EXTRA_ENV_SETTINGS +#define CONFIG_EXTRA_ENV_SETTINGS \ + ENV_MEM_LAYOUT_SETTINGS \ + "stdin=serial,lcd\0" \ + "stderr=serial,lcd\0" \ + "stdout=serial,lcd\0" \ + \ + "Fatboot=" \ + "env exists bootfile || bootfile=ubldr.bin; " \ + "env exists loaderdev || env set loaderdev ${fatdev}; " \ + "test ${loaderdev} = net && env exists SetupNetconfig && run SetupNetconfig; " \ + "echo Booting from: ${fatdev} ${bootfile}; " \ + "fatload ${fatdev} ${loadaddr} ${bootfile} && bootelf || go ${loadaddr}; " \ + "\0" \ + "Preboot=" \ + "fdt addr 0x100; " \ + "env exists uenv_file || uenv_file=uEnv.txt; " \ + "env exists SetupFatdev && run SetupFatdev; " \ + "env exists SetupUenv && run SetupUenv; " \ + "env exists UserPreboot && run UserPreboot; " \ + "\0" \ + "SetupFatdev=" \ + "env exists fatdev || fatdev='mmc 0'; " \ + "\0" \ + "SetupNetconfig=" \ + "env exists ethact || usb start; " \ + "env exists UserNetconfig && run UserNetconfig; " \ + "\0" \ + "SetupUenv=" \ + "fatload ${fatdev} ${loadaddr} ${uenv_file} && " \ + "env import -t ${loadaddr} ${filesize}; " \ + "\0" + +#undef CONFIG_BOOTCOMMAND +#define CONFIG_BOOTCOMMAND "run Fatboot" +#undef CONFIG_PREBOOT +#define CONFIG_PREBOOT "run Preboot" + +#define CONFIG_CMD_CACHE + #endif