[U-Boot] [PATCH] Use memcpy in print_buffer to fix unaligned dumps
Anatolij Gustschin
agust at denx.de
Tue Jun 29 14:45:14 CEST 2010
Unaligned 32-/16-bit accesses to local bus on MPC5200
and MPC512x deliver corrupted data:
=> md F0000000 10
f0000000: 27051956 552d426f 6f742032 3031302e '..VU-Boot 2010.
f0000010: 30362d72 63332d30 38303336 2d676665 06-rc3-08036-gfe
f0000020: 38663238 362d6469 72747920 284a756e 8f286-dirty (Jun
f0000030: 20323920 32303130 202d2031 343a3235 29 2010 - 14:25
=> md F0000001 10
f0000001: 00005655 00006f6f 00003230 00002e30 ..VU..oo..20...0
f0000011: 00007263 00003038 0000362d 00006538 ..rc..08..6-..e8
f0000021: 00003836 00006972 00002028 00006e20 ..86..ir.. (..n
f0000031: 00002032 00003020 00003134 0000353a .. 2..0 ..14..5:
=> md.w F0000001 20
f0000001: 0000 5655 0000 6f6f 0000 3230 0000 2e30 ..VU..oo..20...0
f0000011: 0000 7263 0000 3038 0000 362d 0000 6538 ..rc..08..6-..e8
f0000021: 0000 3836 0000 6972 0000 2028 0000 6e20 ..86..ir.. (..n
f0000031: 0000 2032 0000 3020 0000 3134 0000 353a .. 2..0 ..14..5:
Use memcpy in print_buffer() to fix the problem.
Signed-off-by: Anatolij Gustschin <agust at denx.de>
Cc: Wolfgang Denk <wd at denx.de>
Cc: Detlev Zundel <dzu at denx.de>
---
lib/display_options.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/lib/display_options.c b/lib/display_options.c
index a711425..c0b89b2 100644
--- a/lib/display_options.c
+++ b/lib/display_options.c
@@ -122,10 +122,24 @@ int print_buffer (ulong addr, void* data, uint width, uint count, uint linelen)
/* Copy from memory into linebuf and print hex values */
for (i = 0; i < linelen; i++) {
if (width == 4) {
+#if defined(CONFIG_MPC5200) || defined(CONFIG_MPC512X)
+ /*
+ * workaround for issues on the MPC5200/MPC512X,
+ * where unaligned 32-/16-bit-accesses to the
+ * local bus will deliver corrupted data. Just
+ * use fixed memcpy here.
+ */
+ memcpy(&uip[i], data, 4);
+#else
uip[i] = *(volatile uint32_t *)data;
+#endif
printf(" %08x", uip[i]);
} else if (width == 2) {
+#if defined(CONFIG_MPC5200) || defined(CONFIG_MPC512X)
+ memcpy(&usp[i], data, 2);
+#else
usp[i] = *(volatile uint16_t *)data;
+#endif
printf(" %04x", usp[i]);
} else {
ucp[i] = *(volatile uint8_t *)data;
--
1.7.0.4
More information about the U-Boot
mailing list