All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/5] cmd: mvebu: bubt: Add support for legacy Marvell SoCs
Date: Wed, 19 Sep 2018 15:13:05 +0200	[thread overview]
Message-ID: <0cfbf871-dcc8-1d91-559a-264333d477b8@denx.de> (raw)
In-Reply-To: <1535549696-17222-5-git-send-email-kostap@marvell.com>

On 29.08.2018 15:34, kostap at marvell.com wrote:
> From: Konstantin Porotchkin <kostap@marvell.com>
> 
> Add support for image load and basic verification in bubt
> for legacy Marvell SoCs (A38x, A39x, ...)
> 
> Signed-off-by: Konstantin Porotchkin <kostap@marvell.com>
> Cc: Igal Liberman <igall@marvell.com>
> Cc: Stefan Roese <sr@denx.de>
> ---
>   cmd/mvebu/bubt.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
>   1 file changed, 72 insertions(+), 3 deletions(-)
> 
> diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c
> index b4d371f..e10d079 100644
> --- a/cmd/mvebu/bubt.c
> +++ b/cmd/mvebu/bubt.c
> @@ -83,6 +83,33 @@ struct mvebu_image_info {
>   	u32	encrypt_start_offset;
>   	u32	encrypt_size;
>   };
> +
> +#else /* Older Armada SoCs - A38x, A39x, ... */
> +
> +#define	LEGACY_HDR_VERSION	1
> +
> +struct legacy_image_header {
> +/*	type	name			byte order */
> +	u8	block_id;		/*   0   */
> +	u8	flags;			/*   1   */
> +	u16	nand_pge_size;		/*  2-3  */
> +	u32	block_size;		/*  4-7  */
> +	u8	version;		/*   8   */
> +	u8	hdr_size_msb;		/*   9   */
> +	u16	hdr_size_lsb;		/* 10-11 */
> +	u32	source_addr;		/* 12-15 */
> +	u32	destination_addr;	/* 16-19 */
> +	u32	execution_addr;		/* 20-23 */
> +	u8	options;		/*  24   */
> +	u8	nand_block_size;	/*  25   */
> +	u8	nand_technology;	/*  26   */
> +	u8	rsvd4;			/*  27   */
> +	u16	rsvd2;			/* 28-29 */
> +	u8	ext;			/*  30   */
> +	u8	checksum;		/*  31   */
> +
> +};
> +
>   #endif /* CONFIG_ARMADA_XXX */
>   
>   struct bubt_dev {
> @@ -618,11 +645,53 @@ static int check_image_header(void)
>   	return 0;
>   }
>   
> -#else /* Not ARMADA? */
> +#else /* Legacy SoCs */
> +u8 do_checksum8(u8 *start, u32 len)
> +{
> +	u8 sum = 0;
> +	u8 *startp = start;
> +
> +	do {
> +		sum += *startp;
> +		startp++;
> +	} while (--len);
> +
> +	return sum;
> +}
> +
>   static int check_image_header(void)
>   {
> -	printf("bubt cmd does not support this SoC device or family!\n");
> -	return -ENOEXEC;
> +	struct legacy_image_header *hdr =
> +			(struct legacy_image_header *)get_load_addr();
> +	u32 header_len = hdr->hdr_size_lsb + (hdr->hdr_size_msb << 16);
> +	u8 checksum;
> +	u8 checksum_ref = hdr->checksum;
> +
> +	/*
> +	 * For now compare checksum, and header version. Later we can
> +	 * verify more stuff on the header like interface type, etc
> +	 */
> +	if (hdr->version != LEGACY_HDR_VERSION) {
> +		printf("ERROR: Bad HDR Version 0x%x != 0x%x\n",
> +		       hdr->version, LEGACY_HDR_VERSION);
> +		return -ENOEXEC;
> +	}
> +
> +	/* The checksum value is discarded from checksum calculation */
> +	hdr->checksum = 0;
> +
> +	checksum = do_checksum8((u8 *)hdr, header_len);
> +	if (checksum != checksum_ref) {
> +		printf("Error: Bad Image checksum. 0x%x != 0x%x\n",
> +		       checksum, checksum_ref);
> +		return -ENOEXEC;
> +	}
> +
> +	/* Restore the checksum before writing */
> +	hdr->checksum = checksum_ref;
> +	printf("Image checksum...OK!\n");
> +
> +	return 0;
>   }
>   #endif
>   
> 

Dropped for now, as a result of your discussion in this thread.

Thanks,
Stefan

  parent reply	other threads:[~2018-09-19 13:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-29 13:34 [U-Boot] [PATCH 0/5] Fixes to Marvell A38x platforms kostap at marvell.com
2018-08-29 13:34 ` [U-Boot] [PATCH 1/5] fix: env: Fix the SPI flash device setup for DM mode kostap at marvell.com
2018-09-19 13:11   ` Stefan Roese
2018-11-20 14:31   ` Adam Ford
2018-08-29 13:34 ` [U-Boot] [PATCH 2/5] fix: mvebu: Add SPI parameters for environment setup kostap at marvell.com
2018-09-19 13:12   ` Stefan Roese
2018-08-29 13:34 ` [U-Boot] [PATCH 3/5] fix: cmd: mvebu: Eclude mvebu commands from SPL builds kostap at marvell.com
2018-09-19 13:12   ` Stefan Roese
2018-08-29 13:34 ` [U-Boot] [PATCH 4/5] cmd: mvebu: bubt: Add support for legacy Marvell SoCs kostap at marvell.com
2018-08-29 14:27   ` Jon Nettleton
2018-08-29 14:34     ` [U-Boot] [EXT] " Kostya Porotchkin
2018-09-19 13:13   ` Stefan Roese [this message]
2018-08-29 13:34 ` [U-Boot] [PATCH 5/5] defconfig: db-88f6820-gp: Add bubt command to the build kostap at marvell.com
2018-09-19 13:13   ` Stefan Roese

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=0cfbf871-dcc8-1d91-559a-264333d477b8@denx.de \
    --to=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.