Re: [OpenWrt-Devel] [PATCH v2] upgrade and improve uboot-envtools

2012-04-01 Thread Luka Perkov
I did not have time to test it on live board tonight (and I wont have time for
it this week), that is why I'm sending it here and not in separate thread
called v3...

This will be good enough for comments.

upgrade and improve uboot-env package

 * bumps to version 2011.12
 * adds md5sum
 * creates a menu so it will look better in "make menuconfig"
 * adds /etc/fw_env.config to conffile
 * adds /etc/config/ubootenv to conffile
 * refresh patches
 * removes init script because we should be using uci-defaults instead
 * supports all current targets using this package - ar71xx and lantiq

Regarding board all0258n:

 * fw_env.config is presrved during upgrade, it's in conffile
 * not included in patch but should be removed completely imho is 
platform_add_ramfs_ubootenv from:

target/linux/ar71xx/base-files/lib/upgrade/all0258n.sh

Also, can somebody explain why do we need platform_add_ramfs_ubootenv in that
file in the first place?

And here is the proposal:

 package/uboot-envtools/Makefile|   54 ++--
 package/uboot-envtools/files/ar71xx|   25 +
 package/uboot-envtools/files/lantiq|   25 +
 package/uboot-envtools/files/uboot-envtools.init   |   27 --
 package/uboot-envtools/files/uboot-envtools.sh |   36 +
 .../patches/001-crc32_func_signature.patch |9 
 package/uboot-envtools/patches/002-makefile.patch  |   39 +++---
 .../ar71xx/base-files/etc/uci-defaults/ubootenv|   37 --
 .../ar71xx/base-files/lib/upgrade/all0258n.sh  |1 -
 .../base-files/etc/uci-defaults/uboot_environment  |   32 
 10 files changed, 143 insertions(+), 142 deletions(-)

diff --git a/package/uboot-envtools/Makefile b/package/uboot-envtools/Makefile
index adb2aea..003eecc 100644
--- a/package/uboot-envtools/Makefile
+++ b/package/uboot-envtools/Makefile
@@ -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.
 # See /LICENSE for more information.
@@ -9,12 +9,12 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=uboot-envtools
 PKG_DISTNAME:=u-boot
-PKG_VERSION:=2011.06
-PKG_RELEASE:=4
+PKG_VERSION:=2011.12
+PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_DISTNAME)-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot
-PKG_MD5SUM:=
+PKG_MD5SUM:=7f29b9f6da44d6e46e988e7561fd1d5f
 PKG_BUILD_DEPENDS:=zlib
 
 include $(INCLUDE_DIR)/package.mk
@@ -26,31 +26,53 @@ define Package/uboot-envtools
   CATEGORY:=Utilities
   TITLE:=read/modify U-Boot bootloader environment
   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
 
 define Package/uboot-envtools/description
  This package includes tools to read and modify U-Boot bootloader environment.
 endef
 
-define Package/uboot-envtools/config
-config PACKAGE_uboot-envtools_setenv_symlink
-bool "create fw_setenv symlink"
+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/
+   $(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
-   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)
+   $(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))
diff --git a/package/uboot-envtools/files/ar71xx 
b/package/uboot-envtools/files/ar71xx
new file mode 100644
index 000..15b6b15
--- /dev/null
+++ b/package/uboot-en

Re: [OpenWrt-Devel] [PATCH v2] upgrade and improve uboot-envtools

2012-04-01 Thread Luka Perkov
Hi Daniel,

On Sun, Apr 01, 2012 at 11:44:11AM +0300, Daniel Golle wrote:
> > * removes init script because we should be using uci-defaults instead
> nack.
> The actual board-detection and uboot-env config should not be in the
> uboot-envtools package as it is very platform dependent. adding lantiq_env to
> uci-defaults obviously makes on lantiq platform only, but we are using
> uboot-envtools on a couple of different platforms.
> the approach of creating uci-configuration values from the a uci-default
> script of the platform and then have a run-once init script to generate the
> actual /etc/fw_env.config had a couple of reasons to be exactly as it was:
> in this way, the platform *defaults* always live in /etc/config/ubootenv and
> can be created by a uci-default script for every platform.

Agreed. Makes sense for me to leave this then. I will change it in v3.

> fw_env.config gets generated only if it doesn't exist yet and values in uci 
> exist.
> in this way, uboot-env remains target agnostic.

But we should do this with uci-defaults and not init script. init script is a
waste of resources uci-defaults will do a job just fine.

> the configuration, a far as OpenWrt is concerned, lives in uci.
> the configuration-file used by the fw_printenv/fw_setenv tool is generated
> from uci, just like it happens for most config-files in OpenWrt which are
> run-time generated out of uci. in this specific case I see that it makes sense
> to store it in /etc instead of /var/etc, as we don't want to overwrite
> user-made changes to this file and have the user brick his system...

Yes.
 
> > Changes since v1:
> > 
> > We should put target uboot environment uci-defaults in this package and use
> > Makefile to install correct one. I should have think of that the first
> > time. Idea is from owsip package.
> See above. target uboot environment uci-defaults should live at the targets
> imho , see
> target/linux/ar71xx/base-files/etc/uci-defaults/ubootenv
> for the way I intended it.

I dont think that is a good place to put the script there because every ar71xx
target will have that uci file even if user does not have uboot-envtools.

Look at this section from my patch:

+ifneq ($(CONFIG_TARGET_lantiq),)
+   $(INSTALL_DIR) $(1)/etc/uci-defaults
+   $(INSTALL_BIN) ./files/lantiq_env $(1)/etc/uci-defaults/uboot-envtools
+endif

I'll resend v3 with ar71xx included this way too.

Regards,
Luka
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH v2] upgrade and improve uboot-envtools

2012-04-01 Thread Daniel Golle
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 17/02/12 01:50, Luka Perkov wrote:
> This patch makes several changes with uboot-envtools package:
> 
> * bumps to version 2011.12
ack.
> * adds md5sum
ack.
> * creates a menu so it will look better in 'make menuconfig'
ack.
> * adds /etc/fw_env.config to conffile
ack.
> * refresh patches
ack.
> * removes init script because we should be using uci-defaults instead
nack.
The actual board-detection and uboot-env config should not be in the
uboot-envtools package as it is very platform dependent. adding lantiq_env to
uci-defaults obviously makes on lantiq platform only, but we are using
uboot-envtools on a couple of different platforms.
the approach of creating uci-configuration values from the a uci-default
script of the platform and then have a run-once init script to generate the
actual /etc/fw_env.config had a couple of reasons to be exactly as it was:
in this way, the platform *defaults* always live in /etc/config/ubootenv and
can be created by a uci-default script for every platform.
fw_env.config gets generated only if it doesn't exist yet and values in uci 
exist.
in this way, uboot-env remains target agnostic.
the configuration, a far as OpenWrt is concerned, lives in uci.
the configuration-file used by the fw_printenv/fw_setenv tool is generated
from uci, just like it happens for most config-files in OpenWrt which are
run-time generated out of uci. in this specific case I see that it makes sense
to store it in /etc instead of /var/etc, as we don't want to overwrite
user-made changes to this file and have the user brick his system...

> I would also like to maintain this package.
ack, it would be nice to have you maintining it :)

> Changes since v1:
> 
> We should put target uboot environment uci-defaults in this package and use
> Makefile to install correct one. I should have think of that the first
> time. Idea is from owsip package.
See above. target uboot environment uci-defaults should live at the targets
imho , see
target/linux/ar71xx/base-files/etc/uci-defaults/ubootenv
for the way I intended it.


Cheers for the good work!


Daniel
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.12 (GNU/Linux)

iQIcBAEBAgAGBQJPeBVTAAoJEDy9cKN/1Et0f4oP/20h1fXw4iry2luvHIRGrT9F
pjDmGBRstXW1MUx3otdCHbnJgblxGvjCLrdCT7k65Ph5oWFA+jN3l1ea8CS94054
vA6bPAISJg2MVdb2HwSCsFhSoGkMzm4tuC1BRrcSVaetvvci0o5ilnqr/n4L4Riq
HZCEDkPpq4t5Hb5yftYmrWvB6S6tsSIHSiLLx+Gt6GkV8fVjJ77X/P/TAwIYLzLE
aR4UZVAcOzk7fOu4qLMFFUUH5v4XKN3F8fKBVOU4gDgPsXqn9Q/gni/XkFF/CVn2
82kFgFz5FBSHUiNPmEmB+2KSs1WY8kgLRc/ZMcBr/f3EfMazsP3Ela/ycCtoTmS9
hD2KE3EKSK2J+Ibb7R0TzqPmFHpDYmKqYPEcYUo7vbgRTZKf+8ZTPZSc51vEPxsG
vui1MKisbB8tb3cASb0yAz1MXG1sPorE/IFcPM2g3L6yknl47XvkIoICRfAGzWDM
xNZZCfgcqxKCtgJFMjEXWegRaw3pxqAFRCilJxsXNdVZJXq4wLj3bAbG0k1X/eYz
i5//ykCb6xJHHuKwIUP2zm5rF4QDdT0iTpCEGQLOzYN/001qplRzc00NcTEow7Ce
iJHjIVJuaJkKDB2H9Krcv8rb4jNujjCFh6vaIOeN91YzjWMmaCJ8Royc9t1ucNQg
3K3pu+io7rElSQbbyXmH
=qNF5
-END PGP SIGNATURE-
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH v2] upgrade and improve uboot-envtools

2012-03-31 Thread Luka Perkov
Hi Conor,

On Fri, Mar 30, 2012 at 04:17:06PM +0100, Conor O'Gorman wrote:
> On Fri, 2012-02-17 at 00:50 +0100, Luka Perkov wrote:
> > This patch makes several changes with uboot-envtools package:
> > 
> >  * bumps to version 2011.12
> >  * adds md5sum
> >  * creates a menu so it will look better in 'make menuconfig'
> >  * adds /etc/fw_env.config to conffile
> >  * refresh patches
> >  * removes init script because we should be using uci-defaults instead
> > 
> > -board=$(lantiq_board_name)
> > -
> > -case "$board" in
> > -GIGASX76X)
> > -   uboot_environment_configuration "/dev/mtd1" "0x0" "0x1" "0x1" 
> > "1"
> > -   ;;
> 
> Why not go for a more general mechanism, you will have a lot of board
> specific options here. Is there a convention (or majority) for naming
> the env partition? such as 'uboot_env':
> 
> root@OpenWrt:/# cat /proc/mtd 
> dev:size   erasesize  name
> mtd0: 0001 0001 "uboot"
> mtd1: 003e 0001 "spare"
> mtd2: 0001 0001 "uboot_env"
> mtd3: 00c0 0001 "linux"
> mtd4: 00105026 0001 "kernel"
> mtd5: 00afafda 0001 "rootfs"
> mtd6: 0099 0001 "rootfs_data"

I dont think that would be a good approach. This way you could get "MTD
device name", "Device offset" and "Env. size". But "Flash sector size"
and "Number of sectors" I'm not so sure... Also, if the script would mess
something up you could brick the unit when using fw_setenv.

This patch as it is makes a big improvement to the package.

I'll resend v3 tomorrow due to recent changes in lantiq target.

Regards,
Luka

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH v2] upgrade and improve uboot-envtools

2012-03-30 Thread Conor O'Gorman
On Fri, 2012-02-17 at 00:50 +0100, Luka Perkov wrote:
> This patch makes several changes with uboot-envtools package:
> 
>  * bumps to version 2011.12
>  * adds md5sum
>  * creates a menu so it will look better in 'make menuconfig'
>  * adds /etc/fw_env.config to conffile
>  * refresh patches
>  * removes init script because we should be using uci-defaults instead
> 
> -board=$(lantiq_board_name)
> -
> -case "$board" in
> -GIGASX76X)
> - uboot_environment_configuration "/dev/mtd1" "0x0" "0x1" "0x1" 
> "1"
> - ;;

Why not go for a more general mechanism, you will have a lot of board
specific options here. Is there a convention (or majority) for naming
the env partition? such as 'uboot_env':

root@OpenWrt:/# cat /proc/mtd 
dev:size   erasesize  name
mtd0: 0001 0001 "uboot"
mtd1: 003e 0001 "spare"
mtd2: 0001 0001 "uboot_env"
mtd3: 00c0 0001 "linux"
mtd4: 00105026 0001 "kernel"
mtd5: 00afafda 0001 "rootfs"
mtd6: 0099 0001 "rootfs_data"

Conor

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v2] upgrade and improve uboot-envtools

2012-02-16 Thread Luka Perkov
This patch makes several changes with uboot-envtools package:

 * bumps to version 2011.12
 * adds md5sum
 * creates a menu so it will look better in 'make menuconfig'
 * adds /etc/fw_env.config to conffile
 * refresh patches
 * removes init script because we should be using uci-defaults instead

I would also like to maintain this package.

Changes since v1:

We should put target uboot environment uci-defaults in this package and
use Makefile to install correct one. I should have think of that the
first time. Idea is from owsip package.

Signed-off-by: Luka Perkov 
---

Index: target/linux/lantiq/base-files/etc/uci-defaults/uboot_environment
===
--- target/linux/lantiq/base-files/etc/uci-defaults/uboot_environment   
(revision 30604)
+++ target/linux/lantiq/base-files/etc/uci-defaults/uboot_environment   
(working copy)
@@ -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" "0x1" "0x1" 
"1"
-   ;;
-
-*)
-   # custom foo goes here
-   true
-   ;;
-esac
-
-exit 0
Index: package/uboot-envtools/files/lantiq_env
===
--- package/uboot-envtools/files/lantiq_env (revision 0)
+++ package/uboot-envtools/files/lantiq_env (working copy)
@@ -0,0 +1,32 @@
+#!/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" "0x1" "0x1" 
"1"
+   ;;
+
+*)
+   # custom foo goes here
+   true
+   ;;
+esac
+
+exit 0
Index: package/uboot-envtools/files/uboot-envtools.init
===
--- package/uboot-envtools/files/uboot-envtools.init(revision 30604)
+++ package/uboot-envtools/files/uboot-envtools.init(working copy)
@@ -1,27 +0,0 @@
-#!/bin/sh /etc/rc.common
-# (C) 2011 OpenWrt.org
-# Creates /etc/fw_env.conf for fw_printenv (and fw_setenv)
-
-START=80
-
-create_fwenv_config() {
-   local dev
-   local offset
-   local envsize
-   local secsize
-   local numsec
-   config_get dev "$1" dev
-   config_get offset "$1" offset "0x"
-   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
-}
-
-start() {
-   [ ! -e /etc/fw_env.config ] && {
-   echo "# MTD device name Device offset   Env. size   Flash 
sector size   Number of sectors" >/etc/fw_env.config
-   config_load ubootenv
-   config_foreach create_fwenv_config ubootenv
-   }
-}
Index: package/uboot-envtools/patches/001-crc32_func_signature.patch
===
--- package/uboot-envtools/patches/001-crc32_func_signature.patch   
(revision 30604)
+++ package/uboot-envtools/patches/001-crc32_func_signature.patch   
(working copy)
@@ -110,15 +110,6 @@
  
/* write environment back to flash */
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,
--   "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))
return -1;
Index: package/uboot-envtools/patches/002-makefile.patch
===
--- package/uboot-envtools/patches/002-makefile.patch   (revision 30604)
+++ package/uboot-envtools/patches/002-makefile.patch   (working copy)
@@ -1,13 +1,13 @@
 --- a/Makefile
 +++ b/Makefile
-@@ -21,37 +21,16 @@
+@@ -21,34 +21,17 @@
  # MA 02111-1307 USA
  #
  
 -include $(TOPDIR)/config.mk
 -
--HOSTSRCS := $(obj)crc32.c  fw_env.c  fw_env_main.c
-+SRCS := crc32.c  fw_env.c  fw_env_main.c
+-HOSTSRCS := $(SRCTREE)/lib/c