[U-Boot] [PATCH] Use memcpy in print_buffer to fix unaligned dumps

Wolfgang Denk wd at denx.de
Tue Jun 29 14:53:06 CEST 2010


Dear Anatolij Gustschin,

In message <1277815514-32120-1-git-send-email-agust at 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.


More information about the U-Boot mailing list