Author: titmuss
Date: Thu Jul 17 13:22:33 2008
New Revision: 2714
URL: http://svn.slimdevices.com?rev=2714&root=Jive&view=rev
Log:
Bug: N/A
Description:
Added uboot fw_env tools to build.
Compile jive kernel with EXTRAVERSION=-P7 for legacy reasons.
Added a pre-generated dropbear key, it takes too long to generate on the target.
Fixed paths, some programs are installed in a different place by poky.
Added:
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/base-files/files/dropbear_dss_host_key
(with props)
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/base-files/files/dropbear_rsa_host_key
(with props)
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/Makefile
(with props)
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/README
(with props)
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/crc32.c
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env.c
(with props)
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env.config
(with props)
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env.h
(with props)
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env_main.c
(with props)
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/uboot-env_1.0.bb
Modified:
7.2/trunk/squeezeos/poky/meta-squeezeos/classes/squeezeos-upgrade-image.bbclass
7.2/trunk/squeezeos/poky/meta-squeezeos/conf/machine/jive.conf
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/base-files/files/rcS
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/base-files/files/wlan
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/base-files/squeezeos-base-files_1.0.bb
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/images/squeezeos-image-boot.bb
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/linux/linux-jive_2.6.22.bb
Modified:
7.2/trunk/squeezeos/poky/meta-squeezeos/classes/squeezeos-upgrade-image.bbclass
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeos/poky/meta-squeezeos/classes/squeezeos-upgrade-image.bbclass?rev=2714&root=Jive&r1=2713&r2=2714&view=diff
==============================================================================
---
7.2/trunk/squeezeos/poky/meta-squeezeos/classes/squeezeos-upgrade-image.bbclass
(original)
+++
7.2/trunk/squeezeos/poky/meta-squeezeos/classes/squeezeos-upgrade-image.bbclass
Thu Jul 17 13:22:33 2008
@@ -22,7 +22,7 @@
zip ${DEPLOY_DIR_IMAGE}/jive_${VERSION}.bin *
cd ${DEPLOY_DIR_IMAGE}
- rm jive.bin
+ rm -f jive.bin
ln -s jive_${VERSION}.bin jive.bin
# Cleanup
Modified: 7.2/trunk/squeezeos/poky/meta-squeezeos/conf/machine/jive.conf
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeos/poky/meta-squeezeos/conf/machine/jive.conf?rev=2714&root=Jive&r1=2713&r2=2714&view=diff
==============================================================================
--- 7.2/trunk/squeezeos/poky/meta-squeezeos/conf/machine/jive.conf (original)
+++ 7.2/trunk/squeezeos/poky/meta-squeezeos/conf/machine/jive.conf Thu Jul 17
13:22:33 2008
@@ -11,4 +11,7 @@
IMAGE_FSTYPES ?= "cramfs"
SERIAL_CONSOLE = "-L 115200 tts/0"
+IMAGE_INSTALL += "uboot-env"
+#IMAGE_INSTALL += "marvell-gspi-jive"
+
require conf/machine/include/tune-arm926ejs.inc
Added:
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/base-files/files/dropbear_dss_host_key
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeos/poky/meta-squeezeos/packages/base-files/files/dropbear_dss_host_key?rev=2714&root=Jive&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/base-files/files/dropbear_dss_host_key
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/base-files/files/dropbear_rsa_host_key
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeos/poky/meta-squeezeos/packages/base-files/files/dropbear_rsa_host_key?rev=2714&root=Jive&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/base-files/files/dropbear_rsa_host_key
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: 7.2/trunk/squeezeos/poky/meta-squeezeos/packages/base-files/files/rcS
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeos/poky/meta-squeezeos/packages/base-files/files/rcS?rev=2714&root=Jive&r1=2713&r2=2714&view=diff
==============================================================================
--- 7.2/trunk/squeezeos/poky/meta-squeezeos/packages/base-files/files/rcS
(original)
+++ 7.2/trunk/squeezeos/poky/meta-squeezeos/packages/base-files/files/rcS Thu
Jul 17 13:22:33 2008
@@ -75,12 +75,12 @@
# Create ssh keys
if ! [ -f /etc/dropbear/dropbear_rsa_host_key ] ; then
echo "Creating dropbear rsa host key"
- /usr/bin/dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
+ /usr/sbin/dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
fi
if ! [ -f /etc/dropbear/dropbear_dss_host_key ]; then
echo "Creating dropbear dss host key"
- /usr/bin/dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key
+ /usr/sbin/dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key
fi
Modified: 7.2/trunk/squeezeos/poky/meta-squeezeos/packages/base-files/files/wlan
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeos/poky/meta-squeezeos/packages/base-files/files/wlan?rev=2714&root=Jive&r1=2713&r2=2714&view=diff
==============================================================================
--- 7.2/trunk/squeezeos/poky/meta-squeezeos/packages/base-files/files/wlan
(original)
+++ 7.2/trunk/squeezeos/poky/meta-squeezeos/packages/base-files/files/wlan Thu
Jul 17 13:22:33 2008
@@ -30,11 +30,11 @@
if [ "x${REGIONCODE}" != "x" ]
then
echo "Setting region: ${REGIONCODE}"
- /usr/sbin/iwpriv eth0 setregioncode ${REGIONCODE}
+ /sbin/iwpriv eth0 setregioncode ${REGIONCODE}
fi
# Enable power save
- /usr/sbin/iwconfig eth0 power on
+ /sbin/iwconfig eth0 power on
# Start wpa supplicant
/usr/bin/logger "Starting wpa_supplicant"
Modified:
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/base-files/squeezeos-base-files_1.0.bb
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeos/poky/meta-squeezeos/packages/base-files/squeezeos-base-files_1.0.bb?rev=2714&root=Jive&r1=2713&r2=2714&view=diff
==============================================================================
---
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/base-files/squeezeos-base-files_1.0.bb
(original)
+++
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/base-files/squeezeos-base-files_1.0.bb
Thu Jul 17 13:22:33 2008
@@ -3,7 +3,7 @@
PRIORITY = "required"
LICENSE = "GPL"
-PR = "r5"
+PR = "r7"
SRC_URI = " \
file://config \
@@ -33,6 +33,8 @@
file://wlan \
file://wpa_action \
file://wpa_supplicant.conf \
+ file://dropbear_dss_host_key \
+ file://dropbear_rsa_host_key \
"
S = "${WORKDIR}"
@@ -46,9 +48,9 @@
${localstatedir}/lib ${localstatedir}/log ${localstatedir}/run \
/sys ${localstatedir}/lib/misc ${localstatedir}/spool \
/mnt /media /media/card /media/cf /media/net /media/ram \
- /media/union /media/realroot /media/hdd \
- /media/mmc1 \
- /mnt/storage /mnt/overlay /mnt/mmc ${sysconfdir}/init.d"
+ /media/union /media/realroot /media/hdd /media/mmc1 \
+ /mnt/storage /mnt/overlay /mnt/mmc ${sysconfdir}/init.d \
+ ${sysconfdir}/dropbear"
do_install () {
@@ -86,6 +88,10 @@
install -m 0644 ${WORKDIR}/hostname ${D}${sysconfdir}/hostname
ln -sf /proc/mounts ${D}${sysconfdir}/mtab
+ # dropbear keys - these should be dynamically generated, but it takes
too long
+ install -m 0600 ${WORKDIR}/dropbear_dss_host_key
${D}${sysconfdir}/dropbear/dropbear_dss_host_key
+ install -m 0600 ${WORKDIR}/dropbear_rsa_host_key
${D}${sysconfdir}/dropbear/dropbear_rsa_host_key
+
# network scripts
install -m 0755 -d ${D}${sysconfdir}/network/if-down.d
install -m 0755 -d ${D}${sysconfdir}/network/if-post-down.d
Modified:
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/images/squeezeos-image-boot.bb
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeos/poky/meta-squeezeos/packages/images/squeezeos-image-boot.bb?rev=2714&root=Jive&r1=2713&r2=2714&view=diff
==============================================================================
---
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/images/squeezeos-image-boot.bb
(original)
+++
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/images/squeezeos-image-boot.bb
Thu Jul 17 13:22:33 2008
@@ -5,7 +5,7 @@
inherit image squeezeos-upgrade-image
-IMAGE_INSTALL = " \
+IMAGE_INSTALL += " \
squeezeos-base-files \
busybox \
mtd-utils \
Modified:
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/linux/linux-jive_2.6.22.bb
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeos/poky/meta-squeezeos/packages/linux/linux-jive_2.6.22.bb?rev=2714&root=Jive&r1=2713&r2=2714&view=diff
==============================================================================
--- 7.2/trunk/squeezeos/poky/meta-squeezeos/packages/linux/linux-jive_2.6.22.bb
(original)
+++ 7.2/trunk/squeezeos/poky/meta-squeezeos/packages/linux/linux-jive_2.6.22.bb
Thu Jul 17 13:22:33 2008
@@ -2,7 +2,7 @@
SECTION = "kernel"
LICENSE = "GPL"
-#PR = "r0"
+PR = "r1"
inherit kernel
@@ -35,6 +35,13 @@
}
+# jive needs EXTRAVERSION -P7 for legacy reasons
+EXTRA_OEMAKE = "EXTRAVERSION=-P7"
+
+# adjust the package names to remove the -P7
+PKG_kernel-image = "kernel-image-${PV}"
+PKG_kernel-base = "kernel-${PV}"
+
do_deploy() {
install -d ${DEPLOY_DIR_IMAGE}
install -m 0644 arch/${ARCH}/boot/${KERNEL_IMAGETYPE}
${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${PV}-${MACHINE}-${DATETIME}.bin
Added:
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/Makefile
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/Makefile?rev=2714&root=Jive&view=auto
==============================================================================
--- 7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/Makefile
(added)
+++ 7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/Makefile
Thu Jul 17 13:22:33 2008
@@ -1,0 +1,42 @@
+#
+# (C) Copyright 2002
+# Wolfgang Denk, DENX Software Engineering, [EMAIL PROTECTED]
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+SOURCES := crc32.c fw_env.c fw_env_main.c
+HEADERS := fw_env.h
+
+all: fw_printenv
+
+fw_printenv: $(SOURCES) $(HEADERS)
+ $(CC) -Wall $(CFLAGS) -DUSE_HOSTCC $(SOURCES) -o fw_printenv
+
+clean:
+ rm -f fw_printenv
+
+#########################################################################
+
+.depend: Makefile $(SOURCES)
+ $(CC) -M $(HOST_CFLAGS) $(CPPFLAGS) -DUSE_HOSTCC $(SOURCES) > $@
+
+sinclude .depend
+
+#########################################################################
Propchange:
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/Makefile
------------------------------------------------------------------------------
svn:executable = *
Added: 7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/README
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/README?rev=2714&root=Jive&view=auto
==============================================================================
--- 7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/README
(added)
+++ 7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/README
Thu Jul 17 13:22:33 2008
@@ -1,0 +1,44 @@
+
+This is a demo implementation of a Linux command line tool to access
+the U-Boot's environment variables.
+
+For the run-time utiltity configuration uncomment the line
+#define CONFIG_FILE "/etc/fw_env.config"
+in fw_env.h.
+
+See comments in the fw_env.config file for definitions for the
+particular board.
+
+Configuration can also be done via #defines in the fw_env.h file. The
+following lines are relevant:
+
+#define HAVE_REDUND /* For systems with 2 env sectors */
+#define DEVICE1_NAME "/dev/mtd1"
+#define DEVICE2_NAME "/dev/mtd2"
+#define DEVICE1_OFFSET 0x0000
+#define ENV1_SIZE 0x4000
+#define DEVICE1_ESIZE 0x4000
+#define DEVICE2_OFFSET 0x0000
+#define ENV2_SIZE 0x4000
+#define DEVICE2_ESIZE 0x4000
+
+Current configuration matches the environment layout of the TRAB
+board.
+
+Un-define HAVE_REDUND, if you want to use the utlities on a system
+that does not have support for redundant environment enabled.
+If HAVE_REDUND is undefined, DEVICE2_NAME is ignored,
+as is ENV2_SIZE and DEVICE2_ESIZE.
+
+The DEVICEx_NAME constants define which MTD character devices are to
+be used to access the environment.
+
+The DEVICEx_OFFSET constants define the environment offset within the
+MTD character device.
+
+ENVx_SIZE defines the size in bytes taken by the environment, which
+may be less then flash sector size, if the environment takes less
+then 1 sector.
+
+DEVICEx_ESIZE defines the size of the first sector in the flash
+partition where the environment resides.
Propchange:
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/README
------------------------------------------------------------------------------
svn:executable = *
Added:
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/crc32.c
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/crc32.c?rev=2714&root=Jive&view=auto
==============================================================================
--- 7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/crc32.c
(added)
+++ 7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/crc32.c
Thu Jul 17 13:22:33 2008
@@ -1,0 +1,197 @@
+/*
+ * This file is derived from crc32.c from the zlib-1.1.3 distribution
+ * by Jean-loup Gailly and Mark Adler.
+ */
+
+/* crc32.c -- compute the CRC-32 of a data stream
+ * Copyright (C) 1995-1998 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#ifndef USE_HOSTCC /* Shut down "ANSI does not permit..." warnings */
+#include <common.h> /* to get command definitions like CFG_CMD_JFFS2 */
+#endif
+
+#include "zlib.h"
+
+#define local static
+#define ZEXPORT /* empty */
+unsigned long crc32 (unsigned long, const unsigned char *, unsigned int);
+
+#ifdef DYNAMIC_CRC_TABLE
+
+local int crc_table_empty = 1;
+local uLongf crc_table[256];
+local void make_crc_table OF((void));
+
+/*
+ Generate a table for a byte-wise 32-bit CRC calculation on the polynomial:
+ x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
+
+ Polynomials over GF(2) are represented in binary, one bit per coefficient,
+ with the lowest powers in the most significant bit. Then adding polynomials
+ is just exclusive-or, and multiplying a polynomial by x is a right shift by
+ one. If we call the above polynomial p, and represent a byte as the
+ polynomial q, also with the lowest power in the most significant bit (so the
+ byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
+ where a mod b means the remainder after dividing a by b.
+
+ This calculation is done using the shift-register method of multiplying and
+ taking the remainder. The register is initialized to zero, and for each
+ incoming bit, x^32 is added mod p to the register if the bit is a one (where
+ x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
+ x (which is shifting right by one and adding x^32 mod p if the bit shifted
+ out is a one). We start with the highest power (least significant bit) of
+ q and repeat for all eight bits of q.
+
+ The table is simply the CRC of all possible eight bit values. This is all
+ the information needed to generate CRC's on data a byte at a time for all
+ combinations of CRC register values and incoming bytes.
+*/
+local void make_crc_table()
+{
+ uLong c;
+ int n, k;
+ uLong poly; /* polynomial exclusive-or pattern */
+ /* terms of polynomial defining this crc (except x^32): */
+ static const Byte p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
+
+ /* make exclusive-or pattern from polynomial (0xedb88320L) */
+ poly = 0L;
+ for (n = 0; n < sizeof(p)/sizeof(Byte); n++)
+ poly |= 1L << (31 - p[n]);
+
+ for (n = 0; n < 256; n++)
+ {
+ c = (uLong)n;
+ for (k = 0; k < 8; k++)
+ c = c & 1 ? poly ^ (c >> 1) : c >> 1;
+ crc_table[n] = c;
+ }
+ crc_table_empty = 0;
+}
+#else
+/* ========================================================================
+ * Table of CRC-32's of all single-byte values (made by make_crc_table)
+ */
+local const uLongf crc_table[256] = {
+ 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
+ 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
+ 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
+ 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
+ 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
+ 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
+ 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
+ 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
+ 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
+ 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
+ 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
+ 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
+ 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
+ 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
+ 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
+ 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
+ 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
+ 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
+ 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
+ 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
+ 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
+ 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
+ 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
+ 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
+ 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
+ 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
+ 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
+ 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
+ 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
+ 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
+ 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
+ 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
+ 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
+ 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
+ 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
+ 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
+ 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
+ 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
+ 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
+ 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
+ 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
+ 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
+ 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
+ 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
+ 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
+ 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
+ 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
+ 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
+ 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
+ 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
+ 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
+ 0x2d02ef8dL
+};
+#endif
+
+#if 0
+/* =========================================================================
+ * This function can be used by asm versions of crc32()
+ */
+const uLongf * ZEXPORT get_crc_table()
+{
+#ifdef DYNAMIC_CRC_TABLE
+ if (crc_table_empty) make_crc_table();
+#endif
+ return (const uLongf *)crc_table;
+}
+#endif
+
+/* ========================================================================= */
+#define DO1(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
+#define DO2(buf) DO1(buf); DO1(buf);
+#define DO4(buf) DO2(buf); DO2(buf);
+#define DO8(buf) DO4(buf); DO4(buf);
+
+/* ========================================================================= */
+uLong ZEXPORT crc32(crc, buf, len)
+ uLong crc;
+ const Bytef *buf;
+ uInt len;
+{
+#ifdef DYNAMIC_CRC_TABLE
+ if (crc_table_empty)
+ make_crc_table();
+#endif
+ crc = crc ^ 0xffffffffL;
+ while (len >= 8)
+ {
+ DO8(buf);
+ len -= 8;
+ }
+ if (len) do {
+ DO1(buf);
+ } while (--len);
+ return crc ^ 0xffffffffL;
+}
+
+#if (CONFIG_COMMANDS & CFG_CMD_JFFS2)
+
+/* No ones complement version. JFFS2 (and other things ?)
+ * don't use ones compliment in their CRC calculations.
+ */
+uLong ZEXPORT crc32_no_comp(uLong crc, const Bytef *buf, uInt len)
+{
+#ifdef DYNAMIC_CRC_TABLE
+ if (crc_table_empty)
+ make_crc_table();
+#endif
+ while (len >= 8)
+ {
+ DO8(buf);
+ len -= 8;
+ }
+ if (len) do {
+ DO1(buf);
+ } while (--len);
+
+ return crc;
+}
+
+#endif /* CFG_CMD_JFFS2 */
Added:
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env.c
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env.c?rev=2714&root=Jive&view=auto
==============================================================================
--- 7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env.c
(added)
+++ 7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env.c
Thu Jul 17 13:22:33 2008
@@ -1,0 +1,671 @@
+/*
+ * (C) Copyright 2000-2003
+ * Wolfgang Denk, DENX Software Engineering, [EMAIL PROTECTED]
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+//#include <linux/compiler.h>
+#include <mtd/mtd-user.h>
+#include "fw_env.h"
+
+typedef unsigned char uchar;
+
+#define CMD_GETENV "fw_printenv"
+#define CMD_SETENV "fw_setenv"
+
+typedef struct envdev_s {
+ uchar devname[16]; /* Device name */
+ ulong devoff; /* Device offset */
+ ulong env_size; /* environment size */
+ ulong erase_size; /* device erase size */
+} envdev_t;
+
+static envdev_t envdevices[2];
+static int curdev;
+
+#define DEVNAME(i) envdevices[(i)].devname
+#define DEVOFFSET(i) envdevices[(i)].devoff
+#define ENVSIZE(i) envdevices[(i)].env_size
+#define DEVESIZE(i) envdevices[(i)].erase_size
+
+#define CFG_ENV_SIZE ENVSIZE(curdev)
+
+#define ENV_SIZE getenvsize()
+
+typedef struct environment_s {
+ ulong crc; /* CRC32 over data bytes */
+ uchar flags; /* active or obsolete */
+ uchar *data;
+} env_t;
+
+static env_t environment;
+
+static int HaveRedundEnv = 0;
+
+
+#define XMK_STR(x) #x
+#define MK_STR(x) XMK_STR(x)
+
+static uchar default_environment[] = {
+#if defined(CONFIG_BOOTARGS)
+ "bootargs=" CONFIG_BOOTARGS "\0"
+#endif
+#if defined(CONFIG_BOOTCOMMAND)
+ "bootcmd=" CONFIG_BOOTCOMMAND "\0"
+#endif
+#if defined(CONFIG_RAMBOOTCOMMAND)
+ "ramboot=" CONFIG_RAMBOOTCOMMAND "\0"
+#endif
+#if defined(CONFIG_NFSBOOTCOMMAND)
+ "nfsboot=" CONFIG_NFSBOOTCOMMAND "\0"
+#endif
+#if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0)
+ "bootdelay=" MK_STR (CONFIG_BOOTDELAY) "\0"
+#endif
+#if defined(CONFIG_BAUDRATE) && (CONFIG_BAUDRATE >= 0)
+ "baudrate=" MK_STR (CONFIG_BAUDRATE) "\0"
+#endif
+#ifdef CONFIG_LOADS_ECHO
+ "loads_echo=" MK_STR (CONFIG_LOADS_ECHO) "\0"
+#endif
+#ifdef CONFIG_ETHADDR
+ "ethaddr=" MK_STR (CONFIG_ETHADDR) "\0"
+#endif
+#ifdef CONFIG_ETH1ADDR
+ "eth1addr=" MK_STR (CONFIG_ETH1ADDR) "\0"
+#endif
+#ifdef CONFIG_ETH2ADDR
+ "eth2addr=" MK_STR (CONFIG_ETH2ADDR) "\0"
+#endif
+#ifdef CONFIG_ETHPRIME
+ "ethprime=" CONFIG_ETHPRIME "\0"
+#endif
+#ifdef CONFIG_IPADDR
+ "ipaddr=" MK_STR (CONFIG_IPADDR) "\0"
+#endif
+#ifdef CONFIG_SERVERIP
+ "serverip=" MK_STR (CONFIG_SERVERIP) "\0"
+#endif
+#ifdef CFG_AUTOLOAD
+ "autoload=" CFG_AUTOLOAD "\0"
+#endif
+#ifdef CONFIG_ROOTPATH
+ "rootpath=" MK_STR (CONFIG_ROOTPATH) "\0"
+#endif
+#ifdef CONFIG_GATEWAYIP
+ "gatewayip=" MK_STR (CONFIG_GATEWAYIP) "\0"
+#endif
+#ifdef CONFIG_NETMASK
+ "netmask=" MK_STR (CONFIG_NETMASK) "\0"
+#endif
+#ifdef CONFIG_HOSTNAME
+ "hostname=" MK_STR (CONFIG_HOSTNAME) "\0"
+#endif
+#ifdef CONFIG_BOOTFILE
+ "bootfile=" MK_STR (CONFIG_BOOTFILE) "\0"
+#endif
+#ifdef CONFIG_LOADADDR
+ "loadaddr=" MK_STR (CONFIG_LOADADDR) "\0"
+#endif
+#ifdef CONFIG_PREBOOT
+ "preboot=" CONFIG_PREBOOT "\0"
+#endif
+#ifdef CONFIG_CLOCKS_IN_MHZ
+ "clocks_in_mhz=" "1" "\0"
+#endif
+#if defined(CONFIG_PCI_BOOTDELAY) && (CONFIG_PCI_BOOTDELAY > 0)
+ "pcidelay=" MK_STR (CONFIG_PCI_BOOTDELAY) "\0"
+#endif
+#ifdef CONFIG_EXTRA_ENV_SETTINGS
+ CONFIG_EXTRA_ENV_SETTINGS
+#endif
+ "\0" /* Termimate env_t data with 2 NULs */
+};
+
+static int flash_io_read ();
+static int flash_io_write ();
+static uchar *envmatch (uchar * s1, uchar * s2);
+static int env_init (void);
+static int parse_config (void);
+
+#if defined(CONFIG_FILE)
+static int get_config (char *);
+#endif
+static inline ulong getenvsize (void)
+{
+ ulong rc = CFG_ENV_SIZE - sizeof (long);
+
+ // if (HaveRedundEnv)
+ // rc -= sizeof (char);
+ return rc;
+}
+
+/*
+ * Search the environment for a variable.
+ * Return the value, if found, or NULL, if not found.
+ */
+unsigned char *fw_getenv (unsigned char *name)
+{
+ uchar *env, *nxt;
+
+ if (env_init ())
+ return (NULL);
+
+ for (env = environment.data; *env; env = nxt + 1) {
+ uchar *val;
+
+ for (nxt = env; *nxt; ++nxt) {
+ if (nxt >= &environment.data[ENV_SIZE]) {
+ fprintf (stderr, "## Error: "
+ "environment not terminated\n");
+ return (NULL);
+ }
+ }
+ val = envmatch (name, env);
+ if (!val)
+ continue;
+ return (val);
+ }
+ return (NULL);
+}
+
+/*
+ * Print the current definition of one, or more, or all
+ * environment variables
+ */
+void fw_printenv (int argc, char *argv[])
+{
+ uchar *env, *nxt;
+ int i, n_flag;
+
+ if (env_init ())
+ return;
+
+ if (argc == 1) { /* Print all env variables */
+ for (env = environment.data; *env; env = nxt + 1) {
+ for (nxt = env; *nxt; ++nxt) {
+ if (nxt >= &environment.data[ENV_SIZE]) {
+ fprintf (stderr, "## Error: "
+ "environment not terminated\n");
+ return;
+ }
+ }
+
+ printf ("%s\n", env);
+ }
+ return;
+ }
+
+ if (strcmp (argv[1], "-n") == 0) {
+ n_flag = 1;
+ ++argv;
+ --argc;
+ if (argc != 2) {
+ fprintf (stderr, "## Error: "
+ "`-n' option requires exactly one argument\n");
+ return;
+ }
+ } else {
+ n_flag = 0;
+ }
+
+ for (i = 1; i < argc; ++i) { /* print single env variables */
+ uchar *name = (uchar *) argv[i];
+ uchar *val = NULL;
+
+ for (env = environment.data; *env; env = nxt + 1) {
+
+ for (nxt = env; *nxt; ++nxt) {
+ if (nxt >= &environment.data[ENV_SIZE]) {
+ fprintf (stderr, "## Error: "
+ "environment not terminated\n");
+ return;
+ }
+ }
+ val = envmatch (name, env);
+ if (val) {
+ if (!n_flag) {
+ fputs ((char *)name, stdout);
+ putc ('=', stdout);
+ }
+ puts ((char *)val);
+ break;
+ }
+ }
+ if (!val)
+ fprintf (stderr, "## Error: \"%s\" not defined\n",
name);
+ }
+}
+
+int fw_setenvs(int argc, char *argv[])
+{
+ int argNb;
+ int len;
+ uchar *env, *nxt;
+ uchar *oldval = NULL;
+ uchar *name;
+ uchar *value;
+
+ if (argc < 2) {
+ return (EINVAL);
+ }
+
+ if (env_init ())
+ return (errno);
+
+ for (argNb=1;argNb<argc;argNb+=2) {
+ name = (uchar *)(argv[argNb]);
+ value = (uchar *)(argv[argNb+1]);
+ /*
+ * search if variable with this name already exists
+ */
+ for (nxt = env = environment.data; *env; env = nxt + 1) {
+ for (nxt = env; *nxt; ++nxt) {
+ if (nxt >= &environment.data[ENV_SIZE]) {
+ fprintf (stderr, "## Error: "
+ "environment not terminated\n");
+ return (EINVAL);
+ }
+ }
+ if ((oldval = envmatch (name, env)) != NULL)
+ break;
+ }
+
+ /*
+ * Delete any existing definition
+ */
+ if (oldval) {
+ /*
+ * Ethernet Address and serial# can be set only once
+ */
+ if ((strcmp ((char *)name, "ethaddr") == 0) ||
+ (strcmp ((char *)name, "serial#") == 0)) {
+ fprintf (stderr, "Can't overwrite \"%s\"\n",
name);
+ return (EROFS);
+ }
+
+ if (*++nxt == '\0') {
+ *env = '\0';
+ } else {
+ for (;;) {
+ *env = *nxt++;
+ if ((*env == '\0') && (*nxt == '\0'))
+ break;
+ ++env;
+ }
+ }
+ *++env = '\0';
+ }
+
+ /* Delete only ? */
+ if (strlen((char *)value)!=0) {
+ /*
+ * Append new definition at the end
+ */
+ for (env = environment.data; *env || *(env + 1); ++env);
+ if (env > environment.data)
+ ++env;
+ /*
+ * Overflow when:
+ * "name" + "=" + "val" +"\0\0" > CFG_ENV_SIZE -
(env-environment)
+ */
+ len = strlen ((char *)name) + 2;
+ /* add '=' for first arg, ' ' for all others */
+ len += strlen ((char *)value) + 1;
+ if (len > (&environment.data[ENV_SIZE] - env)) {
+ fprintf (stderr,
+ "Error: environment overflow\n");
+ return (-1);
+ }
+ while ((*env = *name++) != '\0')
+ env++;
+ uchar *val = (uchar *)argv[argNb+1];
+ *env = '=';
+ while ((*++env = *val++) != '\0');
+ }
+
+ /* end is marked with double '\0' */
+ *++env = '\0';
+ }
+
+ /* Update CRC */
+ environment.crc = crc32 (0, environment.data, ENV_SIZE);
+
+ /* write environment back to flash */
+ if (flash_io_write ()) {
+ fprintf (stderr, "Error: can't write fw_env to flash\n");
+ return (-1);
+ }
+
+ return (0);
+
+}
+
+
+static int flash_io_write_part (int fd, int otherdev) {
+ int len;
+ erase_info_t erase;
+ char *data = NULL;
+
+ len = sizeof (environment.crc);
+
+ /* erase existing environment */
+ printf ("Erasing old environment %s:%lx\n", DEVNAME (otherdev),
DEVOFFSET(otherdev));
+
+ erase.length = DEVESIZE (otherdev);
+ erase.start = DEVOFFSET (otherdev);
+ if (ioctl (fd, MEMERASE, &erase) != 0) {
+ fprintf (stderr, "MTD erase error on %s: %s\n",
+ DEVNAME (otherdev),
+ strerror (errno));
+ return (-1);
+ }
+
+ printf ("Writing environment to %s:%lx\n", DEVNAME (otherdev),
DEVOFFSET(otherdev));
+
+ if ((data = malloc(DEVESIZE(otherdev))) == NULL) {
+ fprintf(stderr, "Cannot malloc %ld bytes: %s\n",
+ DEVESIZE(otherdev),
+ strerror (errno));
+ return (-1);
+ }
+
+ /* set environment data */
+ memcpy(data, &environment, len);
+ memcpy(data + len, environment.data, ENV_SIZE);
+
+ /* write updated environment */
+ if (lseek (fd, DEVOFFSET (otherdev), SEEK_SET) == -1) {
+ fprintf (stderr,
+ "seek error on %s: %s\n",
+ DEVNAME (otherdev), strerror (errno));
+ return (-1);
+ }
+
+ if (write (fd, data, DEVESIZE(otherdev)) != DEVESIZE(otherdev)) {
+ fprintf (stderr,
+ "MTD write error on %s: %s\n",
+ DEVNAME (otherdev), strerror (errno));
+ return (-1);
+ }
+
+ free(data);
+
+ return 0;
+}
+
+
+static int flash_io_write ()
+{
+ int fd;
+
+ if ((fd = open ((char *)DEVNAME (curdev), O_RDWR)) < 0) {
+ fprintf (stderr,
+ "Can't open %s: %s\n",
+ DEVNAME (curdev), strerror (errno));
+ return (-1);
+ }
+
+ if (HaveRedundEnv) {
+
+ if (curdev == 0) {
+ flash_io_write_part (fd, 1);
+ flash_io_write_part (fd, 0);
+ }
+ else {
+ flash_io_write_part (fd, 0);
+ flash_io_write_part (fd, 1);
+ }
+ }
+ else {
+ flash_io_write_part (fd, 0);
+ }
+
+ if (close (fd)) {
+ fprintf (stderr,
+ "I/O error on %s: %s\n",
+ DEVNAME (curdev), strerror (errno));
+ return (-1);
+ }
+
+ /* everything ok */
+ return (0);
+}
+
+static int flash_io_read()
+{
+ int fd, rc, len;
+
+ //printf ("Reading environment to %s:%lx\n", DEVNAME (curdev),
DEVOFFSET(curdev));
+
+ if ((fd = open ((char *)DEVNAME (curdev), O_RDONLY)) < 0) {
+ fprintf (stderr,
+ "Can't open %s: %s\n",
+ DEVNAME (curdev), strerror (errno));
+ return (-1);
+ }
+
+ len = sizeof (environment.crc);
+ //if (HaveRedundEnv) {
+ // len += sizeof (environment.flags);
+ //}
+
+ if (lseek (fd, DEVOFFSET (curdev), SEEK_SET) == -1) {
+ fprintf (stderr,
+ "seek error on %s: %s\n",
+ DEVNAME (curdev), strerror (errno));
+ return (-1);
+ }
+ if (read (fd, &environment, len) != len) {
+ fprintf (stderr,
+ "CRC read error on %s: %s\n",
+ DEVNAME (curdev), strerror (errno));
+ return (-1);
+ }
+ if ((rc = read (fd, environment.data, ENV_SIZE)) != ENV_SIZE) {
+ fprintf (stderr,
+ "Read error on %s: %s\n",
+ DEVNAME (curdev), strerror (errno));
+ return (-1);
+ }
+
+ if (close (fd)) {
+ fprintf (stderr,
+ "I/O error on %s: %s\n",
+ DEVNAME (curdev), strerror (errno));
+ return (-1);
+ }
+
+ /* everything ok */
+ return (0);
+}
+
+/*
+ * s1 is either a simple 'name', or a 'name=value' pair.
+ * s2 is a 'name=value' pair.
+ * If the names match, return the value of s2, else NULL.
+ */
+
+static uchar *envmatch (uchar * s1, uchar * s2)
+{
+
+ while (*s1 == *s2++)
+ if (*s1++ == '=')
+ return (s2);
+ if (*s1 == '\0' && *(s2 - 1) == '=')
+ return (s2);
+ return (NULL);
+}
+
+/*
+ * Prevent confusion if running from erased flash memory
+ */
+static int env_init (void)
+{
+ int crc1, crc1_ok;
+ uchar *addr1;
+
+ int crc2, crc2_ok;
+
+ if (parse_config ()) /* should fill envdevices */
+ return 1;
+
+ if ((addr1 = calloc (1, ENV_SIZE)) == NULL) {
+ fprintf (stderr,
+ "Not enough memory for environment (%ld bytes)\n",
+ ENV_SIZE);
+ return (errno);
+ }
+
+ /* read environment block 0 from FLASH to local buffer */
+ environment.data = addr1;
+ curdev = 0;
+ if (flash_io_read()) {
+ return (errno);
+ }
+
+ crc1_ok = ((crc1 = crc32 (0, environment.data, ENV_SIZE))
+ == environment.crc);
+
+ if (crc1_ok) {
+ return 0;
+ }
+
+ if (!HaveRedundEnv) {
+ if (!crc1_ok) {
+ fprintf (stderr,
+ "Warning: Bad CRC, using default
environment\n");
+ memcpy(environment.data, default_environment,
sizeof(default_environment));
+ }
+ }
+
+ memset(addr1, 0, ENV_SIZE);
+
+ /* read environment block 1 from FLASH to local buffer */
+ curdev = 1;
+ if (flash_io_read()) {
+ return (errno);
+ }
+
+ crc2_ok = ((crc2 = crc32 (0, environment.data, ENV_SIZE))
+ == environment.crc);
+
+ if (crc2_ok) {
+ return (0);
+ }
+
+ /* default environment */
+ fprintf (stderr,
+ "Warning: Bad CRC, using default environment\n");
+ memcpy(environment.data, default_environment,
sizeof(default_environment));
+ curdev = 0;
+
+ return (0);
+}
+
+
+static int parse_config ()
+{
+ struct stat st;
+
+#if defined(CONFIG_FILE)
+ /* Fills in DEVNAME(), ENVSIZE(), DEVESIZE(). Or don't. */
+ if (get_config (CONFIG_FILE)) {
+ fprintf (stderr,
+ "Cannot parse config file: %s\n", strerror (errno));
+ return 1;
+ }
+#else
+ strcpy ((char *)DEVNAME (0), (char *)DEVICE1_NAME);
+ DEVOFFSET (0) = DEVICE1_OFFSET;
+ ENVSIZE (0) = ENV1_SIZE;
+ DEVESIZE (0) = DEVICE1_ESIZE;
+
+#if defined HAVE_REDUND
+ strcpy ((char *)DEVNAME (1), (char *)DEVICE2_NAME);
+ DEVOFFSET (1) = DEVICE2_OFFSET;
+ ENVSIZE (1) = ENV2_SIZE;
+ DEVESIZE (1) = DEVICE2_ESIZE;
+ HaveRedundEnv = 1;
+#endif
+#endif
+ if (stat ((char *)DEVNAME (0), &st)) {
+ fprintf (stderr,
+ "Cannot access MTD device %s: %s\n",
+ DEVNAME (0), strerror (errno));
+ return 1;
+ }
+
+ if (HaveRedundEnv && stat ((char *)DEVNAME (1), &st)) {
+ fprintf (stderr,
+ "Cannot access MTD device %s: %s\n",
+ DEVNAME (2), strerror (errno));
+ return 1;
+ }
+ return 0;
+}
+
+#if defined(CONFIG_FILE)
+static int get_config (char *fname)
+{
+ FILE *fp;
+ int i = 0;
+ int rc;
+ char dump[128];
+
+ if ((fp = fopen (fname, "r")) == NULL) {
+ return 1;
+ }
+
+ while ((i < 2) && ((rc = fscanf (fp, "%s %lx %lx %lx",
+ DEVNAME (i),
+ &DEVOFFSET (i),
+ &ENVSIZE (i),
+ &DEVESIZE (i) )) != EOF)) {
+
+ /* Skip incomplete conversions and comment strings */
+ if ((rc < 3) || (*DEVNAME (i) == '#')) {
+ fgets (dump, sizeof (dump), fp); /* Consume till
end */
+ continue;
+ }
+
+ i++;
+ }
+ fclose (fp);
+
+ HaveRedundEnv = i - 1;
+ if (!i) { /* No valid entries found */
+ errno = EINVAL;
+ return 1;
+ } else
+ return 0;
+}
+#endif
Propchange:
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env.c
------------------------------------------------------------------------------
svn:executable = *
Added:
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env.config
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env.config?rev=2714&root=Jive&view=auto
==============================================================================
---
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env.config
(added)
+++
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env.config
Thu Jul 17 13:22:33 2008
@@ -1,0 +1,7 @@
+# Configuration file for fw_(printenv/saveenv) utility.
+# Up to two entries are valid, in this case the redundand
+# environment sector is assumed present.
+
+# MTD device name Device offset Env. size Flash sector size
+/dev/mtd1 0x0000 0x4000 0x4000
+/dev/mtd2 0x0000 0x4000 0x4000
Propchange:
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env.config
------------------------------------------------------------------------------
svn:executable = *
Added:
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env.h
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env.h?rev=2714&root=Jive&view=auto
==============================================================================
--- 7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env.h
(added)
+++ 7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env.h
Thu Jul 17 13:22:33 2008
@@ -1,0 +1,64 @@
+/*
+ * (C) Copyright 2002
+ * Wolfgang Denk, DENX Software Engineering, [EMAIL PROTECTED]
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * To build the utility with the run-time configuration
+ * uncomment the next line.
+ * See included "fw_env.config" sample file (TRAB board)
+ * for notes on configuration.
+ */
+/*#define CONFIG_FILE "/etc/fw_env.config"*/
+
+#define HAVE_REDUND /* For systems with 2 env sectors */
+
+#define DEVICE1_NAME "/dev/mtd/3"
+#define DEVICE1_OFFSET 0x0000
+#define ENV1_SIZE 0x4000
+#define DEVICE1_ESIZE 0x4000
+
+#define DEVICE2_NAME "/dev/mtd/3"
+#define DEVICE2_OFFSET 0x4000
+#define ENV2_SIZE 0x4000
+#define DEVICE2_ESIZE 0x4000
+
+
+/*
+ * !!! WARNING !!!
+ *
+ * If you update these defines you MUST also update the values in
+ * include/configs/smdk2413.h.
+ */
+#define CONFIG_BOOTDELAY 1
+#define CONFIG_BOOTARGS "root=/dev/mtdblock1 console=ttySAC0,115200
mem=64M init=/linuxrc"
+#define CONFIG_BOOTCOMMAND "nandr $(kernelblock) 1d0000 30008000; setenv
bootargs $(bootargs) mtdset=$(mtdset); bootm"
+
+#define CONFIG_EXTRA_ENV_SETTINGS "sw6=echo Factory reset; blink; nande b00
1400000; blink\0" \
+ "kernelblock=c\0" \
+ "mtdset=0\0"
+
+
+extern void fw_printenv(int argc, char *argv[]);
+extern unsigned char *fw_getenv (unsigned char *name);
+extern int fw_setenvs (int argc, char *argv[]);
+
+extern unsigned long crc32 (unsigned long, const unsigned char *,
unsigned);
Propchange:
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env.h
------------------------------------------------------------------------------
svn:executable = *
Added:
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env_main.c
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env_main.c?rev=2714&root=Jive&view=auto
==============================================================================
---
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env_main.c
(added)
+++
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env_main.c
Thu Jul 17 13:22:33 2008
@@ -1,0 +1,76 @@
+/*
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, [EMAIL PROTECTED]
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * Command line user interface to firmware (=U-Boot) environment.
+ *
+ * Implements:
+ * Warning, quotes are important
+ * fw_printenv [ name ... ]
+ * - prints the values of the environment variables
+ * "name", or the whole environment if no names are
+ * specified
+ * fw_setenv name "value" name "value"
+ * - If a value "" is given, the variable
+ * with this name is deleted from the environment;
+ * otherwise the value is assigned to the environment
+ * variable "name"
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "fw_env.h"
+
+#define CMD_PRINTENV "fw_printenv"
+#define CMD_SETENV "fw_setenv"
+
+int
+main(int argc, char *argv[])
+{
+ char *p;
+ char *cmdname = *argv;
+
+ if ((p = strrchr (cmdname, '/')) != NULL) {
+ cmdname = p + 1;
+ }
+
+ if (strcmp(cmdname, CMD_PRINTENV) == 0) {
+
+ fw_printenv (argc, argv);
+ return (EXIT_SUCCESS);
+
+ } else if (strcmp(cmdname, CMD_SETENV) == 0) {
+
+ if (fw_setenvs (argc, argv) != 0) {
+ return (EXIT_FAILURE);
+ }
+ return (EXIT_SUCCESS);
+ }
+
+ fprintf (stderr,
+ "Identity crisis - may be called as `" CMD_PRINTENV
+ "' or as `" CMD_SETENV "' but not as `%s'\n",
+ cmdname);
+ return (EXIT_FAILURE);
+}
Propchange:
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/files/fw_env_main.c
------------------------------------------------------------------------------
svn:executable = *
Added:
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/uboot-env_1.0.bb
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/uboot-env_1.0.bb?rev=2714&root=Jive&view=auto
==============================================================================
---
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/uboot-env_1.0.bb
(added)
+++
7.2/trunk/squeezeos/poky/meta-squeezeos/packages/uboot-tools/uboot-env_1.0.bb
Thu Jul 17 13:22:33 2008
@@ -1,0 +1,22 @@
+DESCRIPTION = "uboot fw-env tools"
+SECTION = "base"
+LICENSE = "GPL"
+
+PR = "r1"
+
+SRC_URI=" \
+ file://Makefile \
+ file://fw_env.c \
+ file://fw_env.config \
+ file://fw_env.h \
+ file://fw_env_main.c \
+ file://crc32.c \
+ "
+
+S = ${WORKDIR}
+
+do_install() {
+ install -m 0755 -d ${D}${sbindir}
+ install -m 0755 ${WORKDIR}/fw_printenv ${D}${sbindir}/fw_printenv
+ ln -s fw_printenv.c ${D}${sbindir}/fw_setenv
+}
_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins