summaryrefslogtreecommitdiffstats
path: root/package/boot/uboot-envtools
diff options
context:
space:
mode:
Diffstat (limited to 'package/boot/uboot-envtools')
-rw-r--r--package/boot/uboot-envtools/Makefile70
-rw-r--r--package/boot/uboot-envtools/files/ar71xx31
-rw-r--r--package/boot/uboot-envtools/files/kirkwood25
-rw-r--r--package/boot/uboot-envtools/files/lantiq25
-rw-r--r--package/boot/uboot-envtools/files/ramips27
-rw-r--r--package/boot/uboot-envtools/files/uboot-envtools.sh36
-rw-r--r--package/boot/uboot-envtools/patches/001-crc32_func_signature.patch130
-rw-r--r--package/boot/uboot-envtools/patches/002-makefile.patch44
-rw-r--r--package/boot/uboot-envtools/patches/003-nor-eraselen.patch14
-rw-r--r--package/boot/uboot-envtools/patches/004-allow_mac_change.patch21
10 files changed, 423 insertions, 0 deletions
diff --git a/package/boot/uboot-envtools/Makefile b/package/boot/uboot-envtools/Makefile
new file mode 100644
index 000000000..74da5ea12
--- /dev/null
+++ b/package/boot/uboot-envtools/Makefile
@@ -0,0 +1,70 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=uboot-envtools
+PKG_DISTNAME:=u-boot
+PKG_VERSION:=2012.04.01
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_DISTNAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot
+PKG_MD5SUM:=192bb231082d9159fb6e16de3039b6b2
+PKG_BUILD_DEPENDS:=zlib
+
+include $(INCLUDE_DIR)/package.mk
+
+TAR_OPTIONS+= --strip-components=3 -C $(PKG_BUILD_DIR) $(PKG_DISTNAME)-$(PKG_VERSION)/tools/env
+
+define Package/uboot-envtools
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=read/modify U-Boot bootloader environment
+ URL:=http://www.denx.de/wiki/U-Boot
+endef
+
+define Package/uboot-envtools/description
+ This package includes tools to read and modify U-Boot bootloader environment.
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ tar xvjf $(DL_DIR)/$(PKG_SOURCE) --strip-components=2 -C $(PKG_BUILD_DIR) $(PKG_DISTNAME)-$(PKG_VERSION)/lib/crc32.c
+ $(call Build/Prepare/Default)
+endef
+
+define Package/uboot-envtools/conffiles
+/etc/config/ubootenv
+/etc/fw_env.config
+endef
+
+define Package/uboot-envtools/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/fw_printenv $(1)/usr/sbin
+ ln -s fw_printenv $(1)/usr/sbin/fw_setenv
+ $(INSTALL_DIR) $(1)/lib
+ $(INSTALL_DATA) ./files/uboot-envtools.sh $(1)/lib
+ifneq ($(CONFIG_TARGET_ar71xx),)
+ $(INSTALL_DIR) $(1)/etc/uci-defaults
+ $(INSTALL_BIN) ./files/ar71xx $(1)/etc/uci-defaults/uboot-envtools
+endif
+ifneq ($(CONFIG_TARGET_kirkwood),)
+ $(INSTALL_DIR) $(1)/etc/uci-defaults
+ $(INSTALL_BIN) ./files/kirkwood $(1)/etc/uci-defaults/uboot-envtools
+endif
+ifneq ($(CONFIG_TARGET_lantiq),)
+ $(INSTALL_DIR) $(1)/etc/uci-defaults
+ $(INSTALL_BIN) ./files/lantiq $(1)/etc/uci-defaults/uboot-envtools
+endif
+ifneq ($(CONFIG_TARGET_ramips),)
+ $(INSTALL_DIR) $(1)/etc/uci-defaults
+ $(INSTALL_BIN) ./files/ramips $(1)/etc/uci-defaults/uboot-envtools
+endif
+endef
+
+$(eval $(call BuildPackage,uboot-envtools))
diff --git a/package/boot/uboot-envtools/files/ar71xx b/package/boot/uboot-envtools/files/ar71xx
new file mode 100644
index 000000000..ad0d921a5
--- /dev/null
+++ b/package/boot/uboot-envtools/files/ar71xx
@@ -0,0 +1,31 @@
+#!/bin/sh
+#
+# Copyright (C) 2011-2012 OpenWrt.org
+#
+
+[ -e /etc/config/ubootenv ] && exit 0
+
+touch /etc/config/ubootenv
+
+. /lib/ar71xx.sh
+. /lib/uboot-envtools.sh
+. /lib/functions.sh
+
+board=$(ar71xx_board_name)
+
+case "$board" in
+all0258n)
+ ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
+ ;;
+alfa-ap96 | \
+all0315n | \
+om2p | \
+om2p-lc)
+ ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x40000" "0x40000"
+ ;;
+esac
+
+config_load ubootenv
+config_foreach ubootenv_add_app_config ubootenv
+
+exit 0
diff --git a/package/boot/uboot-envtools/files/kirkwood b/package/boot/uboot-envtools/files/kirkwood
new file mode 100644
index 000000000..cad53aa37
--- /dev/null
+++ b/package/boot/uboot-envtools/files/kirkwood
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+
+[ -e /etc/config/ubootenv ] && exit 0
+
+touch /etc/config/ubootenv
+
+. /lib/kirkwood.sh
+. /lib/uboot-envtools.sh
+. /lib/functions.sh
+
+hardware=$(kirkwood_hardware_name)
+
+case "$hardware" in
+"RaidSonic ICY BOX IB-NAS6210")
+ ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
+ ;;
+esac
+
+config_load ubootenv
+config_foreach ubootenv_add_app_config ubootenv
+
+exit 0
diff --git a/package/boot/uboot-envtools/files/lantiq b/package/boot/uboot-envtools/files/lantiq
new file mode 100644
index 000000000..40befc368
--- /dev/null
+++ b/package/boot/uboot-envtools/files/lantiq
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+
+[ -e /etc/config/ubootenv ] && exit 0
+
+touch /etc/config/ubootenv
+
+. /lib/lantiq.sh
+. /lib/uboot-envtools.sh
+. /lib/functions.sh
+
+board=$(lantiq_board_name)
+
+case "$board" in
+GIGASX76X)
+ ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000" "1"
+ ;;
+esac
+
+config_load ubootenv
+config_foreach ubootenv_add_app_config ubootenv
+
+exit 0
diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips
new file mode 100644
index 000000000..65cd49cf1
--- /dev/null
+++ b/package/boot/uboot-envtools/files/ramips
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# Copyright (C) 2011-2012 OpenWrt.org
+#
+
+[ -e /etc/config/ubootenv ] && exit 0
+
+touch /etc/config/ubootenv
+
+. /lib/ramips.sh
+. /lib/uboot-envtools.sh
+. /lib/functions.sh
+
+board=$(ramips_board_name)
+
+case "$board" in
+all0239-3g | \
+all0256n | \
+all5002)
+ ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
+ ;;
+esac
+
+config_load ubootenv
+config_foreach ubootenv_add_app_config ubootenv
+
+exit 0
diff --git a/package/boot/uboot-envtools/files/uboot-envtools.sh b/package/boot/uboot-envtools/files/uboot-envtools.sh
new file mode 100644
index 000000000..e21b28367
--- /dev/null
+++ b/package/boot/uboot-envtools/files/uboot-envtools.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+#
+# Copyright (C) 2011-2012 OpenWrt.org
+#
+
+ubootenv_add_uci_config() {
+ local dev=$1
+ local offset=$2
+ local envsize=$3
+ local secsize=$4
+ local numsec=$5
+ uci batch <<EOF
+add ubootenv ubootenv
+set ubootenv.@ubootenv[-1].dev='$dev'
+set ubootenv.@ubootenv[-1].offset='$offset'
+set ubootenv.@ubootenv[-1].envsize='$envsize'
+set ubootenv.@ubootenv[-1].secsize='$secsize'
+set ubootenv.@ubootenv[-1].numsec='$numsec'
+EOF
+ uci commit ubootenv
+}
+
+ubootenv_add_app_config() {
+ local dev
+ local offset
+ local envsize
+ local secsize
+ local numsec
+ config_get dev "$1" dev
+ config_get offset "$1" offset
+ config_get envsize "$1" envsize
+ config_get secsize "$1" secsize
+ config_get numsec "$1" numsec
+ echo "$dev $offset $envsize $secsize $numsec" >>/etc/fw_env.config
+}
+
diff --git a/package/boot/uboot-envtools/patches/001-crc32_func_signature.patch b/package/boot/uboot-envtools/patches/001-crc32_func_signature.patch
new file mode 100644
index 000000000..f68f29ea0
--- /dev/null
+++ b/package/boot/uboot-envtools/patches/001-crc32_func_signature.patch
@@ -0,0 +1,130 @@
+--- a/crc32.c
++++ b/crc32.c
+@@ -8,21 +8,16 @@
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+-#ifndef USE_HOSTCC
+-#include <common.h>
+-#endif
+-#include <compiler.h>
+-#include <u-boot/crc.h>
++#include <stdint.h>
++#include <asm/byteorder.h>
++
++#include "zlib.h"
+
+-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+-#include <watchdog.h>
+-#endif
+-#include "u-boot/zlib.h"
+
+ #define local static
+ #define ZEXPORT /* empty */
+
+-#define tole(x) cpu_to_le32(x)
++#define tole(x) __constant_cpu_to_le32(x)
+
+ #ifdef DYNAMIC_CRC_TABLE
+
+@@ -151,7 +146,7 @@ tole(0xb40bbe37L), tole(0xc30c8ea1L), to
+
+ #if 0
+ /* =========================================================================
+- * This function can be used by asm versions of crc32()
++ * This function can be used by asm versions of uboot_crc32()
+ */
+ const uint32_t * ZEXPORT get_crc_table()
+ {
+@@ -183,7 +178,7 @@ uint32_t ZEXPORT crc32_no_comp(uint32_t
+ if (crc_table_empty)
+ make_crc_table();
+ #endif
+- crc = cpu_to_le32(crc);
++ crc = __cpu_to_le32(crc);
+ /* Align it */
+ if (((long)b) & 3 && len) {
+ uint8_t *p = (uint8_t *)b;
+@@ -212,11 +207,11 @@ uint32_t ZEXPORT crc32_no_comp(uint32_t
+ } while (--len);
+ }
+
+- return le32_to_cpu(crc);
++ return __le32_to_cpu(crc);
+ }
+ #undef DO_CRC
+
+-uint32_t ZEXPORT crc32 (uint32_t crc, const Bytef *p, uInt len)
++uint32_t ZEXPORT uboot_crc32 (uint32_t crc, const Bytef *p, uInt len)
+ {
+ return crc32_no_comp(crc ^ 0xffffffffL, p, len) ^ 0xffffffffL;
+ }
+@@ -239,12 +234,12 @@ uint32_t ZEXPORT crc32_wd (uint32_t crc,
+ chunk = end - curr;
+ if (chunk > chunk_sz)
+ chunk = chunk_sz;
+- crc = crc32 (crc, curr, chunk);
++ crc = uboot_crc32 (crc, curr, chunk);
+ curr += chunk;
+ WATCHDOG_RESET ();
+ }
+ #else
+- crc = crc32 (crc, buf, len);
++ crc = uboot_crc32 (crc, buf, len);
+ #endif
+
+ return crc;
+--- a/fw_env.c
++++ b/fw_env.c
+@@ -34,6 +34,7 @@
+ #include <sys/ioctl.h>
+ #include <sys/stat.h>
+ #include <unistd.h>
++#include <zlib.h>
+
+ #ifdef MTD_OLD
+ # include <stdint.h>
+@@ -212,13 +213,14 @@ static char default_environment[] = {
+ static int flash_io (int mode);
+ static char *envmatch (char * s1, char * s2);
+ static int parse_config (void);
++uint32_t uboot_crc32 (uint32_t crc, const Bytef *p, uInt len);
+
+ #if defined(CONFIG_FILE)
+ static int get_config (char *);
+ #endif
+-static inline ulong getenvsize (void)
++static inline uint32_t getenvsize (void)
+ {
+- ulong rc = CONFIG_ENV_SIZE - sizeof (long);
++ uint32_t rc = CONFIG_ENV_SIZE - sizeof (uint32_t);
+
+ if (HaveRedundEnv)
+ rc -= sizeof (char);
+@@ -348,7 +350,7 @@ int fw_env_close(void)
+ /*
+ * Update CRC
+ */
+- *environment.crc = crc32(0, (uint8_t *) environment.data, ENV_SIZE);
++ *environment.crc = uboot_crc32(0, (uint8_t *) environment.data, ENV_SIZE);
+
+ /* write environment back to flash */
+ if (flash_io(O_RDWR)) {
+@@ -1116,7 +1118,7 @@ int fw_env_open(void)
+ if (flash_io (O_RDONLY))
+ return -1;
+
+- crc0 = crc32 (0, (uint8_t *) environment.data, ENV_SIZE);
++ crc0 = uboot_crc32 (0, (uint8_t *) environment.data, ENV_SIZE);
+ crc0_ok = (crc0 == *environment.crc);
+ if (!HaveRedundEnv) {
+ if (!crc0_ok) {
+@@ -1160,7 +1162,7 @@ int fw_env_open(void)
+ return -1;
+ }
+
+- crc1 = crc32 (0, (uint8_t *) redundant->data, ENV_SIZE);
++ crc1 = uboot_crc32 (0, (uint8_t *) redundant->data, ENV_SIZE);
+ crc1_ok = (crc1 == redundant->crc);
+ flag1 = redundant->flags;
+
diff --git a/package/boot/uboot-envtools/patches/002-makefile.patch b/package/boot/uboot-envtools/patches/002-makefile.patch
new file mode 100644
index 000000000..b18bff6e7
--- /dev/null
+++ b/package/boot/uboot-envtools/patches/002-makefile.patch
@@ -0,0 +1,44 @@
+--- a/Makefile
++++ b/Makefile
+@@ -21,34 +21,17 @@
+ # MA 02111-1307 USA
+ #
+
+-include $(TOPDIR)/config.mk
+-
+-HOSTSRCS := $(SRCTREE)/lib/crc32.c fw_env.c fw_env_main.c
++SRCS := crc32.c fw_env.c fw_env_main.c
+ HEADERS := fw_env.h
+
+-# Compile for a hosted environment on the target
+-HOSTCPPFLAGS = -idirafter $(SRCTREE)/include \
+- -idirafter $(OBJTREE)/include2 \
+- -idirafter $(OBJTREE)/include \
+- -DUSE_HOSTCC
+-
+-ifeq ($(MTD_VERSION),old)
+-HOSTCPPFLAGS += -DMTD_OLD
+-endif
+-
+-all: $(obj)fw_printenv
+-
+-# Some files complain if compiled with -pedantic, use HOSTCFLAGS_NOPED
+-$(obj)fw_printenv: $(HOSTSRCS) $(HEADERS)
+- $(HOSTCC) $(HOSTCFLAGS_NOPED) $(HOSTLDFLAGS) -o $@ $(HOSTSRCS)
++CPPFLAGS := -Wall $(CFLAGS)
+
+-clean:
+- rm -f $(obj)fw_printenv
++all: fw_printenv
+
+-#########################################################################
++fw_printenv: $(SRCS) $(HEADERS)
++ $(CC) $(CPPFLAGS) $(SRCS) -o fw_printenv
+
+-include $(TOPDIR)/rules.mk
+-
+-sinclude $(obj).depend
++clean:
++ rm -f fw_printenv
+
+ #########################################################################
diff --git a/package/boot/uboot-envtools/patches/003-nor-eraselen.patch b/package/boot/uboot-envtools/patches/003-nor-eraselen.patch
new file mode 100644
index 000000000..c6eb59a72
--- /dev/null
+++ b/package/boot/uboot-envtools/patches/003-nor-eraselen.patch
@@ -0,0 +1,14 @@
+--- a/fw_env.c
++++ b/fw_env.c
+@@ -790,7 +790,10 @@ static int flash_write_buf (int dev, int
+ erase_offset = (offset / blocklen) * blocklen;
+
+ /* Maximum area we may use */
+- erase_len = top_of_range - erase_offset;
++ if (mtd_type == MTD_NANDFLASH)
++ erase_len = top_of_range - erase_offset;
++ else
++ erase_len = blocklen;
+
+ blockstart = erase_offset;
+ /* Offset inside a block */
diff --git a/package/boot/uboot-envtools/patches/004-allow_mac_change.patch b/package/boot/uboot-envtools/patches/004-allow_mac_change.patch
new file mode 100644
index 000000000..b7d600b69
--- /dev/null
+++ b/package/boot/uboot-envtools/patches/004-allow_mac_change.patch
@@ -0,0 +1,21 @@
+--- a/fw_env.c
++++ b/fw_env.c
+@@ -46,8 +46,6 @@
+
+ #include "fw_env.h"
+
+-#include <config.h>
+-
+ #define WHITESPACE(c) ((c == '\t') || (c == ' '))
+
+ #define min(x, y) ({ \
+@@ -401,9 +399,7 @@ int fw_env_write(char *name, char *value
+ if (
+ (strcmp(name, "serial#") == 0) ||
+ ((strcmp(name, "ethaddr") == 0)
+-#if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
+ && (strcmp(oldval, MK_STR(CONFIG_ETHADDR)) != 0)
+-#endif /* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */
+ ) ) {
+ fprintf (stderr, "Can't overwrite \"%s\"\n", name);
+ errno = EROFS;