From 56ee5d3aac2d73dbe1e699000cb83eea18278e68 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Tue, 17 Sep 2013 09:50:04 +0200 Subject: [PATCH 01/14] process_escape_sequence: add support to \$? Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Signed-off-by: Sascha Hauer --- common/hush.c | 6 ++++++ common/parser.c | 9 +++++++++ include/shell.h | 12 ++++++++++++ lib/process_escape_sequence.c | 7 +++++++ 4 files changed, 34 insertions(+) create mode 100644 include/shell.h diff --git a/common/hush.c b/common/hush.c index a3235ba19..bf1d9e6fd 100644 --- a/common/hush.c +++ b/common/hush.c @@ -123,6 +123,7 @@ #include #include #include +#include /*cmd_boot.c*/ extern int do_bootd(int flag, int argc, char *argv[]); /* do_bootd */ @@ -226,6 +227,11 @@ static char console_buffer[CONFIG_CBSIZE]; /* console I/O buffer */ * the first three support $?, $#, and $1 */ static unsigned int last_return_code; +int shell_get_last_return_code(void) +{ + return last_return_code; +} + /* "globals" within this file */ static uchar *ifs; static char map[256]; diff --git a/common/parser.c b/common/parser.c index 4d993dfd3..d390fb6af 100644 --- a/common/parser.c +++ b/common/parser.c @@ -1,6 +1,15 @@ #include #include #include +#include + +/* + * not yet supported + */ +int shell_get_last_return_code(void) +{ + return 0; +} static int parse_line (char *line, char *argv[]) { diff --git a/include/shell.h b/include/shell.h new file mode 100644 index 000000000..b98cac3dc --- /dev/null +++ b/include/shell.h @@ -0,0 +1,12 @@ +/* + * (C) Copyright 2013 Jean-Christophe PLAGNIOL-VILLARD + * + * Under GPLv2 only + */ + +#ifndef __SHELL_H__ +#define __SHELL_H__ + +int shell_get_last_return_code(void); + +#endif /* __SHELL_H__ */ diff --git a/lib/process_escape_sequence.c b/lib/process_escape_sequence.c index be7779278..47a7e5cd9 100644 --- a/lib/process_escape_sequence.c +++ b/lib/process_escape_sequence.c @@ -19,6 +19,7 @@ #include #include #include +#include int process_escape_sequence(const char *source, char *dest, int destlen) { @@ -59,6 +60,12 @@ int process_escape_sequence(const char *source, char *dest, int destlen) case 'w': i += snprintf(dest + i, destlen - i, "%s", getcwd()); break; + case '$': + if (*(source + 2) == '?') { + i += snprintf(dest + i, destlen - i, "%d", shell_get_last_return_code()); + source++; + break; + } default: dest[i++] = '\\'; dest[i++] = *(source + 1); From 2830faf5e5080aa1177cf42246db3b20825ff697 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Tue, 17 Sep 2013 07:12:08 +0200 Subject: [PATCH 02/14] command: ubiattach: add option to pass VID offset use the same option as linux -O as example due to a bug in already deployed kernel we must for the VID offset at 512 even it should be at 256 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Signed-off-by: Sascha Hauer --- commands/ubi.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/commands/ubi.c b/commands/ubi.c index 2041df3fd..57ae79025 100644 --- a/commands/ubi.c +++ b/commands/ubi.c @@ -58,13 +58,25 @@ BAREBOX_CMD_END static int do_ubiattach(int argc, char *argv[]) { + int opt; struct mtd_info_user user; int fd, ret; + int vid_hdr_offset = 0; - if (argc != 2) + while((opt = getopt(argc, argv, "O:")) > 0) { + switch(opt) { + case 'O': + vid_hdr_offset = simple_strtoul(optarg, NULL, 0); + break; + default: + return COMMAND_ERROR_USAGE; + } + } + + if (optind == argc) return COMMAND_ERROR_USAGE; - fd = open(argv[1], O_RDWR); + fd = open(argv[optind], O_RDWR); if (fd < 0) { perror("open"); return 1; @@ -76,7 +88,7 @@ static int do_ubiattach(int argc, char *argv[]) goto err; } - ret = ubi_attach_mtd_dev(user.mtd, UBI_DEV_NUM_AUTO, 0, 20); + ret = ubi_attach_mtd_dev(user.mtd, UBI_DEV_NUM_AUTO, vid_hdr_offset, 20); if (ret < 0) printf("failed to attach: %s\n", strerror(-ret)); else @@ -88,7 +100,7 @@ err: } static const __maybe_unused char cmd_ubiattach_help[] = -"Usage: ubiattach \n" +"Usage: ubiattach [-O vid-hdr-offset] \n" "Attach to ubi\n"; BAREBOX_CMD_START(ubiattach) From 48eb76b5546deca026c8abf687c1af576b4c00fd Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Sat, 14 Sep 2013 14:27:18 +0200 Subject: [PATCH 03/14] add fix size tools this will allow to write the size of barebox at an offset of the binary this is needed for ARM when using relocated binary Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Signed-off-by: Sascha Hauer --- scripts/Makefile | 1 + scripts/fix_size.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 scripts/fix_size.c diff --git a/scripts/Makefile b/scripts/Makefile index 307dc3d1a..61f31dbfb 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -7,6 +7,7 @@ hostprogs-$(CONFIG_KALLSYMS) += kallsyms hostprogs-y += bin2c hostprogs-y += mkimage +hostprogs-y += fix_size hostprogs-y += bareboxenv hostprogs-$(CONFIG_ARCH_MVEBU) += kwbimage kwboot hostprogs-$(CONFIG_ARCH_NETX) += gen_netx_image diff --git a/scripts/fix_size.c b/scripts/fix_size.c new file mode 100644 index 000000000..869ae7e32 --- /dev/null +++ b/scripts/fix_size.c @@ -0,0 +1,81 @@ +#include +#include +#include +#include +#include +#include +#include +#ifndef _BSD_SOURCE +#define _BSD_SOURCE /* See feature_test_macros(7) */ +#endif +#include + +int main(int argc, char**argv) +{ + struct stat s; + int c; + int fd; + uint64_t offset = 0; + uint32_t size = 0; + char *file = NULL; + int ret = 1; + int is_bigendian = 0; + + while ((c = getopt (argc, argv, "hf:o:b")) != -1) { + switch (c) { + case 'f': + file = optarg; + break; + case 'o': + offset = strtoul(optarg, NULL, 16); + break; + case 'b': + is_bigendian = 1; + break; + } + } + + if (!file) { + fprintf(stderr, "missing file\n"); + return 1; + } + + if (stat(file, &s)) { + perror("stat"); + return 1; + } + + fd = open(file, O_WRONLY); + if (fd < 0) { + perror("open"); + return 1; + } + + ret = lseek(fd, offset, SEEK_SET); + if (ret < 0) { + perror("lseek"); + ret = 1; + goto err; + } + + size = s.st_size; + + if (is_bigendian) + size = htobe32(size); + else + size = htole32(size); + + ret = write(fd, &size, 4); + if (ret != 4) { + perror("write"); + ret = 1; + goto err; + } + + ret = 0; +err: + + close(fd); + + return ret; +} From d36178223b5f32821555dafbd8e065d326209cdc Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Sat, 14 Sep 2013 14:27:19 +0200 Subject: [PATCH 04/14] ARM: PBL: fix binary size Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Signed-off-by: Sascha Hauer --- arch/arm/pbl/Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm/pbl/Makefile b/arch/arm/pbl/Makefile index dd3e94680..bfa73b91a 100644 --- a/arch/arm/pbl/Makefile +++ b/arch/arm/pbl/Makefile @@ -13,9 +13,17 @@ targets := zbarebox.lds zbarebox zbarebox.bin zbarebox.S \ # Make sure files are removed during clean extra-y += piggy.gzip piggy.lz4 piggy.lzo piggy.lzma piggy.xzkern piggy.shipped zbarebox.map +ifeq ($(CONFIG_CPU_BIG_ENDIAN),y) +FIX_SIZE=-b +else +FIX_SIZE= +endif + $(obj)/zbarebox.bin: $(obj)/zbarebox FORCE $(call if_changed,objcopy) $(call cmd,check_file_size,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE)) + $(Q)$(kecho) ' Barebox: fix size' + $(Q)$(objtree)/scripts/fix_size -f $(objtree)/$@ -o 0x2c $(FIX_SIZE) $(Q)$(kecho) ' Barebox: $@ is ready' $(obj)/zbarebox.S: $(obj)/zbarebox FORCE From 78182d5d4f8532ab1018c99a7271005d9bb1bad2 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Thu, 19 Sep 2013 14:47:24 +0200 Subject: [PATCH 05/14] command: crc: add -V option to check the crc store in a file the format is %08x Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Signed-off-by: Sascha Hauer --- commands/crc.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/commands/crc.c b/commands/crc.c index a0071b0e8..ee8dacff0 100644 --- a/commands/crc.c +++ b/commands/crc.c @@ -82,6 +82,19 @@ out: return ret; } +static int crc_from_file(const char* file, ulong *crc) +{ + char * buf; + + buf= read_file(file, NULL); + + if (!buf) + return -ENOMEM; + + *crc = simple_strtoul(buf, NULL, 16); + return 0; +} + static int do_crc(int argc, char *argv[]) { loff_t start = 0, size = ~0; @@ -92,7 +105,7 @@ static int do_crc(int argc, char *argv[]) #endif int opt, err = 0, filegiven = 0, verify = 0; - while((opt = getopt(argc, argv, "f:F:v:")) > 0) { + while((opt = getopt(argc, argv, "f:F:v:V:")) > 0) { switch(opt) { case 'f': filename = optarg; @@ -108,6 +121,10 @@ static int do_crc(int argc, char *argv[]) verify = 1; vcrc = simple_strtoul(optarg, NULL, 0); break; + case 'V': + if (!crc_from_file(optarg, &vcrc)) + verify = 1; + break; default: return COMMAND_ERROR_USAGE; } @@ -153,6 +170,7 @@ BAREBOX_CMD_HELP_OPT ("-f ", "Use file instead of memory.\n") BAREBOX_CMD_HELP_OPT ("-F ", "Use file to compare.\n") #endif BAREBOX_CMD_HELP_OPT ("-v ", "Verify\n") +BAREBOX_CMD_HELP_OPT ("-V ", "Verify with crc read from \n") BAREBOX_CMD_HELP_END BAREBOX_CMD_START(crc32) From eacd5e7cc3af3eb044f997d6bd3aa69c0ae7c772 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Sun, 22 Sep 2013 14:41:24 +0200 Subject: [PATCH 06/14] usb: make usb devices children of the corresponding host To be able to find usb devices in the hardware tree. Signed-off-by: Sascha Hauer --- drivers/usb/core/usb.c | 2 ++ drivers/usb/host/ehci-hcd.c | 1 + drivers/usb/host/ohci-hcd.c | 1 + include/usb/usb.h | 1 + 4 files changed, 5 insertions(+) diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 36fc736fd..a7dbe2afa 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -440,6 +440,8 @@ static int usb_new_device(struct usb_device *dev) dev->dev.id = DEVICE_ID_SINGLE; + if (dev->host->hw_dev) + dev->dev.parent = dev->host->hw_dev; register_device(&dev->dev); /* now prode if the device is a hub */ diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index f44f83635..cb6a59246 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -883,6 +883,7 @@ int ehci_register(struct device_d *dev, struct ehci_data *data) ehci->qh_list = dma_alloc_coherent(sizeof(struct QH) * NUM_TD); ehci->td = dma_alloc_coherent(sizeof(struct qTD) * NUM_TD); + host->hw_dev = dev; host->init = ehci_init; host->submit_int_msg = submit_int_msg; host->submit_control_msg = submit_control_msg; diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index ad39bcf6a..8bf20d0d6 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -1794,6 +1794,7 @@ static int ohci_probe(struct device_d *dev) ohci = xzalloc(sizeof(struct ohci)); host = &ohci->host; + host->hw_dev = dev; host->init = ohci_init; host->submit_int_msg = submit_int_msg; host->submit_control_msg = submit_control_msg; diff --git a/include/usb/usb.h b/include/usb/usb.h index 95fb6f3a3..821724e54 100644 --- a/include/usb/usb.h +++ b/include/usb/usb.h @@ -210,6 +210,7 @@ struct usb_host { struct list_head list; + struct device_d *hw_dev; int busnum; int scanned; }; From 4a22305307c8f57dd1155cb6ffdcc6c40f8043f2 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 25 Sep 2013 18:51:28 +0200 Subject: [PATCH 07/14] move devinfo command to its own file Just like nearly all other commands are in individual files. Signed-off-by: Sascha Hauer --- commands/Makefile | 1 + commands/devinfo.c | 158 ++++++++++++++++++++++++++++++++++++++++++ drivers/base/driver.c | 142 ------------------------------------- 3 files changed, 159 insertions(+), 142 deletions(-) create mode 100644 commands/devinfo.c diff --git a/commands/Makefile b/commands/Makefile index 6acffc828..e02711231 100644 --- a/commands/Makefile +++ b/commands/Makefile @@ -91,3 +91,4 @@ obj-$(CONFIG_CMD_FILETYPE) += filetype.o obj-$(CONFIG_CMD_BAREBOX_UPDATE)+= barebox-update.o obj-$(CONFIG_CMD_MIITOOL) += miitool.o obj-$(CONFIG_CMD_DETECT) += detect.o +obj-$(CONFIG_CMD_DEVINFO) += devinfo.o diff --git a/commands/devinfo.c b/commands/devinfo.c new file mode 100644 index 000000000..806e45c9b --- /dev/null +++ b/commands/devinfo.c @@ -0,0 +1,158 @@ +/* + * Copyright (C) 2013 Sascha Hauer, Pengutronix + * + * 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. + * + */ + +#include +#include +#include +#include + +static int do_devinfo_subtree(struct device_d *dev, int depth) +{ + struct device_d *child; + struct cdev *cdev; + int i; + + for (i = 0; i < depth; i++) + printf(" "); + + printf("`---- %s", dev_name(dev)); + if (!list_empty(&dev->cdevs)) { + printf("\n"); + list_for_each_entry(cdev, &dev->cdevs, devices_list) { + for (i = 0; i < depth + 1; i++) + printf(" "); + printf("`---- 0x%08llx-0x%08llx: /dev/%s\n", + cdev->offset, + cdev->offset + cdev->size - 1, + cdev->name); + } + } else { + printf("\n"); + } + + if (!list_empty(&dev->children)) { + device_for_each_child(dev, child) { + do_devinfo_subtree(child, depth + 1); + } + } + + return 0; +} + +static int do_devinfo(int argc, char *argv[]) +{ + struct device_d *dev; + struct driver_d *drv; + struct param_d *param; + int i; + struct resource *res; + + if (argc == 1) { + printf("devices:\n"); + + for_each_device(dev) { + if (!dev->parent) + do_devinfo_subtree(dev, 0); + } + + printf("\ndrivers:\n"); + for_each_driver(drv) + printf("%s\n",drv->name); + } else { + dev = get_device_by_name(argv[1]); + + if (!dev) { + printf("no such device: %s\n",argv[1]); + return -1; + } + + printf("resources:\n"); + for (i = 0; i < dev->num_resources; i++) { + res = &dev->resource[i]; + printf("num : %d\n", i); + if (res->name) + printf("name : %s\n", res->name); + printf("start : " PRINTF_CONVERSION_RESOURCE "\nsize : " + PRINTF_CONVERSION_RESOURCE "\n", + res->start, resource_size(res)); + } + + printf("driver: %s\n", dev->driver ? + dev->driver->name : "none"); + + printf("bus: %s\n\n", dev->bus ? + dev->bus->name : "none"); + + if (dev->info) + dev->info(dev); + + printf("%s\n", list_empty(&dev->parameters) ? + "no parameters available" : "Parameters:"); + + list_for_each_entry(param, &dev->parameters, list) { + printf("%16s = %s", param->name, dev_get_param(dev, param->name)); + if (param->info) + param->info(param); + printf("\n"); + } +#ifdef CONFIG_OFDEVICE + if (dev->device_node) { + printf("\ndevice node: %s\n", dev->device_node->full_name); + of_print_nodes(dev->device_node, 0); + } +#endif + } + + return 0; +} + +BAREBOX_CMD_HELP_START(devinfo) +BAREBOX_CMD_HELP_USAGE("devinfo [DEVICE]\n") +BAREBOX_CMD_HELP_SHORT("Output device information.\n") +BAREBOX_CMD_HELP_END + +/** + * @page devinfo_command + +If called without arguments, devinfo shows a summary of the known +devices and drivers. + +If called with a device path being the argument, devinfo shows more +default information about this device and its parameters. + +Example from an MPC5200 based system: + +@verbatim + barebox:/ devinfo /dev/eth0 + base : 0x1002b000 + size : 0x00000000 + driver: fec_mpc5xxx + + no info available for eth0 + Parameters: + ipaddr = 192.168.23.197 + ethaddr = 80:81:82:83:84:86 + gateway = 192.168.23.1 + netmask = 255.255.255.0 + serverip = 192.168.23.2 +@endverbatim + */ + +BAREBOX_CMD_START(devinfo) + .cmd = do_devinfo, + .usage = "Show information about devices and drivers.", + BAREBOX_CMD_HELP(cmd_devinfo_help) + BAREBOX_CMD_COMPLETE(device_complete) +BAREBOX_CMD_END diff --git a/drivers/base/driver.c b/drivers/base/driver.c index 16b7f06c4..8b70e9f57 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -413,145 +413,3 @@ int dev_get_drvdata(struct device_d *dev, unsigned long *data) return -ENODEV; } - -#ifdef CONFIG_CMD_DEVINFO -static int do_devinfo_subtree(struct device_d *dev, int depth) -{ - struct device_d *child; - struct cdev *cdev; - int i; - - for (i = 0; i < depth; i++) - printf(" "); - - printf("`---- %s", dev_name(dev)); - if (!list_empty(&dev->cdevs)) { - printf("\n"); - list_for_each_entry(cdev, &dev->cdevs, devices_list) { - for (i = 0; i < depth + 1; i++) - printf(" "); - printf("`---- 0x%08llx-0x%08llx: /dev/%s\n", - cdev->offset, - cdev->offset + cdev->size - 1, - cdev->name); - } - } else { - printf("\n"); - } - - if (!list_empty(&dev->children)) { - device_for_each_child(dev, child) { - do_devinfo_subtree(child, depth + 1); - } - } - - return 0; -} - -static int do_devinfo(int argc, char *argv[]) -{ - struct device_d *dev; - struct driver_d *drv; - struct param_d *param; - int i; - struct resource *res; - - if (argc == 1) { - printf("devices:\n"); - - for_each_device(dev) { - if (!dev->parent) - do_devinfo_subtree(dev, 0); - } - - printf("\ndrivers:\n"); - for_each_driver(drv) - printf("%s\n",drv->name); - } else { - dev = get_device_by_name(argv[1]); - - if (!dev) { - printf("no such device: %s\n",argv[1]); - return -1; - } - - printf("resources:\n"); - for (i = 0; i < dev->num_resources; i++) { - res = &dev->resource[i]; - printf("num : %d\n", i); - if (res->name) - printf("name : %s\n", res->name); - printf("start : " PRINTF_CONVERSION_RESOURCE "\nsize : " - PRINTF_CONVERSION_RESOURCE "\n", - res->start, resource_size(res)); - } - - printf("driver: %s\n", dev->driver ? - dev->driver->name : "none"); - - printf("bus: %s\n\n", dev->bus ? - dev->bus->name : "none"); - - if (dev->info) - dev->info(dev); - - printf("%s\n", list_empty(&dev->parameters) ? - "no parameters available" : "Parameters:"); - - list_for_each_entry(param, &dev->parameters, list) { - printf("%16s = %s", param->name, dev_get_param(dev, param->name)); - if (param->info) - param->info(param); - printf("\n"); - } -#ifdef CONFIG_OFDEVICE - if (dev->device_node) { - printf("\ndevice node: %s\n", dev->device_node->full_name); - of_print_nodes(dev->device_node, 0); - } -#endif - } - - return 0; -} - -BAREBOX_CMD_HELP_START(devinfo) -BAREBOX_CMD_HELP_USAGE("devinfo [DEVICE]\n") -BAREBOX_CMD_HELP_SHORT("Output device information.\n") -BAREBOX_CMD_HELP_END - -/** - * @page devinfo_command - -If called without arguments, devinfo shows a summary of the known -devices and drivers. - -If called with a device path being the argument, devinfo shows more -default information about this device and its parameters. - -Example from an MPC5200 based system: - -@verbatim - barebox:/ devinfo /dev/eth0 - base : 0x1002b000 - size : 0x00000000 - driver: fec_mpc5xxx - - no info available for eth0 - Parameters: - ipaddr = 192.168.23.197 - ethaddr = 80:81:82:83:84:86 - gateway = 192.168.23.1 - netmask = 255.255.255.0 - serverip = 192.168.23.2 -@endverbatim - */ - -BAREBOX_CMD_START(devinfo) - .cmd = do_devinfo, - .usage = "Show information about devices and drivers.", - BAREBOX_CMD_HELP(cmd_devinfo_help) - BAREBOX_CMD_COMPLETE(device_complete) -BAREBOX_CMD_END -#endif - From 61d6a8485db04bdf6eeed187e9790c9a7f38e848 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 24 Sep 2013 22:46:34 +0200 Subject: [PATCH 08/14] usb: Turn some printf into pr_* So that these messages can be suppressed if necessary. Signed-off-by: Sascha Hauer --- drivers/usb/core/usb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index a7dbe2afa..68a51d1e1 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -74,7 +74,7 @@ static LIST_HEAD(usb_device_list); static void print_usb_device(struct usb_device *dev) { - printf("Bus %03d Device %03d: ID %04x:%04x %s\n", + pr_info("Bus %03d Device %03d: ID %04x:%04x %s\n", dev->host->busnum, dev->devnum, dev->descriptor->idVendor, dev->descriptor->idProduct, @@ -529,7 +529,7 @@ void usb_rescan(int force) struct usb_host *host; int ret; - printf("USB: scanning bus for devices...\n"); + pr_info("USB: scanning bus for devices...\n"); dev_index = 0; list_for_each_entry(host, &host_list, list) { @@ -538,7 +538,7 @@ void usb_rescan(int force) continue; } - printf("%d USB Device(s) found\n", dev_index); + pr_info("%d USB Device(s) found\n", dev_index); } /* From 49730778729ec9b237a9b87d77ea688de09966b5 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 25 Sep 2013 17:15:23 +0200 Subject: [PATCH 09/14] globalvar: Do not modify already existing variables When globalvar_add_simple was called on previously existing variables then the value was overwritten, even when value was passed as NULL. Do not overwrite the value in this case which allows us to do a 'global' on the same variable multiple times without loosing the values. Signed-off-by: Sascha Hauer --- common/globalvar.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/globalvar.c b/common/globalvar.c index edb66ddca..abd1270f7 100644 --- a/common/globalvar.c +++ b/common/globalvar.c @@ -72,6 +72,9 @@ int globalvar_add_simple(const char *name, const char *value) if (ret && ret != -EEXIST) return ret; + if (!value) + return 0; + return dev_set_param(&global_device, name, value); } From 371c36da4850c410f94a2911fb2e72a227a750f6 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 26 Sep 2013 07:38:00 +0200 Subject: [PATCH 10/14] scripts/Makefile: cleanup Sort so that we have the object files on top, sorted by hostprogs-y and then subdir-y. Signed-off-by: Sascha Hauer --- scripts/Makefile | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/Makefile b/scripts/Makefile index 61f31dbfb..b6fd1f132 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -1,32 +1,32 @@ ### # scripts contains sources for various helper programs used throughout -# the kernel for the build process. +# barebox for the build process. # --------------------------------------------------------------------------- # kallsyms: Find all symbols in barebox -hostprogs-$(CONFIG_KALLSYMS) += kallsyms hostprogs-y += bin2c hostprogs-y += mkimage hostprogs-y += fix_size hostprogs-y += bareboxenv +hostprogs-$(CONFIG_KALLSYMS) += kallsyms hostprogs-$(CONFIG_ARCH_MVEBU) += kwbimage kwboot hostprogs-$(CONFIG_ARCH_NETX) += gen_netx_image hostprogs-$(CONFIG_ARCH_OMAP) += omap_signGP mk-am35xx-spi-image hostprogs-$(CONFIG_ARCH_S5PCxx) += s5p_cksum hostprogs-$(CONFIG_ARCH_DAVINCI) += mkublheader hostprogs-$(CONFIG_ARCH_ZYNQ) += zynq_mkimage -subdir-$(CONFIG_ARCH_IMX) += imx + +subdir-y += mod +subdir-$(CONFIG_ARCH_IMX) += imx +subdir-$(CONFIG_X86) += setupmbr +subdir-$(CONFIG_DTC) += dtc + +targetprogs-y += bareboxenv-target HOSTLOADLIBES_omap4_usbboot = -lpthread omap4_usbboot-objs := usb_linux.o omap4_usbboot.o hostprogs-$(CONFIG_OMAP4_USBBOOT)+= omap4_usbboot -always := $(hostprogs-y) $(hostprogs-m) - -subdir-y += mod - -subdir-$(CONFIG_X86) += setupmbr - # Let clean descend into subdirs subdir- += basic kconfig setupmbr @@ -38,4 +38,4 @@ obj-$(CONFIG_BAREBOXENV_TARGET) += bareboxenv-target scripts/bareboxenv-target: scripts/bareboxenv.c FORCE $(call if_changed_dep,csingle) -subdir-$(CONFIG_DTC) += dtc +always := $(hostprogs-y) $(hostprogs-m) From b5f99965b6c9e76f0e12737d2b3424281e28ca5a Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 26 Sep 2013 07:53:11 +0200 Subject: [PATCH 11/14] scripts/Makefile: implement targetprogs-y using obj-y for targetprogs only works until only a single program is compiled. Adding the second one will end up in the linker trying to link both together. Add targetprogs-y to fix this. Signed-off-by: Sascha Hauer --- scripts/Makefile | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/Makefile b/scripts/Makefile index b6fd1f132..7d98a2d2f 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -21,7 +21,7 @@ subdir-$(CONFIG_ARCH_IMX) += imx subdir-$(CONFIG_X86) += setupmbr subdir-$(CONFIG_DTC) += dtc -targetprogs-y += bareboxenv-target +targetprogs-$(CONFIG_BAREBOXENV_TARGET) += bareboxenv-target HOSTLOADLIBES_omap4_usbboot = -lpthread omap4_usbboot-objs := usb_linux.o omap4_usbboot.o @@ -33,9 +33,12 @@ subdir- += basic kconfig setupmbr quiet_cmd_csingle = CC $@ cmd_csingle = $(CC) -Wp,-MD,$(depfile) $(CFLAGS) -o $@ $< -obj-$(CONFIG_BAREBOXENV_TARGET) += bareboxenv-target +__targetprogs := $(sort $(targetprogs-y) $(targetprogs-m)) +target-csingle := $(foreach m,$(__targetprogs),$(if $($(m)-objs),,$(m))) +__targetprogs := $(addprefix $(obj)/,$(__targetprogs)) +target-csingle := $(addprefix $(obj)/,$(target-csingle)) -scripts/bareboxenv-target: scripts/bareboxenv.c FORCE +always := $(hostprogs-y) $(hostprogs-m) $(targetprogs-y) + +$(target-csingle): %-target: %.c FORCE $(call if_changed_dep,csingle) - -always := $(hostprogs-y) $(hostprogs-m) From ac6d9243013ac5cb08d87e0715c5234cca248401 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 26 Sep 2013 08:01:21 +0200 Subject: [PATCH 12/14] scripts: Move omap4_usbboot to its own directory Signed-off-by: Sascha Hauer --- scripts/.gitignore | 1 - scripts/Makefile | 5 +---- scripts/omap4_usbboot/.gitignore | 1 + scripts/omap4_usbboot/Makefile | 5 +++++ scripts/{ => omap4_usbboot}/omap4_usbboot.c | 0 scripts/{ => omap4_usbboot}/usb.h | 0 scripts/{ => omap4_usbboot}/usb_linux.c | 0 7 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 scripts/omap4_usbboot/.gitignore create mode 100644 scripts/omap4_usbboot/Makefile rename scripts/{ => omap4_usbboot}/omap4_usbboot.c (100%) rename scripts/{ => omap4_usbboot}/usb.h (100%) rename scripts/{ => omap4_usbboot}/usb_linux.c (100%) diff --git a/scripts/.gitignore b/scripts/.gitignore index 6518c0f07..53f46d913 100644 --- a/scripts/.gitignore +++ b/scripts/.gitignore @@ -8,5 +8,4 @@ mk-am35xx-spi-image mkimage mkublheader omap_signGP -omap4_usbboot zynq_mkimage diff --git a/scripts/Makefile b/scripts/Makefile index 7d98a2d2f..71d30be20 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -17,16 +17,13 @@ hostprogs-$(CONFIG_ARCH_DAVINCI) += mkublheader hostprogs-$(CONFIG_ARCH_ZYNQ) += zynq_mkimage subdir-y += mod +subdir-$(CONFIG_OMAP4_USBBOOT) += omap4_usbboot subdir-$(CONFIG_ARCH_IMX) += imx subdir-$(CONFIG_X86) += setupmbr subdir-$(CONFIG_DTC) += dtc targetprogs-$(CONFIG_BAREBOXENV_TARGET) += bareboxenv-target -HOSTLOADLIBES_omap4_usbboot = -lpthread -omap4_usbboot-objs := usb_linux.o omap4_usbboot.o -hostprogs-$(CONFIG_OMAP4_USBBOOT)+= omap4_usbboot - # Let clean descend into subdirs subdir- += basic kconfig setupmbr diff --git a/scripts/omap4_usbboot/.gitignore b/scripts/omap4_usbboot/.gitignore new file mode 100644 index 000000000..1975a2172 --- /dev/null +++ b/scripts/omap4_usbboot/.gitignore @@ -0,0 +1 @@ +omap4_usbboot diff --git a/scripts/omap4_usbboot/Makefile b/scripts/omap4_usbboot/Makefile new file mode 100644 index 000000000..af6444b0e --- /dev/null +++ b/scripts/omap4_usbboot/Makefile @@ -0,0 +1,5 @@ +HOSTLOADLIBES_omap4_usbboot = -lpthread +omap4_usbboot-objs := usb_linux.o omap4_usbboot.o +hostprogs-$(CONFIG_OMAP4_USBBOOT) += omap4_usbboot + +always := $(hostprogs-y) diff --git a/scripts/omap4_usbboot.c b/scripts/omap4_usbboot/omap4_usbboot.c similarity index 100% rename from scripts/omap4_usbboot.c rename to scripts/omap4_usbboot/omap4_usbboot.c diff --git a/scripts/usb.h b/scripts/omap4_usbboot/usb.h similarity index 100% rename from scripts/usb.h rename to scripts/omap4_usbboot/usb.h diff --git a/scripts/usb_linux.c b/scripts/omap4_usbboot/usb_linux.c similarity index 100% rename from scripts/usb_linux.c rename to scripts/omap4_usbboot/usb_linux.c From f7c132fa4c271eeea800ec9228a81b6fb5bcc0c6 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 25 Sep 2013 17:51:16 +0200 Subject: [PATCH 13/14] defenv-2: Do not overwrite previously existing global variables In case board code has already initialized global variables during init do not overwrite them. Signed-off-by: Sascha Hauer --- defaultenv-2/base/bin/init | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/defaultenv-2/base/bin/init b/defaultenv-2/base/bin/init index ca02ba642..996fea7e8 100644 --- a/defaultenv-2/base/bin/init +++ b/defaultenv-2/base/bin/init @@ -2,16 +2,23 @@ export PATH=/env/bin -global hostname=generic -global user=none -global autoboot_timeout=3 -global boot.default=net -global allow_color=true +global hostname +global user +global autoboot_timeout +global boot.default +global allow_color global linux.bootargs.base #linux.bootargs.dyn.* will be cleared at the beginning of boot global linux.bootargs.dyn.ip global linux.bootargs.dyn.root -global editcmd=sedit +global editcmd + +[ -z "${global.hostname}" ] && global.hostname=generic +[ -z "${global.user}" ] && global.user=none +[ -z "${global.autoboot_timeout}" ] && global.autoboot_timeout=3 +[ -z "${global.boot.default}" ] && global.boot.default=net +[ -z "${global.allow_color}" ] && global.allow_color=true +[ -z "${global.editcmd}" ] && global.editcmd=sedit [ -e /env/config-board ] && /env/config-board /env/config From ce8f489122e8390360e87c84888aacfc87743a83 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 26 Sep 2013 14:53:55 +0200 Subject: [PATCH 14/14] scripts/bareboxenv: Make locally used functions static Signed-off-by: Sascha Hauer --- scripts/bareboxenv.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/bareboxenv.c b/scripts/bareboxenv.c index 6d6d55b1d..f372685ae 100644 --- a/scripts/bareboxenv.c +++ b/scripts/bareboxenv.c @@ -35,7 +35,7 @@ #define debug(...) -void *xmalloc(size_t size) +static void *xmalloc(size_t size) { void *p = NULL; @@ -47,7 +47,7 @@ void *xmalloc(size_t size) return p; } -void *xzalloc(size_t size) +static void *xzalloc(size_t size) { void *p = xmalloc(size); memset(p, 0, size); @@ -57,7 +57,7 @@ void *xzalloc(size_t size) /* Find out if the last character of a string matches the one given. * Don't underrun the buffer if the string length is 0. */ -char* last_char_is(const char *s, int c) +static char *last_char_is(const char *s, int c) { if (s && *s) { size_t sz = strlen(s) - 1; @@ -85,7 +85,7 @@ int recursive_action(const char *fileName, unsigned flags, /* concatenate path and file name to new allocation buffer, * not adding '/' if path name already has '/' */ -char *concat_path_file(const char *path, const char *filename) +static char *concat_path_file(const char *path, const char *filename) { char *lc, *str; @@ -107,7 +107,7 @@ char *concat_path_file(const char *path, const char *filename) * and skipping "." and ".." directory entries */ -char *concat_subpath_file(const char *path, const char *f) +static char *concat_subpath_file(const char *path, const char *f) { if (f && DOT_OR_DOTDOT(f)) return NULL; @@ -120,7 +120,7 @@ char *concat_subpath_file(const char *path, const char *f) #include "../lib/make_directory.c" #include "../common/environment.c" -void usage(char *prgname) +static void usage(char *prgname) { printf( "Usage : %s [OPTION] DIRECTORY FILE\n" "Load a barebox environment sector into a directory or\n"