mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Peter Rosin <peda@axentia.se>
To: Sascha Hauer <s.hauer@pengutronix.de>, Ahmad Fatoum <ahmad@a3f.at>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 2/4] ARM: copy data if there is a region overlap
Date: Sat, 18 Sep 2021 00:39:46 +0200
Message-ID: <1ae69c03-3da5-4676-5d3b-612a8c5bf3a9@axentia.se> (raw)
In-Reply-To: <781e128b-14f3-3577-e433-f6a13fff8159@axentia.se>

This is a partial revert of patch
070de908da ("ARM: remove PBL_FORCE_PIGGYDATA_COPY")

Without this copy, my SAMA5D3 board fails to start.

Fixes: 070de908da ("ARM: remove PBL_FORCE_PIGGYDATA_COPY")
Signed-off-by: Peter Rosin <peda@axentia.se>
---
 arch/arm/cpu/uncompress.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/cpu/uncompress.c b/arch/arm/cpu/uncompress.c
index 2250b8ccd375..d725e7c2c34d 100644
--- a/arch/arm/cpu/uncompress.c
+++ b/arch/arm/cpu/uncompress.c
@@ -45,6 +45,7 @@ extern unsigned char input_data_end[];
 void __noreturn barebox_pbl_start(unsigned long membase, unsigned long memsize,
 				  void *boarddata)
 {
+	unsigned long offset;
 	uint32_t pg_len, uncompressed_len;
 	void __noreturn (*barebox)(unsigned long, unsigned long, void *);
 	unsigned long endmem = membase + memsize;
@@ -52,6 +53,9 @@ void __noreturn barebox_pbl_start(unsigned long membase, unsigned long memsize,
 	void *pg_start, *pg_end;
 	unsigned long pc = get_pc();
 
+	/* Get offset between linked address and runtime address */
+	offset = get_runtime_offset();
+
 	/* piggy data is not relocated, so determine the bounds now */
 	pg_start = input_data + global_variable_offset();
 	pg_end = input_data_end + global_variable_offset();
@@ -77,6 +81,14 @@ void __noreturn barebox_pbl_start(unsigned long membase, unsigned long memsize,
 	else
 		barebox_base = TEXT_BASE;
 
+	if (offset && old_region_overlap(pg_start, pg_len, barebox_base, pg_len * 4)) {
+		/*
+		 * copy piggydata binary to its link address
+		 */
+		memcpy(&input_data, (void *)pg_start, pg_len);
+		pg_start = (uint32_t)&input_data;
+	}
+
 	setup_c();
 
 	pr_debug("memory at 0x%08lx, size 0x%08lx\n", membase, memsize);
-- 
2.20.1



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


  parent reply	other threads:[~2021-09-17 22:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-17 22:37 at91 sama5d3 "regressions" Peter Rosin
2021-09-17 22:39 ` [PATCH 1/4] common.h: reintroduce region_overlap() as, old_region_overlap() Peter Rosin
2021-09-17 22:39 ` Peter Rosin [this message]
2021-09-17 22:40 ` [PATCH 3/4] Revert "ARM: mmu: use client domain permissions to support ARMv7 eXecute Never" Peter Rosin
2021-09-19  7:06   ` Rouven Czerwinski
2021-09-19  7:50     ` Peter Rosin
2021-09-19 20:33       ` Peter Rosin
2021-09-20  9:14       ` Ahmad Fatoum
2021-09-20 10:22         ` Peter Rosin
2021-09-17 22:41 ` [PATCH 4/4] lds: the RO_DATA_SECTION macro does not work on my SAMA5D3 board Peter Rosin
2021-09-17 23:57 ` at91 sama5d3 "regressions" Peter Rosin
2021-09-19  6:32   ` Peter Rosin
2021-09-22  7:06     ` Ahmad Fatoum
2021-09-22  7:41       ` Peter Rosin

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=1ae69c03-3da5-4676-5d3b-612a8c5bf3a9@axentia.se \
    --to=peda@axentia.se \
    --cc=ahmad@a3f.at \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.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

mail archive of the barebox mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lore.barebox.org/barebox/0 barebox/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 barebox barebox/ https://lore.barebox.org/barebox \
		barebox@lists.infradead.org barebox@lists.infradead.org
	public-inbox-index barebox

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git