summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/pbl/Makefile8
-rw-r--r--commands/Makefile1
-rw-r--r--commands/crc.c20
-rw-r--r--commands/devinfo.c158
-rw-r--r--commands/ubi.c20
-rw-r--r--common/globalvar.c3
-rw-r--r--common/hush.c6
-rw-r--r--common/parser.c9
-rw-r--r--defaultenv-2/base/bin/init19
-rw-r--r--drivers/base/driver.c142
-rw-r--r--drivers/usb/core/usb.c8
-rw-r--r--drivers/usb/host/ehci-hcd.c1
-rw-r--r--drivers/usb/host/ohci-hcd.c1
-rw-r--r--include/shell.h12
-rw-r--r--include/usb/usb.h1
-rw-r--r--lib/process_escape_sequence.c7
-rw-r--r--scripts/.gitignore1
-rw-r--r--scripts/Makefile31
-rw-r--r--scripts/bareboxenv.c12
-rw-r--r--scripts/fix_size.c81
-rw-r--r--scripts/omap4_usbboot/.gitignore1
-rw-r--r--scripts/omap4_usbboot/Makefile5
-rw-r--r--scripts/omap4_usbboot/omap4_usbboot.c (renamed from scripts/omap4_usbboot.c)0
-rw-r--r--scripts/omap4_usbboot/usb.h (renamed from scripts/usb.h)0
-rw-r--r--scripts/omap4_usbboot/usb_linux.c (renamed from scripts/usb_linux.c)0
25 files changed, 369 insertions, 178 deletions
diff --git a/arch/arm/pbl/Makefile b/arch/arm/pbl/Makefile
index dd3e94680b..bfa73b91a7 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
diff --git a/commands/Makefile b/commands/Makefile
index f4e0ac63a6..58d27fa905 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -92,3 +92,4 @@ obj-$(CONFIG_CMD_BAREBOX_UPDATE)+= barebox-update.o
obj-$(CONFIG_CMD_MIITOOL) += miitool.o
obj-$(CONFIG_CMD_DETECT) += detect.o
obj-$(CONFIG_CMD_BOOT) += boot.o
+obj-$(CONFIG_CMD_DEVINFO) += devinfo.o
diff --git a/commands/crc.c b/commands/crc.c
index a0071b0e8b..ee8dacff0b 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 <file>", "Use file instead of memory.\n")
BAREBOX_CMD_HELP_OPT ("-F <file>", "Use file to compare.\n")
#endif
BAREBOX_CMD_HELP_OPT ("-v <crc>", "Verify\n")
+BAREBOX_CMD_HELP_OPT ("-V <file>", "Verify with crc read from <file>\n")
BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(crc32)
diff --git a/commands/devinfo.c b/commands/devinfo.c
new file mode 100644
index 0000000000..806e45c9ba
--- /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 <command.h>
+#include <common.h>
+#include <complete.h>
+#include <driver.h>
+
+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/commands/ubi.c b/commands/ubi.c
index 2041df3fd5..57ae79025d 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;
+
+ 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 (argc != 2)
+ 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 <mtddev>\n"
+"Usage: ubiattach [-O vid-hdr-offset] <mtddev>\n"
"Attach <mtddev> to ubi\n";
BAREBOX_CMD_START(ubiattach)
diff --git a/common/globalvar.c b/common/globalvar.c
index 6ef4a6a680..41ce06e468 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);
}
diff --git a/common/hush.c b/common/hush.c
index a3235ba19f..bf1d9e6fd7 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -123,6 +123,7 @@
#include <linux/list.h>
#include <binfmt.h>
#include <init.h>
+#include <shell.h>
/*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 4d993dfd35..d390fb6afe 100644
--- a/common/parser.c
+++ b/common/parser.c
@@ -1,6 +1,15 @@
#include <common.h>
#include <command.h>
#include <environment.h>
+#include <shell.h>
+
+/*
+ * not yet supported
+ */
+int shell_get_last_return_code(void)
+{
+ return 0;
+}
static int parse_line (char *line, char *argv[])
{
diff --git a/defaultenv-2/base/bin/init b/defaultenv-2/base/bin/init
index 81b3434913..d7bd0cb140 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
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index e587e3acc1..80e0ea882f 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -417,145 +417,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
-
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 36fc736fd0..68a51d1e1e 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,
@@ -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 */
@@ -527,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) {
@@ -536,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);
}
/*
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index f44f836357..cb6a592466 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 ad39bcf6ad..8bf20d0d61 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/shell.h b/include/shell.h
new file mode 100644
index 0000000000..b98cac3dc5
--- /dev/null
+++ b/include/shell.h
@@ -0,0 +1,12 @@
+/*
+ * (C) Copyright 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * Under GPLv2 only
+ */
+
+#ifndef __SHELL_H__
+#define __SHELL_H__
+
+int shell_get_last_return_code(void);
+
+#endif /* __SHELL_H__ */
diff --git a/include/usb/usb.h b/include/usb/usb.h
index 95fb6f3a3b..821724e544 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;
};
diff --git a/lib/process_escape_sequence.c b/lib/process_escape_sequence.c
index be77792787..47a7e5cd92 100644
--- a/lib/process_escape_sequence.c
+++ b/lib/process_escape_sequence.c
@@ -19,6 +19,7 @@
#include <common.h>
#include <fs.h>
#include <libbb.h>
+#include <shell.h>
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);
diff --git a/scripts/.gitignore b/scripts/.gitignore
index 6518c0f076..53f46d913f 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 307dc3d1a4..71d30be20a 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -1,30 +1,28 @@
###
# 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
-
-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_OMAP4_USBBOOT) += omap4_usbboot
+subdir-$(CONFIG_ARCH_IMX) += imx
+subdir-$(CONFIG_X86) += setupmbr
+subdir-$(CONFIG_DTC) += dtc
-subdir-y += mod
-
-subdir-$(CONFIG_X86) += setupmbr
+targetprogs-$(CONFIG_BAREBOXENV_TARGET) += bareboxenv-target
# Let clean descend into subdirs
subdir- += basic kconfig setupmbr
@@ -32,9 +30,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
- $(call if_changed_dep,csingle)
+always := $(hostprogs-y) $(hostprogs-m) $(targetprogs-y)
-subdir-$(CONFIG_DTC) += dtc
+$(target-csingle): %-target: %.c FORCE
+ $(call if_changed_dep,csingle)
diff --git a/scripts/bareboxenv.c b/scripts/bareboxenv.c
index 6d6d55b1db..f372685ae7 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"
diff --git a/scripts/fix_size.c b/scripts/fix_size.c
new file mode 100644
index 0000000000..869ae7e32b
--- /dev/null
+++ b/scripts/fix_size.c
@@ -0,0 +1,81 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <fcntl.h>
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE /* See feature_test_macros(7) */
+#endif
+#include <endian.h>
+
+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;
+}
diff --git a/scripts/omap4_usbboot/.gitignore b/scripts/omap4_usbboot/.gitignore
new file mode 100644
index 0000000000..1975a2172f
--- /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 0000000000..af6444b0e2
--- /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
index e52108614b..e52108614b 100644
--- a/scripts/omap4_usbboot.c
+++ b/scripts/omap4_usbboot/omap4_usbboot.c
diff --git a/scripts/usb.h b/scripts/omap4_usbboot/usb.h
index d50aa6aa6f..d50aa6aa6f 100644
--- a/scripts/usb.h
+++ b/scripts/omap4_usbboot/usb.h
diff --git a/scripts/usb_linux.c b/scripts/omap4_usbboot/usb_linux.c
index 9a6e0b84d0..9a6e0b84d0 100644
--- a/scripts/usb_linux.c
+++ b/scripts/omap4_usbboot/usb_linux.c