Skip to contentSkip to conversation

Introduce low-level debug for ARM architecture

PATCH Superseded Masahiro Yamada 2 participants 8 messages Aug 28, 2014

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 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/6 and 2/6 refactor a bit and move CONFIG_ARM64 to Kconfig.

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

Masahiro Yamada (6):
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: replace license blocks with SPDX
arm: debug: add Kconfig entries for lowlevel debug
arm: debug: adjust for U-Boot

 arch/arm/Kconfig                       |  13 +-
 arch/arm/Kconfig.debug                 |  64 ++++++
 arch/arm/cpu/armv8/Kconfig             |   7 +
 arch/arm/include/debug/8250.S          |  52 +++++
 arch/arm/lib/Makefile                  |   2 +
 arch/arm/lib/debug.S                   | 136 ++++++++++++
 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             | 388 +++++++++++++++++++++++++++++++++
 14 files changed, 664 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 v2 1/6 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.

---

Changes in v2: None

 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 v2 2/6 kconfig: armv8: move CONFIG_ARM64 to Kconfig

In reply to Masahiro Yamada

---

Changes in v2: None

 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
#3 lore raw

PATCH v2 3/6 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

---

Changes in v2: None

 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
#4 lore raw

PATCH v2 4/6 arm: debug: replace license blocks with SPDX

In reply to Masahiro Yamada

---

Changes in v2: None

 arch/arm/include/debug/8250.S | 4 +---
 arch/arm/lib/debug.S          | 4 +---
 include/linux/serial_reg.h    | 5 ++---
 3 files changed, 4 insertions(+), 9 deletions(-)
arch/arm/include/debug/8250.S +1 -3
index 7a2baf9..d47a892 100644
@@ -3,9 +3,7 @@
  *
  *  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.
+ * SPDX-License-Identifier:	GPL-2.0+
  */
 #include <linux/serial_reg.h>
 
arch/arm/lib/debug.S +1 -3
index 14f7c3b..ddee7c0 100644
@@ -3,9 +3,7 @@
  *
  *  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.
+ * SPDX-License-Identifier:	GPL-2.0+
  *
  *  32-bit debugging code
  */
include/linux/serial_reg.h +2 -3
index 99b4705..9214b67 100644
@@ -2,9 +2,8 @@
  * include/linux/serial_reg.h
  *
  * Copyright (C) 1992, 1994 by Theodore Ts'o.
- * 
- * Redistribution of this file is permitted under the terms of the GNU 
- * Public License (GPL)
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
  * 
  * These are the UART port assignments, expressed as offsets from the base
  * register.  These assignments should hold for any serial port based on
Signature · 1 line
1.9.1
#5 lore raw

PATCH v2 5/6 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.

---

Changes in v2: None

 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
#6 lore raw

PATCH v2 6/6 arm: debug: adjust for U-Boot

In reply to Masahiro Yamada

Because CONFIG_MMU is never defined in U-Boot,
the non-MMU code in debug.S is always used.

Unfortunately, the number of arguments of the addruart macro in Linux is different between MMU and non-MMU.
This causes a build error when importing some debug macros using the third argument. (For ex. arch/arm/include/debug/exynos.S) Pass the third argument to the non-MMU addruart to avoid such a problem.

---

Changes in v2:
- Newly added

 arch/arm/lib/debug.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/lib/debug.S +1 -1
index ddee7c0..760ba74 100644
@@ -33,7 +33,7 @@
 
 #else /* !CONFIG_MMU */
 		.macro	addruart_current, rx, tmp1, tmp2
-		addruart	\rx, \tmp1
+		addruart	\rx, \tmp1, \tmp2
 		.endm
 
 #endif /* CONFIG_MMU */
Signature · 1 line
1.9.1
#7 lore raw

v2 cover Introduce low-level debug for ARM architecture

In reply to Masahiro Yamada

Hello Masahiro,

Quoted 41 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.

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/6 and 2/6 refactor a bit and move CONFIG_ARM64 to Kconfig.

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

Masahiro Yamada (6):
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: replace license blocks with SPDX
arm: debug: add Kconfig entries for lowlevel debug
arm: debug: adjust for U-Boot

  arch/arm/Kconfig                       |  13 +-
  arch/arm/Kconfig.debug                 |  64 ++++++
  arch/arm/cpu/armv8/Kconfig             |   7 +
  arch/arm/include/debug/8250.S          |  52 +++++
  arch/arm/lib/Makefile                  |   2 +
  arch/arm/lib/debug.S                   | 136 ++++++++++++
  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             | 388 +++++++++++++++++++++++++++++++++
  14 files changed, 664 insertions(+), 41 deletions(-)
Quoted 6 lines

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

Tested on Trats2(Exynos4412) - works fine.

Best Regards,

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