[U-Boot] [PATCH 3/4] arm: debug: import debug files from Linux 3.16

Masahiro Yamada
2014-08-26T03:26:48Z

Hi Przemyslaw,

On Mon, 25 Aug 2014 11:03:13 +0200
Przemyslaw Marczak <p.marczak@samsung.com> wrote:

> Hello Masahiro,
> I tried to test this on Trats2(Exynos4412) with required files from the linux and the code doesn't build.
>
> On 08/17/2014 08:16 AM, Masahiro Yamada wrote:
> > U-Boot does not have arch/arm/kernel, include/uapi directories,
> > This commit copies files as follows:
> >
> > + .text
> > +
> > +/*
> > + * Some debugging routines (useful if you've got MM problems and
> > + * printk isn't working). For DEBUGGING ONLY!!! Do not leave
> > + * references to these in a production kernel!
> > + */
> > +
> > +#if !defined(CONFIG_DEBUG_SEMIHOSTING)
> > +#include CONFIG_DEBUG_LL_INCLUDE
> > +#endif
> > +
> > +#ifdef CONFIG_MMU
>
> This config: "CONFIG_MMU" is nowhere defined in the u-boot.

Yes, CONFIG_MMU is never defined in U-Boot,
therefore, the code inside #ifdef CONFIG_MMU ... #endif is never enabled.

> U-boot uses (n)def CONFIG_SYS_DCACHE_OFF - for enable/disable the mmu in ARM.

CONFIG_SYS_DCACHE_OFF has nothing to do with this debug function.

> But when I do the change like this:
> -#ifdef CONFIG_MMU
> +#ifndef CONFIG_SYS_DCACHE_OFF
>
> Then I got the data abort, after use a printch(). But without this change the printch() function works fine (after the uart init).

Please do not change this part.
On U-Boot, virt addr is always the same as phys addr,
so use the code for non CONFIG_MMU.

> > + .macro addruart_current, rx, tmp1, tmp2
> > + addruart \tmp1, \tmp2, \rx
> > + mrc p15, 0, \rx, c1, c0
> > + tst \rx, #1
> > + moveq \rx, \tmp1
> > + movne \rx, \tmp2
> > + .endm
> > +
> > +#else /* !CONFIG_MMU */
> > + .macro addruart_current, rx, tmp1, tmp2
> > + addruart \rx, \tmp1
> Generates build error:
> This asm macro: "addruart" gets 3 arguments but in this place got only two. After fix - works fine.
> It's strange, no one use this in the kernel before?

I guess you imported arch/arm/include/debug/exynos.S

In Linux, unfortunately, the number of arguments of this macro is different
between CONFIG_MMU and non CONFIG_MMU.

(Fox ex, addruart in arch/arm/include/debug/efm32.S in Linux gives only two arguments.)

Could you modify as follows and try it again, please?

--- a/arch/arm/lib/debug.S
+++ b/arch/arm/lib/debug.S
@@ -33,7 +33,7 @@

#else /* !CONFIG_MMU */
.macro addruart_current, rx, tmp1, tmp2
- addruart \rx, \tmp1
+ addruart \rx, \tmp1, \tmp2
.endm

#endif /* CONFIG_MMU */

If it works, I will post v2.

Best Regards
Masahiro Yamada

> And moreover I think that functions declarations are welcome for this code.
>
> Best regards,
> -- Przemyslaw Marczak
> Samsung R&D Institute Poland
> Samsung Electronics
> p.marczak at samsung.com