mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Trent Piepho <trent.piepho@igorinstitute.com>
To: Barebox List <barebox@lists.infradead.org>
Cc: Yunus Bas <Y.Bas@phytec.de>,
	Trent Piepho <trent.piepho@igorinstitute.com>
Subject: [PATCH 2/3] imx-bbu-nand-fcb: Save bootloader location into device parameters
Date: Mon, 11 Oct 2021 18:53:58 -0700	[thread overview]
Message-ID: <20211012015359.933464-2-trent.piepho@igorinstitute.com> (raw)
In-Reply-To: <20211012015359.933464-1-trent.piepho@igorinstitute.com>

When updating the FCB, save the location and size of the Barebox images
into parameters on the NAND device.  Since the location and padding is
calculated based on net NAND partition size, with an unknown number of
bad blocks, these values aren't known beforehard.  Saving them will
allow extracting or checksumming the Barebox image in NAND.

For example:
sha256sum /dev/nand0.barebox ${nand0.barebox.firmware1_addr}+${nand0.barebox.firmware1_size}
memcpy -s /dev/nand0.barebox -d /mnt/mmc0.0/imagedump ${nand0.barebox.firmware2_addr} 0 ${nand0.barebox.firmware2_size}

Find sum of Barebox image file with NUL padding to NAND page size (4kB
here) in Linux:
dd if=barebox-myboard.img ibs=4k conv=sync | sha256sum

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
---
 common/imx-bbu-nand-fcb.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/common/imx-bbu-nand-fcb.c b/common/imx-bbu-nand-fcb.c
index 7108a327a..76ac1d4f2 100644
--- a/common/imx-bbu-nand-fcb.c
+++ b/common/imx-bbu-nand-fcb.c
@@ -227,6 +227,15 @@ static uint32_t calc_chksum(void *buf, size_t size)
 	return ~chksum;
 }
 
+/* Set parameters on the device with the firmware location and size */
+static void set_dev_params(struct cdev *cdev, const struct fcb_block *fcb)
+{
+	dev_add_param_uint32_fixed(cdev->dev, "firmware1_addr", fcb->Firmware1_startingPage * fcb->PageDataSize, "0x%08x");
+	dev_add_param_uint32_fixed(cdev->dev, "firmware2_addr", fcb->Firmware2_startingPage * fcb->PageDataSize, "0x%08x");
+	dev_add_param_uint32_fixed(cdev->dev, "firmware1_size", fcb->PagesInFirmware1 * fcb->PageDataSize, "0x%08x");
+	dev_add_param_uint32_fixed(cdev->dev, "firmware2_size", fcb->PagesInFirmware2 * fcb->PageDataSize, "0x%08x");
+}
+
 static struct fcb_block *read_fcb_hamming_13_8(void *rawpage)
 {
 	int i;
@@ -1363,6 +1372,8 @@ static int imx_bbu_nand_update(struct bbu_handler *handler, struct bbu_data *dat
 			goto out;
 	}
 
+	set_dev_params(bcb_cdev, fcb);
+
 out:
 	free(fw);
 	free(fcb);
-- 
2.31.1


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


  reply	other threads:[~2021-10-12  1:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-12  1:53 [PATCH 1/3] imx-bbu-nand-fcb: Show additional information from decoded FCB Trent Piepho
2021-10-12  1:53 ` Trent Piepho [this message]
2021-10-12  8:11   ` [PATCH 2/3] imx-bbu-nand-fcb: Save bootloader location into device parameters Sascha Hauer
2021-10-12  1:53 ` [PATCH 3/3] imx-bbu-nand-fcb: Add command to help debug FCB issues Trent Piepho
2021-10-12  8:21   ` Sascha Hauer
2021-10-13 10:14     ` Trent Piepho
2021-10-14 12:09       ` Sascha Hauer

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=20211012015359.933464-2-trent.piepho@igorinstitute.com \
    --to=trent.piepho@igorinstitute.com \
    --cc=Y.Bas@phytec.de \
    --cc=barebox@lists.infradead.org \
    /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