From: Wolfgang Denk Date: Tue, 29 Jun 2010 14:53:06 +0200 Subject: [U-Boot] [PATCH] Use memcpy in print_buffer to fix unaligned dumps In-Reply-To: <1277815514-32120-1-git-send-email-agust@denx.de> References: <1277804892-453-1-git-send-email-wd@denx.de> <1277815514-32120-1-git-send-email-agust@denx.de> Message-ID: <20100629125306.C3F7414EBF8@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Anatolij Gustschin, In message <1277815514-32120-1-git-send-email-agust@denx.de> you wrote: > Unaligned 32-/16-bit accesses to local bus on MPC5200 > and MPC512x deliver corrupted data: Right, and the current version of print_buffer() shopws the real data, i. e. you can see that such a corruption happens. > Use memcpy in print_buffer() to fix the problem. NAK. This violates the design of the command. > for (i = 0; i < linelen; i++) { > if (width == 4) { The "width == 4" part means that we want to access the memory with 32 bit accesses - nothing else. > +#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 If we would go this route, we could drop the #ifdef and always perform a memcpy(), but then we have absolutley no guarantee about which kind of accesses would be used. No, please leave as is - this part of U-Boot is working exactly as intended. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Be kind to unkind people - they need it the most.