Skip to contentSkip to conversation

Introduce low-level debug for ARM architecture

PATCH New Masahiro Yamada 5 participants 13 messages Aug 17, 2014 – Aug 27, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Introduce low-level debug for ARM architecture

I have been in trouble for a while to debug some nasty problem where neighter a debugger nor printf() function is available.

I found the lowlevel debug feature in ARM Linux can be used as is in U-Boot too.

I tested this series on our SoCs (32bit ARM, specificly Coretex-A9). Because I was not sure about aarch64, I have this feature depend on "! ARM64".

1/4 and 2/4 refactor a bit and move CONFIG_ARM64 to Kconfig.

3/4 imports some source files from Linux 3.16 and
4/4 adds the Kconfig menu.

Masahiro Yamada (4):
vexpress64: kconfig: consolidate CONFIG_TARGET_VEXPRESS_AEMV8A_SEMI
kconfig: armv8: move CONFIG_ARM64 to Kconfig
arm: debug: import debug files from Linux 3.16
arm: debug: add Kconfig entries for lowlevel debug

 arch/arm/Kconfig                       |  13 +-
 arch/arm/Kconfig.debug                 |  64 ++++++
 arch/arm/cpu/armv8/Kconfig             |   7 +
 arch/arm/include/debug/8250.S          |  54 +++++
 arch/arm/lib/Makefile                  |   2 +
 arch/arm/lib/debug.S                   | 138 ++++++++++++
 board/armltd/vexpress64/Kconfig        |  24 --
 board/freescale/ls2085a/Kconfig        |   8 -
 configs/ls2085a_emu_D4_defconfig       |   2 +-
 configs/ls2085a_emu_defconfig          |   2 +-
 configs/ls2085a_simu_defconfig         |   2 +-
 configs/vexpress_aemv8a_defconfig      |   1 -
 configs/vexpress_aemv8a_semi_defconfig |   4 +-
 include/linux/serial_reg.h             | 389 +++++++++++++++++++++++++++++++++
 14 files changed, 669 insertions(+), 41 deletions(-)
 create mode 100644 arch/arm/Kconfig.debug
 create mode 100644 arch/arm/cpu/armv8/Kconfig
 create mode 100644 arch/arm/include/debug/8250.S
 create mode 100644 arch/arm/lib/debug.S
 create mode 100644 include/linux/serial_reg.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/4 vexpress64: kconfig: consolidate CONFIG_TARGET_VEXPRESS_AEMV8A_SEMI

We do not have to distinguish CONFIG_TARGET_VEXPRESS_AEMV8A_SEMI from CONFIG_TARGET_VEXPRESS_AEMV8A. Rename the former to the latter.

Cc David Feng <[email protected]>
Cc Steve Rae <[email protected]>

---

 arch/arm/Kconfig                       |  3 ---
 board/armltd/vexpress64/Kconfig        | 20 --------------------
 configs/vexpress_aemv8a_semi_defconfig |  2 +-
 3 files changed, 1 insertion(+), 24 deletions(-)
arch/arm/Kconfig +0 -3
index e97f94d..2bd19b8 100644
@@ -719,9 +719,6 @@ config TARGET_VENICE2
 config TARGET_VEXPRESS_AEMV8A
 	bool "Support vexpress_aemv8a"
 
-config TARGET_VEXPRESS_AEMV8A_SEMI
-	bool "Support vexpress_aemv8a_semi"
-
 config TARGET_LS2085A_EMU
 	bool "Support ls2085a_emu"
 
board/armltd/vexpress64/Kconfig +0 -20
index 91eb8d2..d8c4e21 100644
@@ -17,23 +17,3 @@ config SYS_CONFIG_NAME
 	default "vexpress_aemv8a"
 
 endif
-
-if TARGET_VEXPRESS_AEMV8A_SEMI
-
-config SYS_CPU
-	string
-	default "armv8"
-
-config SYS_BOARD
-	string
-	default "vexpress64"
-
-config SYS_VENDOR
-	string
-	default "armltd"
-
-config SYS_CONFIG_NAME
-	string
-	default "vexpress_aemv8a"
-
-endif
configs/vexpress_aemv8a_semi_defconfig +1 -1
index e6dd8e7..24b868c 100644
@@ -1,3 +1,3 @@
 CONFIG_SYS_EXTRA_OPTIONS="ARM64,SEMIHOSTING,BASE_FVP"
 CONFIG_ARM=y
-CONFIG_TARGET_VEXPRESS_AEMV8A_SEMI=y
+CONFIG_TARGET_VEXPRESS_AEMV8A=y
Signature · 1 line
1.9.1
#2 lore raw

PATCH 1/4 vexpress64: kconfig: consolidate CONFIG_TARGET_VEXPRESS_AEMV8A_SEMI

Thanks, Steve

Quoted 66 lines · Masahiro Yamada

We do not have to distinguish CONFIG_TARGET_VEXPRESS_AEMV8A_SEMI from CONFIG_TARGET_VEXPRESS_AEMV8A. Rename the former to the latter.

Cc David Feng <[email protected]>
Cc Steve Rae <[email protected]>

---

  arch/arm/Kconfig                       |  3 ---
  board/armltd/vexpress64/Kconfig        | 20 --------------------
  configs/vexpress_aemv8a_semi_defconfig |  2 +-
  3 files changed, 1 insertion(+), 24 deletions(-)
arch/arm/Kconfig +0 -3
index e97f94d..2bd19b8 100644
@@ -719,9 +719,6 @@ config TARGET_VENICE2
  config TARGET_VEXPRESS_AEMV8A
  	bool "Support vexpress_aemv8a"
 
-config TARGET_VEXPRESS_AEMV8A_SEMI
-	bool "Support vexpress_aemv8a_semi"
-
  config TARGET_LS2085A_EMU
  	bool "Support ls2085a_emu"
 
board/armltd/vexpress64/Kconfig +0 -20
index 91eb8d2..d8c4e21 100644
@@ -17,23 +17,3 @@ config SYS_CONFIG_NAME
  	default "vexpress_aemv8a"
 
  endif
-
-if TARGET_VEXPRESS_AEMV8A_SEMI
-
-config SYS_CPU
-	string
-	default "armv8"
-
-config SYS_BOARD
-	string
-	default "vexpress64"
-
-config SYS_VENDOR
-	string
-	default "armltd"
-
-config SYS_CONFIG_NAME
-	string
-	default "vexpress_aemv8a"
-
-endif
configs/vexpress_aemv8a_semi_defconfig +1 -1
index e6dd8e7..24b868c 100644
@@ -1,3 +1,3 @@
  CONFIG_SYS_EXTRA_OPTIONS="ARM64,SEMIHOSTING,BASE_FVP"
  CONFIG_ARM=y
-CONFIG_TARGET_VEXPRESS_AEMV8A_SEMI=y
+CONFIG_TARGET_VEXPRESS_AEMV8A=y
#3 lore raw

PATCH 2/4 kconfig: armv8: move CONFIG_ARM64 to Kconfig

In reply to Masahiro Yamada

---

 arch/arm/Kconfig                       | 8 ++++++++
 arch/arm/cpu/armv8/Kconfig             | 7 +++++++
 board/armltd/vexpress64/Kconfig        | 4 ----
 board/freescale/ls2085a/Kconfig        | 8 --------
 configs/ls2085a_emu_D4_defconfig       | 2 +-
 configs/ls2085a_emu_defconfig          | 2 +-
 configs/ls2085a_simu_defconfig         | 2 +-
 configs/vexpress_aemv8a_defconfig      | 1 -
 configs/vexpress_aemv8a_semi_defconfig | 2 +-
 9 files changed, 19 insertions(+), 17 deletions(-)
 create mode 100644 arch/arm/cpu/armv8/Kconfig
arch/arm/Kconfig +8 -0
index 2bd19b8..3c712bb 100644
@@ -5,6 +5,9 @@ config SYS_ARCH
 	string
 	default "arm"
 
+config ARM64
+	bool
+
 choice
 	prompt "Target select"
 
@@ -718,12 +721,15 @@ config TARGET_VENICE2
 
 config TARGET_VEXPRESS_AEMV8A
 	bool "Support vexpress_aemv8a"
+	select ARM64
 
 config TARGET_LS2085A_EMU
 	bool "Support ls2085a_emu"
+	select ARM64
 
 config TARGET_LS2085A_SIMU
 	bool "Support ls2085a_simu"
+	select ARM64
 
 config TARGET_BALLOON3
 	bool "Support balloon3"
@@ -766,6 +772,8 @@ config TARGET_JORNADA
 
 endchoice
 
+source "arch/arm/cpu/armv8/Kconfig"
+
 source "board/8dtech/eco5pk/Kconfig"
 source "board/Barix/ipam390/Kconfig"
 source "board/BuR/kwb/Kconfig"
arch/arm/cpu/armv8/Kconfig new file +7 -0
new file mode 100644
index 0000000..af6a457
@@ -0,0 +1,7 @@
+if ARM64
+
+config SYS_CPU
+	string
+	default "armv8"
+
+endif
board/armltd/vexpress64/Kconfig +0 -4
index d8c4e21..519c544 100644
@@ -1,9 +1,5 @@
 if TARGET_VEXPRESS_AEMV8A
 
-config SYS_CPU
-	string
-	default "armv8"
-
 config SYS_BOARD
 	string
 	default "vexpress64"
board/freescale/ls2085a/Kconfig +0 -8
index 5655e18..f33ebcb 100644
@@ -1,9 +1,5 @@
 if TARGET_LS2085A_EMU
 
-config SYS_CPU
-	string
-	default "armv8"
-
 config SYS_BOARD
 	string
 	default "ls2085a"
@@ -24,10 +20,6 @@ endif
 
 if TARGET_LS2085A_SIMU
 
-config SYS_CPU
-	string
-	default "armv8"
-
 config SYS_BOARD
 	string
 	default "ls2085a"
configs/ls2085a_emu_D4_defconfig +1 -1
index f2f6882..0bc36ed 100644
@@ -1,3 +1,3 @@
-CONFIG_SYS_EXTRA_OPTIONS="ARM64,EMU,SYS_FSL_DDR4"
+CONFIG_SYS_EXTRA_OPTIONS="EMU,SYS_FSL_DDR4"
 CONFIG_ARM=y
 CONFIG_TARGET_LS2085A_EMU=y
configs/ls2085a_emu_defconfig +1 -1
index 51ffa56..a2efec3 100644
@@ -1,3 +1,3 @@
-CONFIG_SYS_EXTRA_OPTIONS="ARM64,EMU"
+CONFIG_SYS_EXTRA_OPTIONS="EMU"
 CONFIG_ARM=y
 CONFIG_TARGET_LS2085A_EMU=y
configs/ls2085a_simu_defconfig +1 -1
index efa8e74..7563a75 100644
@@ -1,3 +1,3 @@
-CONFIG_SYS_EXTRA_OPTIONS="ARM64,SIMU"
+CONFIG_SYS_EXTRA_OPTIONS="SIMU"
 CONFIG_ARM=y
 CONFIG_TARGET_LS2085A_SIMU=y
configs/vexpress_aemv8a_defconfig +0 -1
index a335abc..9e0a175 100644
@@ -1,3 +1,2 @@
-CONFIG_SYS_EXTRA_OPTIONS="ARM64"
 CONFIG_ARM=y
 CONFIG_TARGET_VEXPRESS_AEMV8A=y
configs/vexpress_aemv8a_semi_defconfig +1 -1
index 24b868c..8fdf4e0 100644
@@ -1,3 +1,3 @@
-CONFIG_SYS_EXTRA_OPTIONS="ARM64,SEMIHOSTING,BASE_FVP"
+CONFIG_SYS_EXTRA_OPTIONS="SEMIHOSTING,BASE_FVP"
 CONFIG_ARM=y
 CONFIG_TARGET_VEXPRESS_AEMV8A=y
Signature · 1 line
1.9.1
#4 lore raw

PATCH 3/4 arm: debug: import debug files from Linux 3.16

In reply to Masahiro Yamada

U-Boot does not have arch/arm/kernel, include/uapi directories, This commit copies files as follows:

Location in Linux -> Location in U-Boot

arch/arm/kernel/debug.S -> arch/arm/lib/debug.S
arch/arm/include/debug/8250.S -> arch/arm/include/debug/8250.S
include/uapi/linux/serial_reg.h -> include/linux/serial_reg.h

---

 arch/arm/include/debug/8250.S |  54 ++++++
 arch/arm/lib/debug.S          | 138 +++++++++++++++
 include/linux/serial_reg.h    | 389 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 581 insertions(+)
 create mode 100644 arch/arm/include/debug/8250.S
 create mode 100644 arch/arm/lib/debug.S
 create mode 100644 include/linux/serial_reg.h
arch/arm/include/debug/8250.S new file +54 -0
new file mode 100644
index 0000000..7a2baf9
@@ -0,0 +1,54 @@
+/*
+ * arch/arm/include/debug/8250.S
+ *
+ *  Copyright (C) 1994-2013 Russell King
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/serial_reg.h>
+
+		.macro	addruart, rp, rv, tmp
+		ldr	\rp, =CONFIG_DEBUG_UART_PHYS
+		ldr	\rv, =CONFIG_DEBUG_UART_VIRT
+		.endm
+
+#ifdef CONFIG_DEBUG_UART_8250_WORD
+		.macro	store, rd, rx:vararg
+		str	\rd, \rx
+		.endm
+
+		.macro	load, rd, rx:vararg
+		ldr	\rd, \rx
+		.endm
+#else
+		.macro	store, rd, rx:vararg
+		strb	\rd, \rx
+		.endm
+
+		.macro	load, rd, rx:vararg
+		ldrb	\rd, \rx
+		.endm
+#endif
+
+#define UART_SHIFT CONFIG_DEBUG_UART_8250_SHIFT
+
+		.macro	senduart,rd,rx
+		store	\rd, [\rx, #UART_TX << UART_SHIFT]
+		.endm
+
+		.macro	busyuart,rd,rx
+1002:		load	\rd, [\rx, #UART_LSR << UART_SHIFT]
+		and	\rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE
+		teq	\rd, #UART_LSR_TEMT | UART_LSR_THRE
+		bne	1002b
+		.endm
+
+		.macro	waituart,rd,rx
+#ifdef CONFIG_DEBUG_UART_8250_FLOW_CONTROL
+1001:		load	\rd, [\rx, #UART_MSR << UART_SHIFT]
+		tst	\rd, #UART_MSR_CTS
+		beq	1001b
+#endif
+		.endm
arch/arm/lib/debug.S new file +138 -0

138 lines not on this page · raw message

include/linux/serial_reg.h new file +389 -0

389 lines not on this page · raw message

Signature · 1 line
1.9.1
#5 lore raw

PATCH 3/4 arm: debug: import debug files from Linux 3.16

Hi Masahiro!

Quoted 10 lines · Masahiro Yamada

U-Boot does not have arch/arm/kernel, include/uapi directories, This commit copies files as follows:

   Location in Linux               -> Location in U-Boot

   arch/arm/kernel/debug.S         -> arch/arm/lib/debug.S
   arch/arm/include/debug/8250.S   -> arch/arm/include/debug/8250.S
   include/uapi/linux/serial_reg.h -> include/linux/serial_reg.h

Nice! I have quite often found myself also in the need of an very early serial debug output functionality. Thanks for this series. One comment below:

Quoted 16 lines

---

  arch/arm/include/debug/8250.S |  54 ++++++
  arch/arm/lib/debug.S          | 138 +++++++++++++++
  include/linux/serial_reg.h    | 389 ++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 581 insertions(+)

create mode 100644 arch/arm/include/debug/8250.S create mode 100644 arch/arm/lib/debug.S create mode 100644 include/linux/serial_reg.h

arch/arm/include/debug/8250.S new file +0 -0
new file mode 100644
index 0000000..7a2baf9

arch/arm/include/debug/8250.S line 8

Quoted 8 lines
arch/arm/include/debug/8250.S new file +8 -0
@@ -0,0 +1,54 @@
+/*
+ * arch/arm/include/debug/8250.S
+ *
+ *  Copyright (C) 1994-2013 Russell King
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.

Please use SPDX license identifiers instead. Please fix this globally.

Thanks,
Stefan

#7 lore raw

PATCH 3/4 arm: debug: import debug files from Linux 3.16

In reply to Masahiro Yamada

Hello Masahiro,
I tried to test this on Trats2(Exynos4412) with required files from the linux and the code doesn't build.

Quoted 36 lines · Masahiro Yamada

U-Boot does not have arch/arm/kernel, include/uapi directories, This commit copies files as follows:

   Location in Linux               -> Location in U-Boot

   arch/arm/kernel/debug.S         -> arch/arm/lib/debug.S
   arch/arm/include/debug/8250.S   -> arch/arm/include/debug/8250.S
   include/uapi/linux/serial_reg.h -> include/linux/serial_reg.h

---

arch/arm/lib/debug.S new file +17 -0
new file mode 100644
index 0000000..14f7c3b
@@ -0,0 +1,138 @@
+/*
+ *  linux/arch/arm/kernel/debug.S
+ *
+ *  Copyright (C) 1994-1999 Russell King
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ *  32-bit debugging code
+ */
+#include <linux/linkage.h>
+#include <asm/assembler.h>
+
+		.text
+
+/*

arch/arm/lib/debug.S line 27

Quoted 10 lines
arch/arm/lib/debug.S new file +10 -0
+ * 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. U-boot uses (n)def CONFIG_SYS_DCACHE_OFF - for enable/disable the mmu in ARM.

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).

arch/arm/lib/debug.S line 38

Quoted 11 lines
arch/arm/lib/debug.S new file +11 -0
+		.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?

And moreover I think that functions declarations are welcome for this code.

Best regards,

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#8 lore raw

PATCH 3/4 arm: debug: import debug files from Linux 3.16

Hi Przemyslaw,

Quoted 7 lines · On Mon, 25 Aug 2014 11:03:13 +0200 Przemyslaw Marczak <[email protected]>…

Hello Masahiro,
I tried to test this on Trats2(Exynos4412) with required files from the linux and the code doesn't build.

Quoted 3 lines · Masahiro Yamada

U-Boot does not have arch/arm/kernel, include/uapi directories, This commit copies files as follows:

Quoted 15 lines

arch/arm/lib/debug.S line 27

Quoted 13 lines
arch/arm/lib/debug.S new file +13 -0
+		.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.

Quoted 1 line

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.

Quoted 5 lines

But when I do the change like this:

(quoted diff) +1 -1
-#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.

Quoted 6 lines
Quoted 6 lines
arch/arm/lib/debug.S new file +6 -0
+		.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
Quoted 8 lines

arch/arm/lib/debug.S line 38

Quoted 5 lines
arch/arm/lib/debug.S new file +5 -0
+		.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

Quoted 7 lines

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

#9 lore raw

PATCH 3/4 arm: debug: import debug files from Linux 3.16

Hello Masahiro,

Quoted 43 lines · Masahiro Yamada

Hi Przemyslaw,

Quoted 7 lines · On Mon, 25 Aug 2014 11:03:13 +0200 Przemyslaw Marczak <[email protected]>…

Hello Masahiro,
I tried to test this on Trats2(Exynos4412) with required files from the linux and the code doesn't build.

Quoted 3 lines · Masahiro Yamada

U-Boot does not have arch/arm/kernel, include/uapi directories, This commit copies files as follows:

Quoted 15 lines

arch/arm/lib/debug.S line 27

Quoted 13 lines
arch/arm/lib/debug.S new file +13 -0
+		.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.

Quoted 1 line

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.

Quoted 4 lines

But when I do the change like this:

(quoted diff) +1 -1
-#ifdef CONFIG_MMU
+#ifndef CONFIG_SYS_DCACHE_OFF
Quoted 5 lines
Quoted 1 line

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.

Ok, I see.

Quoted 34 lines
Quoted 17 lines
Quoted 4 lines
arch/arm/lib/debug.S new file +1 -0
+		.macro	addruart_current, rx, tmp1, tmp2

arch/arm/lib/debug.S line 38

Quoted 10 lines
arch/arm/lib/debug.S new file +10 -0
+		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?

Quoted 8 lines

--- 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

Yes, I fixed it by the same way before and it works fine with that change.

Quoted 7 lines

.endm

   #endif /* CONFIG_MMU */
Quoted 15 lines

If it works, I will post v2.

Best Regards
Masahiro Yamada

Quoted 7 lines

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

Best Regards,

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#10 lore raw

PATCH 4/4 arm: debug: add Kconfig entries for lowlevel debug

In reply to Masahiro Yamada

We have not had a good method to debug the early boot stage such as lowlevel_init function. I guess developers generally use dedicated debuggers for that, but it is difficult in some cases. (For example, my debugger cannot connect to the ARM processor when it is in the secure state. It sometimes happens when I need to debug the early boot stage on ARM SoCs with secure extension.)

The low level debug feature in Linux would be also helpful for U-boot when we are stucking in nasty problems where the console is not available yet.

You have to enable CONFIG_DEBUG_LL to use this feature. For now, only 8250-compatible UART devices are supported. You can add a header file under arch/arm/include/debug/ directory to support your UART device if necessary.

---

 arch/arm/Kconfig       |  2 ++
 arch/arm/Kconfig.debug | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/lib/Makefile  |  2 ++
 3 files changed, 68 insertions(+)
 create mode 100644 arch/arm/Kconfig.debug
arch/arm/Kconfig +2 -0
index 3c712bb..8984685 100644
@@ -1000,4 +1000,6 @@ source "board/xaeniax/Kconfig"
 source "board/xilinx/zynq/Kconfig"
 source "board/zipitz2/Kconfig"
 
+source "arch/arm/Kconfig.debug"
+
 endmenu
arch/arm/Kconfig.debug new file +64 -0

64 lines not on this page · raw message

arch/arm/lib/Makefile +2 -0
index 1ef2400..d74e4b8 100644
@@ -48,6 +48,8 @@ ifndef CONFIG_ARM64
 obj-y	+= cache-cp15.o
 endif
 
+obj-$(CONFIG_DEBUG_LL)	+= debug.o
+
 # For EABI conformant tool chains, provide eabi_compat()
 ifneq (,$(findstring -mabi=aapcs-linux,$(PLATFORM_CPPFLAGS)))
 extra-y	+= eabi_compat.o
Signature · 1 line
1.9.1
#11 lore raw

cover Introduce low-level debug for ARM architecture

In reply to Masahiro Yamada
Quoted 6 lines · Masahiro Yamada

I have been in trouble for a while to debug some nasty problem where neighter a debugger nor printf() function is available.

I found the lowlevel debug feature in ARM Linux can be used as is in U-Boot too.

Quoted 8 lines

I tested this series on our SoCs (32bit ARM, specificly Coretex-A9). Because I was not sure about aarch64, I have this feature depend on "! ARM64".

1/4 and 2/4 refactor a bit and move CONFIG_ARM64 to Kconfig.

3/4 imports some source files from Linux 3.16 and
4/4 adds the Kconfig menu.

Dear Masahiro,

How do you use this debug facility? Do you print to memory?

I don't know enough to comment on the patch. I don't see CP15 co-process in the SoC I am debugging.

York

#12 lore raw

cover Introduce low-level debug for ARM architecture

Hi York,

Quoted 16 lines · On Mon, 18 Aug 2014 19:14:07 -0700 York Sun <[email protected]> wrote:
Quoted 6 lines · Masahiro Yamada

I have been in trouble for a while to debug some nasty problem where neighter a debugger nor printf() function is available.

I found the lowlevel debug feature in ARM Linux can be used as is in U-Boot too.

Quoted 8 lines

I tested this series on our SoCs (32bit ARM, specificly Coretex-A9). Because I was not sure about aarch64, I have this feature depend on "! ARM64".

1/4 and 2/4 refactor a bit and move CONFIG_ARM64 to Kconfig.

3/4 imports some source files from Linux 3.16 and
4/4 adds the Kconfig menu.

Quoted 7 lines

Dear Masahiro,

How do you use this debug facility? Do you print to memory?

I don't know enough to comment on the patch. I don't see CP15 co-process in the SoC I am debugging.

At least one UART device must be available to use this facility.

The UART should be initialized (setup appropriate baudrate etc.) in the early boot stage of U-Boot (= generally lowlevel_init() func) or in another boot loader if U-Boot is loaded by it.

Best Regards
Masahiro Yamada