From 788312ae298c61a530a828a33cb0e77e92d40c1e Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Fri, 15 Feb 2008 11:38:31 +0100 Subject: [PATCH 01/11] add alternating mechanism and flash scripts for ipe337 - add scripts to flash kernel & environment from U-Boot - add mechanism to check which of the two kernels to boot - add script to initialize the ageing partition - cosmetic changes to the init-scripts --- .gitattributes | 1 + board/ipe337/env/bin/_alternate | 9 +++++++++ board/ipe337/env/bin/magic.bin | 1 + board/ipe337/env/bin/reset_ageing | 27 +++++++++++++++++++++++++ board/ipe337/env/bin/update_application | 8 ++++++++ board/ipe337/env/bin/update_persistent | 8 ++++++++ board/ipe337/env/bin/update_system | 14 +++++++++++++ board/ipe337/env/bin/update_ubootenv | 8 ++++++++ 8 files changed, 76 insertions(+) create mode 100644 .gitattributes create mode 100644 board/ipe337/env/bin/_alternate create mode 100644 board/ipe337/env/bin/magic.bin create mode 100644 board/ipe337/env/bin/reset_ageing create mode 100644 board/ipe337/env/bin/update_application create mode 100644 board/ipe337/env/bin/update_persistent create mode 100644 board/ipe337/env/bin/update_system create mode 100644 board/ipe337/env/bin/update_ubootenv diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..c24dffe1b --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.bin -crlf -diff -merge diff --git a/board/ipe337/env/bin/_alternate b/board/ipe337/env/bin/_alternate new file mode 100644 index 000000000..10ae2134c --- /dev/null +++ b/board/ipe337/env/bin/_alternate @@ -0,0 +1,9 @@ +#!/bin/sh + +. /env/config + +alternate $ageing +if [ $? -lt 2 ]; then + echo "Error when accesing ageing-partition!" + exit 1 +fi diff --git a/board/ipe337/env/bin/magic.bin b/board/ipe337/env/bin/magic.bin new file mode 100644 index 000000000..f8bff393c --- /dev/null +++ b/board/ipe337/env/bin/magic.bin @@ -0,0 +1 @@ +(i \ No newline at end of file diff --git a/board/ipe337/env/bin/reset_ageing b/board/ipe337/env/bin/reset_ageing new file mode 100644 index 000000000..2c95ae762 --- /dev/null +++ b/board/ipe337/env/bin/reset_ageing @@ -0,0 +1,27 @@ +#!/bin/sh + +. /env/config + +image=/env/bin/magic.bin +part=$ageing + +if [ \! -e "$part" ]; then + echo "Partition $part does not exist" + exit 1 +fi + +unprotect $part + +echo +echo "Erasing partition $part" +erase $part + +echo +echo "Creating magic" +cp $image $part + +echo +echo "Testing partition" +. /env/bin/_alternate + +protect $part diff --git a/board/ipe337/env/bin/update_application b/board/ipe337/env/bin/update_application new file mode 100644 index 000000000..46ad210e3 --- /dev/null +++ b/board/ipe337/env/bin/update_application @@ -0,0 +1,8 @@ +#!/bin/sh + +. /env/config + +image=$appimage +part=/dev/nor0.application + +. /env/bin/_update $1 diff --git a/board/ipe337/env/bin/update_persistent b/board/ipe337/env/bin/update_persistent new file mode 100644 index 000000000..a869b2218 --- /dev/null +++ b/board/ipe337/env/bin/update_persistent @@ -0,0 +1,8 @@ +#!/bin/sh + +. /env/config + +image=$perimage +part=/dev/nor0.persistent + +. /env/bin/_update $1 diff --git a/board/ipe337/env/bin/update_system b/board/ipe337/env/bin/update_system new file mode 100644 index 000000000..ac2e3e89a --- /dev/null +++ b/board/ipe337/env/bin/update_system @@ -0,0 +1,14 @@ +#!/bin/sh + +. /env/config + +image=$jffs2 + +alternate $ageing +if [ $? = 2 ]; then + part=/dev/nor0.system0 +else + part=/dev/nor0.system1 +fi + +. /env/bin/_update $1 diff --git a/board/ipe337/env/bin/update_ubootenv b/board/ipe337/env/bin/update_ubootenv new file mode 100644 index 000000000..301072ff5 --- /dev/null +++ b/board/ipe337/env/bin/update_ubootenv @@ -0,0 +1,8 @@ +#!/bin/sh + +. /env/config + +image=$envimage +part=/dev/nor0.ubootenv + +. /env/bin/_update $1 From 11d26a7de4eae04b78fd63d4bb16c1410cbfaafc Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Fri, 15 Feb 2008 11:47:18 +0100 Subject: [PATCH 02/11] add alternate mechanism & flash scripts - part2 sorry, forgot to add these files :( --- board/ipe337/cmd_alternate.c | 16 +++++++++--- board/ipe337/env/bin/_update | 30 ++++++++++++++++------ board/ipe337/env/bin/boot | 31 +++++++++++++++++------ board/ipe337/env/bin/init | 18 +++++++++++--- board/ipe337/env/bin/update_kernel | 10 +++++++- board/ipe337/env/bin/update_root | 6 ----- board/ipe337/env/bin/update_system | 2 +- board/ipe337/env/config | 40 +++++++++++++++++------------- 8 files changed, 104 insertions(+), 49 deletions(-) delete mode 100644 board/ipe337/env/bin/update_root diff --git a/board/ipe337/cmd_alternate.c b/board/ipe337/cmd_alternate.c index afe75d4bf..ce2e3e0e7 100644 --- a/board/ipe337/cmd_alternate.c +++ b/board/ipe337/cmd_alternate.c @@ -4,6 +4,8 @@ #include #include +#define MAGIC 0x19691228 + static int do_alternate (cmd_tbl_t *cmdtp, int argc, char *argv[]) { void *buf; @@ -12,7 +14,7 @@ static int do_alternate (cmd_tbl_t *cmdtp, int argc, char *argv[]) if (argc != 2) { u_boot_cmd_usage(cmdtp); - return 1; + return 0; } buf = read_file(argv[1], &size); @@ -20,6 +22,12 @@ static int do_alternate (cmd_tbl_t *cmdtp, int argc, char *argv[]) return 1; ptr = buf; + if ((*ptr) != MAGIC) { + printf("Wrong magic! Expected 0x%08x, got 0x%08x.\n", MAGIC, *ptr); + return 1; + } + + ptr++; while ((ulong)ptr <= (ulong)buf + size && !(val = *ptr++)) bitcount += 32; @@ -32,14 +40,14 @@ static int do_alternate (cmd_tbl_t *cmdtp, int argc, char *argv[]) } while (val >>= 1); } - printf("bitcount : %d\n", bitcount); + printf("Bitcount : %d\n", bitcount); free(buf); - return (bitcount & 1) ? 2 : 3; + return (bitcount & 1) ? 3 : 2; } static __maybe_unused char cmd_alternate_help[] = -"Usage: alternate \n" +"Usage: alternate " "\n"; U_BOOT_CMD_START(alternate) diff --git a/board/ipe337/env/bin/_update b/board/ipe337/env/bin/_update index b21d17378..124e28582 100644 --- a/board/ipe337/env/bin/_update +++ b/board/ipe337/env/bin/_update @@ -1,4 +1,8 @@ -echo "updating $image to $part" +#!/bin/sh + +if [ $# = 1 ]; then + image=$1 +fi if [ -z "$part" -o -z "$image" ]; then echo "define \$part and \$image" @@ -6,18 +10,28 @@ if [ -z "$part" -o -z "$image" ]; then fi if [ \! -e "$part" ]; then - echo "Partition $part does not exist" - exit 1 -fi - -if [ $# = 1 ]; then - image=$1 + echo "Partition $part does not exist" + exit 1 fi if [ x$ip = xdhcp ]; then - dhcp + dhcp +fi + +ping $eth0.serverip +if [ $? -ne 0 ] ; then + echo "update aborted" + exit 1 fi unprotect $part + +echo +echo "Erasing partition $part" erase $part + +echo +echo "Flashing $image to $part" tftp $image $part + +protect $part diff --git a/board/ipe337/env/bin/boot b/board/ipe337/env/bin/boot index 20c59b98e..8e4458903 100644 --- a/board/ipe337/env/bin/boot +++ b/board/ipe337/env/bin/boot @@ -1,5 +1,19 @@ +#!/bin/sh + . /env/config +. /env/bin/_alternate +if [ $? = 2 ]; then + act_kernel=/dev/nor0.kernel0 + act_rootfs=/dev/mtdblock5 +else + act_kernel=/dev/nor0.kernel1 + act_rootfs=/dev/mtdblock6 +fi +echo "-> Active kernel: $act_kernel" +echo "-> Active system: $act_rootfs" +echo + if [ x$1 = xflash ]; then root=flash kernel=flash @@ -10,14 +24,15 @@ if [ x$1 = xnet ]; then kernel=net fi -if [ $root = flash ]; then - bootargs="$bootargs root=/dev/mtdblock4 rootfstype=jffs2" +if [ x$ip = xdhcp ]; then + bootargs="$bootargs ip=dhcp" +else + bootargs="$bootargs ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask:::" +fi + +if [ x$root = xflash ]; then + bootargs="$bootargs root=$act_rootfs rootfstype=jffs2" else - if [ x$ip = xdhcp ]; then - bootargs="$bootargs ip=dhcp" - else - bootargs="$bootargs ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask:::" - fi bootargs="$bootargs root=/dev/nfs nfsroot=$eth0.serverip:$nfsroot,v3,tcp" fi @@ -30,5 +45,5 @@ if [ $kernel = net ]; then tftp $uimage uImage bootm uImage else - bootm /dev/nor0.kernel + bootm $act_kernel fi diff --git a/board/ipe337/env/bin/init b/board/ipe337/env/bin/init index 93eef1c9c..9ca41d615 100644 --- a/board/ipe337/env/bin/init +++ b/board/ipe337/env/bin/init @@ -1,14 +1,24 @@ +#!/bin/sh + PATH=/env/bin export PATH . /env/config +addpart /dev/nor0 $mtdparts +echo echo -n "Hit any key to stop autoboot: " -timeout -a 1 +timeout -a $autoboot_timeout if [ $? != 0 ]; then - echo "type update_kernel to update kernel into flash" - echo "type udate_root to update rootfs into flash" - exit + echo + echo "Type update_kernel [] to update kernel into flash." + echo "Type update_system [] to update rootfs into flash." + echo "Type update_application [] to update applications into flash." + echo "Type update_persistent [] to update persistent into flash." + echo "Type update_ubootenv [] to update ubootenv into flash (use with care!)." + echo "Type reset_ageing to initialize the ageing partittion (use with care!)." + echo + exit fi boot diff --git a/board/ipe337/env/bin/update_kernel b/board/ipe337/env/bin/update_kernel index b62caea72..fd3ad235b 100644 --- a/board/ipe337/env/bin/update_kernel +++ b/board/ipe337/env/bin/update_kernel @@ -1,6 +1,14 @@ +#!/bin/sh + . /env/config image=$uimage -part=/dev/nor0.kernel + +. /env/bin/_alternate +if [ $? = 2 ]; then + part=/dev/nor0.kernel0 +else + part=/dev/nor0.kernel1 +fi . /env/bin/_update $1 diff --git a/board/ipe337/env/bin/update_root b/board/ipe337/env/bin/update_root deleted file mode 100644 index 4d0c9b680..000000000 --- a/board/ipe337/env/bin/update_root +++ /dev/null @@ -1,6 +0,0 @@ -. /env/config - -image=$jffs2 -part=/dev/nor0.root - -. /env/bin/_update $1 diff --git a/board/ipe337/env/bin/update_system b/board/ipe337/env/bin/update_system index ac2e3e89a..32d22e649 100644 --- a/board/ipe337/env/bin/update_system +++ b/board/ipe337/env/bin/update_system @@ -4,7 +4,7 @@ image=$jffs2 -alternate $ageing +. /env/bin/_alternate if [ $? = 2 ]; then part=/dev/nor0.system0 else diff --git a/board/ipe337/env/config b/board/ipe337/env/config index c15fba89b..1fd7fbceb 100644 --- a/board/ipe337/env/config +++ b/board/ipe337/env/config @@ -1,22 +1,28 @@ -echo /env/config - -ip=dhcp - -eth0.ipaddr=192.168.23.164 -eth0.ethaddr=80:87:78:74:73:63 -eth0.serverip=192.168.23.1 -eth0.netmask=255.255.255.0 -eth0.gateway=192.168.23.1 - -uimage=uImage-bfin -jffs2=root-bfin.jffs2 - -nfsroot="/home/kleineb/pengutronix/pii-bf/OSELAS.BSP-Pipetronix-ipe337-trunk/root" -bootargs="console=ttyBF0,115200" +#!/bin/sh # can be either 'net' or 'flash' kernel=net root=net -mtdparts="128k(uboot)ro,128k(ubootenv),128k(alternate),1536k(kernel),-(root)" -addpart /dev/nor0 $mtdparts +# use 'dhcp' todo dhcp in uboot and in kernel +#ip=dhcp + +eth0.ipaddr=192.168.23.164 +eth0.netmask=255.255.255.0 +eth0.gateway=192.168.23.2 +eth0.serverip=192.168.23.2 +eth0.ethaddr=00:50:c2:72:a7:4a + +uimage=uImage-bfin +jffs2=root-bfin.jffs2 +appimage=apps-bfin +perimage=pers-bfin +envimage=uEnv-bfin + +autoboot_timeout=1 + +nfsroot="/ptx/work/octopus/wsa/svn/OSELAS.BSP-Pipetronix-ipe337-trunk/root" +bootargs="console=ttyBF0,115200" + +mtdparts="128k(uboot)ro,128k(ubootenv),128k(ageing),1280k(kernel0),1280k(kernel1),8704k(system0),8704k(system1),8320k(application),4096k(persistent)" +ageing=/dev/nor0.ageing From 89f94eb41fa1356b1bce0a4f2762441c7f2f1f02 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Wed, 20 Feb 2008 16:58:38 +0100 Subject: [PATCH 03/11] Version bump up rc4 Signed-off-by: Wolfram Sang --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index dd0bd1cc6..8423b91dc 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ VERSION = 2 PATCHLEVEL = 0 SUBLEVEL = 0 -EXTRAVERSION =-rc4-git +EXTRAVERSION =-rc4 NAME = Amissive Actinocutious Kiwi # From 0bf51469d73a934eaaad3f89e60f025c9e2a73d2 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Wed, 20 Feb 2008 17:02:27 +0100 Subject: [PATCH 04/11] back to -git Signed-off-by: Wolfram Sang --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8423b91dc..913c0f19a 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ VERSION = 2 PATCHLEVEL = 0 SUBLEVEL = 0 -EXTRAVERSION =-rc4 +EXTRAVERSION =-rc5-git NAME = Amissive Actinocutious Kiwi # From 630dcb6fd574b18512d1786b6f674caa5ff9fc22 Mon Sep 17 00:00:00 2001 From: Carsten Schlote Date: Tue, 12 Feb 2008 11:37:24 +0100 Subject: [PATCH 05/11] [general] Added docs and htmldocs target to master makefile Added two targets to the toplevel Makefile : docs and htmdocs. Further output formats might be added later (PDF, TeX, ...) and wrapped by the docs target. Signed-off-by: Carsten Schlote --- Makefile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Makefile b/Makefile index 913c0f19a..0765dbf17 100644 --- a/Makefile +++ b/Makefile @@ -1002,6 +1002,8 @@ help: @echo ' enough build support to build external modules' @echo ' mrproper - Remove all generated files + config + various backup files' @echo ' distclean - mrproper + remove editor backup and patch files' + @echo ' docs - start doxygen for all output types (only HTML - FIXME)' + @echo ' htmldocs - create documentation in HTML format' @echo '' @echo 'Configuration targets:' @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help @@ -1041,6 +1043,16 @@ help: @echo 'Execute "make" or "make all" to build all targets marked with [*] ' @echo 'For further info see the ./README file' +# Generate doxygen docs +# --------------------------------------------------------------------------- +.PHONY += docs htmldocs + +docs : htmldocs + +htmldocs: + @echo 'Running doxygen with local Doxyfile' + $(Q)doxygen Doxyfile + # Generate tags for editors # --------------------------------------------------------------------------- From 8c29ed08f21cf0b57066a01bfc0bd4c996d3edda Mon Sep 17 00:00:00 2001 From: Carsten Schlote Date: Fri, 15 Feb 2008 13:40:30 +0100 Subject: [PATCH 06/11] [general] Fixed endian handling for envfs Fixed the handling of data similiar as found in cramfs. This fixes the problem with an unreadable defaultenv on big-endian targets. The endian macors are now loaded from /asm/common.h by default. Signed-off-by: Carsten Schlote --- common/environment.c | 62 ++++++++++++++++++++------------------ include/cramfs/cramfs_fs.h | 4 +++ include/envfs.h | 18 ++++++++++- 3 files changed, 53 insertions(+), 31 deletions(-) diff --git a/common/environment.c b/common/environment.c index 67ede3834..6e414d975 100644 --- a/common/environment.c +++ b/common/environment.c @@ -67,9 +67,9 @@ int file_save_action(const char *filename, struct stat *statbuf, statbuf->st_size, namelen); inode = (struct envfs_inode*)data->writep; - inode->magic = ENVFS_INODE_MAGIC; - inode->namelen = namelen; - inode->size = statbuf->st_size; + inode->magic = ENVFS_32(ENVFS_INODE_MAGIC); + inode->namelen = ENVFS_32(namelen); + inode->size = ENVFS_32(statbuf->st_size); data->writep += sizeof(struct envfs_inode); strcpy(data->writep, filename + strlen(data->base)); @@ -122,15 +122,15 @@ int envfs_save(char *filename, char *dirname) data.writep = buf + sizeof(struct envfs_super); super = (struct envfs_super *)buf; - super->magic = ENVFS_MAGIC; - super->size = size; + super->magic = ENVFS_32(ENVFS_MAGIC); + super->size = ENVFS_32(size); /* second pass: copy files to buffer */ recursive_action(dirname, ACTION_RECURSE, file_save_action, NULL, &data, 0); - super->crc = crc32(0, buf + sizeof(struct envfs_super), size); - super->sb_crc = crc32(0, buf, sizeof(struct envfs_super) - 4); + super->crc = ENVFS_32(crc32(0, buf + sizeof(struct envfs_super), size)); + super->sb_crc = ENVFS_32(crc32(0, buf, sizeof(struct envfs_super) - 4)); envfd = open(filename, O_WRONLY | O_CREAT); if (envfd < 0) { @@ -189,53 +189,55 @@ int envfs_load(char *filename, char *dir) goto out; } - if (super.magic != ENVFS_MAGIC) { + if ( ENVFS_32(super.magic) != ENVFS_MAGIC) { printf("envfs: wrong magic on %s\n", filename); ret = -EIO; goto out; } if (crc32(0, (unsigned char *)&super, sizeof(struct envfs_super) - 4) - != super.sb_crc) { + != ENVFS_32(super.sb_crc)) { printf("wrong crc on env superblock\n"); goto out; } - buf = xmalloc(super.size); + size = ENVFS_32(super.size); + buf = xmalloc(size); buf_free = buf; - ret = read(envfd, buf, super.size); - if (ret < super.size) { + ret = read(envfd, buf, size); + if (ret < size) { perror("read"); goto out; } - if (crc32(0, (unsigned char *)buf, super.size) - != super.crc) { + if (crc32(0, (unsigned char *)buf, size) + != ENVFS_32(super.crc)) { printf("wrong crc on env\n"); goto out; } - - size = super.size; - + while (size) { struct envfs_inode *inode; - + uint32_t inode_size,inode_namelen; + inode = (struct envfs_inode *)buf; - - if (inode->magic != ENVFS_INODE_MAGIC) { + + if (ENVFS_32(inode->magic) != ENVFS_INODE_MAGIC) { printf("envfs: wrong magic on %s\n", filename); ret = -EIO; goto out; } - + inode_size = ENVFS_32(inode->size); + inode_namelen = ENVFS_32(inode->namelen); + debug("loading %s size %d namelen %d\n", inode->data, - inode->size, inode->namelen); - + inode_size, inode_namelen); + str = concat_path_file(dir, inode->data); tmp = strdup(str); make_directory(dirname(tmp)); free(tmp); - + fd = open(str, O_WRONLY | O_CREAT | O_TRUNC, 0644); free(str); if (fd < 0) { @@ -244,19 +246,19 @@ int envfs_load(char *filename, char *dir) goto out; } - namelen_full = PAD4(inode->namelen); + namelen_full = PAD4(inode_namelen); ret = write(fd, buf + namelen_full + sizeof(struct envfs_inode), - inode->size); - if (ret < inode->size) { + inode_size); + if (ret < inode_size) { perror("write"); close(fd); goto out; } close(fd); - - buf += PAD4(inode->namelen) + PAD4(inode->size) + + + buf += PAD4(inode_namelen) + PAD4(inode_size) + sizeof(struct envfs_inode); - size -= PAD4(inode->namelen) + PAD4(inode->size) + + size -= PAD4(inode_namelen) + PAD4(inode_size) + sizeof(struct envfs_inode); } diff --git a/include/cramfs/cramfs_fs.h b/include/cramfs/cramfs_fs.h index 9f1b1d529..6f2ee6871 100644 --- a/include/cramfs/cramfs_fs.h +++ b/include/cramfs/cramfs_fs.h @@ -84,6 +84,10 @@ struct cramfs_super { | CRAMFS_FLAG_WRONG_SIGNATURE \ | CRAMFS_FLAG_SHIFTED_ROOT_OFFSET ) +#ifndef __BYTE_ORDER +#error "No byte order defined in __BYTE_ORDER" +#endif + #if __BYTE_ORDER == __LITTLE_ENDIAN #define CRAMFS_16(x) (x) #define CRAMFS_24(x) (x) diff --git a/include/envfs.h b/include/envfs.h index 6f1234283..406bc61e7 100644 --- a/include/envfs.h +++ b/include/envfs.h @@ -1,7 +1,7 @@ #ifndef _ENVFS_H #define _ENVFS_H -#define ENVFS_MAGIC 0x798fba79 /* some random number */ +#define ENVFS_MAGIC 0x798fba79 /* some random number */ #define ENVFS_INODE_MAGIC 0x67a8c78d #define ENVFS_END_MAGIC 0x6a87d6cd #define ENVFS_SIGNATURE "U-Boot envfs" @@ -30,7 +30,12 @@ struct envfs_super { uint32_t sb_crc; /* crc for the superblock */ }; +#ifndef __BYTE_ORDER +#error "No byte order defined in __BYTE_ORDER" +#endif + #if __BYTE_ORDER == __LITTLE_ENDIAN +#warning "envfs compiled on little endian host" #define ENVFS_16(x) (x) #define ENVFS_24(x) (x) #define ENVFS_32(x) (x) @@ -39,6 +44,7 @@ struct envfs_super { #define ENVFS_SET_OFFSET(x,y) ((x)->offset = (y)) #define ENVFS_SET_NAMELEN(x,y) ((x)->namelen = (y)) #elif __BYTE_ORDER == __BIG_ENDIAN +#warning "envfs compiled on big endian host" #ifdef __KERNEL__ #define ENVFS_16(x) swab16(x) #define ENVFS_24(x) ((swab32(x)) >> 8) @@ -48,6 +54,16 @@ struct envfs_super { #define ENVFS_24(x) ((bswap_32(x)) >> 8) #define ENVFS_32(x) bswap_32(x) #endif /* not __KERNEL__ */ +#define CRAMFS_GET_NAMELEN(x) (((u8*)(x))[8] & 0x3f) +#define CRAMFS_GET_OFFSET(x) ((CRAMFS_24(((u32*)(x))[2] & 0xffffff) << 2) |\ + ((((u32*)(x))[2] & 0xc0000000) >> 30)) +#define CRAMFS_SET_NAMELEN(x,y) (((u8*)(x))[8] = (((0x3f & (y))) | \ + (0xc0 & ((u8*)(x))[8]))) +#define CRAMFS_SET_OFFSET(x,y) (((u32*)(x))[2] = (((y) & 3) << 30) | \ + CRAMFS_24((((y) & 0x03ffffff) >> 2)) | \ + (((u32)(((u8*)(x))[8] & 0x3f)) << 24)) +#else +#error "__BYTE_ORDER must be __LITTLE_ENDIAN or __BIG_ENDIAN" #endif #endif /* _ENVFS_H */ From 6a8ef6a4f3b8572d8a49c44c8cbc04b889d50d40 Mon Sep 17 00:00:00 2001 From: Carsten Schlote Date: Fri, 15 Feb 2008 14:43:12 +0100 Subject: [PATCH 07/11] [general] Fixed remaining defines for envfs in big-endian mode Trivial - completed macros --- include/envfs.h | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/include/envfs.h b/include/envfs.h index 406bc61e7..f5ea9c3ef 100644 --- a/include/envfs.h +++ b/include/envfs.h @@ -54,14 +54,10 @@ struct envfs_super { #define ENVFS_24(x) ((bswap_32(x)) >> 8) #define ENVFS_32(x) bswap_32(x) #endif /* not __KERNEL__ */ -#define CRAMFS_GET_NAMELEN(x) (((u8*)(x))[8] & 0x3f) -#define CRAMFS_GET_OFFSET(x) ((CRAMFS_24(((u32*)(x))[2] & 0xffffff) << 2) |\ - ((((u32*)(x))[2] & 0xc0000000) >> 30)) -#define CRAMFS_SET_NAMELEN(x,y) (((u8*)(x))[8] = (((0x3f & (y))) | \ - (0xc0 & ((u8*)(x))[8]))) -#define CRAMFS_SET_OFFSET(x,y) (((u32*)(x))[2] = (((y) & 3) << 30) | \ - CRAMFS_24((((y) & 0x03ffffff) >> 2)) | \ - (((u32)(((u8*)(x))[8] & 0x3f)) << 24)) +#define ENVFS_GET_NAMELEN(x) ENVFS_32(((x)->namelen)) +#define ENVFS_GET_OFFSET(x) ENVFS_32(((x)->offset)) +#define ENVFS_SET_NAMELEN(x,y)((x)->offset = ENVFS_32((y))) +#define ENVFS_SET_OFFSET(x,y) ((x)->namelen = ENVFS_32((y))) #else #error "__BYTE_ORDER must be __LITTLE_ENDIAN or __BIG_ENDIAN" #endif From 32a094cac5488facef17d6a2d7a3f194afc9eea8 Mon Sep 17 00:00:00 2001 From: Carsten Schlote Date: Fri, 15 Feb 2008 14:42:26 +0100 Subject: [PATCH 08/11] [general] Hide doxygen HTML output Trivial. --- Documentation/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 Documentation/.gitignore diff --git a/Documentation/.gitignore b/Documentation/.gitignore new file mode 100644 index 000000000..1936cc1d4 --- /dev/null +++ b/Documentation/.gitignore @@ -0,0 +1 @@ +html From 05de3be9e407ff37d3d8a49dced07bf30cdca9e7 Mon Sep 17 00:00:00 2001 From: Carsten Schlote Date: Fri, 15 Feb 2008 20:26:45 +0100 Subject: [PATCH 09/11] [general] Fixed crash in fs.h, when called with fsdrv.create == NULL When a nor0 devices has no partitions assigned, then a call to open() to create a file will jump with a NULL fct ptr. Much more cheching code is missing and pointers to function are jumped without any NULL ptr check. This must be fixed as well later. Signed-off-by: Carsten Schlote --- fs/fs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/fs.c b/fs/fs.c index 8d3923281..6be2eba39 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -406,8 +406,11 @@ int open(const char *pathname, int flags, ...) } if (!exist) { - errno = fsdrv->create(dev, path, - S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO); + if (NULL != fsdrv->create) + errno = fsdrv->create(dev, path, + S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO); + else + errno = -EROFS; if (errno) goto out; } From b8993a8bb878784538191766c6c73cf082d605f1 Mon Sep 17 00:00:00 2001 From: Carsten Schlote Date: Sat, 16 Feb 2008 01:01:20 +0100 Subject: [PATCH 10/11] [general] Added more outputs to partition.c Added more outputs to partition code. Signed-off-by: Carsten Schlote --- commands/partition.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) mode change 100644 => 100755 commands/partition.c diff --git a/commands/partition.c b/commands/partition.c old mode 100644 new mode 100755 index 97acac77c..164d4f0b5 --- a/commands/partition.c +++ b/commands/partition.c @@ -45,11 +45,11 @@ static int dev_del_partitions(struct device_d *physdev) device_for_each_child_safe(physdev, tmp, child) { struct partition *part = child->type_data; - - debug("delete partition: %s\n", child->id); - if (part->flags & PARTITION_FIXED) + if (part->flags & PARTITION_FIXED) { + debug("Skip fixed partition: %s\n", child->id); continue; + } ret = unregister_device(child); if (ret) { @@ -57,6 +57,8 @@ static int dev_del_partitions(struct device_d *physdev) return errno; } + debug("deleted partition: %s\n", child->id); + free(part); } @@ -70,27 +72,35 @@ static int dev_check_fixed(struct device_d *physdev, struct partition *new_part) device_for_each_child(physdev, child) { struct partition *part = child->type_data; - debug("check aginst partition: %s\n", child->id); + debug("check aginst partition: %s -", child->id); - if (!(part->flags & PARTITION_FIXED)) + if (!(part->flags & PARTITION_FIXED)) { + debug(" not fixed, ok\n"); continue; + } - if (new_part->offset == part->offset && /* new_part is exactly part */ - new_part->device.size == part->device.size) + if (new_part->offset == part->offset && /* new_part is exactly part */ + ((new_part->device.size==0) || (new_part->device.size == part->device.size)) ) { + debug(" fixed, but same size, ok\n"); continue; + } if ((new_part->offset >= part->offset && new_part->offset < part->offset + part->device.size) || (new_part->offset + new_part->device.size > part->offset && new_part->offset + new_part->device.size <= part->offset + part->device.size)) { - printf("partition violates fixed partition\n"); + printf( + " failed\n" + " partition spec %s \n" + " violates fixed partition %s\n", new_part->name, child->id); errno = -EINVAL; return errno; } + else + debug(" fixed and within limit?, ok\n"); } return 0; - } static int mtd_part_do_parse_one(struct partition *part, const char *str, @@ -110,7 +120,7 @@ static int mtd_part_do_parse_one(struct partition *part, const char *str, } if (size + part->offset > part->physdev->size) { - printf("partition end is beyond device\n"); + printf("partition %s end is beyond device\n", part->name); return -EINVAL; } @@ -157,7 +167,7 @@ static int do_addpart(cmd_tbl_t * cmdtp, int argc, char *argv[]) unsigned long offset; if (argc != 3) { - printf("Usage:\n%s\n", cmdtp->usage); + printf("Usage:\n %s\n", cmdtp->usage); return 1; } @@ -218,6 +228,7 @@ err_out: static __maybe_unused char cmd_addpart_help[] = "Usage: addpart \n" +"\n" "addpart adds a partition description to a device. The partition description\n" "has the form\n" "size1(name1)[ro],size2(name2)[ro],...\n" @@ -225,12 +236,13 @@ static __maybe_unused char cmd_addpart_help[] = "with 0x in hex. Sizes can have an optional suffix K,M,G. The size of the last\n" "partition can be specified as '-' for the remaining space of the device.\n" "This format is the same as used in the Linux kernel for cmdline mtd partitions.\n" -"Note That this command has to be reworked and will probably change it's API."; +"\n" +"Note: That this command has to be reworked and will probably change it's API."; U_BOOT_CMD_START(addpart) .maxargs = 3, .cmd = do_addpart, - .usage = "add a partition table to a device", + .usage = "adds a partition table to a device", U_BOOT_CMD_HELP(cmd_addpart_help) U_BOOT_CMD_END From 9bd5e87192880e995b35a25f95cbe5242d803955 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 19 Feb 2008 09:53:48 +0100 Subject: [PATCH 11/11] [netx]: Fix function prototype for do_loadxc --- arch/arm/mach-netx/generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-netx/generic.c b/arch/arm/mach-netx/generic.c index 148337f0c..e65c2fa09 100644 --- a/arch/arm/mach-netx/generic.c +++ b/arch/arm/mach-netx/generic.c @@ -116,7 +116,7 @@ int loadxc(int xcno) { return 0; } -int do_loadxc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +int do_loadxc (cmd_tbl_t *cmdtp, int argc, char *argv[]) { int xcno;