diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/.gitignore | 1 | ||||
-rw-r--r-- | scripts/Makefile | 31 | ||||
-rw-r--r-- | scripts/bareboxenv.c | 12 | ||||
-rw-r--r-- | scripts/fix_size.c | 81 | ||||
-rw-r--r-- | scripts/omap4_usbboot/.gitignore | 1 | ||||
-rw-r--r-- | scripts/omap4_usbboot/Makefile | 5 | ||||
-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 |
9 files changed, 109 insertions, 22 deletions
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 |