package/u-boot-envtools: update to version 2011.06.

This updates uboot-envtools to the version which comes with U-Boot 2011.06.
The important novelity is that fw_setenv now supports batch processing, which
greatly improves sysupgrade of the ALL0258N as otherwise we would have to
overwrite uboot-env up to 8x in a single firmware upgrade.
Unfortunately, no newer version of the sources is available from Debian, so we
got to take it from the u-boot source which is kinda ugly...

Signed-off-by: Daniel Golle <dgolle@allnet.de>

SVN-Revision: 28566
v19.07.3_mercusys_ac12_duma
Gabor Juhos 13 years ago
parent 0ab6be2ba3
commit 61441fe2de

@ -1,5 +1,5 @@
#
# Copyright (C) 2006-2010 OpenWrt.org
# Copyright (C) 2006-2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@ -8,14 +8,18 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=uboot-envtools
PKG_VERSION:=20081215
PKG_RELEASE:=2
PKG_DISTNAME:=u-boot
PKG_VERSION:=2011.06
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).orig.tar.gz
PKG_SOURCE_URL:=http://ftp.de.debian.org/debian/pool/main/u/uboot-envtools/
PKG_SOURCE:=$(PKG_DISTNAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot
PKG_MD5SUM:=
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
@ -34,4 +38,10 @@ define Package/uboot-envtools/install
ln -sf fw_printenv $(1)/usr/sbin/fw_setenv
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
$(eval $(call BuildPackage,uboot-envtools))

@ -1,18 +1,33 @@
--- a/crc32.c
+++ b/crc32.c
@@ -8,11 +8,7 @@
@@ -8,21 +8,16 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-#ifndef USE_HOSTCC /* Shut down "ANSI does not permit..." warnings */
-#ifndef USE_HOSTCC
-#include <common.h>
-#else
#include <stdint.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"
#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
#include <watchdog.h>
@@ -136,7 +132,7 @@ local const uint32_t crc_table[256] = {
#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
/* =========================================================================
@ -21,16 +36,30 @@
*/
const uint32_t * ZEXPORT get_crc_table()
{
@@ -154,7 +150,7 @@ const uint32_t * ZEXPORT get_crc_table()
#define DO8(buf) DO4(buf); DO4(buf);
@@ -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);
}
/* ========================================================================= */
-uint32_t ZEXPORT crc32 (uint32_t crc, const Bytef *buf, uInt len)
+uint32_t ZEXPORT uboot_crc32 (uint32_t crc, const Bytef *buf, uInt 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)
{
#ifdef DYNAMIC_CRC_TABLE
if (crc_table_empty)
@@ -217,12 +213,12 @@ uint32_t ZEXPORT crc32_wd (uint32_t crc,
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;
@ -47,7 +76,20 @@
return crc;
--- a/fw_env.c
+++ b/fw_env.c
@@ -216,9 +216,9 @@ static int parse_config (void);
@@ -34,6 +34,7 @@
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <zlib.h>
#ifdef MTD_OLD
# include <stdint.h>
@@ -210,13 +211,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
@ -59,16 +101,16 @@
if (HaveRedundEnv)
rc -= sizeof (char);
@@ -437,7 +437,7 @@ int fw_setenv (int argc, char *argv[])
@@ -346,7 +348,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);
- *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)) {
@@ -627,7 +627,7 @@ static int flash_write_buf (int dev, int
if (flash_io(O_RDWR)) {
@@ -802,7 +804,7 @@ static int flash_write_buf (int dev, int
data = malloc (erase_len);
if (!data) {
fprintf (stderr,
@ -77,21 +119,7 @@
erase_len, strerror (errno));
return -1;
}
@@ -883,11 +883,11 @@ static char *envmatch (char * s1, char *
static int env_init (void)
{
int crc0, crc0_ok;
- char flag0;
+ unsigned char flag0;
void *addr0;
int crc1, crc1_ok;
- char flag1;
+ unsigned char flag1;
void *addr1;
struct env_image_single *single;
@@ -923,7 +923,7 @@ static int env_init (void)
@@ -1107,7 +1109,7 @@ int fw_env_open(void)
if (flash_io (O_RDONLY))
return -1;
@ -100,7 +128,7 @@
crc0_ok = (crc0 == *environment.crc);
if (!HaveRedundEnv) {
if (!crc0_ok) {
@@ -964,7 +964,7 @@ static int env_init (void)
@@ -1151,7 +1153,7 @@ int fw_env_open(void)
return -1;
}
@ -109,17 +137,3 @@
crc1_ok = (crc1 == redundant->crc);
flag1 = redundant->flags;
--- a/fw_env.h
+++ b/fw_env.h
@@ -47,8 +47,10 @@
"ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; " \
"bootm"
+# include <stdint.h>
+
extern int fw_printenv(int argc, char *argv[]);
extern char *fw_getenv (char *name);
extern int fw_setenv (int argc, char *argv[]);
-extern unsigned long crc32 (unsigned long, const unsigned char *, unsigned);
+extern uint32_t uboot_crc32 (uint32_t, const unsigned char *, unsigned);

@ -1,31 +1,39 @@
--- a/Makefile
+++ b/Makefile
@@ -21,12 +21,10 @@
@@ -21,37 +21,16 @@
# MA 02111-1307 USA
#
-include $(TOPDIR)/config.mk
-
SRCS := $(obj)crc32.c fw_env.c fw_env_main.c
-HOSTSRCS := $(obj)crc32.c fw_env.c fw_env_main.c
+SRCS := crc32.c fw_env.c fw_env_main.c
HEADERS := fw_env.h
-CPPFLAGS := -Wall -DUSE_HOSTCC -I$(SRCTREE)/include
-# 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
+CPPFLAGS := -Wall $(CFLAGS)
ifeq ($(MTD_VERSION),old)
CPPFLAGS += -DMTD_OLD
@@ -35,18 +33,7 @@ endif
all: $(obj)fw_printenv
$(obj)fw_printenv: $(SRCS) $(HEADERS)
- $(CROSS_COMPILE)gcc $(CPPFLAGS) $(SRCS) -o $(obj)fw_printenv
# Some files complain if compiled with -pedantic, use HOSTCFLAGS_NOPED
-$(obj)fw_printenv: $(HOSTSRCS) $(HEADERS)
- $(HOSTCC) $(HOSTCFLAGS_NOPED) $(HOSTLDFLAGS) -o $@ $(HOSTSRCS)
+$(obj)fw_printenv: $(SRCS) $(HEADERS)
+ $(CC) $(CPPFLAGS) $(SRCS) -o $(obj)fw_printenv
clean:
rm -f $(obj)fw_printenv $(obj)crc32.c
- rm -f $(obj)fw_printenv $(obj)crc32.c
-
-$(obj)crc32.c:
- ln -s $(src)../../lib_generic/crc32.c $(obj)crc32.c
- ln -s $(src)../../lib/crc32.c $(obj)crc32.c
-
-#########################################################################
-
@ -34,3 +42,4 @@
-sinclude $(obj).depend
-
-#########################################################################
+ rm -f $(obj)fw_printenv

@ -1,7 +1,7 @@
--- a/fw_env.c
+++ b/fw_env.c
@@ -605,7 +605,10 @@ static int flash_write_buf (int dev, int
erase_offset = offset & ~(blocklen - 1);
@@ -779,7 +779,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;

Loading…
Cancel
Save