Re: [PATCH 1/1] omap: xload: switch to generic bootstrap

2013-09-30 Thread Sascha Hauer
On Fri, Sep 27, 2013 at 10:47:21AM +0200, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
 dissimilarity index 76%
 index 3cce3f2..74a5f00 100644
 --- a/arch/arm/mach-omap/xload.c
 +++ b/arch/arm/mach-omap/xload.c

How is this patch generated? It's strange that this file is completely removed
and added again.

 +/*
 + * Replaces the default shell in xload configuration
 + */
 +static __noreturn int omap_xload(void)
 +{
 + int (*func)(void) = NULL;
 +
 + switch (bootsource_get()) {
 + case BOOTSOURCE_MMC:
 + printf(booting from MMC\n);
 + func = bootstrap_read_disk(disk0.0, fat);
 + break;
 + case BOOTSOURCE_USB:
 + if (IS_ENABLED(CONFIG_FS_OMAP4_USBBOOT)) {
 + printf(booting from USB\n);
 + func = bootstrap_read_disk(omap4_usbboot, 
 omap4_usbbootfs);
 + break;
 + } else {
 + printf(booting from USB not enabled\n);
 + }
 + case BOOTSOURCE_NAND:
 + printf(booting from NAND\n);
 + func = bootstrap_read_devfs(nand0, true, SZ_128K, SZ_256K, 
 SZ_1M);
 + break;
 + case BOOTSOURCE_SPI:
 + printf(booting from SPI\n);
 + func = bootstrap_read_devfs(m25p0, false, SZ_128K, SZ_256K, 
 SZ_1M);
 + break;
 + default:
 + printf(unknown boot source. Fall back to nand\n);
 + func = bootstrap_read_devfs(nand0, true, SZ_128K, SZ_256K, 
 SZ_1M);
 + break;
 + }
 +
 + bootstrap_boot(func, false);

This won't work anymore since the omap barebox function now takes an
argument which is currently not supported by the bootstrap code.

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: strtoull_suffix

2013-09-30 Thread Sascha Hauer
Hi,

On Sun, Sep 29, 2013 at 07:57:39PM +0800, Yi Qingliang wrote:
 the strtoull_suffix can't identify 'g' and 'm', but the 'memparse' in kernel 
 can, do we should follow the kernel?

Go ahead and send a patch. I remember the original reason I haven't
supported 'm' was that it reminded me too much on 'milli'. I still
haven't seen a millibyte though...

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] i2c-omap: Update driver

2013-09-30 Thread Sascha Hauer
On Thu, Sep 26, 2013 at 01:40:24PM +0200, Jan Weitzel wrote:
 The driver didn't work well with at24 driver. NACKS are lost.
 Errors are lost in isr due to the local variable err. Also we didn't wait for
 bus free in omap_i2c_xfer_msg.
 
 Fix issues and get other improvements from linux kernel
 
 Tested on OMAP4 and AM335x
 
 Signed-off-by: Jan Weitzel j.weit...@phytec.de

Applied, thanks

Sascha

 ---
  arch/arm/mach-omap/include/mach/generic.h |9 +-
  drivers/i2c/busses/i2c-omap.c |  635 
 -
  include/i2c/i2c.h |1 +
  3 files changed, 454 insertions(+), 191 deletions(-)
 
 diff --git a/arch/arm/mach-omap/include/mach/generic.h 
 b/arch/arm/mach-omap/include/mach/generic.h
 index ece8c2b..31ab100 100644
 --- a/arch/arm/mach-omap/include/mach/generic.h
 +++ b/arch/arm/mach-omap/include/mach/generic.h
 @@ -2,12 +2,13 @@
  #define _MACH_GENERIC_H
  
  /* I2C controller revisions */
 -#define OMAP_I2C_REV_2   0x20
 +#define OMAP_I2C_OMAP1_REV_20x20
  
  /* I2C controller revisions present on specific hardware */
 -#define OMAP_I2C_REV_ON_2430 0x36
 -#define OMAP_I2C_REV_ON_3430 0x3C
 -#define OMAP_I2C_REV_ON_4430 0x40
 +#define OMAP_I2C_REV_ON_2430 0x0036
 +#define OMAP_I2C_REV_ON_3430_3530   0x003C
 +#define OMAP_I2C_REV_ON_36300x0040
 +#define OMAP_I2C_REV_ON_4430_PLUS   0x5042
  
  #ifdef CONFIG_ARCH_OMAP
  #define cpu_is_omap2430()(1)
 diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
 index 2eb5133..bec3b29 100644
 --- a/drivers/i2c/busses/i2c-omap.c
 +++ b/drivers/i2c/busses/i2c-omap.c
 @@ -131,29 +131,41 @@
  #define SYSC_IDLEMODE_SMART  0x2
  #define SYSC_CLOCKACTIVITY_FCLK  0x2
  
 +/* Errata definitions */
 +#define I2C_OMAP_ERRATA_I207 (1  0)
 +#define I2C_OMAP_ERRATA_I462 (1  1)
 +
  /* i2c driver flags from kernel */
 -#define OMAP_I2C_FLAG_RESET_REGS_POSTIDLEBIT(3)
 +#define OMAP_I2C_FLAG_NO_FIFOBIT(0)
 +#define OMAP_I2C_FLAG_16BIT_DATA_REG BIT(2)
  #define OMAP_I2C_FLAG_BUS_SHIFT_NONE 0
  #define OMAP_I2C_FLAG_BUS_SHIFT_1BIT(7)
  #define OMAP_I2C_FLAG_BUS_SHIFT_2BIT(8)
  #define OMAP_I2C_FLAG_BUS_SHIFT__SHIFT   7
  
 +/* timeout waiting for the controller to respond */
 +#define OMAP_I2C_TIMEOUT (1000 * MSECOND)/* ms */
 +
  struct omap_i2c_struct {
   void*base;
   u8  reg_shift;
   struct omap_i2c_driver_data *data;
   struct resource *ioarea;
   u32 speed;  /* Speed of bus in Khz */
 + u16 scheme;
   u16 cmd_err;
   u8  *buf;
 + u8  *regs;
   size_t  buf_len;
   struct i2c_adapter  adapter;
 + u8  threshold;
   u8  fifo_size;  /* use as flag and value
* fifo_size==0 implies no fifo
* if set, should be trsh+1
*/
 - u8  rev;
 + u32 rev;
   unsignedb_hw:1; /* bad h/w fixes */
 + unsignedreceiver:1; /* true for receiver mode */
   u16 iestate;/* Saved interrupt register */
   u16 pscstate;
   u16 scllstate;
 @@ -161,6 +173,7 @@ struct omap_i2c_struct {
   u16 bufstate;
   u16 syscstate;
   u16 westate;
 + u16 errata;
  };
  #define to_omap_i2c_struct(a)container_of(a, struct omap_i2c_struct, 
 adapter)
  
 @@ -183,14 +196,15 @@ enum {
   OMAP_I2C_SCLH_REG,
   OMAP_I2C_SYSTEST_REG,
   OMAP_I2C_BUFSTAT_REG,
 - OMAP_I2C_REVNB_LO,
 - OMAP_I2C_REVNB_HI,
 - OMAP_I2C_IRQSTATUS_RAW,
 - OMAP_I2C_IRQENABLE_SET,
 - OMAP_I2C_IRQENABLE_CLR,
 + /* only on OMAP4430 */
 + OMAP_I2C_IP_V2_REVNB_LO,
 + OMAP_I2C_IP_V2_REVNB_HI,
 + OMAP_I2C_IP_V2_IRQSTATUS_RAW,
 + OMAP_I2C_IP_V2_IRQENABLE_SET,
 + OMAP_I2C_IP_V2_IRQENABLE_CLR,
  };
  
 -static const u8 reg_map[] = {
 +static const u8 reg_map_ip_v1[] = {
   [OMAP_I2C_REV_REG] = 0x00,
   [OMAP_I2C_IE_REG] = 0x01,
   [OMAP_I2C_STAT_REG] = 0x02,
 @@ -211,7 +225,7 @@ static const u8 reg_map[] = {
   [OMAP_I2C_BUFSTAT_REG] = 0x10,
  };
  
 -static const u8 omap4_reg_map[] = {
 +static const u8 reg_map_ip_v2[] = {
   [OMAP_I2C_REV_REG] = 0x04,
   [OMAP_I2C_IE_REG] = 0x2c,
   [OMAP_I2C_STAT_REG] = 0x28,
 @@ -230,92 +244,104 @@ static const u8 omap4_reg_map[] = {
   

[PATCH 2/4] cdev: store dos partition type in struct cdev

2013-09-30 Thread Sascha Hauer
Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 common/partitions.c| 4 +++-
 common/partitions/dos.c| 7 +--
 common/partitions/parser.h | 1 +
 include/driver.h   | 1 +
 4 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/common/partitions.c b/common/partitions.c
index 38032a3..694c6f6 100644
--- a/common/partitions.c
+++ b/common/partitions.c
@@ -63,6 +63,8 @@ static int register_one_partition(struct block_device *blk,
goto out;
}
 
+   cdev-dos_partition_type = part-dos_partition_type;
+
free(partition_name);
 
if (!part-name[0])
@@ -84,7 +86,7 @@ static int register_one_partition(struct block_device *blk,
ret = 0;
 out:
free(partition_name);
-   return 0;
+   return ret;
 }
 
 static struct partition_parser *partition_parser_get_by_filetype(uint8_t *buf)
diff --git a/common/partitions/dos.c b/common/partitions/dos.c
index 29f1375..31b1ed6 100644
--- a/common/partitions/dos.c
+++ b/common/partitions/dos.c
@@ -138,10 +138,13 @@ static void dos_partition(void *buf, struct block_device 
*blk,
for (i = 0; i  4; i++) {
pentry.first_sec = 
get_unaligned_le32(table[i].partition_start);
pentry.size = get_unaligned_le32(table[i].partition_size);
+   pentry.dos_partition_type = table[i].type;
 
if (pentry.first_sec != 0) {
-   pd-parts[pd-used_entries].first_sec = 
pentry.first_sec;
-   pd-parts[pd-used_entries].size = pentry.size;
+   int n = pd-used_entries;
+   pd-parts[n].first_sec = pentry.first_sec;
+   pd-parts[n].size = pentry.size;
+   pd-parts[n].dos_partition_type = 
pentry.dos_partition_type;
pd-used_entries++;
} else {
dev_dbg(blk-dev, Skipping empty partition %d\n, i);
diff --git a/common/partitions/parser.h b/common/partitions/parser.h
index f5bdbd1..8d39452 100644
--- a/common/partitions/parser.h
+++ b/common/partitions/parser.h
@@ -16,6 +16,7 @@
 
 struct partition {
char name[MAX_PARTITION_NAME];
+   u8 dos_partition_type;
uint64_t first_sec;
uint64_t size;
 };
diff --git a/include/driver.h b/include/driver.h
index 9e4bffd..7f0532e 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -456,6 +456,7 @@ struct cdev {
unsigned int flags;
int open;
struct mtd_info *mtd;
+   u8 dos_partition_type;
 };
 
 int devfs_create(struct cdev *);
-- 
1.8.4.rc3


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/4] add function to read single line files

2013-09-30 Thread Sascha Hauer
Often small files are used to store the value od a variable. This
adds a function to easily read such a variable.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 include/libbb.h |  2 ++
 lib/libbb.c | 42 ++
 2 files changed, 44 insertions(+)

diff --git a/include/libbb.h b/include/libbb.h
index 47b2e08..2fe710c 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -35,4 +35,6 @@ char *simple_itoa(unsigned int i);
 int write_full(int fd, void *buf, size_t size);
 int read_full(int fd, void *buf, size_t size);
 
+char *read_file_line(const char *fmt, ...);
+
 #endif /* __LIBBB_H */
diff --git a/lib/libbb.c b/lib/libbb.c
index e0d7481..6a083f9 100644
--- a/lib/libbb.c
+++ b/lib/libbb.c
@@ -176,3 +176,45 @@ int read_full(int fd, void *buf, size_t size)
return insize;
 }
 EXPORT_SYMBOL(read_full);
+
+/*
+ * read_file_line - read a line from a file
+ *
+ * Used to compose a filename from a printf format and to read a line from this
+ * file. All leading and trailing whitespaces (including line endings) are
+ * removed. The returned buffer must be freed with free(). This function is
+ * supposed for reading variable like content into a buffer, so files  1024
+ * bytes are ignored.
+ */
+char *read_file_line(const char *fmt, ...)
+{
+   va_list args;
+   char *filename;
+   char *buf, *line = NULL;
+   int size, ret;
+   struct stat s;
+
+   va_start(args, fmt);
+   filename = vasprintf(fmt, args);
+   va_end(args);
+
+   ret = stat(filename, s);
+   if (ret)
+   goto out;
+
+   if (s.st_size  1024)
+   goto out;
+
+   buf = read_file(filename, size);
+   if (!buf)
+   goto out;
+
+   line = strim(buf);
+
+   line = xstrdup(line);
+   free(buf);
+out:
+   free(filename);
+   return line;
+}
+EXPORT_SYMBOL_GPL(read_file_line);
-- 
1.8.4.rc3


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


bootloader specification for barebox

2013-09-30 Thread Sascha Hauer
Hi All,

The following implements the bootloader specification for barebox.

See http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/ for a
description of the bootloader spec.

Quoting from it:

| Currently there's little cooperation between multiple distributions in
| dual-boot (or triple, ... multi-boot) setups, and we'd like to improve this
| situation by getting everybody to commit to a single boot configuration format
| that is based on drop-in files, and thus is robust, simple, works without
| rewriting configuration files and is free of namespace clashes.
| 
| The Boot Loader Specification defines a scheme how different operating systems
| can cooperatively manage a boot loader configuration directory, that accepts
| drop-in files for boot menu items that are defined in a format that is shared
| between various boot loader implementations, operating systems, and userspace
| programs. The target audience for this specification is:
| 
| * Boot loader developers, to write a boot loader that directly reads its
|   configuration at runtime from these drop-in snippets Distribution and Core
| * OS developers, in order to create these snippets at OS/kernel package
|   installation time
| * UI developers, for implementing a user interface that discovers the 
available
|   boot options
| * OS Installer developers, for setting up the initial drop-in directory

With this it is for the first time possible for a distribution to install a
kernel for barebox in a completely bootloader or board agnostic way. systemd
based distributions already ship a kernel-install script which can be used
to install a kernel.

With the following series it's possible to discover bootloader spec entries
on a device and to start them. For the user it basically goes down to adding
a device to the boot order, so either call 'boot devname' (with devname being
disk0, emmc, sd, or the hardware device, like omap-hsmmc0...) or add this to
global.boot.default.

I already used systemds kernel-install script successfully to install a kernel.
However, embedded users often have the task of making SD cards bootable from
a development host, so barebox has its own tool which is able to work in a
cross environment.

To test this do the following:

- build and start barebox with these patches (obviously)
- create a SD card with a VFAT partition big enough to hold your kernels,
  preferably with a partition type of 0xea
- Add a partition to hold your rootfs, copy your rootfs to it.
- build a kernel.
- Call the barebox kernel-install tool like this, assuming your SD card is
  /dev/sde and the rootfs is on /dev/sde2:

./scripts/kernel-install --add --device=/dev/sde --root=/dev/sde2 \
--kernel=/path/to/zImage --devicetree=/path/to/dtb \
--options=console=ttySx,115200 --title=My Linux 3.12-rc3 \
--kernel-version=3.12-rc3 --add-root-option

- put the SD card into the board, try 'boot -l'. It should then list the
  entry. Start it with boot devname. If menu support is enabled try 'boot -m'

With the Fedora FC19 SD images it should be possible to simply call the 
following
from a running system:

kernel-install add v3.12-rc3 /path/to/zImage

(The official bootloader spec currently has no support for devicetrees, barebox
must provide it should you need one)

This all probably still has some rough edges, but it really already shows the
potential of making generic ARM distribution (and installer) images possible.
Also there's only little configuration of the bootloader needed which hopefully
makes usage of barebox easier.

Sascha


Sascha Hauer (4):
  add function to read single line files
  cdev: store dos partition type in struct cdev
  Implement bootloader spec support for barebox
  add kernel-install tool for bootloader Spec

 commands/boot.c|  172 +-
 common/Kconfig |   14 +
 common/Makefile|2 +
 common/blspec.c|  516 
 common/partitions.c|4 +-
 common/partitions/dos.c|7 +-
 common/partitions/parser.h |1 +
 include/blspec.h   |   92 +++
 include/driver.h   |1 +
 include/libbb.h|2 +
 lib/libbb.c|   42 ++
 scripts/Makefile   |2 +
 scripts/kernel-install.c   | 1399 
 13 files changed, 2226 insertions(+), 28 deletions(-)
 create mode 100644 common/blspec.c
 create mode 100644 include/blspec.h
 create mode 100644 scripts/kernel-install.c

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 4/4] add kernel-install tool for bootloader Spec

2013-09-30 Thread Sascha Hauer
This adds a tool for installing kernels according to the bootloader
spec. systemd already has a similar tool, but it is limited to installing
kernels on the currently running system. The barebox kernel-install
tool instead can also be used to install kernels on removable media on a
development host for cross development. It is compiled in two variants,
as 'kernel-install' for the host and as 'kernel-install-target' using
$CROSS_COMPILE.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 scripts/Makefile |2 +
 scripts/kernel-install.c | 1399 ++
 2 files changed, 1401 insertions(+)
 create mode 100644 scripts/kernel-install.c

diff --git a/scripts/Makefile b/scripts/Makefile
index 2c43f66..a5cdf30 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -8,6 +8,7 @@ hostprogs-y  += bin2c
 hostprogs-y  += mkimage
 hostprogs-y  += fix_size
 hostprogs-y  += bareboxenv
+hostprogs-y  += kernel-install
 hostprogs-$(CONFIG_KALLSYMS) += kallsyms
 hostprogs-$(CONFIG_ARCH_MVEBU)   += kwbimage kwboot
 hostprogs-$(CONFIG_ARCH_NETX)+= gen_netx_image
@@ -24,6 +25,7 @@ subdir-$(CONFIG_X86)  += setupmbr
 subdir-$(CONFIG_DTC)   += dtc
 
 targetprogs-$(CONFIG_BAREBOXENV_TARGET) += bareboxenv-target
+targetprogs-y += kernel-install-target
 
 # Let clean descend into subdirs
 subdir-+= basic kconfig setupmbr
diff --git a/scripts/kernel-install.c b/scripts/kernel-install.c
new file mode 100644
index 000..ed9f8bd
--- /dev/null
+++ b/scripts/kernel-install.c
@@ -0,0 +1,1399 @@
+/*
+ * kernel-install - install a kernel according to the bootloader spec:
+ * http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/
+ *
+ * Copyright (C) 2013 Sascha Hauer, Pengutronix s.ha...@pengutronix.de
+ *
+ * This tool is useful for installing kernels in a bootloader spec
+ * conformant way. It can be used to install kernels for the currently
+ * running system, but also to install kernels for another system which
+ * is available as a removable media such as an SD card.
+ *
+ * Some examples:
+ *
+ * kernel-install --add --kernel-version=3.11 --kernel=/somewhere/zImage \
+ * --title Linux-3.11
+ *
+ * This is the simplest example. It assumes we want to install a kernel for the
+ * currently running system. Usually the kernel should get some commandline
+ * options which can be passed using the -o option. Devicetree and initrd can 
be
+ * specified with --devicetree=file or --initrd=file.
+ *
+ * For preparing boot media from another host (or the same host, but another
+ * rootfs) things get slightly more complicated. Apart from the image files
+ * kernel-install generally needs a machine-id (which is, in native mode, read
+ * from /etc/machine-id) and access to /boot of newly installed entry.
+ * /boot can be specified in different ways:
+ *
+ * --boot=/boot - specify the path where /boot is mounted
+ * --boot=/dev/sdd1 - specify the partition which contains /boot.
+ *It is mounted using pmount or mount
+ * --device=/dev/sdd- If this option is given kernel-install tries
+ *to find /boot on this device using the mechanisms
+ *described in the bootloader spec.
+ *
+ * machine-id can be specified with:
+ * --machine-id=machine-id- explicitly specify a machine-id
+ * --root=/root or
+ * --root=/dev/sdd2 - specify where the root of the installed 
system
+ *can be found. The machine id is then taken
+ *from /etc/machine-id from this 
filesystem/path
+ *
+ * Optionally kernel-install can automatically generate a root=PARTUUID= kernel
+ * parameter for the kernel to find its root filesystem. This is done with the
+ * --add-root-option parameter. Additionally the --device= parameter must be
+ * specified so that kernel-install can determine the UUID of the device.
+ *
+ * Now for an example using most of the available features:
+ *
+ * kernel-install --device=/dev/sdd --root=/dev/sdd2 --title=Linux-3.12 \
+ * --kernel-version=3.12 --kernel=/some/zImage \
+ * --devicetree=/some/devicetree --initrd=/some/initrd \
+ * --add-root-option --options=console=ttyS0,115200
+ *
+ * This would install a kernel on /dev/sdd. The /boot partition would be found
+ * automatically, the root partition has to be specified due to the usage of
+ * --add-root-option
+ *
+ * BUGS:
+ * - Currently only DOS partition tables are supported. There's no support
+ *   for GPT yet.
+ *
+ *
+ * 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 

[PATCH 3/4] Implement bootloader spec support for barebox

2013-09-30 Thread Sascha Hauer
The Bootloader Specification describes a way how kernels can
be installed on devices and how they can be started by the bootloader.

The bootloader spec is currently supported by (x86) gummiboot and
by systemd which provides a kernel-install script. With the bootloader
spec it's possible for the Operating system to install a new kernel
without knowing about the bootloader and for the bootloader it's possible
to discover and start Operating Systems on a media without being
configured.

For more details about the spec see:

http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/

This patch adds barebox support for the spec. It enhances the 'boot'
command so that not only boot script names can be given, but also
devices containing bootloader spec entries. With this it's possible
to call the 'boot' command like: 'boot sd emmc net'. It would then
first look for bootloader spec entries on the (removable) sd card,
then, is nothing is found, on the internal emmc and if still
unsuccessful would call the 'net' bootscript.

The bootloader Spec currently doesn't specify which entry should be
default if multiple entries are found on a single device. Therefore
barebox currently has two extensions of the spec. The $BOOT diretory
can contain a file named 'default'. If present, the content of the
file is treated as a filename under $BOOT/loader/entries/ which is
used as default. Similarly if a file named 'once' is present, the
entry is started once and the file is removed afterwards. This is
useful for testing if a newly installed kernel works before making
it the default.

As on ARM and other Architectures a devicetree has to be specified
for the kernel, the 'devicetree' property is used to specify a
devicetree. Like 'kernel' and 'initrd' this also contains a pth
relative to $BOOT.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 commands/boot.c  | 172 ---
 common/Kconfig   |  14 ++
 common/Makefile  |   2 +
 common/blspec.c  | 516 +++
 include/blspec.h |  92 ++
 5 files changed, 771 insertions(+), 25 deletions(-)
 create mode 100644 common/blspec.c
 create mode 100644 include/blspec.h

diff --git a/commands/boot.c b/commands/boot.c
index 93bf148..7850805 100644
--- a/commands/boot.c
+++ b/commands/boot.c
@@ -15,51 +15,155 @@
 #include globalvar.h
 #include magicvar.h
 #include command.h
+#include readkey.h
 #include common.h
 #include getopt.h
+#include blspec.h
 #include libgen.h
 #include malloc.h
 #include boot.h
+#include menu.h
 #include fs.h
+#include complete.h
 
 #include linux/stat.h
 
+static int boot_script(char *path);
+
 static int verbose;
 static int dryrun;
 
-static void bootsources_list(void)
+static void bootsource_action(struct menu *m, struct menu_entry *me)
+{
+   struct blspec_entry *be = container_of(me, struct blspec_entry, me);
+   int ret;
+
+   if (be-scriptpath) {
+   ret = boot_script(be-scriptpath);
+   } else {
+   if (IS_ENABLED(CONFIG_BLSPEC))
+   ret = blspec_boot(be, 0, 0);
+   else
+   ret = -ENOSYS;
+   }
+
+   if (ret)
+   printf(Booting failed with: %s\n, strerror(-ret));
+
+   printf(Press any key to continue\n);
+
+   read_key();
+}
+
+static int bootsources_menu_env_entries(struct blspec *blspec)
 {
+   const char *path = /env/boot, *title;
DIR *dir;
struct dirent *d;
-   const char *path = /env/boot;
+   struct blspec_entry *be;
+   char *cmd;
 
dir = opendir(path);
-   if (!dir) {
-   printf(cannot open %s: %s\n, path, strerror(-errno));
-   return;
-   }
-
-   printf(Bootsources: );
+   if (!dir)
+   return -errno;
 
while ((d = readdir(dir))) {
+
if (*d-d_name == '.')
continue;
 
-   printf(%s , d-d_name);
-   }
+   be = blspec_entry_alloc(blspec);
+   be-me.type = MENU_ENTRY_NORMAL;
+   be-scriptpath = asprintf(/env/boot/%s, d-d_name);
+
+   cmd = asprintf(. %s menu, be-scriptpath);
+   setenv(title, );
+   run_command(cmd, 0);
+   free(cmd);
+   title = getenv(title);
 
-   printf(\n);
+   if (title)
+   be-me.display = xstrdup(title);
+   else
+   be-me.display = xstrdup(d-d_name);
+   }
 
closedir(dir);
+
+   return 0;
 }
 
-static const char *getenv_or_null(const char *var)
+static struct blspec *bootentries_collect(void)
 {
-   const char *val = getenv(var);
+   struct blspec *blspec;
+
+   blspec = blspec_alloc();
+   blspec-menu-display = asprintf(boot);
+   bootsources_menu_env_entries(blspec);
+   if (IS_ENABLED(CONFIG_BLSPEC))
+   blspec_scan_devices(blspec);
+   return blspec;
+}
 
-   

Is Relocation forced?

2013-09-30 Thread Allen Kennedy Jr.
Hello,
  I have relocatable binary set to n  and I load barebox into ram
exactly where it is supposed to be, but it still runs the function
relocate binary

  Is the option to not relocate barebox, not supported?

Why would I want it not-relocated?  Because relocate_to_current_adr()
causes an exception every time, and barebox won't boot.  And I can't
figure out why the exception occurs.

thanks,
-allen

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: Is Relocation forced?

2013-09-30 Thread Sascha Hauer
Hi Allen,

On Mon, Sep 30, 2013 at 09:24:17AM -0500, Allen Kennedy Jr. wrote:
 Hello,
   I have relocatable binary set to n  and I load barebox into ram
 exactly where it is supposed to be, but it still runs the function
 relocate binary
 
   Is the option to not relocate barebox, not supported?
 
 Why would I want it not-relocated?  Because relocate_to_current_adr()
 causes an exception every time, and barebox won't boot.  And I can't
 figure out why the exception occurs.

Generally relocatable barebox is not enforced and barebox runs happily
without it. However, there are some combinations of PBL/TEXT_BASE which
really do need relocation support.

What SoC/board are you running? Could you post your .config file?

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: Is Relocation forced?

2013-09-30 Thread Allen Kennedy Jr.
Sascha,
  I figured out the issue.  'scp' was not copying my new version..
and not indicating failure.
Once i deleted the old bin and copied a new one, i see it is running
without relocation.

Sorry.

On Mon, Sep 30, 2013 at 10:38 AM, Sascha Hauer s.ha...@pengutronix.de wrote:
 Hi Allen,

 On Mon, Sep 30, 2013 at 09:24:17AM -0500, Allen Kennedy Jr. wrote:
 Hello,
   I have relocatable binary set to n  and I load barebox into ram
 exactly where it is supposed to be, but it still runs the function
 relocate binary

   Is the option to not relocate barebox, not supported?

 Why would I want it not-relocated?  Because relocate_to_current_adr()
 causes an exception every time, and barebox won't boot.  And I can't
 figure out why the exception occurs.

 Generally relocatable barebox is not enforced and barebox runs happily
 without it. However, there are some combinations of PBL/TEXT_BASE which
 really do need relocation support.

 What SoC/board are you running? Could you post your .config file?

 Sascha

 --
 Pengutronix e.K.   | |
 Industrial Linux Solutions | http://www.pengutronix.de/  |
 Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
 Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

 ___
 barebox mailing list
 barebox@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/barebox

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[SOLVED] Re: Porting to a new board

2013-09-30 Thread Allen Kennedy Jr.
I think i finally figured out the issue.  I was compiling with
arm-none-eabi bare-board compiler.  Which seemed to make sense to me
since the bootloader is not running on top of an OS, but...
when I recompiled using a arm-none-linux-gnueabi toolchain, the
Ethernet driver jumped to life and started working.

thanks for all of your support with this one.

Now if only i can figure out how to make it boot from flash but
that's for another thread.

-Allen

On Tue, Sep 24, 2013 at 12:06 PM, Allen Kennedy Jr.
al...@kennedystuff.com wrote:
 The power is stable.  The garbled message happens whenever too many
 strings are printed out.  So I don't think that's anything to do with
 my specific setup.  You might be able to reproduce it.  Try this:

 md 0xa000+2000
 substitute the beginning of your ram range for 0xa000

 On Tue, Sep 24, 2013 at 11:33 AM, Jean-Christophe PLAGNIOL-VILLARD
 plagn...@jcrosoft.com wrote:
 On 10:00 Tue 24 Sep , Allen Kennedy Jr. wrote:
 The dhcp command gives:
 warning: No MAC address set. Using random address 62:1C:8B:DF:6D:4D
 Then the device console hangs, Ctrl-C does nothing.  Breaking into it
 via JTAG, I see
 the PC and LR are off in the weeds and the stack and registers
 contains nothing of
 indication as to where it went awry.

 md 0x1002b000 does show the FEC registers:
  md 0x1002b000
 1002b000: 0600   0600
 
 1002b010:    
 
 1002b020: 0600 f000 0600 0600
 
 1002b030: 0600 0600 0600 0600
 
 1002b040: 6f86782d 0018 00060006 00040006
 -x.o
 1002b050: 6f86782d 0018 000a0006 00080006
 -x.o
 1002b060:  c000 fffd fffd
 
 1002b070: fffd fffd fffd fffd
 
 1002b080: 000b 05ee0004 1900 84680868
 h.h.
 1002b090:   10008208 33428006
 ..B3
 1002b0a0: 00c4   
 
 1002b0b0:    
 
 1002b0c0:    
 
 1002b0d0: 02b2 91cc3d09  0180c200
 .=..
 1002b0e0: 0001 068f6c9e b50d8808 00010020.l.. 
 ...
 1002b0f0:    
 


 iomem output:
  iomem
 0x - 0x (size 0x) iomem
   0x10002000 - 0x10002fff (size 0x1000) imx21-wdt0
   0x10003000 - 0x100030ff (size 0x0100) imx1-gpt0
   0x1000a000 - 0x1000afff (size 0x1000) imx21-uart0
   0x10015000 - 0x100150ff (size 0x0100) imx1-gpio0
   0x10015100 - 0x100151ff (size 0x0100) imx1-gpio1
   0x10015200 - 0x100152ff (size 0x0100) imx1-gpio2
   0x10015300 - 0x100153ff (size 0x0100) imx1-gpio3
   0x10015400 - 0x100154ff (size 0x0100) imx1-gpio4
   0x10015500 - 0x100155ff (size 0x0100) imx1-gpio5
   0x10027000 - 0x10027fff (size 0x1000) imx27-ccm
   0x10028000 - 0x10028fff (size 0x1000) imx_iim
   0x1002b000 - 0x1002bfff (size 0x1000) imx27-fec
   0xa000 - 0xa7ff (size 0x0800) ram0
 0xa7a0 - 0xa7df (size 0x0040) malloc space
 0xa7e0 - 0xa7e1afdf (size 0x0001afe0) barebox
 0xa7e1afe0 - 0xa7e20aaf (size 0x5ad0) barebox data
 0xa7e20ab0 - 0xa7e24f4b (size 0x449c) bss
 0xa7ff8000 - 0xa7ff (size 0x8000) stack
   0xd8001000 - 0xd8001fff (size 0x1000) imx27-esdctl

 This seems valid to me... does anyone see anything missing?

 As to putting in some debug statements in the FEC driver, I put an
 enter and exit line in each function.  Startup gave me this:
 fec_probe enter
 fec_alloc_receive_packets enter
 fec_alloc_receive_packets exit
 fec_init enter
 fec_init exit
 mdio_bus: miibus0: probed
 fec_probe exit 0

 So that looks good I would think.

 The DHCP command as follows:
 dhcpenter
 warning: No MAC address set. Using random address 12:D4:85:77:78:E4
 fec_set_hwaddr enter
 fec_set_hwaddr exit
 fec_open enter
 fec_miibus_read enter
 fec_miibus_read exit
 ... more reads ... 
 fec_miibus_read enter
 fec_miibus_read exit
 fec_miibus_write enter
 fec_miibus_write exit
 fec_miibus_read enter
 fec_miibus_read exit
 fec_miibus_read enter
 fec_miibus_read exit
 fec_miibus_write enter
 fec_miibus_write exit
 fec_miibus_read enter
 fec_miibus_read exit
 fec_miibus_write enter
 fec_miibus_write exit
 fec_rbd_init enter
 fec_rbd_init exit
 fec_tbd_init enter
 fec_tbd_init exit
 fec_rx_task_enable enter
 fec_rx_task_enable exit
 fec_open exit
 fec_miibus_read enter
 fec_miibus_read exit

 this is followed by many more reads, until the output garbles:
 fec_miibus_read exit