mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Alexander Aring <alex.aring@gmail.com>
To: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: barebox <barebox@lists.infradead.org>
Subject: Re: [PATCH 04/10] at91: add test commamd to emulate bootrom boot
Date: Mon, 21 Jan 2013 12:04:19 +0100	[thread overview]
Message-ID: <CAB_54W5-9sNc7cdLWo_RHK0y7qinJP-0-gGVK9=6rwEtLuya7A@mail.gmail.com> (raw)
In-Reply-To: <1358764040-10690-4-git-send-email-plagnioj@jcrosoft.com>


[-- Attachment #1.1: Type: text/plain, Size: 4509 bytes --]

hi


2013/1/21 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  arch/arm/mach-at91/Kconfig         |    6 +++
>  arch/arm/mach-at91/Makefile        |    1 +
>  arch/arm/mach-at91/boot_test_cmd.c |   95
> ++++++++++++++++++++++++++++++++++++
>  3 files changed, 102 insertions(+)
>  create mode 100644 arch/arm/mach-at91/boot_test_cmd.c
>
> diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
> index 0fd9122..2815d5f 100644
> --- a/arch/arm/mach-at91/Kconfig
> +++ b/arch/arm/mach-at91/Kconfig
> @@ -485,6 +485,12 @@ config CMD_AT91MUX
>         bool "at91mux dump command"
>         default y
>
> +config CMD_AT91_BOOT_TEST
> +       bool "at91_boot_test"
> +       help
> +         allow to upload a boot binary to sram and execute it
> +         usefull to test bootstrap or barebox lowlevel init
> +
>  endif
>
>  endif
> diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
> index 53b4dd8..4404d23 100644
> --- a/arch/arm/mach-at91/Makefile
> +++ b/arch/arm/mach-at91/Makefile
> @@ -1,4 +1,5 @@
>  obj-y += setup.o clock.o gpio.o
> +obj-$(CONFIG_CMD_AT91_BOOT_TEST) += boot_test_cmd.o
>
>  lowlevel_init-y = at91sam926x_lowlevel_init.o
>  lowlevel_init-$(CONFIG_ARCH_AT91RM9200) = at91rm9200_lowlevel_init.o
> diff --git a/arch/arm/mach-at91/boot_test_cmd.c
> b/arch/arm/mach-at91/boot_test_cmd.c
> new file mode 100644
> index 0000000..90093d8
> --- /dev/null
> +++ b/arch/arm/mach-at91/boot_test_cmd.c
> @@ -0,0 +1,95 @@
> +/*
> + * Copyright (c) 2012 Jean-Christophe PLAGNIOL-VILLARD <
> plagnioj@jcrosoft.com>
> + *
> + * Under GPLv2 only
> + */
> +
> +#include <common.h>
> +#include <command.h>
> +#include <libbb.h>
> +#include <getopt.h>
> +#include <fs.h>
> +#include <fcntl.h>
> +#include <malloc.h>
> +#include <errno.h>
> +
> +static int do_at91_boot_test(int argc, char *argv[])
> +{
> +       int opt;
> +       u32 *buf32;
> +       void *buf;
> +       void (*jump)(void) = NULL;
> +       int fd;
> +       int ret = 1;
> +       char *sram = "/dev/sram0";
> +       u32 read_size, write_size;
> +       u32 tmp = 0;
> +
> +       while ((opt = getopt(argc, argv, "j:s:")) > 0) {
> +               switch (opt) {
> +               case 'j':
> +                       jump = (void*)simple_strtoul(optarg, NULL, 0);
> +                       break;
> +               case 's':
> +                       sram = optarg;
> +                       break;
> +               default:
> +                       return COMMAND_ERROR_USAGE;
> +               }
> +       }
> +
> +       if (argc < optind + 1)
> +               return COMMAND_ERROR_USAGE;
> +
> +       buf32 = buf = read_file(argv[optind], &read_size);
> +       if (!buf)
> +               return -EINVAL;
> +
> +       write_size = buf32[5];
> +
> +       printf("size of the size %d\n", read_size);
> +       printf("size to load in sram %d\n", write_size);
> +
> +       if (write_size > read_size) {
> +               printf("file smaller than requested sram loading size (%d
> < %d)\n", write_size, read_size);
> +               goto err;
> +       }
> +
> +       fd = open(sram, O_WRONLY);
> +       if (fd < 0) {
> +               printf("could not open %s: %s\n", sram, errno_str());
> +               ret = fd;
> +               goto err;
> +       }
> +
> +       while(write_size) {
>
while (foo)


> +               tmp = write(fd, buf, write_size);
> +               if (tmp < 0) {
> +                       perror("write");
> +                       goto err_open;
> +               }
> +               buf += tmp;
> +               write_size -= tmp;
> +       }
> +
> +       shutdown_barebox();
> +
> +       jump();
> +
> +err_open:
> +       close(fd);
> +err:
> +       free(buf);
> +       return ret;
> +}
> +
> +BAREBOX_CMD_HELP_START(at91_boot_test)
> +BAREBOX_CMD_HELP_USAGE("at91_boot_test [-j <jump addr>] [-s <sram>]
> file\n")
> +BAREBOX_CMD_HELP_SHORT("upload the binary to sram and jump as will do the
> romcode\n")
> +BAREBOX_CMD_HELP_END
> +
> +BAREBOX_CMD_START(at91_boot_test)
> +       .cmd            = do_at91_boot_test,
> +       .usage          = "upload the binary to sram and jump as will do
> the romcode",
> +       BAREBOX_CMD_HELP(cmd_at91_boot_test_help)
> +BAREBOX_CMD_END
> --
> 1.7.10.4
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>

[-- Attachment #1.2: Type: text/html, Size: 6220 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

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

  reply	other threads:[~2013-01-21 11:05 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-21 10:23 [PATCH 00/10 v5] at91: add bootstrap support Jean-Christophe PLAGNIOL-VILLARD
2013-01-21 10:27 ` [PATCH 01/10] filetype: add is_barebox_mips_head support Jean-Christophe PLAGNIOL-VILLARD
2013-01-21 10:27   ` [PATCH 02/10] filetype: add is_barebox_head Jean-Christophe PLAGNIOL-VILLARD
2013-01-21 10:27   ` [PATCH 03/10] at91: dump mux command: make it depends on COMMAND_SUPPORT Jean-Christophe PLAGNIOL-VILLARD
2013-01-21 10:27   ` [PATCH 04/10] at91: add test commamd to emulate bootrom boot Jean-Christophe PLAGNIOL-VILLARD
2013-01-21 11:04     ` Alexander Aring [this message]
2013-01-21 10:27   ` [PATCH 05/10] at91sam926x: lowlevel add external boot support Jean-Christophe PLAGNIOL-VILLARD
2013-01-21 10:27   ` [PATCH 06/10] at91: sam926x: switch lowlevel param to c code Jean-Christophe PLAGNIOL-VILLARD
2013-01-21 10:27   ` [PATCH 07/10] at91: usb-a9263 add lowlevel init Jean-Christophe PLAGNIOL-VILLARD
2013-01-21 10:27   ` [PATCH 08/10] introduce common bootstrap code Jean-Christophe PLAGNIOL-VILLARD
2013-01-21 11:04     ` Alexander Aring
2013-01-21 12:51       ` Sascha Hauer
2013-01-21 13:09         ` Alexander Aring
2013-01-21 13:59         ` Jean-Christophe PLAGNIOL-VILLARD
2013-01-21 14:26           ` Jean-Christophe PLAGNIOL-VILLARD
2013-01-21 10:27   ` [PATCH 09/10] at91: add bootstrap version Jean-Christophe PLAGNIOL-VILLARD
2013-01-21 10:27   ` [PATCH 10/10] at91: usb_a9263: " Jean-Christophe PLAGNIOL-VILLARD
2013-01-21 14:28 [PATCH 00/10 v6] at91: add bootstrap support Jean-Christophe PLAGNIOL-VILLARD
2013-01-21 14:33 ` [PATCH 01/10] filetype: add is_barebox_mips_head support Jean-Christophe PLAGNIOL-VILLARD
2013-01-21 14:33   ` [PATCH 04/10] at91: add test commamd to emulate bootrom boot Jean-Christophe PLAGNIOL-VILLARD
2013-01-22  8:12     ` Sascha Hauer
2013-01-22 14:38 [PATCH 00/10 v7] at91: add bootstrap support Jean-Christophe PLAGNIOL-VILLARD
2013-01-22 14:40 ` [PATCH 01/10] filetype: add is_barebox_mips_head support Jean-Christophe PLAGNIOL-VILLARD
2013-01-22 14:40   ` [PATCH 04/10] at91: add test commamd to emulate bootrom boot Jean-Christophe PLAGNIOL-VILLARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAB_54W5-9sNc7cdLWo_RHK0y7qinJP-0-gGVK9=6rwEtLuya7A@mail.gmail.com' \
    --to=alex.aring@gmail.com \
    --cc=barebox@lists.infradead.org \
    --cc=plagnioj@jcrosoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox