diff --git a/arch/arm/boards/zylonite/board.c b/arch/arm/boards/zylonite/board.c index dabc6ff..2caadbc 100644 --- a/arch/arm/boards/zylonite/board.c +++ b/arch/arm/boards/zylonite/board.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -66,6 +67,8 @@ &smsc91x_pdata); add_generic_device("mrvl_nand", DEVICE_ID_DYNAMIC, NULL, 0x43100000, 0x1000, IORESOURCE_MEM, &nand_pdata); + devfs_add_partition("nand0", SZ_1M, SZ_256K, DEVFS_PARTITION_FIXED, + "env0"); return 0; } device_initcall(zylonite_devices_init); diff --git a/arch/arm/boards/zylonite/env/bin/init b/arch/arm/boards/zylonite/env/bin/init deleted file mode 100644 index a6bc087..0000000 --- a/arch/arm/boards/zylonite/env/bin/init +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -PATH=/env/bin -export PATH - -. /env/config -addpart /dev/nand0 $mtdparts -usbserial -s "Zylonite usb gadget" - -# Phase1: check for MTD override -mtd_env_override -if [ $? = 0 ]; then - echo "Switching to custom environment" - /env/init - exit -fi - -# Phase2: initiate network -dhcp -H zylonite - -# Phase3: activate netconsole, broadcast everywhere -netconsole.ip=255.255.255.255 -netconsole.active=ioe -netconsole.port=6666 - diff --git a/arch/arm/boards/zylonite/env/bin/mtd_env_override b/arch/arm/boards/zylonite/env/bin/mtd_env_override deleted file mode 100644 index 6ea253a..0000000 --- a/arch/arm/boards/zylonite/env/bin/mtd_env_override +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -loadenv /dev/nand0.barebox-env -exit $? diff --git a/arch/arm/boards/zylonite/env/boot/nand-ubi b/arch/arm/boards/zylonite/env/boot/nand-ubi new file mode 100644 index 0000000..2231738 --- /dev/null +++ b/arch/arm/boards/zylonite/env/boot/nand-ubi @@ -0,0 +1,5 @@ +#!/bin/sh + +global.bootm.image="/dev/nand0.kernel" +#global.bootm.oftree="/env/oftree" +global.linux.bootargs.dyn.root="root=ubi0:linux_root ubi.mtd=nand.root rootfstype=ubifs" diff --git a/arch/arm/boards/zylonite/env/config b/arch/arm/boards/zylonite/env/config deleted file mode 100644 index ee66e37..0000000 --- a/arch/arm/boards/zylonite/env/config +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -autoboot_timeout=3 - -mtdparts="128k@0(TIMH)ro,128k@128k(OBMI)ro,768k@256k(barebox),256k@1024k(barebox-env),12M@1280k(kernel),38016k@13568k(root)" -bootargs="$bootargs mtdparts=pxa3xx_nand-0:$mtdparts ubi.mtd=5 rootfstype=ubifs root=ubi0:root ro ram=64M console=ttyS0,115200" diff --git a/arch/arm/boards/zylonite/env/init/mtdparts-nand b/arch/arm/boards/zylonite/env/init/mtdparts-nand new file mode 100644 index 0000000..9db4652 --- /dev/null +++ b/arch/arm/boards/zylonite/env/init/mtdparts-nand @@ -0,0 +1,11 @@ +#!/bin/sh + +if [ "$1" = menu ]; then + init-menu-add-entry "$0" "NAND partitions" + exit +fi + +mtdparts="128k@0(TIMH)ro,128k@128k(OBMI)ro,768k@256k(barebox),256k@1024k(barebox-env),12M@1280k(kernel),38016k@13568k(root)" +kernelname="pxa3xx_nand-0" + +mtdparts-add -d nand0 -k ${kernelname} -p ${mtdparts} diff --git a/arch/arm/boards/zylonite/env/nv/hostname b/arch/arm/boards/zylonite/env/nv/hostname new file mode 100644 index 0000000..6e6d865 --- /dev/null +++ b/arch/arm/boards/zylonite/env/nv/hostname @@ -0,0 +1 @@ +zylonite diff --git a/arch/arm/boards/zylonite/env/nv/linux.bootargs.base b/arch/arm/boards/zylonite/env/nv/linux.bootargs.base new file mode 100644 index 0000000..317f8b1 --- /dev/null +++ b/arch/arm/boards/zylonite/env/nv/linux.bootargs.base @@ -0,0 +1 @@ +ram=64M diff --git a/arch/arm/boards/zylonite/env/nv/linux.bootargs.console b/arch/arm/boards/zylonite/env/nv/linux.bootargs.console new file mode 100644 index 0000000..476b1fb --- /dev/null +++ b/arch/arm/boards/zylonite/env/nv/linux.bootargs.console @@ -0,0 +1 @@ +console=ttyS0,115200 diff --git a/arch/arm/configs/zylonite310_defconfig b/arch/arm/configs/zylonite310_defconfig index fa6587c..ffe3215 100644 --- a/arch/arm/configs/zylonite310_defconfig +++ b/arch/arm/configs/zylonite310_defconfig @@ -8,17 +8,17 @@ # CONFIG_BANNER is not set CONFIG_MMU=y CONFIG_BAREBOX_MAX_BARE_INIT_SIZE=0x80000 -CONFIG_MALLOC_SIZE=0x1000000 +CONFIG_MALLOC_SIZE=0x800000 CONFIG_EXPERIMENTAL=y CONFIG_MODULES=y CONFIG_KALLSYMS=y CONFIG_PROMPT="zylonite-barebox:" -CONFIG_GLOB=y CONFIG_HUSH_FANCY_PROMPT=y CONFIG_CMDLINE_EDITING=y CONFIG_AUTO_COMPLETE=y CONFIG_MENU=y CONFIG_CONSOLE_ACTIVATE_ALL=y +CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/zylonite/env" CONFIG_RESET_SOURCE=y CONFIG_DEFAULT_LOGLEVEL=8 @@ -27,8 +27,6 @@ CONFIG_LONGHELP=y CONFIG_CMD_IOMEM=y CONFIG_CMD_MEMINFO=y -CONFIG_FLEXIBLE_BOOTARGS=y -CONFIG_CMD_BOOT=y CONFIG_CMD_BOOTM_SHOW_TYPE=y CONFIG_CMD_BOOTM_VERBOSE=y CONFIG_CMD_BOOTM_INITRD=y @@ -40,26 +38,20 @@ CONFIG_CMD_RESET=y CONFIG_CMD_SAVES=y CONFIG_CMD_PARTITION=y -CONFIG_CMD_AUTOMOUNT=y CONFIG_CMD_UBIFORMAT=y CONFIG_CMD_EXPORT=y -CONFIG_CMD_GLOBAL=y CONFIG_CMD_LOADENV=y CONFIG_CMD_PRINTENV=y CONFIG_CMD_SAVEENV=y -CONFIG_CMD_BASENAME=y CONFIG_CMD_CMP=y -CONFIG_CMD_DIRNAME=y CONFIG_CMD_FILETYPE=y CONFIG_CMD_LN=y -CONFIG_CMD_READLINK=y CONFIG_CMD_UNCOMPRESS=y CONFIG_CMD_LET=y CONFIG_CMD_MSLEEP=y CONFIG_CMD_SLEEP=y CONFIG_CMD_DHCP=y CONFIG_CMD_HOST=y -CONFIG_NET_CMD_IFUP=y CONFIG_CMD_MIITOOL=y CONFIG_CMD_PING=y CONFIG_CMD_TFTP=y diff --git a/commands/boot.c b/commands/boot.c index 3341a05..fd58824 100644 --- a/commands/boot.c +++ b/commands/boot.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -24,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -71,10 +73,28 @@ return ret; } +static unsigned int boot_watchdog_timeout; + +static int init_boot_watchdog_timeout(void) +{ + return globalvar_add_simple_int("boot.watchdog_timeout", + &boot_watchdog_timeout, "%u"); +} +late_initcall(init_boot_watchdog_timeout); + +BAREBOX_MAGICVAR_NAMED(global_watchdog_timeout, global.boot.watchdog_timeout, + "Watchdog enable timeout in seconds before booting"); + static int boot_entry(struct blspec_entry *be) { int ret; + if (IS_ENABLED(CONFIG_WATCHDOG) && boot_watchdog_timeout) { + ret = watchdog_set_timeout(boot_watchdog_timeout); + if (ret) + pr_warn("Failed to enable watchdog: %s\n", strerror(-ret)); + } + if (be->scriptpath) { ret = boot_script(be->scriptpath); } else { @@ -375,7 +395,7 @@ dryrun = 0; timeout = -1; - while ((opt = getopt(argc, argv, "vldmt:")) > 0) { + while ((opt = getopt(argc, argv, "vldmt:w:")) > 0) { switch (opt) { case 'v': verbose++; @@ -392,6 +412,9 @@ case 't': timeout = simple_strtoul(optarg, NULL, 0); break; + case 'w': + boot_watchdog_timeout = simple_strtoul(optarg, NULL, 0); + break; } } @@ -477,6 +500,7 @@ BAREBOX_CMD_HELP_OPT ("-d","Dryrun. See what happens but do no actually boot") BAREBOX_CMD_HELP_OPT ("-l","List available boot sources") BAREBOX_CMD_HELP_OPT ("-m","Show a menu with boot options") +BAREBOX_CMD_HELP_OPT ("-w SECS","Start watchdog with timeout SECS before booting") BAREBOX_CMD_HELP_OPT ("-t SECS","specify timeout in SECS") BAREBOX_CMD_HELP_END diff --git a/commands/ubiformat.c b/commands/ubiformat.c index e63f16e..f9d952c 100644 --- a/commands/ubiformat.c +++ b/commands/ubiformat.c @@ -779,6 +779,7 @@ BAREBOX_CMD_HELP_OPT("-e VALUE", "use VALUE as erase counter value for all eraseblocks") BAREBOX_CMD_HELP_OPT("-x NUM\t", "UBI version number to put to EC headers (default 1)") BAREBOX_CMD_HELP_OPT("-Q NUM\t", "32-bit UBI image sequence number to use") +BAREBOX_CMD_HELP_OPT("-y\t", "Assume yes for all questions") BAREBOX_CMD_HELP_OPT("-q\t", "suppress progress percentage information") BAREBOX_CMD_HELP_OPT("-v\t", "be verbose") BAREBOX_CMD_HELP_TEXT("") diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 714e83c..4cd03e1 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -539,8 +539,10 @@ #ifdef CONFIG_COMMON_CLK i2c_fsl->clk = clk_get(pdev, NULL); - if (IS_ERR(i2c_fsl->clk)) - return PTR_ERR(i2c_fsl->clk); + if (IS_ERR(i2c_fsl->clk)) { + ret = PTR_ERR(i2c_fsl->clk); + goto fail; + } #endif /* Setup i2c_fsl driver structure */ i2c_fsl->adapter.master_xfer = i2c_fsl_xfer; @@ -548,8 +550,10 @@ i2c_fsl->adapter.dev.parent = pdev; i2c_fsl->adapter.dev.device_node = pdev->device_node; i2c_fsl->base = dev_request_mem_region(pdev, 0); - if (IS_ERR(i2c_fsl->base)) - return PTR_ERR(i2c_fsl->base); + if (IS_ERR(i2c_fsl->base)) { + ret = PTR_ERR(i2c_fsl->base); + goto fail; + } i2c_fsl->dfsrr = -1; diff --git a/drivers/mci/mmci.c b/drivers/mci/mmci.c index 608cac1..9d1e858 100644 --- a/drivers/mci/mmci.c +++ b/drivers/mci/mmci.c @@ -269,18 +269,18 @@ xfercount -= len; dest += len; status = mmci_readl(host, MMCISTATUS); - status_err = status & (MCI_CMDCRCFAIL | MCI_DATATIMEOUT | - MCI_RXOVERRUN); + status_err = status & (MCI_DATACRCFAIL | MCI_DATATIMEOUT | + MCI_RXOVERRUN); } while(xfercount && !status_err); status_err = status & - (MCI_CMDCRCFAIL | MCI_DATATIMEOUT | MCI_DATABLOCKEND | + (MCI_DATACRCFAIL | MCI_DATATIMEOUT | MCI_DATABLOCKEND | MCI_RXOVERRUN); while (!status_err) { status = mmci_readl(host, MMCISTATUS); status_err = status & - (MCI_CMDCRCFAIL | MCI_DATATIMEOUT | MCI_DATABLOCKEND | + (MCI_DATACRCFAIL | MCI_DATATIMEOUT | MCI_DATABLOCKEND | MCI_RXOVERRUN); } @@ -288,7 +288,7 @@ dev_err(host->hw_dev, "Read data timed out, xfercount: %u, status: 0x%08X\n", xfercount, status); return -ETIMEDOUT; - } else if (status & MCI_CMDCRCFAIL) { + } else if (status & MCI_DATACRCFAIL) { dev_err(host->hw_dev, "Read data bytes CRC error: 0x%x\n", status); return -EILSEQ; } else if (status & MCI_RXOVERRUN) { @@ -351,7 +351,7 @@ dev_dbg(host->hw_dev, "write_bytes: blkcount=%u blksize=%u\n", blkcount, blksize); status = mmci_readl(host, MMCISTATUS); - status_err = status & (MCI_CMDCRCFAIL | MCI_DATATIMEOUT); + status_err = status & (MCI_DATACRCFAIL | MCI_DATATIMEOUT); do { len = mmci_pio_write(host, dest, xfercount, status); @@ -359,11 +359,11 @@ dest += len; status = mmci_readl(host, MMCISTATUS); - status_err = status & (MCI_CMDCRCFAIL | MCI_DATATIMEOUT); + status_err = status & (MCI_DATACRCFAIL | MCI_DATATIMEOUT); } while (!status_err && xfercount); status_err = status & - (MCI_CMDCRCFAIL | MCI_DATATIMEOUT | MCI_DATABLOCKEND); + (MCI_DATACRCFAIL | MCI_DATATIMEOUT | MCI_DATABLOCKEND); while (!status_err) { status = mmci_readl(host, MMCISTATUS); status_err = status & @@ -374,7 +374,7 @@ dev_err(host->hw_dev, "Write data timed out, xfercount:%u,status:0x%08X\n", xfercount, status); return -ETIMEDOUT; - } else if (status & MCI_CMDCRCFAIL) { + } else if (status & MCI_DATACRCFAIL) { dev_err(host->hw_dev, "Write data CRC error\n"); return -EILSEQ; } diff --git a/drivers/mtd/nand/nand_mrvl_nfc.c b/drivers/mtd/nand/nand_mrvl_nfc.c index 258ff75..1ec48cc 100644 --- a/drivers/mtd/nand/nand_mrvl_nfc.c +++ b/drivers/mtd/nand/nand_mrvl_nfc.c @@ -881,8 +881,9 @@ * We'll use a bad block table stored in-flash and don't * allow writing the bad block marker to the flash. */ - chip->bbt_options |= NAND_BBT_USE_FLASH | - NAND_BBT_NO_OOB_BBM; + chip->bbt_options |= + NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB_BBM | + NAND_BBT_CREATE_EMPTY; chip->bbt_td = &bbt_main_descr; chip->bbt_md = &bbt_mirror_descr; } diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index c85ed34..9435424 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -523,6 +523,7 @@ { "en25q64", INFO(0x1c3017, 0, 64 * 1024, 128, SECT_4K) }, { "en25qh128", INFO(0x1c7018, 0, 64 * 1024, 256, 0) }, { "en25qh256", INFO(0x1c7019, 0, 64 * 1024, 512, 0) }, + { "en25s64", INFO(0x1c3817, 0, 64 * 1024, 128, 0) }, /* ESMT */ { "f25l32pa", INFO(0x8c2016, 0, 64 * 1024, 64, SECT_4K) }, @@ -537,6 +538,7 @@ /* GigaDevice */ { "gd25q32", INFO(0xc84016, 0, 64 * 1024, 64, SECT_4K) }, { "gd25q64", INFO(0xc84017, 0, 64 * 1024, 128, SECT_4K) }, + { "gd25q128", INFO(0xc84018, 0, 64 * 1024, 256, SECT_4K) }, /* Intel/Numonyx -- xxxs33b */ { "160s33b", INFO(0x898911, 0, 64 * 1024, 32, 0) }, @@ -551,6 +553,7 @@ { "mx25l3205d", INFO(0xc22016, 0, 64 * 1024, 64, 0) }, { "mx25l3255e", INFO(0xc29e16, 0, 64 * 1024, 64, SECT_4K) }, { "mx25l6405d", INFO(0xc22017, 0, 64 * 1024, 128, 0) }, + { "mx25u6435f", INFO(0xc22537, 0, 64 * 1024, 128, SECT_4K) }, { "mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256, 0) }, { "mx25l12855e", INFO(0xc22618, 0, 64 * 1024, 256, 0) }, { "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, 0) }, @@ -559,14 +562,14 @@ { "mx66l1g55g", INFO(0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_QUAD_READ) }, /* Micron */ - { "n25q032", INFO(0x20ba16, 0, 64 * 1024, 64, 0) }, - { "n25q064", INFO(0x20ba17, 0, 64 * 1024, 128, 0) }, - { "n25q128a11", INFO(0x20bb18, 0, 64 * 1024, 256, 0) }, - { "n25q128a13", INFO(0x20ba18, 0, 64 * 1024, 256, 0) }, + { "n25q032", INFO(0x20ba16, 0, 64 * 1024, 64, SPI_NOR_QUAD_READ) }, + { "n25q064", INFO(0x20ba17, 0, 64 * 1024, 128, SPI_NOR_QUAD_READ) }, + { "n25q128a11", INFO(0x20bb18, 0, 64 * 1024, 256, SPI_NOR_QUAD_READ) }, + { "n25q128a13", INFO(0x20ba18, 0, 64 * 1024, 256, SPI_NOR_QUAD_READ) }, { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_QUAD_READ) }, - { "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K) }, - { "n25q512ax3", INFO(0x20ba20, 0, 64 * 1024, 1024, USE_FSR) }, - { "n25q00", INFO(0x20ba21, 0, 64 * 1024, 2048, USE_FSR | SPI_NOR_QUAD_READ) }, + { "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) }, + { "n25q512ax3", INFO(0x20ba20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) }, + { "n25q00", INFO(0x20ba21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) }, /* PMC */ { "pm25lv512", INFO(0, 0, 32 * 1024, 2, SECT_4K_PMC) }, @@ -646,6 +649,7 @@ { "m25px80", INFO(0x207114, 0, 64 * 1024, 16, 0) }, /* Winbond -- w25x "blocks" are 64K, "sectors" are 4KiB */ + { "w25x05", INFO(0xef3010, 0, 64 * 1024, 1, SECT_4K) }, { "w25x10", INFO(0xef3011, 0, 64 * 1024, 2, SECT_4K) }, { "w25x20", INFO(0xef3012, 0, 64 * 1024, 4, SECT_4K) }, { "w25x40", INFO(0xef3013, 0, 64 * 1024, 8, SECT_4K) }, @@ -656,6 +660,7 @@ { "w25q32dw", INFO(0xef6016, 0, 64 * 1024, 64, SECT_4K) }, { "w25x64", INFO(0xef3017, 0, 64 * 1024, 128, SECT_4K) }, { "w25q64", INFO(0xef4017, 0, 64 * 1024, 128, SECT_4K) }, + { "w25q64dw", INFO(0xef6017, 0, 64 * 1024, 128, SECT_4K) }, { "w25q80", INFO(0xef5014, 0, 64 * 1024, 16, SECT_4K) }, { "w25q80bl", INFO(0xef4014, 0, 64 * 1024, 16, SECT_4K) }, { "w25q128", INFO(0xef4018, 0, 64 * 1024, 256, SECT_4K) }, diff --git a/include/watchdog.h b/include/watchdog.h index 7e37b7c..7a98ae4 100644 --- a/include/watchdog.h +++ b/include/watchdog.h @@ -27,12 +27,12 @@ return 0; } -int watchdog_deregister(struct watchdog *w) +static inline int watchdog_deregister(struct watchdog *w) { return 0; } -int watchdog_set_timeout(unsigned t) +static inline int watchdog_set_timeout(unsigned t) { return 0; } diff --git a/lib/libfile.c b/lib/libfile.c index ba03700..a27460c 100644 --- a/lib/libfile.c +++ b/lib/libfile.c @@ -262,7 +262,7 @@ char *rw_buf = NULL; int srcfd = 0, dstfd = 0; int r, w; - int ret = 1; + int ret = 1, err1 = 0; void *buf; int total = 0; struct stat statbuf; @@ -326,9 +326,9 @@ if (srcfd > 0) close(srcfd); if (dstfd > 0) - close(dstfd); + err1 = close(dstfd); - return ret; + return ret ?: err1; } EXPORT_SYMBOL(copy_file);