From 21b6863a4b2d6ed5bd11949de415b817057303e6 Mon Sep 17 00:00:00 2001 From: Koen Kooi Date: Wed, 13 Jun 2007 10:00:50 +0000 Subject: netbase: one more missing dir --- packages/netbase/netbase/if-down.d/.mtn2git_empty | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 packages/netbase/netbase/if-down.d/.mtn2git_empty diff --git a/packages/netbase/netbase/if-down.d/.mtn2git_empty b/packages/netbase/netbase/if-down.d/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 -- cgit v1.2.3 From 17e73f44c043e98722fb0220457cbc845b95fc37 Mon Sep 17 00:00:00 2001 From: Koen Kooi Date: Wed, 13 Jun 2007 10:30:07 +0000 Subject: u-boot-mkimage-gta01-native: add a static git tag and put patches in OE to stop breakage --- .../u-boot-mkimage-gta01-native/.mtn2git_empty | 0 .../bbt-create-optional.patch | 52 + .../bbt-scan-second.patch | 69 + .../boot-from-ram-and-nand.patch | 98 + .../boot-from-ram-reloc.patch | 62 + .../u-boot-mkimage-gta01-native/boot-menu.patch | 769 ++++ .../u-boot-mkimage-gta01-native/cmd-unzip.patch | 58 + .../u-boot-mkimage-gta01-native/console-ansi.patch | 127 + .../u-boot-mkimage-gta01-native/default-env.patch | 101 + .../u-boot-mkimage-gta01-native/dontask.patch | 22 + .../dynenv-harden.patch | 139 + .../early-powerdown.patch | 40 + .../enable-splash-bmp.patch | 56 + .../u-boot-mkimage-gta01-native/env_nand_oob.patch | 198 + .../u-boot-mkimage-gta01-native/ext2load_hex.patch | 17 + .../u-boot-mkimage-gta01-native/lowlevel_foo.patch | 229 ++ .../mmcinit-power-up.patch | 73 + .../nand-badisbad.patch | 30 + .../nand-createbbt.patch | 126 + .../nand-dynamic_partitions.patch | 354 ++ .../u-boot-mkimage-gta01-native/nand-otp.patch | 302 ++ .../nand-read_write_oob.patch | 23 + .../neo1973-chargefast.patch | 316 ++ .../preboot-override.patch | 137 + .../u-boot-mkimage-gta01-native/raise-limits.patch | 31 + packages/uboot/u-boot-mkimage-gta01-native/series | 76 + .../splashimage-command.patch | 24 + .../uboot-20061030-neo1973.patch | 2248 +++++++++++ .../uboot-20061030-qt2410.patch | 1233 ++++++ .../uboot-arm920_s3c2410_irq_demux.patch | 56 + .../uboot-arm920t-gd_in_irq.patch | 28 + .../uboot-bbt-quiet.patch | 43 + .../uboot-cmd_s3c2410.patch | 175 + .../uboot-cramfs_but_no_jffs2.patch | 41 + .../u-boot-mkimage-gta01-native/uboot-dfu.patch | 2081 ++++++++++ .../u-boot-mkimage-gta01-native/uboot-gta02.patch | 1560 ++++++++ .../u-boot-mkimage-gta01-native/uboot-hxd8.patch | 1169 ++++++ .../uboot-license.patch | 712 ++++ .../uboot-machtypes.patch | 4121 ++++++++++++++++++++ .../uboot-mokoversion.patch | 10 + .../uboot-nand-markbad-reallybad.patch | 20 + .../uboot-neo1973-defaultenv.patch | 31 + .../uboot-neo1973-resume.patch | 113 + .../uboot-s3c2410-misccr-definitions.patch | 45 + .../uboot-s3c2410-mmc.patch | 818 ++++ .../uboot-s3c2410-nand.patch | 525 +++ .../uboot-s3c2410-norelocate_irqvec_cpy.patch | 32 + .../uboot-s3c2410-warnings-fix.patch | 98 + .../uboot-s3c2410_fb.patch | 215 + .../uboot-s3c2410_udc.patch | 1263 ++++++ .../uboot-s3c2440.patch | 1301 ++++++ .../uboot-s3c2443.patch | 256 ++ .../uboot-smdk2440.patch | 1481 +++++++ .../uboot-smdk2443.patch | 1411 +++++++ .../uboot-strtoul.patch | 43 + .../uboot-usbtty-acm.patch | 1607 ++++++++ .../u-boot-mkimage-gta01-native/unbusy-i2c.patch | 88 + .../usbdcore-multiple_configs.patch | 63 + .../wakeup-reason-nand-only.patch | 68 + packages/uboot/u-boot-mkimage-gta01-native_oe.bb | 82 + packages/uboot/u-boot-mkimage-gta01-native_svn.bb | 2 + 61 files changed, 26568 insertions(+) create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/.mtn2git_empty create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/bbt-create-optional.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/bbt-scan-second.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/boot-from-ram-and-nand.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/boot-from-ram-reloc.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/boot-menu.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/cmd-unzip.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/console-ansi.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/default-env.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/dontask.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/dynenv-harden.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/early-powerdown.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/enable-splash-bmp.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/env_nand_oob.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/ext2load_hex.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/lowlevel_foo.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/mmcinit-power-up.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/nand-badisbad.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/nand-createbbt.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/nand-dynamic_partitions.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/nand-otp.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/nand-read_write_oob.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/neo1973-chargefast.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/preboot-override.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/raise-limits.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/series create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/splashimage-command.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-20061030-neo1973.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-20061030-qt2410.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-arm920_s3c2410_irq_demux.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-arm920t-gd_in_irq.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-bbt-quiet.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-cmd_s3c2410.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-cramfs_but_no_jffs2.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-dfu.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-gta02.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-hxd8.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-license.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-machtypes.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-mokoversion.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-nand-markbad-reallybad.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-neo1973-defaultenv.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-neo1973-resume.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-s3c2410-misccr-definitions.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-s3c2410-mmc.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-s3c2410-nand.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-s3c2410-norelocate_irqvec_cpy.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-s3c2410-warnings-fix.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-s3c2410_fb.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-s3c2410_udc.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-s3c2440.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-s3c2443.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-smdk2440.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-smdk2443.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-strtoul.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/uboot-usbtty-acm.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/unbusy-i2c.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/usbdcore-multiple_configs.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native/wakeup-reason-nand-only.patch create mode 100644 packages/uboot/u-boot-mkimage-gta01-native_oe.bb diff --git a/packages/uboot/u-boot-mkimage-gta01-native/.mtn2git_empty b/packages/uboot/u-boot-mkimage-gta01-native/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/uboot/u-boot-mkimage-gta01-native/bbt-create-optional.patch b/packages/uboot/u-boot-mkimage-gta01-native/bbt-create-optional.patch new file mode 100644 index 0000000000..d7a2a872e5 --- /dev/null +++ b/packages/uboot/u-boot-mkimage-gta01-native/bbt-create-optional.patch @@ -0,0 +1,52 @@ +This patch makes creation of the BBT optional for the s3c24x0 platform. +It adds: + +- a new platform-independent NAND-wide flag NAND_DONT_CREATE_BBT +- one user of this flag, namely s3c24x0 + +Experimental. + +- Werner Almesberger + + +Index: u-boot/cpu/arm920t/s3c24x0/nand.c +=================================================================== +--- u-boot.orig/cpu/arm920t/s3c24x0/nand.c 2007-02-16 23:53:29.000000000 +0100 ++++ u-boot/cpu/arm920t/s3c24x0/nand.c 2007-02-16 23:53:54.000000000 +0100 +@@ -169,7 +169,7 @@ + + nand->eccmode = NAND_ECC_SOFT; + #ifdef CONFIG_S3C2410_NAND_BBT +- nand->options = NAND_USE_FLASH_BBT; ++ nand->options = NAND_USE_FLASH_BBT | NAND_DONT_CREATE_BBT; + #else + nand->options = 0; + #endif +Index: u-boot/drivers/nand/nand_bbt.c +=================================================================== +--- u-boot.orig/drivers/nand/nand_bbt.c 2007-02-16 23:53:36.000000000 +0100 ++++ u-boot/drivers/nand/nand_bbt.c 2007-02-16 23:53:54.000000000 +0100 +@@ -678,7 +678,8 @@ + } + create: + /* Create the bad block table by scanning the device ? */ +- if (!(td->options & NAND_BBT_CREATE)) ++ if (!(td->options & NAND_BBT_CREATE) || ++ (this->options & NAND_DONT_CREATE_BBT)) + continue; + + /* Create the table in memory by scanning the chip(s) */ +Index: u-boot/include/linux/mtd/nand.h +=================================================================== +--- u-boot.orig/include/linux/mtd/nand.h 2007-02-16 23:53:08.000000000 +0100 ++++ u-boot/include/linux/mtd/nand.h 2007-02-16 23:53:54.000000000 +0100 +@@ -187,7 +187,8 @@ + * This can only work if we have the ecc bytes directly behind the + * data bytes. Applies for DOC and AG-AND Renesas HW Reed Solomon generators */ + #define NAND_HWECC_SYNDROME 0x00020000 +- ++/* Do not create an BBT if none is found. Overrides NAND_BBT_CREATE. */ ++#define NAND_DONT_CREATE_BBT 0x00040000 + + /* Options set by nand scan */ + /* Nand scan has allocated oob_buf */ diff --git a/packages/uboot/u-boot-mkimage-gta01-native/bbt-scan-second.patch b/packages/uboot/u-boot-mkimage-gta01-native/bbt-scan-second.patch new file mode 100644 index 0000000000..37b2807908 --- /dev/null +++ b/packages/uboot/u-boot-mkimage-gta01-native/bbt-scan-second.patch @@ -0,0 +1,69 @@ +Scan also the second OOB page for bad block information. + +board/neo1973/gta01/nand.c (board_nand_init): added board-specific badblock + pattern which sets NAND_BBT_SCAN2NDPAGE +drivers/nand/nand_base.c (nand_block_bad): also consider the second page in a + block if NAND_BBT_SCAN2NDPAGE is set + +- Werner Almesberger + +Index: u-boot/board/neo1973/gta01/nand.c +=================================================================== +--- u-boot.orig/board/neo1973/gta01/nand.c ++++ u-boot/board/neo1973/gta01/nand.c +@@ -113,9 +113,23 @@ + } + + ++/* Derived from drivers/nand/nand_bbt.c:smallpage_flashbased */ ++ ++static uint8_t scan_ff_pattern[] = { 0xff, 0xff }; ++ ++static struct nand_bbt_descr badblock_pattern = { ++ .options = ++ NAND_BBT_SCANEMPTY | NAND_BBT_SCANALLPAGES | NAND_BBT_SCAN2NDPAGE, ++ .offs = 5, ++ .len = 1, ++ .pattern = scan_ff_pattern ++}; ++ ++ + int board_nand_init(struct nand_chip *nand) + { + nand->read_otp = samsung_nand_read_otp; + nand->write_otp = samsung_nand_write_otp; ++ nand->badblock_pattern = &badblock_pattern; + return s3c24x0_nand_init(nand); + } +Index: u-boot/drivers/nand/nand_base.c +=================================================================== +--- u-boot.orig/drivers/nand/nand_base.c ++++ u-boot/drivers/nand/nand_base.c +@@ -421,7 +421,7 @@ + * + * Check, if the block is bad. + */ +-static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) ++static int nand_block_bad_page(struct mtd_info *mtd, loff_t ofs, int getchip) + { + int page, chipnr, res = 0; + struct nand_chip *this = mtd->priv; +@@ -460,6 +460,18 @@ + return res; + } + ++static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) ++{ ++ struct nand_chip *this = mtd->priv; ++ ++ if (nand_block_bad_page(mtd, ofs, getchip)) ++ return 1; ++ if (this->badblock_pattern->options & NAND_BBT_SCAN2NDPAGE && ++ nand_block_bad_page(mtd, ofs+(1 << this->page_shift), getchip)) ++ return 1; ++ return 0; ++} ++ + /** + * nand_default_block_markbad - [DEFAULT] mark a block bad + * @mtd: MTD device structure diff --git a/packages/uboot/u-boot-mkimage-gta01-native/boot-from-ram-and-nand.patch b/packages/uboot/u-boot-mkimage-gta01-native/boot-from-ram-and-nand.patch new file mode 100644 index 0000000000..fa0de39ab7 --- /dev/null +++ b/packages/uboot/u-boot-mkimage-gta01-native/boot-from-ram-and-nand.patch @@ -0,0 +1,98 @@ +Auto-detect whether we're booting from RAM or NAND, and act accordingly. This +allows us to use the same u-boot binary for all boot modes. + +include/configs/neo1973.h: introduced new config option + CONFIG_LL_INIT_NAND_ONLY to perform low-level initialization only when + booting from NAND +include/configs/neo1973.h: got rid of BUILD_FOR_RAM +cpu/arm920t/start.S: detect if we need to boot from NAND at run time (i.e., if + we're running at address 0) + +- Werner Almesberger + +Index: u-boot/cpu/arm920t/start.S +=================================================================== +--- u-boot.orig/cpu/arm920t/start.S ++++ u-boot/cpu/arm920t/start.S +@@ -157,18 +157,26 @@ + str r1, [r0] + #endif /* CONFIG_S3C2400 || CONFIG_S3C2410 */ + +- /* +- * we do sys-critical inits only at reboot, +- * not when booting from ram! +- */ + #ifndef CONFIG_SKIP_LOWLEVEL_INIT ++#ifndef CONFIG_LL_INIT_NAND_ONLY + bl cpu_init_crit + #endif ++#endif + + #ifndef CONFIG_SKIP_RELOCATE_UBOOT +-#ifndef CONFIG_S3C2410_NAND_BOOT +-relocate: /* relocate U-Boot to RAM */ + adr r0, _start /* r0 <- current position of code */ ++ ++#ifdef CONFIG_S3C2410_NAND_BOOT ++ /* are we running from NAND ? */ ++#define BWSCON 0x48000000 ++ ldr r1, =BWSCON /* Z = CPU booted from NAND */ ++ ldr r1, [r1] ++ tst r1, #6 /* BWSCON[2:1] = OM[1:0] */ ++ teqeq r0, #0 /* Z &= running at address 0 */ ++ beq nand_load ++#endif /* CONFIG_S3C2410_NAND_BOOT */ ++ ++relocate: /* relocate U-Boot to RAM */ + ldr r1, _TEXT_BASE /* test if we run from flash or RAM */ + cmp r0, r1 /* don't reloc during debug */ + beq done_relocate +@@ -188,10 +196,13 @@ + ldr pc, _done_relocate /* jump to relocated code */ + _done_relocate: + .word done_relocate +-done_relocate: +-#else /* NAND_BOOT */ +-relocate: +-copy_myself: ++ ++#ifdef CONFIG_S3C2410_NAND_BOOT ++nand_load: ++#if !defined(CONFIG_SKIP_LOWLEVEL_INIT) && defined(CONFIG_LL_INIT_NAND_ONLY) ++ bl cpu_init_crit ++#endif ++ + /* mov r10, lr */ + + @ reset NAND +@@ -275,7 +286,8 @@ + #endif + 1: b 1b + done_nand_read: +-#endif /* NAND_BOOT */ ++#endif /* CONFIG_S3C2410_NAND_BOOT */ ++done_relocate: + #endif /* CONFIG_SKIP_RELOCATE_UBOOT */ + + /* Set up the stack */ +Index: u-boot/include/configs/neo1973_gta01.h +=================================================================== +--- u-boot.orig/include/configs/neo1973_gta01.h ++++ u-boot/include/configs/neo1973_gta01.h +@@ -26,14 +26,10 @@ + #ifndef __CONFIG_H + #define __CONFIG_H + +-#if defined(BUILD_FOR_RAM) +-/* If we want to start u-boot from inside RAM */ +-#define CONFIG_SKIP_LOWLEVEL_INIT 1 +-#else +-/* we want to start u-boot directly from within NAND flash */ ++/* we want to be able to start u-boot directly from within NAND flash */ ++#define CONFIG_LL_INIT_NAND_ONLY + #define CONFIG_S3C2410_NAND_BOOT 1 + #define CONFIG_S3C2410_NAND_SKIP_BAD 1 +-#endif + + #define CFG_UBOOT_SIZE 0x40000 /* size of u-boot, for NAND loading */ + diff --git a/packages/uboot/u-boot-mkimage-gta01-native/boot-from-ram-reloc.patch b/packages/uboot/u-boot-mkimage-gta01-native/boot-from-ram-reloc.patch new file mode 100644 index 0000000000..53a3e05c67 --- /dev/null +++ b/packages/uboot/u-boot-mkimage-gta01-native/boot-from-ram-reloc.patch @@ -0,0 +1,62 @@ +This patch allows us to boot from anywhere in RAM. It mainly sets the stage +for later patches. The only real changes here is the better handling of already +cached code (e.g., if we were started by a previous instance of u-boot), and +that we drop CONFIG_SKIP_RELOCATE_UBOOT from neo1973.h + +cpu/arm920t/start.S: if not relocating, instead of going straight to + stack_setup, jump to done_relocate, which may perform other setup tasks +cpu/arm920t/start.S: after relocating, flush the cache and jump to the new code +include/configs/neo1973.h: remove CONFIG_SKIP_RELOCATE_UBOOT + +- Werner Almesberger + +Index: u-boot/cpu/arm920t/start.S +=================================================================== +--- u-boot.orig/cpu/arm920t/start.S ++++ u-boot/cpu/arm920t/start.S +@@ -171,7 +171,7 @@ relocate: /* relocate U-Boot to RAM + adr r0, _start /* r0 <- current position of code */ + ldr r1, _TEXT_BASE /* test if we run from flash or RAM */ + cmp r0, r1 /* don't reloc during debug */ +- beq stack_setup ++ beq done_relocate + + ldr r2, _armboot_start + ldr r3, _bss_start +@@ -181,8 +181,14 @@ relocate: /* relocate U-Boot to RAM + copy_loop: + ldmia r0!, {r3-r10} /* copy from source address [r0] */ + stmia r1!, {r3-r10} /* copy to target address [r1] */ +- cmp r0, r2 /* until source end addreee [r2] */ ++ cmp r0, r2 /* until source end address [r2] */ + ble copy_loop ++ mov r0, #0 /* flush v3/v4 cache */ ++ mcr p15, 0, r0, c7, c7, 0 ++ ldr pc, _done_relocate /* jump to relocated code */ ++_done_relocate: ++ .word done_relocate ++done_relocate: + #else /* NAND_BOOT */ + relocate: + copy_myself: +@@ -270,7 +276,7 @@ notmatch: + 1: b 1b + done_nand_read: + #endif /* NAND_BOOT */ +-#endif /* CONFIG_SKIP_RELOCATE_UBOOT */ ++#endif /* CONFIG_SKIP_RELOCATE_UBOOT */ + + /* Set up the stack */ + stack_setup: +Index: u-boot/include/configs/neo1973_gta01.h +=================================================================== +--- u-boot.orig/include/configs/neo1973_gta01.h ++++ u-boot/include/configs/neo1973_gta01.h +@@ -28,7 +28,6 @@ + + #if defined(BUILD_FOR_RAM) + /* If we want to start u-boot from inside RAM */ +-#define CONFIG_SKIP_RELOCATE_UBOOT 1 + #define CONFIG_SKIP_LOWLEVEL_INIT 1 + #else + /* we want to start u-boot directly from within NAND flash */ diff --git a/packages/uboot/u-boot-mkimage-gta01-native/boot-menu.patch b/packages/uboot/u-boot-mkimage-gta01-native/boot-menu.patch new file mode 100644 index 0000000000..352967ae06 --- /dev/null +++ b/packages/uboot/u-boot-mkimage-gta01-native/boot-menu.patch @@ -0,0 +1,769 @@ +board/neo1973/bootmenu.c: simple configurable boot menu +board/neo1973/neo1973.c (neo1973_new_second): return 1 if a new second has + started since the last call +board/neo1973/neo1973.c (neo1973_on_key_pressed): return 1 if the $POWER key is + pressed +board/neo1973/neo1973.c (board_late_init): make use of neo1973_new_second and + neo1973_on_key_pressed +board/neo1973/neo1973.h: added function prototypes +u-boot/board/neo1973/neo1973.c (board_late_init): enter the boot menu when + "AUX" was pressed at least half the time +u-boot/board/neo1973/neo1973.c (board_late_init): minor code cleanup +u-boot/common/console.c, include/console.h: added "console_poll_hook" to be + called when waiting for console in put in "getc" and "tstc" +board/neo1973/neo1973.c (board_late_init): poll for the boot menu also on RAM + boot, reset, or unknown cause +board/neo1973/neo1973.c (board_late_init): don't look for the power key if + woken up by the charger +board/neo1973/neo1973.h, board/neo1973/neo1973.c, board/neo1973/bootmenu.c: + renamed neo1973_911_key_pressed to neo1973_aux_key_pressed + +- Werner Almesberger + +Index: u-boot/board/neo1973/common/bootmenu.c +=================================================================== +--- /dev/null ++++ u-boot/board/neo1973/common/bootmenu.c +@@ -0,0 +1,120 @@ ++/* ++ * bootmenu.c - Boot menu ++ * ++ * Copyright (C) 2006-2007 by OpenMoko, Inc. ++ * Written by Werner Almesberger ++ * All Rights Reserved ++ * ++ * 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., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ */ ++ ++ ++#include ++#include ++#include ++#include ++ ++#ifdef CONFIG_USBD_DFU ++#include "usbdcore.h" ++#include "usb_dfu.h" ++#endif ++ ++#include "neo1973.h" ++ ++ ++#define DEBOUNCE_LOOPS 1000 /* wild guess */ ++ ++ ++static int debounce(int (*fn)(void), int *last) ++{ ++ int on, i; ++ ++again: ++ on = fn(); ++ if (on != *last) ++ for (i = DEBOUNCE_LOOPS; i; i--) ++ if (on != fn()) ++ goto again; ++ *last = on; ++ return on; ++} ++ ++ ++static int aux_key(void *user) ++{ ++ static int last_aux = -1; ++ ++ return debounce(neo1973_aux_key_pressed, &last_aux); ++} ++ ++ ++static int on_key(void *user) ++{ ++ static int last_on = -1; ++ ++ return debounce(neo1973_on_key_pressed, &last_on); ++} ++ ++ ++static void factory_reset(void *user) ++{ ++ default_env(); ++ run_command("dynpart", 0); ++ run_command("bootd", 0); ++} ++ ++ ++static int seconds(void *user) ++{ ++ return neo1973_new_second(); ++} ++ ++ ++static int system_idle(void) ++{ ++#ifdef CONFIG_USBD_DFU ++ if (system_dfu_state) ++ return *system_dfu_state == DFU_STATE_appIDLE; ++#endif ++ return 1; ++} ++ ++ ++static void poweroff_if_idle(void *user) ++{ ++ unsigned long flags; ++ ++ local_irq_save(flags); ++ if (system_idle()) ++ neo1973_poweroff(); ++ local_irq_restore(flags); ++} ++ ++ ++static struct bootmenu_setup bootmenu_setup = { ++ .next_key = aux_key, ++ .enter_key = on_key, ++ .seconds = seconds, ++ .idle_action = poweroff_if_idle, ++}; ++ ++ ++void neo1973_bootmenu(void) ++{ ++ bootmenu_add("Boot", NULL, "bootd"); ++ bootmenu_init(&bootmenu_setup); ++ bootmenu_add("Factory reset", factory_reset, NULL); ++ bootmenu(); ++} +Index: u-boot/board/neo1973/gta01/gta01.c +=================================================================== +--- u-boot.orig/board/neo1973/gta01/gta01.c ++++ u-boot/board/neo1973/gta01/gta01.c +@@ -229,10 +229,15 @@ int board_late_init(void) + extern unsigned char booted_from_nand; + unsigned char tmp; + char buf[32]; ++ int menu_vote = 0; /* <= 0: no, > 0: yes */ ++ int seconds = 0; + + /* Initialize the Power Management Unit with a safe register set */ + pcf50606_init(); + ++ /* if there's no other reason, must be regular reset */ ++ neo1973_wakeup_cause = NEO1973_WAKEUP_RESET; ++ + if (!booted_from_nand) + goto woken_by_reset; + +@@ -242,45 +247,41 @@ int board_late_init(void) + setenv("pcf50606_int1", buf); + + if (tmp & PCF50606_INT1_ALARM) { +- /* we've been woken up by RTC alarm or charger insert, boot */ ++ /* we've been woken up by RTC alarm, boot */ + neo1973_wakeup_cause = NEO1973_WAKEUP_ALARM; + goto continue_boot; + } + if (tmp & PCF50606_INT1_EXTONR) { ++ /* we've been woken up by charger insert */ + neo1973_wakeup_cause = NEO1973_WAKEUP_CHARGER; + } + + if (tmp & PCF50606_INT1_ONKEYF) { +- int seconds = 0; +- neo1973_wakeup_cause = NEO1973_WAKEUP_POWER_KEY; + /* we've been woken up by a falling edge of the onkey */ ++ neo1973_wakeup_cause = NEO1973_WAKEUP_POWER_KEY; ++ } + +- /* we can't just setenv(bootdelay,-1) because that would +- * accidentially become permanent if the user does saveenv */ +- if (neo1973_911_key_pressed()) +- nobootdelay = 1; +- +- while (1) { +- u_int8_t int1, oocs; +- +- oocs = pcf50606_reg_read(PCF50606_REG_OOCS); +- if (oocs & PFC50606_OOCS_ONKEY) +- break; +- +- int1 = pcf50606_reg_read(PCF50606_REG_INT1); +- if (int1 & PCF50606_INT1_SECOND) +- seconds++; +- +- if (seconds >= POWER_KEY_SECONDS) +- goto continue_boot; +- } +- /* Power off if minimum number of seconds not reached */ +- neo1973_poweroff(); ++ if (neo1973_wakeup_cause == NEO1973_WAKEUP_CHARGER) { ++ /* if we still think it was only a charger insert, boot */ ++ goto continue_boot; + } + + woken_by_reset: +- /* if there's no other reason, must be regular reset */ +- neo1973_wakeup_cause = NEO1973_WAKEUP_RESET; ++ ++ while (neo1973_wakeup_cause == NEO1973_WAKEUP_RESET || ++ neo1973_on_key_pressed()) { ++ if (neo1973_aux_key_pressed()) ++ menu_vote++; ++ else ++ menu_vote--; ++ ++ if (neo1973_new_second()) ++ seconds++; ++ if (seconds >= POWER_KEY_SECONDS) ++ goto continue_boot; ++ } ++ /* Power off if minimum number of seconds not reached */ ++ neo1973_poweroff(); + + continue_boot: + jbt6k74_init(); +@@ -304,6 +305,11 @@ continue_boot: + } + #endif + ++ if (menu_vote > 0) { ++ neo1973_bootmenu(); ++ nobootdelay = 1; ++ } ++ + return 0; + } + +@@ -369,7 +375,17 @@ void neo1973_vibrator(int on) + #endif + } + +-int neo1973_911_key_pressed(void) ++int neo1973_new_second(void) ++{ ++ return pcf50606_reg_read(PCF50606_REG_INT1) & PCF50606_INT1_SECOND; ++} ++ ++int neo1973_on_key_pressed(void) ++{ ++ return !(pcf50606_reg_read(PCF50606_REG_OOCS) & PFC50606_OOCS_ONKEY); ++} ++ ++int neo1973_aux_key_pressed(void) + { + S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO(); + if (gpio->GPFDAT & (1 << 6)) +Index: u-boot/board/neo1973/gta01/Makefile +=================================================================== +--- u-boot.orig/board/neo1973/gta01/Makefile ++++ u-boot/board/neo1973/gta01/Makefile +@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk + + LIB = lib$(BOARD).a + +-OBJS := gta01.o pcf50606.o ../common/cmd_neo1973.o ../common/jbt6k74.o ../common/udc.o ++OBJS := gta01.o pcf50606.o ../common/cmd_neo1973.o ../common/jbt6k74.o ../common/udc.o ../common/bootmenu.o + SOBJS := ../common/lowlevel_init.o + + .PHONY: all +Index: u-boot/board/neo1973/common/neo1973.h +=================================================================== +--- u-boot.orig/board/neo1973/common/neo1973.h ++++ u-boot/board/neo1973/common/neo1973.h +@@ -29,4 +29,10 @@ int neo1973_911_key_pressed(void); + const char *neo1973_get_charge_status(void); + int neo1973_set_charge_mode(enum neo1973_charger_cmd cmd); + ++int neo1973_new_second(void); ++int neo1973_on_key_pressed(void); ++int neo1973_aux_key_pressed(void); ++ ++void neo1973_bootmenu(void); ++ + #endif +Index: u-boot/common/console.c +=================================================================== +--- u-boot.orig/common/console.c ++++ u-boot/common/console.c +@@ -160,8 +160,12 @@ void fprintf (int file, const char *fmt, + + /** U-Boot INITIAL CONSOLE-COMPATIBLE FUNCTION *****************************/ + ++void (*console_poll_hook)(int activity); ++ + int getc (void) + { ++ while (console_poll_hook && !tstc()); ++ + if (gd->flags & GD_FLG_DEVINIT) { + /* Get from the standard input */ + return fgetc (stdin); +@@ -171,7 +175,7 @@ int getc (void) + return serial_getc (); + } + +-int tstc (void) ++static int do_tstc (void) + { + if (gd->flags & GD_FLG_DEVINIT) { + /* Test the standard input */ +@@ -182,6 +186,16 @@ int tstc (void) + return serial_tstc (); + } + ++int tstc (void) ++{ ++ int ret; ++ ++ ret = do_tstc(); ++ if (console_poll_hook) ++ console_poll_hook(ret); ++ return ret; ++} ++ + void putc (const char c) + { + #ifdef CONFIG_SILENT_CONSOLE +Index: u-boot/include/console.h +=================================================================== +--- u-boot.orig/include/console.h ++++ u-boot/include/console.h +@@ -33,6 +33,8 @@ + extern device_t *stdio_devices[] ; + extern char *stdio_names[MAX_FILES] ; + ++extern void (*console_poll_hook)(int activity); ++ + int console_realloc(int top); + + #endif +Index: u-boot/common/Makefile +=================================================================== +--- u-boot.orig/common/Makefile ++++ u-boot/common/Makefile +@@ -50,7 +50,8 @@ COBJS = main.o ACEX1K.o altera.o bedbug. + memsize.o miiphybb.o miiphyutil.o \ + s_record.o serial.o soft_i2c.o soft_spi.o spartan2.o spartan3.o \ + usb.o usb_kbd.o usb_storage.o \ +- virtex2.o xilinx.o crc16.o xyzModem.o cmd_mac.o cmd_mfsl.o ++ virtex2.o xilinx.o crc16.o xyzModem.o cmd_mac.o cmd_mfsl.o \ ++ bootmenu.o + + SRCS := $(AOBJS:.o=.S) $(COBJS:.o=.c) + OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS)) +Index: u-boot/common/bootmenu.c +=================================================================== +--- /dev/null ++++ u-boot/common/bootmenu.c +@@ -0,0 +1,311 @@ ++/* ++ * bootmenu.c - Boot menu ++ * ++ * Copyright (C) 2006-2007 by OpenMoko, Inc. ++ * Written by Werner Almesberger ++ * All Rights Reserved ++ * ++ * 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., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ */ ++ ++ ++#include ++ ++#ifdef CFG_BOOTMENU ++ ++#include ++#include ++#include ++#include ++ ++ ++extern const char version_string[]; ++ ++ ++#define ANSI_CLEAR "\e[2J" ++#define ANSI_REVERSE "\e[7m" ++#define ANSI_NORMAL "\e[m" ++#define ANSI_GOTOYX "\e[%d;%dH" ++ ++/* ++ * MIN_BOOT_MENU_TIMEOUT ensures that users can't by accident set the timeout ++ * unusably short. ++ */ ++#define MIN_BOOT_MENU_TIMEOUT 10 /* 10 seconds */ ++#define BOOT_MENU_TIMEOUT 60 /* 60 seconds */ ++#define AFTER_COMMAND_WAIT 3 /* wait (2,3] after running commands */ ++#define MAX_MENU_ITEMS 10 /* cut off after that many */ ++ ++#define TOP_ROW 2 ++#define MENU_0_ROW (TOP_ROW+5) ++ ++ ++struct option { ++ const char *label; ++ void (*fn)(void *user); /* run_command if NULL */ ++ void *user; ++}; ++ ++ ++static const struct bootmenu_setup *setup; ++static struct option options[MAX_MENU_ITEMS]; ++static int num_options = 0; ++static int max_width = 0; ++ ++static device_t *bm_con; ++ ++ ++static void bm_printf(const char *fmt, ...) ++{ ++ va_list args; ++ char printbuffer[CFG_PBSIZE]; ++ ++ va_start(args, fmt); ++ vsprintf(printbuffer, fmt, args); ++ va_end(args); ++ ++ bm_con->puts(printbuffer); ++} ++ ++ ++static char *get_option(int n) ++{ ++ char name[] = "menu_XX"; ++ ++ sprintf(name+5, "%d", n); ++ return getenv(name); ++} ++ ++ ++static void print_option(const struct option *option, int reverse) ++{ ++ int n = option-options; ++ ++ bm_printf(ANSI_GOTOYX, MENU_0_ROW+n, 1); ++ if (reverse) ++ bm_printf(ANSI_REVERSE); ++ bm_printf(" %-*s ", max_width, option->label); ++ if (reverse) ++ bm_printf(ANSI_NORMAL); ++} ++ ++ ++static int get_var_positive_int(char *var, int default_value) ++{ ++ const char *s; ++ char *end; ++ int n; ++ ++ s = getenv(var); ++ if (!s) ++ return default_value; ++ n = simple_strtoul(s, &end, 0); ++ if (!*s || *end || n < 1) ++ return default_value; ++ return n; ++} ++ ++ ++static void show_bootmenu(void) ++{ ++ const struct option *option; ++ ++ bm_printf(ANSI_CLEAR ANSI_GOTOYX "%s", TOP_ROW, 1, version_string); ++ bm_printf(ANSI_GOTOYX "*** BOOT MENU ***", TOP_ROW+3, 1); ++ bm_printf(ANSI_GOTOYX, MENU_0_ROW, 1); ++ ++ for (option = options; option != options+num_options; option++) ++ print_option(option, option == options); ++ ++ bm_printf("\n\nPress [AUX] to select, [POWER] to execute.\n"); ++} ++ ++ ++static void redirect_console(int grab) ++{ ++ static device_t *orig_stdout, *orig_stderr; ++ ++ if (grab) { ++ orig_stdout = stdio_devices[stdout]; ++ orig_stderr = stdio_devices[stderr]; ++ stdio_devices[stdout] = bm_con; ++ stdio_devices[stderr] = bm_con; ++ } ++ else { ++ /* ++ * Make this conditional, because the command may also change ++ * the console. ++ */ ++ if (stdio_devices[stdout] == bm_con) ++ stdio_devices[stdout] = orig_stdout; ++ if (stdio_devices[stderr] == bm_con) ++ stdio_devices[stderr] = orig_stderr; ++ } ++} ++ ++ ++static void do_option(const struct option *option) ++{ ++ int seconds, aux; ++ ++ bm_printf(ANSI_CLEAR ANSI_GOTOYX, 1, 1); ++ redirect_console(1); ++ ++ if (option->fn) ++ option->fn(option->user); ++ else ++ run_command(option->user, 0); ++ ++ redirect_console(0); ++ seconds = get_var_positive_int("after_command_wait", ++ AFTER_COMMAND_WAIT); ++ if (seconds) ++ bm_printf("\nPress [AUX] to %s.", ++ option ? "return to boot menu" : "power off"); ++ aux = 1; /* require up-down transition */ ++ while (seconds) { ++ int tmp; ++ ++ tmp = setup->next_key(setup->user); ++ if (tmp && !aux) ++ break; ++ aux = tmp; ++ if (setup->seconds(setup->user)) ++ seconds--; ++ } ++ if (!option) ++ setup->idle_action(setup->idle_action); ++ show_bootmenu(); ++} ++ ++ ++static void bootmenu_hook(int activity) ++{ ++ static int aux = 1, on = 1; ++ static const struct option *option = options; ++ static int seconds = 0; ++ int tmp; ++ ++ if (activity) ++ seconds = 0; ++ tmp = setup->next_key(setup->user); ++ if (tmp && !aux) { ++ print_option(option, 0); ++ option++; ++ if (option == options+num_options) ++ option = options; ++ print_option(option, 1); ++ seconds = 0; ++ } ++ aux = tmp; ++ tmp = setup->enter_key(setup->user); ++ if (tmp && !on) { ++ do_option(option); ++ option = options; ++ seconds = 0; ++ } ++ on = tmp; ++ if (setup->seconds(setup->user)) { ++ int timeout; ++ ++ timeout = get_var_positive_int("boot_menu_timeout", ++ BOOT_MENU_TIMEOUT); ++ if (timeout < MIN_BOOT_MENU_TIMEOUT) ++ timeout = MIN_BOOT_MENU_TIMEOUT; ++ if (++seconds > timeout) { ++ setup->idle_action(setup->idle_action); ++ seconds = 0; ++ } ++ } ++} ++ ++ ++static device_t *find_console(const char *name) ++{ ++ int i; ++ ++ for (i = 1; i != ListNumItems(devlist); i++) { ++ device_t *dev = ListGetPtrToItem(devlist, i); ++ ++ if (!strcmp(name, dev->name)) ++ if (dev->flags & DEV_FLAGS_OUTPUT) ++ return dev; ++ } ++ return NULL; ++} ++ ++ ++void bootmenu_add(const char *label, void (*fn)(void *user), void *user) ++{ ++ int len; ++ ++ options[num_options].label = label; ++ options[num_options].fn = fn; ++ options[num_options].user = user; ++ num_options++; ++ ++ len = strlen(label); ++ if (len > max_width) ++ max_width = len; ++} ++ ++ ++void bootmenu_init(struct bootmenu_setup *__setup) ++{ ++ int n; ++ ++ setup = __setup; ++ for (n = 1; n != MAX_MENU_ITEMS+1; n++) { ++ const char *spec, *colon; ++ ++ spec = get_option(n); ++ if (!spec) ++ continue; ++ colon = strchr(spec, ':'); ++ if (!colon) ++ bootmenu_add(spec, NULL, (char *) spec); ++ else { ++ char *label; ++ int len = colon-spec; ++ ++ label = malloc(len+1); ++ if (!label) ++ return; ++ memcpy(label, spec, len); ++ label[len] = 0; ++ bootmenu_add(label, NULL, (char *) colon+1); ++ } ++ } ++} ++ ++ ++void bootmenu(void) ++{ ++ bm_con = find_console("vga"); ++ if (bm_con && bm_con->start && bm_con->start() < 0) ++ bm_con = NULL; ++ if (!bm_con) ++ bm_con = stdio_devices[stdout]; ++ if (!bm_con) ++ return; ++#if 0 ++ console_assign(stdout, "vga"); ++ console_assign(stderr, "vga"); ++#endif ++ show_bootmenu(); ++ console_poll_hook = bootmenu_hook; ++} ++ ++#endif /* CFG_BOOTMENU */ +Index: u-boot/include/bootmenu.h +=================================================================== +--- /dev/null ++++ u-boot/include/bootmenu.h +@@ -0,0 +1,71 @@ ++/* ++ * bootmenu.h - Boot menu ++ * ++ * Copyright (C) 2006-2007 by OpenMoko, Inc. ++ * Written by Werner Almesberger ++ * All Rights Reserved ++ * ++ * 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., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ */ ++ ++#ifndef BOOTMENU_H ++#define BOOTMENU_H ++ ++#define MIN_BOOT_MENU_TIMEOUT 10 /* 10 seconds */ ++#define BOOT_MENU_TIMEOUT 60 /* 60 seconds */ ++#define AFTER_COMMAND_WAIT 3 /* wait (2,3] after running commands */ ++#define MAX_MENU_ITEMS 10 /* cut off after that many */ ++ ++ ++struct bootmenu_setup { ++ /* non-zero while the "next" key is being pressed */ ++ int (*next_key)(void *user); ++ ++ /* non-zero while the "enter" key is being pressed */ ++ int (*enter_key)(void *user); ++ ++ /* return the number of seconds that have passed since the last call ++ to "seconds". It's okay to limit the range to [0, 1]. */ ++ int (*seconds)(void *user); ++ ++ /* action to take if the boot menu times out */ ++ void (*idle_action)(void *user); ++ ++ /* user-specific data, passes "as is" to the functions above */ ++ void *user; ++}; ++ ++ ++/* ++ * Initialize the menu from the environment. ++ */ ++ ++void bootmenu_init(struct bootmenu_setup *setup); ++ ++/* ++ * To add entries on top of the boot menu, call bootmenu_add before ++ * bootmenu_init. To add entries at the end, call it after bootmenu_init. ++ * If "fn" is NULL, the command specified in "user" is executed. ++ */ ++ ++void bootmenu_add(const char *label, void (*fn)(void *user), void *user); ++ ++/* ++ * Run the boot menu. ++ */ ++ ++void bootmenu(void); ++ ++#endif /* !BOOTMENU_H */ +Index: u-boot/include/configs/neo1973_gta01.h +=================================================================== +--- u-boot.orig/include/configs/neo1973_gta01.h ++++ u-boot/include/configs/neo1973_gta01.h +@@ -160,6 +160,8 @@ + /* valid baudrates */ + #define CFG_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 } + ++#define CFG_BOOTMENU ++ + /*----------------------------------------------------------------------- + * Stack sizes + * diff --git a/packages/uboot/u-boot-mkimage-gta01-native/cmd-unzip.patch b/packages/uboot/u-boot-mkimage-gta01-native/cmd-unzip.patch new file mode 100644 index 0000000000..ee4c1984fc --- /dev/null +++ b/packages/uboot/u-boot-mkimage-gta01-native/cmd-unzip.patch @@ -0,0 +1,58 @@ +common/cmd_mem.c: new command "unzip srcaddr dstaddr [dstsize]" to unzip from + memory to memory, and option CONFIG_UNZIP to enable it + +- Werner Almesberger + +Index: u-boot/common/cmd_mem.c +=================================================================== +--- u-boot.orig/common/cmd_mem.c ++++ u-boot/common/cmd_mem.c +@@ -1148,6 +1148,34 @@ int do_mem_crc (cmd_tbl_t *cmdtp, int fl + } + #endif /* CONFIG_CRC32_VERIFY */ + ++ ++#ifdef CONFIG_UNZIP ++int gunzip (void *, int, unsigned char *, unsigned long *); ++ ++int do_unzip ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) ++{ ++ unsigned long src, dst; ++ unsigned long src_len = ~0UL, dst_len = ~0UL; ++ int err; ++ ++ switch (argc) { ++ case 4: ++ dst_len = simple_strtoul(argv[3], NULL, 16); ++ /* fall through */ ++ case 3: ++ src = simple_strtoul(argv[1], NULL, 16); ++ dst = simple_strtoul(argv[2], NULL, 16); ++ break; ++ default: ++ printf ("Usage:\n%s\n", cmdtp->usage); ++ return 1; ++ } ++ ++ return !!gunzip((void *) dst, dst_len, (void *) src, &src_len); ++} ++#endif /* CONFIG_UNZIP */ ++ ++ + /**************************************************/ + #if (CONFIG_COMMANDS & CFG_CMD_MEMORY) + U_BOOT_CMD( +@@ -1251,5 +1279,13 @@ U_BOOT_CMD( + ); + #endif /* CONFIG_MX_CYCLIC */ + ++#ifdef CONFIG_UNZIP ++U_BOOT_CMD( ++ unzip, 4, 1, do_unzip, ++ "unzip - unzip a memory region\n", ++ "srcaddr dstaddr [dstsize]\n" ++); ++#endif /* CONFIG_UNZIP */ ++ + #endif + #endif /* CFG_CMD_MEMORY */ diff --git a/packages/uboot/u-boot-mkimage-gta01-native/console-ansi.patch b/packages/uboot/u-boot-mkimage-gta01-native/console-ansi.patch new file mode 100644 index 0000000000..2ac5b75dee --- /dev/null +++ b/packages/uboot/u-boot-mkimage-gta01-native/console-ansi.patch @@ -0,0 +1,127 @@ +drivers/cfb_console.c: added processing of ANSI escape sequences \e[2J, \e[m, + \e[7m, and \e[row;colH +drivers/cfb_console.c (video_putc): make \r return to the beginning of the line + +- Werner Almesberger + +Index: u-boot/drivers/cfb_console.c +=================================================================== +--- u-boot.orig/drivers/cfb_console.c ++++ u-boot/drivers/cfb_console.c +@@ -181,6 +181,7 @@ CONFIG_VIDEO_HW_CURSOR: - Uses the + + #include + #include ++#include + #include + #include + #ifdef CFG_CMD_DATE +@@ -676,10 +677,96 @@ static void console_newline (void) + + /*****************************************************************************/ + ++static enum { ++ CS_NORMAL = 0, ++ CS_ESC, ++ CS_NUM1, ++ CS_NUM2, ++} state = 0; ++ ++static int num1, num2; ++ ++ ++static void swap_drawing_colors(void) ++{ ++ eorx = fgx; ++ fgx = bgx; ++ bgx = eorx; ++ eorx = fgx ^ bgx; ++} ++ ++ ++static void process_sequence(char c) ++{ ++ static int inverted = 0; ++ int i, inv; ++ ++ switch (c) { ++ case 'J': ++ /* assume num1 == 2 */ ++ for (i = 0; i != CONSOLE_ROWS; i++) ++ console_scrollup(); ++ break; ++ case 'H': ++ if (num1 > CONSOLE_ROWS || num2 > CONSOLE_COLS) ++ break; ++ console_col = num2 ? num2-1 : 0; ++ console_row = num1 ? num1-1 : 0; ++ break; ++ case 'm': ++ inv = num1 == 7; ++ if (num1 && !inv) ++ break; ++ if (inverted != inv) ++ swap_drawing_colors(); ++ inverted = inv; ++ break; ++ } ++} ++ ++ ++static void escape_sequence(char c) ++{ ++ switch (state) { ++ case CS_ESC: ++ state = c == '[' ? CS_NUM1 : CS_NORMAL; ++ num1 = num2 = 0; ++ break; ++ case CS_NUM1: ++ if (isdigit(c)) ++ num1 = num1*10+c-'0'; ++ else if (c == ';') ++ state = CS_NUM2; ++ else { ++ process_sequence(c); ++ state = CS_NORMAL; ++ } ++ break; ++ case CS_NUM2: ++ if (isdigit(c)) ++ num2 = num2*10+c-'0'; ++ else { ++ process_sequence(c); ++ state = CS_NORMAL; ++ } ++ default: ++ /* can't happen */; ++ } ++} ++ ++ + void video_putc (const char c) + { ++ if (state) { ++ escape_sequence(c); ++ CURSOR_SET; ++ return; ++ } ++ + switch (c) { +- case 13: /* ignore */ ++ case 13: /* return to beginning of line */ ++ CURSOR_OFF; ++ console_col = 0; + break; + + case '\n': /* next line */ +@@ -698,6 +785,10 @@ void video_putc (const char c) + console_back (); + break; + ++ case '\e': ++ state = CS_ESC; ++ break; ++ + default: /* draw the char */ + video_putchar (console_col * VIDEO_FONT_WIDTH, + console_row * VIDEO_FONT_HEIGHT, diff --git a/packages/uboot/u-boot-mkimage-gta01-native/default-env.patch b/packages/uboot/u-boot-mkimage-gta01-native/default-env.patch new file mode 100644 index 0000000000..b9ae4f29fe --- /dev/null +++ b/packages/uboot/u-boot-mkimage-gta01-native/default-env.patch @@ -0,0 +1,101 @@ +common/env_common.c (default_env): new function that resets the environment to + the default value +common/env_common.c (env_relocate): use default_env instead of own copy +common/env_nand.c (env_relocate_spec): use default_env instead of own copy +include/environment.h: added default_env prototype + +- Werner Almesberger + +Index: u-boot/common/env_common.c +=================================================================== +--- u-boot.orig/common/env_common.c ++++ u-boot/common/env_common.c +@@ -202,6 +202,25 @@ uchar *env_get_addr (int index) + } + } + ++void default_env(void) ++{ ++ if (sizeof(default_environment) > ENV_SIZE) ++ { ++ puts ("*** Error - default environment is too large\n\n"); ++ return; ++ } ++ ++ memset (env_ptr, 0, sizeof(env_t)); ++ memcpy (env_ptr->data, ++ default_environment, ++ sizeof(default_environment)); ++#ifdef CFG_REDUNDAND_ENVIRONMENT ++ env_ptr->flags = 0xFF; ++#endif ++ env_crc_update (); ++ gd->env_valid = 1; ++} ++ + void env_relocate (void) + { + DEBUGF ("%s[%d] offset = 0x%lx\n", __FUNCTION__,__LINE__, +@@ -245,23 +264,8 @@ void env_relocate (void) + gd->env_valid = 0; + #endif + +- if (gd->env_valid == 0) { +- if (sizeof(default_environment) > ENV_SIZE) +- { +- puts ("*** Error - default environment is too large\n\n"); +- return; +- } +- +- memset (env_ptr, 0, sizeof(env_t)); +- memcpy (env_ptr->data, +- default_environment, +- sizeof(default_environment)); +-#ifdef CFG_REDUNDAND_ENVIRONMENT +- env_ptr->flags = 0xFF; +-#endif +- env_crc_update (); +- gd->env_valid = 1; +- } ++ if (gd->env_valid == 0) ++ default_env(); + else { + env_relocate_spec (); + } +Index: u-boot/common/env_nand.c +=================================================================== +--- u-boot.orig/common/env_nand.c ++++ u-boot/common/env_nand.c +@@ -313,19 +313,7 @@ void env_relocate_spec (void) + static void use_default() + { + puts ("*** Warning - bad CRC or NAND, using default environment\n\n"); +- +- if (default_environment_size > CFG_ENV_SIZE){ +- puts ("*** Error - default environment is too large\n\n"); +- return; +- } +- +- memset (env_ptr, 0, sizeof(env_t)); +- memcpy (env_ptr->data, +- default_environment, +- default_environment_size); +- env_ptr->crc = crc32(0, env_ptr->data, ENV_SIZE); +- gd->env_valid = 1; +- ++ default_env(); + } + #endif + +Index: u-boot/include/environment.h +=================================================================== +--- u-boot.orig/include/environment.h ++++ u-boot/include/environment.h +@@ -107,4 +107,7 @@ typedef struct environment_s { + unsigned char data[ENV_SIZE]; /* Environment data */ + } env_t; + ++ ++void default_env(void); ++ + #endif /* _ENVIRONMENT_H_ */ diff --git a/packages/uboot/u-boot-mkimage-gta01-native/dontask.patch b/packages/uboot/u-boot-mkimage-gta01-native/dontask.patch new file mode 100644 index 0000000000..23d4b13626 --- /dev/null +++ b/packages/uboot/u-boot-mkimage-gta01-native/dontask.patch @@ -0,0 +1,22 @@ +common/cmd_nand.c (yes): if the environment variable "dontask" is set to "y" or + "Y", non-interactively assume the answer was "yes". In all other cases, ask. + +- Werner Almesberger + +Index: u-boot/common/cmd_nand.c +=================================================================== +--- u-boot.orig/common/cmd_nand.c ++++ u-boot/common/cmd_nand.c +@@ -165,8 +165,12 @@ out: + + static int yes(void) + { ++ char *s; + char c; + ++ s = getenv("dontask"); ++ if (s && (s[0] =='y' || s[0] == 'Y') && !s[1]) ++ return 1; + c = getc(); + if (c != 'y' && c != 'Y') + return 0; diff --git a/packages/uboot/u-boot-mkimage-gta01-native/dynenv-harden.patch b/packages/uboot/u-boot-mkimage-gta01-native/dynenv-harden.patch new file mode 100644 index 0000000000..cf12352553 --- /dev/null +++ b/packages/uboot/u-boot-mkimage-gta01-native/dynenv-harden.patch @@ -0,0 +1,139 @@ +common/cmd_nand.c: globalized arg_off_size +include/util.h: new header to convenience functions, such as arg_off_size +common/cmd_dynenv.c (do_dynenv): use arg_off_size to sanity-check offset and to + allow use of partition name +common/cmd_dynenv.c (do_dynenv): indicate in no uncertain terms when an update + would not work due to Flash bits already cleared +common/cmd_dynenv.c (do_dynenv): update CFG_ENV_OFFSET after successful "dynenv + set", so that we can write the new environment without having to reboot + +- Werner Almesberger + +Index: u-boot/common/cmd_nand.c +=================================================================== +--- u-boot.orig/common/cmd_nand.c ++++ u-boot/common/cmd_nand.c +@@ -100,7 +100,7 @@ static inline int str2long(char *p, ulon + return (*p != '\0' && *endptr == '\0') ? 1 : 0; + } + +-static int ++int + arg_off_size(int argc, char *argv[], nand_info_t *nand, ulong *off, ulong *size) + { + int idx = nand_curr_device; +Index: u-boot/include/util.h +=================================================================== +--- /dev/null ++++ u-boot/include/util.h +@@ -0,0 +1,33 @@ ++/* ++ * util.h - Convenience functions ++ * ++ * (C) Copyright 2006-2007 OpenMoko, Inc. ++ * Author: Werner Almesberger ++ * ++ * 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 ++ */ ++ ++#ifndef UTIL_H ++#define UTIL_H ++ ++#include "nand.h" ++ ++ ++/* common/cmd_nand.c */ ++int arg_off_size(int argc, char *argv[], nand_info_t *nand, ulong *off, ++ ulong *size); ++ ++#endif /* UTIL_H */ +Index: u-boot/common/cmd_dynenv.c +=================================================================== +--- u-boot.orig/common/cmd_dynenv.c ++++ u-boot/common/cmd_dynenv.c +@@ -23,6 +23,7 @@ + #include + #include + #include ++#include + #include + + #if defined(CFG_ENV_OFFSET_OOB) +@@ -39,8 +40,8 @@ int do_dynenv(cmd_tbl_t *cmdtp, int flag + if (!buf) + return -ENOMEM; + ++ ret = mtd->read_oob(mtd, 8, size, (size_t *) &size, (u_char *) buf); + if (!strcmp(cmd, "get")) { +- ret = mtd->read_oob(mtd, 8, size, (size_t *) &size, (u_char *) buf); + + if (buf[0] == 'E' && buf[1] == 'N' && + buf[2] == 'V' && buf[3] == '0') +@@ -49,7 +50,8 @@ int do_dynenv(cmd_tbl_t *cmdtp, int flag + printf("No dynamic environment marker in OOB block 0\n"); + + } else if (!strcmp(cmd, "set")) { +- unsigned long addr; ++ unsigned long addr, dummy; ++ + if (argc < 3) + goto usage; + +@@ -57,7 +59,23 @@ int do_dynenv(cmd_tbl_t *cmdtp, int flag + buf[1] = 'N'; + buf[2] = 'V'; + buf[3] = '0'; +- addr = simple_strtoul(argv[2], NULL, 16); ++ ++ if (arg_off_size(argc-2, argv+2, mtd, &addr, &dummy) < 0) { ++ printf("Offset or partition name expected\n"); ++ goto fail; ++ } ++ if (!ret) { ++ uint8_t tmp[4]; ++ int i; ++ ++ memcpy(&tmp, &addr, 4); ++ for (i = 0; i != 4; i++) ++ if (tmp[i] & ~buf[i+4]) { ++ printf("ERROR: erase OOB block to " ++ "write this value\n"); ++ goto fail; ++ } ++ } + memcpy(buf+4, &addr, 4); + + printf("%02x %02x %02x %02x - %02x %02x %02x %02x\n", +@@ -65,6 +83,8 @@ int do_dynenv(cmd_tbl_t *cmdtp, int flag + buf[4], buf[5], buf[6], buf[7]); + + ret = mtd->write_oob(mtd, 8, size, (size_t *) &size, (u_char *) buf); ++ if (!ret) ++ CFG_ENV_OFFSET = addr; + } else + goto usage; + +@@ -72,8 +92,9 @@ int do_dynenv(cmd_tbl_t *cmdtp, int flag + return ret; + + usage: +- free(buf); + printf("Usage:\n%s\n", cmdtp->usage); ++fail: ++ free(buf); + return 1; + } + diff --git a/packages/uboot/u-boot-mkimage-gta01-native/early-powerdown.patch b/packages/uboot/u-boot-mkimage-gta01-native/early-powerdown.patch new file mode 100644 index 0000000000..7326c2daa6 --- /dev/null +++ b/packages/uboot/u-boot-mkimage-gta01-native/early-powerdown.patch @@ -0,0 +1,40 @@ +Index: u-boot/board/neo1973/neo1973.c +=================================================================== +--- u-boot.orig/board/neo1973/gta01/gta01.c ++++ u-boot/board/neo1973/gta01/gta01.c +@@ -68,8 +68,12 @@ DECLARE_GLOBAL_DATA_PTR; + #define U_M_PDIV 0x2 + #define U_M_SDIV 0x3 + ++#define VALID_WAKEUP_REASONS (PCF50606_INT1_ONKEYF | PCF50606_INT1_ALARM) ++ + unsigned int neo1973_wakeup_cause; + extern int nobootdelay; ++static unsigned char int1; ++ + + static inline void delay (unsigned long loops) + { +@@ -179,6 +183,13 @@ int board_init (void) + #error Please define GTA01 version + #endif + ++ i2c_init(CFG_I2C_SPEED, CFG_I2C_SLAVE); ++ int1 = pcf50606_reg_read(PCF50606_REG_INT1); ++ if (!(int1 & VALID_WAKEUP_REASONS) && !neo1973_aux_key_pressed()) { ++ pcf50606_reg_write(PCF50606_REG_OOCC1, PCF50606_OOCC1_GOSTDBY); ++ while (1); ++ } ++ + /* arch number of SMDK2410-Board */ + gd->bd->bi_arch_number = MACH_TYPE_NEO1973_GTA01; + +@@ -200,7 +211,7 @@ int board_late_init(void) + pcf50606_init(); + + /* obtain wake-up reason, save INT1 in environment */ +- tmp = pcf50606_reg_read(PCF50606_REG_INT1); ++ tmp = int1; //pcf50606_reg_read(PCF50606_REG_INT1); + sprintf(buf, "0x%02x", tmp); + setenv("pcf50606_int1", buf); + diff --git a/packages/uboot/u-boot-mkimage-gta01-native/enable-splash-bmp.patch b/packages/uboot/u-boot-mkimage-gta01-native/enable-splash-bmp.patch new file mode 100644 index 0000000000..dcb721c8d3 --- /dev/null +++ b/packages/uboot/u-boot-mkimage-gta01-native/enable-splash-bmp.patch @@ -0,0 +1,56 @@ +drivers/cfb_console.c: include asm/byteorder.h for le32_to_cpu and friends + [ shouldn't someone else have found this long ago ? ] +include/configs/neo1973.h (CONFIG_COMMANDS): add CFG_CMD_BMP +include/configs/neo1973.h: enable splash screen and BMP support +include/configs/neo1973.h: remove #if 1 ... #endif around video definitions + +- Werner Almesberger + +Index: u-boot/drivers/cfb_console.c +=================================================================== +--- u-boot.orig/drivers/cfb_console.c ++++ u-boot/drivers/cfb_console.c +@@ -191,6 +191,7 @@ CONFIG_VIDEO_HW_CURSOR: - Uses the + #if (CONFIG_COMMANDS & CFG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN) + #include + #include ++#include + #endif /* (CONFIG_COMMANDS & CFG_CMD_BMP) || CONFIG_SPLASH_SCREEN */ + + /*****************************************************************************/ +Index: u-boot/include/configs/neo1973_gta01.h +=================================================================== +--- u-boot.orig/include/configs/neo1973_gta01.h ++++ u-boot/include/configs/neo1973_gta01.h +@@ -86,6 +86,7 @@ + /* CFG_CMD_IRQ | */ \ + CFG_CMD_BOOTD | \ + CFG_CMD_CONSOLE | \ ++ CFG_CMD_BMP | \ + CFG_CMD_ASKENV | \ + CFG_CMD_RUN | \ + CFG_CMD_ECHO | \ +@@ -244,19 +245,21 @@ + /* we have a board_late_init() function */ + #define BOARD_LATE_INIT 1 + +-#if 1 + #define CONFIG_VIDEO + #define CONFIG_VIDEO_S3C2410 + #define CONFIG_CFB_CONSOLE + #define CONFIG_VIDEO_LOGO ++#define CONFIG_SPLASH_SCREEN ++#define CFG_VIDEO_LOGO_MAX_SIZE (640*480+1024+100) /* 100 = slack */ ++#define CONFIG_VIDEO_BMP_GZIP + #define CONFIG_VGA_AS_SINGLE_DEVICE ++#define CONFIG_UNZIP + + #define VIDEO_KBD_INIT_FCT 0 + #define VIDEO_TSTC_FCT serial_tstc + #define VIDEO_GETC_FCT serial_getc + + #define LCD_VIDEO_ADDR 0x33d00000 +-#endif + + #define CONFIG_S3C2410_NAND_BBT 1 + diff --git a/packages/uboot/u-boot-mkimage-gta01-native/env_nand_oob.patch b/packages/uboot/u-boot-mkimage-gta01-native/env_nand_oob.patch new file mode 100644 index 0000000000..5a2dd61461 --- /dev/null +++ b/packages/uboot/u-boot-mkimage-gta01-native/env_nand_oob.patch @@ -0,0 +1,198 @@ +This patch adds support for CFG_ENV_OFFSET_PATCHED and +CFG_ENV_OFFSET_OOB. + +Both try to solve the problem of fixing the environment location in NAND flash +at compile time, which doesn't work well if the NAND flash has a bad block at +exactly that location. + +CFG_ENV_OFFSET_PATCHED puts the environment in a global variable. You can then +use the linker script to put that variable to a fixed location in the u-boot +image. Then you can use bianry patching during the production flash process. + +The idea of CFG_ENV_OFFSET_OOB is to store the environment offset in the NAND +OOB data of block 0. We can do this in case the vendor makes a guarantee that +block 0 never is a factory-default bad block. + +Signed-off-by: Harald Welte + +Index: u-boot/common/env_nand.c +=================================================================== +--- u-boot.orig/common/env_nand.c ++++ u-boot/common/env_nand.c +@@ -271,6 +271,33 @@ + ulong total; + int ret; + ++#if defined(CFG_ENV_OFFSET_OOB) ++ struct mtd_info *mtd = &nand_info[0]; ++ struct nand_chip *this = mtd->priv; ++ int buf_len; ++ uint8_t *buf; ++ ++ buf_len = (1 << this->bbt_erase_shift); ++ buf_len += (buf_len >> this->page_shift) * mtd->oobsize; ++ buf = malloc(buf_len); ++ if (!buf) ++ return; ++ ++ nand_read_raw(mtd, buf, 0, mtd->oobblock, mtd->oobsize); ++ if (buf[mtd->oobblock + 8 + 0] == 'E' && ++ buf[mtd->oobblock + 8 + 1] == 'N' && ++ buf[mtd->oobblock + 8 + 2] == 'V' && ++ buf[mtd->oobblock + 8 + 3] == '0') { ++ CFG_ENV_OFFSET = *((unsigned long *) &buf[mtd->oobblock + 8 + 4]); ++ /* fall through to the normal environment reading code below */ ++ free(buf); ++ puts("Found Environment offset in OOB..\n"); ++ } else { ++ free(buf); ++ return use_default(); ++ } ++#endif ++ + total = CFG_ENV_SIZE; + ret = nand_read(&nand_info[0], CFG_ENV_OFFSET, &total, (u_char*)env_ptr); + if (ret || total != CFG_ENV_SIZE) +Index: u-boot/common/environment.c +=================================================================== +--- u-boot.orig/common/environment.c ++++ u-boot/common/environment.c +@@ -29,6 +29,12 @@ + #undef __ASSEMBLY__ + #include + ++#if defined(CFG_ENV_OFFSET_PATCHED) ++unsigned long env_offset = CFG_ENV_OFFSET_PATCHED; ++#elif defined(CFG_ENV_OFFSET_OOB) ++unsigned long env_offset = CFG_ENV_OFFSET_OOB; ++#endif ++ + /* + * Handle HOSTS that have prepended + * crap on symbol names, not TARGETS. +Index: u-boot/include/environment.h +=================================================================== +--- u-boot.orig/include/environment.h ++++ u-boot/include/environment.h +@@ -70,6 +70,10 @@ + #endif /* CFG_ENV_IS_IN_FLASH */ + + #if defined(CFG_ENV_IS_IN_NAND) ++#if defined(CFG_ENV_OFFSET_PATCHED) || defined(CFG_ENV_OFFSET_OOB) ++extern unsigned long env_offset; ++#define CFG_ENV_OFFSET env_offset ++#else + # ifndef CFG_ENV_OFFSET + # error "Need to define CFG_ENV_OFFSET when using CFG_ENV_IS_IN_NAND" + # endif +@@ -82,6 +86,7 @@ + # ifdef CFG_ENV_IS_EMBEDDED + # define ENV_IS_EMBEDDED 1 + # endif ++#endif /* CFG_ENV_NAND_PATCHED */ + #endif /* CFG_ENV_IS_IN_NAND */ + + +Index: u-boot/common/Makefile +=================================================================== +--- u-boot.orig/common/Makefile ++++ u-boot/common/Makefile +@@ -31,7 +31,7 @@ + cmd_bdinfo.o cmd_bedbug.o cmd_bmp.o cmd_boot.o cmd_bootm.o \ + cmd_cache.o cmd_console.o \ + cmd_date.o cmd_dcr.o cmd_diag.o cmd_display.o cmd_doc.o cmd_dtt.o \ +- cmd_eeprom.o cmd_elf.o cmd_ext2.o \ ++ cmd_dynenv.o cmd_eeprom.o cmd_elf.o cmd_ext2.o \ + cmd_fat.o cmd_fdc.o cmd_fdt.o cmd_fdos.o cmd_flash.o cmd_fpga.o \ + cmd_i2c.o cmd_ide.o cmd_immap.o cmd_itest.o cmd_jffs2.o \ + cmd_load.o cmd_log.o \ +Index: u-boot/common/cmd_dynenv.c +=================================================================== +--- /dev/null ++++ u-boot/common/cmd_dynenv.c +@@ -0,0 +1,85 @@ ++/* ++ * (C) Copyright 2006-2007 OpenMoko, Inc. ++ * Author: Harald Welte ++ * ++ * 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 ++#include ++#include ++#include ++#include ++#include ++ ++#if defined(CFG_ENV_OFFSET_OOB) ++ ++int do_dynenv(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) ++{ ++ struct mtd_info *mtd = &nand_info[0]; ++ int ret, size = 8; ++ uint8_t *buf; ++ ++ char *cmd = argv[1]; ++ ++ buf = malloc(mtd->oobsize); ++ if (!buf) ++ return -ENOMEM; ++ ++ if (!strcmp(cmd, "get")) { ++ ret = mtd->read_oob(mtd, 8, size, (size_t *) &size, (u_char *) buf); ++ ++ if (buf[0] == 'E' && buf[1] == 'N' && ++ buf[2] == 'V' && buf[3] == '0') ++ printf("0x%08x\n", *((u_int32_t *) &buf[4])); ++ else ++ printf("No dynamic environment marker in OOB block 0\n"); ++ ++ } else if (!strcmp(cmd, "set")) { ++ unsigned long addr; ++ if (argc < 3) ++ goto usage; ++ ++ buf[0] = 'E'; ++ buf[1] = 'N'; ++ buf[2] = 'V'; ++ buf[3] = '0'; ++ addr = simple_strtoul(argv[2], NULL, 16); ++ memcpy(buf+4, &addr, 4); ++ ++ printf("%02x %02x %02x %02x - %02x %02x %02x %02x\n", ++ buf[0], buf[1], buf[2], buf[3], ++ buf[4], buf[5], buf[6], buf[7]); ++ ++ ret = mtd->write_oob(mtd, 8, size, (size_t *) &size, (u_char *) buf); ++ } else ++ goto usage; ++ ++ free(buf); ++ return ret; ++ ++usage: ++ free(buf); ++ printf("Usage:\n%s\n", cmdtp->usage); ++ return 1; ++} ++ ++U_BOOT_CMD(dynenv, 3, 1, do_dynenv, ++ "dynenv - dynamically placed (NAND) environment\n", ++ "dynenv set off - set enviromnent offset\n" ++ "dynenv get - get environment offset\n"); ++ ++#endif /* CFG_ENV_OFFSET_OOB */ diff --git a/packages/uboot/u-bo