diff --git a/.gitignore b/.gitignore index f6aff49..7fa2948 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ *.bbenv *.bbenv.* *.bct +*.bin.gen.S *.dcd *.dcd.S *.elf @@ -32,7 +33,6 @@ *.so.dbg *.symtypes *.tab.[ch] -*.bin.gen.S Module.symvers # @@ -52,8 +52,8 @@ # # Generated include files # -include/config -include/generated +/include/config/ +/include/generated/ # Generated files Documentation/commands/*.rst @@ -81,4 +81,9 @@ \#*\# # Kconfig presets -all.config +/all.config +/alldef.config +/allmod.config +/allno.config +/allrandom.config +/allyes.config diff --git a/Documentation/user/barebox.rst b/Documentation/user/barebox.rst index 026ed1b..1927fe4 100644 --- a/Documentation/user/barebox.rst +++ b/Documentation/user/barebox.rst @@ -58,6 +58,7 @@ * nios2 * openrisc * ppc +* riscv * sandbox * x86 diff --git a/Makefile b/Makefile index d15d08a..8265e5f 100644 --- a/Makefile +++ b/Makefile @@ -457,9 +457,7 @@ include $(srctree)/arch/$(ARCH)/Makefile -ifdef CONFIG_DEBUG_INFO -CFLAGS += -g -endif +CFLAGS += -ggdb3 # Force gcc to behave correct even for buggy distributions CFLAGS += $(call cc-option, -fno-stack-protector) @@ -1020,9 +1018,8 @@ distclean: mrproper @find $(srctree) $(RCS_FIND_IGNORE) \ \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ - -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ - -o -name '.*.rej' -o -size 0 \ - -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \ + -o -name '*.bak' -o -name '#*#' -o -name '*%' \ + -o -name 'core' \) \ -type f -print | xargs rm -f diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 0daaff2..4d54f33 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -1,3 +1,4 @@ +KBUILD_DEFCONFIG := qemu_virt64_defconfig CPPFLAGS += -D__ARM__ -fno-strict-aliasing # Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb: diff --git a/arch/blackfin/Makefile b/arch/blackfin/Makefile index 381c6a9..5c43bf7 100644 --- a/arch/blackfin/Makefile +++ b/arch/blackfin/Makefile @@ -1,3 +1,4 @@ +KBUILD_DEFCONFIG := ipe337_defconfig CPPFLAGS += -fno-strict-aliasing diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 5901930..936e56f 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -35,7 +35,7 @@ hex "Relocation table size" range 0x100 0x10000 default "0x8000" - ---help--- + help A table of relocation data will be appended to the Barebox binary and parsed in relocate_code() to fix up all offsets in the relocated Barebox. diff --git a/arch/mips/Makefile b/arch/mips/Makefile index 6f1a1ce..ee465dc 100644 --- a/arch/mips/Makefile +++ b/arch/mips/Makefile @@ -1,3 +1,5 @@ +KBUILD_DEFCONFIG := qemu-malta_defconfig + # # Select the object file format to substitute into the linker script. # diff --git a/arch/mips/include/asm/asm.h b/arch/mips/include/asm/asm.h index a85467c..6993166 100644 --- a/arch/mips/include/asm/asm.h +++ b/arch/mips/include/asm/asm.h @@ -102,8 +102,8 @@ nop; \ \ /* No return */ \ -__error: \ - b __error; \ +1: \ + b 1b; \ nop; /* @@ -116,8 +116,8 @@ /* trigger a soft breakpoint for OpenOCD */ \ SDBBP; \ /* position independent variant of dead loop */ \ - __error: \ - b __error; \ +1: \ + b 1b; \ nop; \ /* Call some code from .text section. \ * It is needed to keep same linker script for \ diff --git a/arch/nios2/Makefile b/arch/nios2/Makefile index 3e97155..0dff0be 100644 --- a/arch/nios2/Makefile +++ b/arch/nios2/Makefile @@ -1,3 +1,5 @@ +KBUILD_DEFCONFIG := generic_defconfig + CPPFLAGS += -fno-strict-aliasing -mno-hw-mul board-$(CONFIG_GENERIC) := generic diff --git a/arch/openrisc/Makefile b/arch/openrisc/Makefile index b0c8566..5394afb 100644 --- a/arch/openrisc/Makefile +++ b/arch/openrisc/Makefile @@ -1,3 +1,5 @@ +KBUILD_DEFCONFIG := generic_defconfig + CPPFLAGS += -D__OR1K__ -ffixed-r10 -mhard-mul -mhard-div board-$(CONFIG_GENERIC) := generic diff --git a/arch/riscv/dts/erizo-generic.dts b/arch/riscv/dts/erizo-generic.dts index d1f8d57..29da01e 100644 --- a/arch/riscv/dts/erizo-generic.dts +++ b/arch/riscv/dts/erizo-generic.dts @@ -7,7 +7,7 @@ model = "generic Erizo SoC board"; compatible = "miet-riscv-workgroup,erizo-generic-board"; - memory@0 { + memory@80000000 { device_type = "memory"; reg = <0x80000000 0x00800000>; }; diff --git a/commands/memcmp.c b/commands/memcmp.c index 48957b4..d1c4f52 100644 --- a/commands/memcmp.c +++ b/commands/memcmp.c @@ -34,54 +34,17 @@ #include #include -static char *devmem = "/dev/mem"; - static int do_memcmp(int argc, char *argv[]) { - loff_t addr1, addr2, count = ~0; - int mode = O_RWSIZE_1; - char *sourcefile = devmem; - char *destfile = devmem; + loff_t count; int sourcefd, destfd; char *buf, *source_data, *dest_data; int ret = 1; int offset = 0; - struct stat statbuf; - if (mem_parse_options(argc, argv, "bwlqs:d:", &mode, &sourcefile, - &destfile, NULL) < 0) + if (memcpy_parse_options(argc, argv, &sourcefd, &destfd, &count) < 0) return 1; - if (optind + 2 > argc) - return COMMAND_ERROR_USAGE; - - addr1 = strtoull_suffix(argv[optind], NULL, 0); - addr2 = strtoull_suffix(argv[optind + 1], NULL, 0); - - if (optind + 2 == argc) { - if (sourcefile == devmem) { - printf("source and count not given\n"); - return 1; - } - if (stat(sourcefile, &statbuf)) { - perror("stat"); - return 1; - } - count = statbuf.st_size - addr1; - } else { - count = strtoull_suffix(argv[optind + 2], NULL, 0); - } - - sourcefd = open_and_lseek(sourcefile, mode | O_RDONLY, addr1); - if (sourcefd < 0) - return 1; - - destfd = open_and_lseek(destfile, mode | O_RDONLY, addr2); - if (destfd < 0) { - close(sourcefd); - return 1; - } - buf = xmalloc(RW_BUF_SIZE + RW_BUF_SIZE); source_data = buf; dest_data = buf + RW_BUF_SIZE; diff --git a/commands/memcpy.c b/commands/memcpy.c index ef25fb7..5f0047f 100644 --- a/commands/memcpy.c +++ b/commands/memcpy.c @@ -34,53 +34,16 @@ #include #include -static char *devmem = "/dev/mem"; - static int do_memcpy(int argc, char *argv[]) { - loff_t count, dest, src; - char *sourcefile = devmem; - char *destfile = devmem; + loff_t count; int sourcefd, destfd; - int mode = 0; - struct stat statbuf; int ret = 0; char *buf; - if (mem_parse_options(argc, argv, "bwlqs:d:", &mode, &sourcefile, - &destfile, NULL) < 0) + if (memcpy_parse_options(argc, argv, &sourcefd, &destfd, &count) < 0) return 1; - if (optind + 2 > argc) - return COMMAND_ERROR_USAGE; - - src = strtoull_suffix(argv[optind], NULL, 0); - dest = strtoull_suffix(argv[optind + 1], NULL, 0); - - if (optind + 2 == argc) { - if (sourcefile == devmem) { - printf("source and count not given\n"); - return 1; - } - if (stat(sourcefile, &statbuf)) { - perror("stat"); - return 1; - } - count = statbuf.st_size - src; - } else { - count = strtoull_suffix(argv[optind + 2], NULL, 0); - } - - sourcefd = open_and_lseek(sourcefile, mode | O_RDONLY, src); - if (sourcefd < 0) - return 1; - - destfd = open_and_lseek(destfile, O_WRONLY | O_CREAT | mode, dest); - if (destfd < 0) { - close(sourcefd); - return 1; - } - buf = xmalloc(RW_BUF_SIZE); while (count > 0) { diff --git a/common/Kconfig b/common/Kconfig index cac1113..f5777a3 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -1020,12 +1020,6 @@ 7 debug-level messages (debug) 8 verbose debug messages (vdebug) -config DEBUG_INFO - bool - prompt "enable debug symbols" - help - Enable build of barebox with -g. - config DEBUG_LL bool depends on HAS_DEBUG_LL diff --git a/common/filetype.c b/common/filetype.c index e2d707b..9675009 100644 --- a/common/filetype.c +++ b/common/filetype.c @@ -37,7 +37,7 @@ }; static const struct filetype_str filetype_str[] = { - [filetype_unknown] = { "unknown", "unkown" }, + [filetype_unknown] = { "unknown", "unknown" }, [filetype_arm_zimage] = { "ARM Linux zImage", "arm-zimage" }, [filetype_lzo_compressed] = { "LZO compressed", "lzo" }, [filetype_lz4_compressed] = { "LZ4 compressed", "lz4" }, diff --git a/common/hush.c b/common/hush.c index dab9b04..68c3ecc 100644 --- a/common/hush.c +++ b/common/hush.c @@ -402,7 +402,12 @@ static int b_adduint(o_string *o, unsigned int i) { int r; - char *p = simple_itoa(i); + /* 21 digits plus null terminator, good for 64-bit or smaller + * ints */ + char number[22]; + char *p = number; + + snprintf(number, sizeof(number), "%u", i); /* no escape checking necessary */ do { diff --git a/common/state/backend_bucket_direct.c b/common/state/backend_bucket_direct.c index 95ddb93..0dbd334 100644 --- a/common/state/backend_bucket_direct.c +++ b/common/state/backend_bucket_direct.c @@ -52,7 +52,7 @@ struct state_backend_storage_bucket_direct *direct = get_bucket_direct(bucket); struct state_backend_storage_bucket_direct_meta meta; - ssize_t read_len; + uint32_t read_len; void *buf; int ret; @@ -67,6 +67,11 @@ } if (meta.magic == direct_magic) { read_len = meta.written_length; + if (read_len > direct->max_size) { + dev_err(direct->dev, "Wrong length in meta data\n"); + return -EINVAL; + + } } else { if (meta.magic != ~0 && !!meta.magic) bucket->wrong_magic = 1; diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index c535904..6a4de7f 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -98,6 +98,23 @@ 40 bits: pca9505, pca9698 +config GPIO_PCF857X + tristate "PCF857x, PCA{85,96}7x, and MAX732[89] I2C GPIO expanders" + depends on I2C + depends on CONFIG_OF + help + Say yes here to provide access to most "quasi-bidirectional" I2C + GPIO expanders used for additional digital outputs or inputs. + Most of these parts are from NXP, though TI is a second source for + some of them. Compatible models include: + + 8 bits: pcf8574, pcf8574a, pca8574, pca8574a, + pca9670, pca9672, pca9674, pca9674a, + max7328, max7329 + + 16 bits: pcf8575, pcf8575c, pca8575, + pca9671, pca9673, pca9675 + config GPIO_PL061 bool "PrimeCell PL061 GPIO support" depends on ARM_AMBA diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 52280f0..990df01 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -14,6 +14,7 @@ obj-$(CONFIG_GPIO_ORION) += gpio-orion.o obj-$(CONFIG_GPIO_OMAP) += gpio-omap.o obj-$(CONFIG_GPIO_PCA953X) += gpio-pca953x.o +obj-$(CONFIG_GPIO_PCF857X) += gpio-pcf857x.o obj-$(CONFIG_GPIO_PL061) += gpio-pl061.o obj-$(CONFIG_GPIO_STMPE) += gpio-stmpe.o obj-$(CONFIG_GPIO_TEGRA) += gpio-tegra.o diff --git a/drivers/gpio/gpio-pcf857x.c b/drivers/gpio/gpio-pcf857x.c new file mode 100644 index 0000000..6c1c0ac --- /dev/null +++ b/drivers/gpio/gpio-pcf857x.c @@ -0,0 +1,256 @@ +/* + * Driver for pcf857x, pca857x, and pca967x I2C GPIO expanders + * + * This code was ported from linux-5.1 kernel by Michael Grzeschik. + * + * Copyright (C) 2007 David Brownell + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include + +static const struct platform_device_id pcf857x_id[] = { + { "pcf8574", 8 }, + { "pcf8574a", 8 }, + { "pca8574", 8 }, + { "pca9670", 8 }, + { "pca9672", 8 }, + { "pca9674", 8 }, + { "pcf8575", 16 }, + { "pca8575", 16 }, + { "pca9671", 16 }, + { "pca9673", 16 }, + { "pca9675", 16 }, + { "max7328", 8 }, + { "max7329", 8 }, + { } +}; + +/* + * The pcf857x, pca857x, and pca967x chips only expose one read and one + * write register. Writing a "one" bit (to match the reset state) lets + * that pin be used as an input; it's not an open-drain model, but acts + * a bit like one. This is described as "quasi-bidirectional"; read the + * chip documentation for details. + * + * Many other I2C GPIO expander chips (like the pca953x models) have + * more complex register models and more conventional circuitry using + * push/pull drivers. They often use the same 0x20..0x27 addresses as + * pcf857x parts, making the "legacy" I2C driver model problematic. + */ +struct pcf857x { + struct gpio_chip chip; + struct i2c_client *client; + unsigned out; /* software latch */ + + int (*write)(struct i2c_client *client, unsigned data); + int (*read)(struct i2c_client *client); +}; + +static inline struct pcf857x *to_pcf(struct gpio_chip *gc) +{ + return container_of(gc, struct pcf857x, chip); +} + +/*-------------------------------------------------------------------------*/ + +/* Talk to 8-bit I/O expander */ + +static int i2c_write_le8(struct i2c_client *client, unsigned data) +{ + return i2c_smbus_write_byte(client, data); +} + +static int i2c_read_le8(struct i2c_client *client) +{ + return (int)i2c_smbus_read_byte(client); +} + +/* Talk to 16-bit I/O expander */ + +static int i2c_write_le16(struct i2c_client *client, unsigned word) +{ + u8 buf[2] = { word & 0xff, word >> 8, }; + int ret; + + ret = i2c_master_send(client, buf, 2); + return (ret < 0) ? ret : 0; +} + +static int i2c_read_le16(struct i2c_client *client) +{ + u8 buf[2]; + int ret; + + ret = i2c_master_recv(client, buf, 2); + if (ret < 0) + return ret; + return (buf[1] << 8) | buf[0]; +} + +/*-------------------------------------------------------------------------*/ + +static int pcf857x_input(struct gpio_chip *chip, unsigned offset) +{ + struct pcf857x *gpio = to_pcf(chip); + int ret; + + gpio->out |= (1 << offset); + ret = gpio->write(gpio->client, gpio->out); + + return ret; +} + +static int pcf857x_get(struct gpio_chip *chip, unsigned offset) +{ + struct pcf857x *gpio = to_pcf(chip); + int value; + + value = gpio->read(gpio->client); + return (value < 0) ? value : !!(value & (1 << offset)); +} + +static int pcf857x_output(struct gpio_chip *chip, unsigned offset, int value) +{ + struct pcf857x *gpio = to_pcf(chip); + unsigned bit = 1 << offset; + int ret; + + if (value) + gpio->out |= bit; + else + gpio->out &= ~bit; + ret = gpio->write(gpio->client, gpio->out); + + return ret; +} + +static void pcf857x_set(struct gpio_chip *chip, unsigned offset, int value) +{ + pcf857x_output(chip, offset, value); +} + +/*-------------------------------------------------------------------------*/ + +static struct gpio_ops pcf857x_gpio_ops = { + .direction_input = pcf857x_input, + .direction_output = pcf857x_output, + .get = pcf857x_get, + .set = pcf857x_set, +}; + +static int pcf857x_probe(struct device_d *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct device_node *np = dev->device_node; + struct pcf857x *gpio; + unsigned long driver_data; + unsigned int n_latch = 0; + int ret; + + if (!np) + return -EINVAL; + + of_property_read_u32(np, "lines-initial-states", &n_latch); + + /* Allocate, initialize, and register this gpio_chip. */ + gpio = xzalloc(sizeof(*gpio)); + + ret = dev_get_drvdata(dev, (const void **)&driver_data); + if (ret) + return ret; + + gpio->chip.base = -1; + gpio->chip.ops = &pcf857x_gpio_ops; + gpio->chip.ngpio = driver_data; + gpio->chip.dev = &client->dev; + + /* NOTE: the OnSemi jlc1562b is also largely compatible with + * these parts, notably for output. It has a low-resolution + * DAC instead of pin change IRQs; and its inputs can be the + * result of comparators. + */ + + /* 8574 addresses are 0x20..0x27; 8574a uses 0x38..0x3f; + * 9670, 9672, 9764, and 9764a use quite a variety. + * + * NOTE: we don't distinguish here between *4 and *4a parts. + */ + switch (gpio->chip.ngpio) { + case 8: + gpio->write = i2c_write_le8; + gpio->read = i2c_read_le8; + break; + /* '75/'75c addresses are 0x20..0x27, just like the '74; + * the '75c doesn't have a current source pulling high. + * 9671, 9673, and 9765 use quite a variety of addresses. + * + * NOTE: we don't distinguish here between '75 and '75c parts. + */ + case 16: + gpio->write = i2c_write_le16; + gpio->read = i2c_read_le16; + break; + default: + dev_warn(&client->dev, "unsupported number of gpios\n"); + return -EINVAL; + } + + gpio->client = client; + + /* NOTE: these chips have strange "quasi-bidirectional" I/O pins. + * We can't actually know whether a pin is configured (a) as output + * and driving the signal low, or (b) as input and reporting a low + * value ... without knowing the last value written since the chip + * came out of reset (if any). We can't read the latched output. + * + * In short, the only reliable solution for setting up pin direction + * is to do it explicitly. + * + * Using n_latch avoids that trouble. When left initialized to zero, + * our software copy of the "latch" then matches the chip's all-ones + * reset state. Otherwise it flags pins to be driven low. + */ + gpio->out = ~n_latch; + + ret = gpiochip_add(&gpio->chip); + if (ret) + return ret; + + return ret; +} + +static const struct of_device_id pcf857x_dt_ids[] = { + { .compatible = "nxp,pcf8574", .data = (void *)8 }, + { .compatible = "nxp,pcf8574a", .data = (void *)8 }, + { .compatible = "nxp,pca8574", .data = (void *)8 }, + { .compatible = "nxp,pca9670", .data = (void *)8 }, + { .compatible = "nxp,pca9672", .data = (void *)8 }, + { .compatible = "nxp,pca9674", .data = (void *)8 }, + { .compatible = "nxp,pcf8575", .data = (void *)16 }, + { .compatible = "nxp,pca8575", .data = (void *)16 }, + { .compatible = "nxp,pca9671", .data = (void *)16 }, + { .compatible = "nxp,pca9673", .data = (void *)16 }, + { .compatible = "nxp,pca9675", .data = (void *)16 }, + { .compatible = "maxim,max7328", .data = (void *)8 }, + { .compatible = "maxim,max7329", .data = (void *)8 }, + { } +}; + +static struct driver_d pcf857x_driver = { + .name = "pcf857x", + .probe = pcf857x_probe, + .of_compatible = DRV_OF_COMPAT(pcf857x_dt_ids), + .id_table = pcf857x_id, +}; +device_i2c_driver(pcf857x_driver); diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig index 25db10a..47296cf 100644 --- a/drivers/mtd/devices/Kconfig +++ b/drivers/mtd/devices/Kconfig @@ -52,7 +52,7 @@ bool "M-Systems Disk-On-Chip G3" select BCH select BITREV - ---help--- + help This provides an MTD device driver for the M-Systems DiskOnChip G3 devices. diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 3e3de5a..beeb4b8 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -108,13 +108,13 @@ bool "ENC28J60 support" depends on SPI select PHYLIB - ---help--- + help Support for the Microchip EN28J60 ethernet chip. config DRIVER_NET_ENC28J60_WRITEVERIFY bool "Enable write verify" depends on DRIVER_NET_ENC28J60 - ---help--- + help Enable the verify after the buffer write useful for debugging purpose. If unsure, say N. diff --git a/drivers/net/macb.c b/drivers/net/macb.c index 0c0d17e..a0411d6 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -209,9 +209,11 @@ dev_dbg(macb->dev, "%s\n", __func__); for (;;) { + barrier(); if (!(macb->rx_ring[rx_tail].addr & MACB_BIT(RX_USED))) return -1; + barrier(); status = macb->rx_ring[rx_tail].ctrl; if (status & MACB_BIT(RX_SOF)) { if (rx_tail != macb->rx_tail) @@ -228,14 +230,26 @@ headlen = macb->rx_buffer_size * (macb->rx_ring_size - macb->rx_tail); taillen = length - headlen; - memcpy((void *)NetRxPackets[0], - buffer, headlen); + dma_sync_single_for_cpu((unsigned long)buffer, + headlen, DMA_FROM_DEVICE); + memcpy((void *)NetRxPackets[0], buffer, headlen); + dma_sync_single_for_cpu((unsigned long)macb->rx_buffer, + taillen, DMA_FROM_DEVICE); memcpy((void *)NetRxPackets[0] + headlen, - macb->rx_buffer, taillen); - buffer = (void *)NetRxPackets[0]; + macb->rx_buffer, taillen); + dma_sync_single_for_device((unsigned long)buffer, + headlen, DMA_FROM_DEVICE); + dma_sync_single_for_device((unsigned long)macb->rx_buffer, + taillen, DMA_FROM_DEVICE); + net_receive(edev, NetRxPackets[0], length); + } else { + dma_sync_single_for_cpu((unsigned long)buffer, length, + DMA_FROM_DEVICE); + net_receive(edev, buffer, length); + dma_sync_single_for_device((unsigned long)buffer, length, + DMA_FROM_DEVICE); } - - net_receive(edev, buffer, length); + barrier(); if (++rx_tail >= macb->rx_ring_size) rx_tail = 0; reclaim_rx_buffers(macb, rx_tail); @@ -245,7 +259,6 @@ rx_tail = 0; } } - barrier(); } return 0; diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index c08b825..2806af3 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -10,52 +10,52 @@ config AR8327N_PHY bool "Driver for QCA AR8327N PHYs" - ---help--- + help Currently supports the AR8327N PHY. config AT803X_PHY bool "Driver for Atheros AT803X PHYs" - ---help--- + help Currently supports the AT8030, AT8031 and AT8035 PHYs. config DAVICOM_PHY bool "Driver for Davicom PHYs" - ---help--- + help Currently supports dm9161e and dm9131 config DP83867_PHY tristate "Texas Instruments DP83867 Gigabit PHY" - ---help--- + help Currently supports the DP83867 PHY. config LXT_PHY bool "Driver for the Intel LXT PHYs" - ---help--- + help Currently supports the lxt971 PHY. config MARVELL_PHY tristate "Drivers for Marvell PHYs" - ---help--- + help Add support for various Marvell PHYs (e.g. 88E1121R). config MICREL_PHY bool "Driver for Micrel PHYs" - ---help--- + help Supports the KSZ9021, VSC8201, KS8001 PHYs. config NATIONAL_PHY bool "Driver for National Semiconductor PHYs" - ---help--- + help Currently supports the DP83865 PHY. config REALTEK_PHY bool "Driver for Realtek PHYs" - ---help--- + help Supports the Realtek 821x PHY. config SMSC_PHY bool "Drivers for SMSC PHYs" - ---help--- + help Currently supports the LAN83C185, LAN8187 and LAN8700 PHYs config NET_DSA_MV88E6XXX @@ -69,12 +69,12 @@ config MDIO_MVEBU bool "Driver for MVEBU SoC MDIO bus" depends on ARCH_MVEBU - ---help--- + help Driver for the MDIO bus found on Marvell EBU SoCs. config MDIO_BITBANG bool "Support for bitbanged MDIO buses" - ---help--- + help This module implements the MDIO bus protocol in software, for use by low level drivers that export the ability to drive the relevant pins. @@ -84,7 +84,7 @@ config MDIO_GPIO bool "Support for GPIO lib-based bitbanged MDIO buses" depends on MDIO_BITBANG && GPIOLIB - ---help--- + help Supports GPIO lib-based MDIO busses. config MDIO_BUS_MUX diff --git a/drivers/nvme/host/Kconfig b/drivers/nvme/host/Kconfig index 8888c89..5499f97 100644 --- a/drivers/nvme/host/Kconfig +++ b/drivers/nvme/host/Kconfig @@ -5,7 +5,7 @@ bool "NVM Express block device" depends on PCI && BLOCK select NVME_CORE - ---help--- + help The NVM Express driver is for solid state drives directly connected to the PCI or PCI Express bus. If you know you don't have one of these, it is safe to answer N. diff --git a/drivers/of/partition.c b/drivers/of/partition.c index 2848b96..655b67f 100644 --- a/drivers/of/partition.c +++ b/drivers/of/partition.c @@ -64,9 +64,9 @@ offset = of_read_number(reg, na); size = of_read_number(reg + na, ns); - partname = of_get_property(node, "label", &len); + partname = of_get_property(node, "label", NULL); if (!partname) - partname = of_get_property(node, "name", &len); + partname = of_get_property(node, "name", NULL); if (!partname) return NULL; @@ -74,7 +74,7 @@ debug("add partition: %s.%s 0x%08llx 0x%08llx\n", cdev->name, partname, offset, size); - if (of_get_property(node, "read-only", &len)) + if (of_get_property(node, "read-only", NULL)) flags = DEVFS_PARTITION_READONLY; filename = basprintf("%s.%s", cdev->name, partname); diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index 48ccee2..5186508 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c @@ -115,6 +115,7 @@ cbw.Length = cmdlen; /* copy the command payload */ + memset(cbw.CDB, 0, sizeof(cbw.CDB)); memcpy(cbw.CDB, cmd, cbw.Length); /* send it to out endpoint */ diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index fda24d6..63d624e 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -142,7 +142,7 @@ static int usb_stor_test_unit_ready(struct us_blk_dev *usb_blkdev) { - u8 cmd[12]; + u8 cmd[6]; int ret; memset(cmd, 0, sizeof(cmd)); @@ -439,7 +439,7 @@ int num_devs = 0; /* obtain the max LUN */ - us->max_lun = 1; + us->max_lun = 0; if (us->protocol == US_PR_BULK) us->max_lun = usb_stor_Bulk_max_lun(us); diff --git a/drivers/w1/Kconfig b/drivers/w1/Kconfig index 4a16197..6299f6e 100644 --- a/drivers/w1/Kconfig +++ b/drivers/w1/Kconfig @@ -1,6 +1,6 @@ menuconfig W1 bool "Dallas's 1-wire support" - ---help--- + help Dallas' 1-wire bus is useful to connect slow 1-pin devices such as iButtons and thermal sensors. @@ -13,7 +13,7 @@ config W1_DUAL_SEARCH bool "dual search" - ---help--- + help Some device need to be searched twice to be detected endif # W1 diff --git a/firmware/.gitignore b/firmware/.gitignore new file mode 100644 index 0000000..a8a0dce --- /dev/null +++ b/firmware/.gitignore @@ -0,0 +1 @@ +*.bin diff --git a/images/.gitignore b/images/.gitignore index fcde7f3..2de9822 100644 --- a/images/.gitignore +++ b/images/.gitignore @@ -19,6 +19,7 @@ *.mlospi *.mxsbs *.mxssd +*.csfbin pbl.lds barebox.x barebox.z diff --git a/include/common.h b/include/common.h index 723b9c7..b129497 100644 --- a/include/common.h +++ b/include/common.h @@ -116,6 +116,8 @@ int mem_parse_options(int argc, char *argv[], char *optstr, int *mode, char **sourcefile, char **destfile, int *swab); +int memcpy_parse_options(int argc, char *argv[], int *sourcefd, + int *destfd, loff_t *count); #define RW_BUF_SIZE (unsigned)4096 extern const char version_string[]; diff --git a/include/driver.h b/include/driver.h index 3479e18..26ec413 100644 --- a/include/driver.h +++ b/include/driver.h @@ -489,8 +489,8 @@ #define DEVFS_PARTITION_FIXED (1U << 0) #define DEVFS_PARTITION_READONLY (1U << 1) -#define DEVFS_IS_CHARACTER_DEV (1 << 3) -#define DEVFS_PARTITION_FROM_TABLE (1 << 4) +#define DEVFS_IS_CHARACTER_DEV (1U << 3) +#define DEVFS_PARTITION_FROM_TABLE (1U << 4) struct cdev *devfs_add_partition(const char *devname, loff_t offset, loff_t size, unsigned int flags, const char *name); diff --git a/include/libbb.h b/include/libbb.h index 1f6afaa..d05c190 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -29,6 +29,4 @@ int process_escape_sequence(const char *source, char *dest, int destlen); -char *simple_itoa(unsigned int i); - #endif /* __LIBBB_H */ diff --git a/lib/libbb.c b/lib/libbb.c index 239611c..d0c9bf4 100644 --- a/lib/libbb.c +++ b/lib/libbb.c @@ -112,17 +112,3 @@ return strncpy(dst, src, size); } EXPORT_SYMBOL(safe_strncpy); - -char *simple_itoa(unsigned int i) -{ - /* 21 digits plus null terminator, good for 64-bit or smaller ints */ - static char local[22]; - char *p = &local[21]; - *p-- = '\0'; - do { - *p-- = '0' + i % 10; - i /= 10; - } while (i > 0); - return p + 1; -} -EXPORT_SYMBOL(simple_itoa); diff --git a/lib/libfile.c b/lib/libfile.c index eb12d15..b42753c 100644 --- a/lib/libfile.c +++ b/lib/libfile.c @@ -36,7 +36,11 @@ while (size) { now = pwrite(fd, buf, size, offset); - if (now <= 0) + if (now == 0) { + errno = ENOSPC; + return -1; + } + if (now < 0) return now; size -= now; buf += now; @@ -60,7 +64,11 @@ while (size) { now = write(fd, buf, size); - if (now <= 0) + if (now == 0) { + errno = ENOSPC; + return -1; + } + if (now < 0) return now; size -= now; buf += now; @@ -80,20 +88,18 @@ { size_t insize = size; int now; - int total = 0; while (size) { now = read(fd, buf, size); if (now == 0) - return total; + break; if (now < 0) return now; - total += now; size -= now; buf += now; } - return insize; + return insize - size; } EXPORT_SYMBOL(read_full); diff --git a/lib/misc.c b/lib/misc.c index cd420a5..18153bb 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -24,6 +24,7 @@ #include #include #include +#include /* * Like simple_strtoull() but handles an optional G, M, K or k @@ -171,3 +172,51 @@ return 0; } +int memcpy_parse_options(int argc, char *argv[], int *sourcefd, + int *destfd, loff_t *count) +{ + loff_t dest, src; + int mode = 0; + char *sourcefile = NULL; + char *destfile = NULL; + struct stat statbuf; + + if (mem_parse_options(argc, argv, "bwlqs:d:", &mode, &sourcefile, + &destfile, NULL) < 0) + return -EINVAL; + + if (optind + 2 > argc) + return -EINVAL; + + src = strtoull_suffix(argv[optind], NULL, 0); + dest = strtoull_suffix(argv[optind + 1], NULL, 0); + + if (optind + 2 == argc) { + if (!sourcefile) { + printf("source and count not given\n"); + return -EINVAL; + } + if (stat(sourcefile, &statbuf)) { + perror("stat"); + return -1; + } + *count = statbuf.st_size - src; + } else { + *count = strtoull_suffix(argv[optind + 2], NULL, 0); + } + + sourcefile = sourcefile ?: "/dev/mem"; + destfile = destfile ?: "/dev/mem"; + + *sourcefd = open_and_lseek(sourcefile, mode | O_RDONLY, src); + if (*sourcefd < 0) + return -1; + + *destfd = open_and_lseek(destfile, O_WRONLY | O_CREAT | mode, dest); + if (*destfd < 0) { + close(*sourcefd); + return -1; + } + + return 0; +} diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 5fa7f16..5e7255d 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -129,11 +129,6 @@ # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) cc-ifversion = $(shell [ $(call cc-version, $(CC)) $(1) $(2) ] && echo $(3)) -# cc-ldoption -# Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both) -cc-ldoption = $(call try-run,\ - $(CC) $(1) -nostdlib -xc /dev/null -o "$$TMP",$(1),$(2)) - # ld-option # Usage: LDFLAGS += $(call ld-option, -X) ld-option = $(call try-run,\ diff --git a/scripts/kwboot.c b/scripts/kwboot.c index df52144..43b8b8c 100644 --- a/scripts/kwboot.c +++ b/scripts/kwboot.c @@ -378,10 +378,10 @@ * there is another problem. */ int rc; - char buf[sizeof(struct kwboot_block)]; + uint8_t buf[sizeof(struct kwboot_block)]; unsigned interval = 1; unsigned len; - char *p = buf; + uint8_t *p = buf; memset(buf, 0xff, sizeof(buf)); @@ -407,7 +407,7 @@ kwboot_xm_sendblock(int fd, struct kwboot_block *block) { int rc, retries; - char c; + uint8_t c; retries = 16; do {