1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-07-02 20:55:27 +03:00

uboot-envtools: update to 2012.04.01

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32051 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
luka 2012-06-04 21:55:49 +00:00
parent 43e30b365b
commit 090fe17a5f
10 changed files with 172 additions and 122 deletions

View File

@ -1,5 +1,5 @@
# #
# Copyright (C) 2006-2011 OpenWrt.org # Copyright (C) 2006-2012 OpenWrt.org
# #
# This is free software, licensed under the GNU General Public License v2. # This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information. # See /LICENSE for more information.
@ -9,12 +9,12 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=uboot-envtools PKG_NAME:=uboot-envtools
PKG_DISTNAME:=u-boot PKG_DISTNAME:=u-boot
PKG_VERSION:=2011.06 PKG_VERSION:=2012.04.01
PKG_RELEASE:=4 PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_DISTNAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE:=$(PKG_DISTNAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot
PKG_MD5SUM:= PKG_MD5SUM:=192bb231082d9159fb6e16de3039b6b2
PKG_BUILD_DEPENDS:=zlib PKG_BUILD_DEPENDS:=zlib
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
@ -26,31 +26,53 @@ define Package/uboot-envtools
CATEGORY:=Utilities CATEGORY:=Utilities
TITLE:=read/modify U-Boot bootloader environment TITLE:=read/modify U-Boot bootloader environment
URL:=http://www.denx.de/wiki/U-Boot URL:=http://www.denx.de/wiki/U-Boot
MENU:=1
endef
define Package/uboot-envtools/config
menu "Configuration"
depends on PACKAGE_uboot-envtools
config PACKAGE_uboot-envtools_setenv_symlink
bool "Create fw_setenv symlink"
default n
help
With this option selected you will be able to edit U-Boot bootloader environment.
endmenu
endef endef
define Package/uboot-envtools/description define Package/uboot-envtools/description
This package includes tools to read and modify U-Boot bootloader environment. This package includes tools to read and modify U-Boot bootloader environment.
endef endef
define Package/uboot-envtools/config
config PACKAGE_uboot-envtools_setenv_symlink
bool "create fw_setenv symlink"
endef
define Package/uboot-envtools/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/fw_printenv $(1)/usr/sbin/
ifneq ($(CONFIG_PACKAGE_uboot-envtools_setenv_symlink),)
ln -s fw_printenv $(1)/usr/sbin/fw_setenv
endif
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/uboot-envtools.init $(1)/etc/init.d/uboot-envtools
endef
define Build/Prepare define Build/Prepare
mkdir -p $(PKG_BUILD_DIR) 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 tar xvjf $(DL_DIR)/$(PKG_SOURCE) --strip-components=2 -C $(PKG_BUILD_DIR) $(PKG_DISTNAME)-$(PKG_VERSION)/lib/crc32.c
$(call Build/Prepare/Default) $(call Build/Prepare/Default)
endef 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
ifneq ($(CONFIG_PACKAGE_uboot-envtools_setenv_symlink),)
ln -s fw_printenv $(1)/usr/sbin/fw_setenv
endif
$(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_lantiq),)
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) ./files/lantiq $(1)/etc/uci-defaults/uboot-envtools
endif
endef
$(eval $(call BuildPackage,uboot-envtools)) $(eval $(call BuildPackage,uboot-envtools))

View File

@ -0,0 +1,25 @@
#!/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"
;;
esac
config_load ubootenv
config_foreach ubootenv_add_app_config ubootenv
exit 0

View File

@ -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

View File

@ -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
}

View File

@ -84,7 +84,7 @@
#ifdef MTD_OLD #ifdef MTD_OLD
# include <stdint.h> # include <stdint.h>
@@ -210,13 +211,14 @@ static char default_environment[] = { @@ -212,13 +213,14 @@ static char default_environment[] = {
static int flash_io (int mode); static int flash_io (int mode);
static char *envmatch (char * s1, char * s2); static char *envmatch (char * s1, char * s2);
static int parse_config (void); static int parse_config (void);
@ -101,7 +101,7 @@
if (HaveRedundEnv) if (HaveRedundEnv)
rc -= sizeof (char); rc -= sizeof (char);
@@ -346,7 +348,7 @@ int fw_env_close(void) @@ -348,7 +350,7 @@ int fw_env_close(void)
/* /*
* Update CRC * Update CRC
*/ */
@ -110,16 +110,7 @@
/* write environment back to flash */ /* write environment back to flash */
if (flash_io(O_RDWR)) { if (flash_io(O_RDWR)) {
@@ -802,7 +804,7 @@ static int flash_write_buf (int dev, int @@ -1116,7 +1118,7 @@ int fw_env_open(void)
data = malloc (erase_len);
if (!data) {
fprintf (stderr,
- "Cannot malloc %u bytes: %s\n",
+ "Cannot malloc %zu bytes: %s\n",
erase_len, strerror (errno));
return -1;
}
@@ -1107,7 +1109,7 @@ int fw_env_open(void)
if (flash_io (O_RDONLY)) if (flash_io (O_RDONLY))
return -1; return -1;
@ -128,7 +119,7 @@
crc0_ok = (crc0 == *environment.crc); crc0_ok = (crc0 == *environment.crc);
if (!HaveRedundEnv) { if (!HaveRedundEnv) {
if (!crc0_ok) { if (!crc0_ok) {
@@ -1151,7 +1153,7 @@ int fw_env_open(void) @@ -1160,7 +1162,7 @@ int fw_env_open(void)
return -1; return -1;
} }

View File

@ -1,13 +1,13 @@
--- a/Makefile --- a/Makefile
+++ b/Makefile +++ b/Makefile
@@ -21,37 +21,16 @@ @@ -21,34 +21,17 @@
# MA 02111-1307 USA # MA 02111-1307 USA
# #
-include $(TOPDIR)/config.mk -include $(TOPDIR)/config.mk
- -
-HOSTSRCS := $(obj)crc32.c fw_env.c fw_env_main.c -HOSTSRCS := $(SRCTREE)/lib/crc32.c fw_env.c fw_env_main.c
+SRCS := crc32.c fw_env.c fw_env_main.c +SRCS := crc32.c fw_env.c fw_env_main.c
HEADERS := fw_env.h HEADERS := fw_env.h
-# Compile for a hosted environment on the target -# Compile for a hosted environment on the target
@ -19,27 +19,26 @@
-ifeq ($(MTD_VERSION),old) -ifeq ($(MTD_VERSION),old)
-HOSTCPPFLAGS += -DMTD_OLD -HOSTCPPFLAGS += -DMTD_OLD
-endif -endif
+CPPFLAGS := -Wall $(CFLAGS) -
-all: $(obj)fw_printenv
all: $(obj)fw_printenv -
-# Some files complain if compiled with -pedantic, use HOSTCFLAGS_NOPED
# Some files complain if compiled with -pedantic, use HOSTCFLAGS_NOPED
-$(obj)fw_printenv: $(HOSTSRCS) $(HEADERS) -$(obj)fw_printenv: $(HOSTSRCS) $(HEADERS)
- $(HOSTCC) $(HOSTCFLAGS_NOPED) $(HOSTLDFLAGS) -o $@ $(HOSTSRCS) - $(HOSTCC) $(HOSTCFLAGS_NOPED) $(HOSTLDFLAGS) -o $@ $(HOSTSRCS)
+$(obj)fw_printenv: $(SRCS) $(HEADERS) +CPPFLAGS := -Wall $(CFLAGS)
+ $(CC) $(CPPFLAGS) $(SRCS) -o $(obj)fw_printenv
-clean:
- rm -f $(obj)fw_printenv
+all: fw_printenv
clean:
- rm -f $(obj)fw_printenv $(obj)crc32.c
-
-$(obj)crc32.c:
- ln -s $(src)../../lib/crc32.c $(obj)crc32.c
-
-######################################################################### -#########################################################################
- +fw_printenv: $(SRCS) $(HEADERS)
+ $(CC) $(CPPFLAGS) $(SRCS) -o fw_printenv
-include $(TOPDIR)/rules.mk -include $(TOPDIR)/rules.mk
- -
-sinclude $(obj).depend -sinclude $(obj).depend
- +clean:
-######################################################################### + rm -f fw_printenv
+ rm -f $(obj)fw_printenv
#########################################################################

View File

@ -1,6 +1,6 @@
--- a/fw_env.c --- a/fw_env.c
+++ b/fw_env.c +++ b/fw_env.c
@@ -779,7 +779,10 @@ static int flash_write_buf (int dev, int @@ -790,7 +790,10 @@ static int flash_write_buf (int dev, int
erase_offset = (offset / blocklen) * blocklen; erase_offset = (offset / blocklen) * blocklen;
/* Maximum area we may use */ /* Maximum area we may use */

View File

@ -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;

View File

@ -1,37 +0,0 @@
#!/bin/sh
#
# Copyright (C) 2011 OpenWrt.org
#
add_ubootenv() {
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
}
[ -e /etc/config/ubootenv ] && exit 0
touch /etc/config/ubootenv
. /lib/ar71xx.sh
board=$(ar71xx_board_name)
case "$board" in
all0258n)
add_ubootenv /dev/mtd1 0x0 0x10000 0x10000
;;
esac
uci commit ubootenv

View File

@ -1,32 +0,0 @@
#!/bin/sh
#
# Copyright (C) 2012 OpenWrt.org
#
uboot_environment_configuration() {
local dev=$1
local offset=$2
local envsize=$3
local secsize=$4
local numsec=$5
echo "$dev $offset $envsize $secsize $numsec" > /etc/fw_env.config
}
[ -e /etc/config/fw_env.config ] && exit 0
. /lib/lantiq.sh
board=$(lantiq_board_name)
case "$board" in
GIGASX76X)
uboot_environment_configuration "/dev/mtd1" "0x0" "0x10000" "0x10000" "1"
;;
*)
# custom foo goes here
true
;;
esac
exit 0