Introduce low-level debug for ARM architecture
Subsystems (2)
v3 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
PATCH v3 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 v3: None
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
@@ -461,9 +461,6 @@ config TEGRA 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
@@ -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
@@ -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
PATCH v3 1/6 vexpress64: kconfig: consolidate CONFIG_TARGET_VEXPRESS_AEMV8A_SEMI
Tom, (or Albert if he is ready)
Could you apply these two, please?
http://patchwork.ozlabs.org/patch/384614/
http://patchwork.ozlabs.org/patch/384616/
This kind of patches tend to cause conflicts.
Signature · 2 lines
Best Regards Masahiro Yamada
PATCH v3 2/6 kconfig: armv8: move CONFIG_ARM64 to Kconfig
In reply to Masahiro Yamada---
Changes in v3:
- Rebase on commit a1263632
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
@@ -5,6 +5,9 @@ config SYS_ARCH string default "arm" +config ARM64 + bool + choice prompt "Target select"
@@ -460,12 +463,15 @@ config TEGRA 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"
@@ -508,6 +514,8 @@ config TARGET_JORNADA endchoice +source "arch/arm/cpu/armv8/Kconfig" + source "arch/arm/cpu/arm926ejs/davinci/Kconfig" source "arch/arm/cpu/armv7/exynos/Kconfig"
arch/arm/cpu/armv8/Kconfig new file +7 -0
@@ -0,0 +1,7 @@ +if ARM64 + +config SYS_CPU + string + default "armv8" + +endif
board/armltd/vexpress64/Kconfig +0 -4
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -1,3 +1,2 @@ -CONFIG_SYS_EXTRA_OPTIONS="ARM64" CONFIG_ARM=y CONFIG_TARGET_VEXPRESS_AEMV8A=y
configs/vexpress_aemv8a_semi_defconfig +1 -1
@@ -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
PATCH v3 3/6 arm: debug: import debug files from Linux 3.16
In reply to Masahiro YamadaU-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 v3: None
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
@@ -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
PATCH v3 4/6 arm: debug: replace license blocks with SPDX
In reply to Masahiro Yamada---
Changes in v3: None
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
@@ -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
@@ -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
@@ -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
PATCH v3 5/6 arm: debug: add Kconfig entries for lowlevel debug
In reply to Masahiro YamadaWe 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 v3: None
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
@@ -681,4 +681,6 @@ source "board/woodburn/Kconfig" source "board/xaeniax/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
@@ -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
PATCH v3 5/6 arm: debug: add Kconfig entries for lowlevel debug
Hi Masahiro,
Quoted 11 lines · Masahiro Yamada
We have not had a good method to debug the early boot stage such as
lowlevel_initfunction. 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.
Quoted 6 lines
You have to enable
CONFIG_DEBUG_LLto use this feature. For now, only 8250-compatible UART devices are supported. You can add a header file underarch/arm/include/debug/directory to support your UART device if necessary.Signed-off-by Masahiro Yamada <[email protected]>
Is it possible to use the existing drivers for this? It seems unfortunate to duplicate the ns16550 driver (if that is what has happened).
E.g. I have had good luck just calling that driver code directly. I'm not sure of an overall framework but it must be possible...
Regards,
Simon
PATCH v3 5/6 arm: debug: add Kconfig entries for lowlevel debug
Hi Simon,
Quoted 19 lines · On Wed, 3 Sep 2014 18:01:44 -0600 Simon Glass <[email protected]> wrote:
Hi Masahiro,
Quoted 16 lines · Masahiro Yamada
We have not had a good method to debug the early boot stage such as
lowlevel_initfunction. 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_LLto use this feature. For now, only 8250-compatible UART devices are supported. You can add a header file underarch/arm/include/debug/directory to support your UART device if necessary.
Quoted 5 lines
Quoted 1 line
Signed-off-by Masahiro Yamada <[email protected]>Is it possible to use the existing drivers for this? It seems unfortunate to duplicate the ns16550 driver (if that is what has happened).
I am afraid it is difficult since the serial drivers are too complicated and written in C.
Indeed, it is unfortunate, though.
This low level debug framework only uses r0, r1, r2, r3 registers and does not need stack.
I think it has an advantage over the serial drivers for debugging the lowlevel_init where no stack is ready.
Best Regards
Masahiro Yamada
PATCH v3 5/6 arm: debug: add Kconfig entries for lowlevel debug
Hi Masahiro,
Quoted 35 lines · Masahiro Yamada
Hi Simon,
Quoted 19 lines · On Wed, 3 Sep 2014 18:01:44 -0600 Simon Glass <[email protected]> wrote:
Hi Masahiro,
Quoted 16 lines · Masahiro Yamada
We have not had a good method to debug the early boot stage such as
lowlevel_initfunction. 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_LLto use this feature. For now, only 8250-compatible UART devices are supported. You can add a header file underarch/arm/include/debug/directory to support your UART device if necessary.Quoted 5 lines
Quoted 1 line
Signed-off-by Masahiro Yamada <[email protected]>Is it possible to use the existing drivers for this? It seems unfortunate to duplicate the ns16550 driver (if that is what has happened).
I am afraid it is difficult since the serial drivers are too complicated and written in C.
Indeed, it is unfortunate, though.
Quoted 5 lines
This low level debug framework only uses r0, r1, r2, r3 registers and does not need stack.
I think it has an advantage over the serial drivers for debugging the
lowlevel_initwhere no stack is ready.
We have CONFIG_SYS_INIT_SP_ADDR and the like - if there is no RAM available for a stack then I would question what RAM you are using to hold your code :-)
As an example, for ns16500, you can do something like:
ldr r0, =UART_BASE
ldr r0, =UART_BAUD_DIVISOR
bl NS16550_init
ldr r0, =UART_BASE
mov r1, #'a'
bl NS16550_putc
At least for ARMv7, this actually uses no stack, so you could do that now. I am pretty sure you would find the same with other serial drivers as they are very simple. The cost is that we need to be able to call the output function directly. With driver model we could require this to be part of the API and I'm pretty sure it would be easy enough. I still think this is far preferable to rewriting duplicate drivers in assembler. May this is the only possible way in Linux...
Also you can do:
ldr sp, =CONFIG_SYS_INIT_SP_ADDR
if needed.
Regards,
Simon
PATCH v3 5/6 arm: debug: add Kconfig entries for lowlevel debug
In reply to Simon GlassQuoted 19 lines · Simon Glass
Hi Masahiro,
Quoted 16 lines · Masahiro Yamada
We have not had a good method to debug the early boot stage such as
lowlevel_initfunction. 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_LLto use this feature. For now, only 8250-compatible UART devices are supported. You can add a header file underarch/arm/include/debug/directory to support your UART device if necessary.
Quoted 5 lines
Quoted 1 line
Signed-off-by Masahiro Yamada <[email protected]>Is it possible to use the existing drivers for this? It seems unfortunate to duplicate the ns16550 driver (if that is what has happened).
No, the point of this driver (and the similar ones that exist here and elsewhere) is to have something small and seperate that we know is not the cause of the problem.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140906/7b9189b9/attachment.pgp>
PATCH v3 5/6 arm: debug: add Kconfig entries for lowlevel debug
Hi Tom,
Quoted 23 lines · Tom Rini
Quoted 3 lines · Simon Glass
Hi Masahiro,
On 31 August 2014 20:06, Masahiro Yamada <[email protected]>
Quoted 18 lines · wrote:
Quoted 17 lines
We have not had a good method to debug the early boot stage such as
lowlevel_initfunction. 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_LLto use this feature. For now, only 8250-compatible UART devices are supported. You can add a header file underarch/arm/include/debug/directory to support your UART device if necessary.Signed-off-by Masahiro Yamada <[email protected]>
Quoted 8 lines
Quoted 3 lines
Is it possible to use the existing drivers for this? It seems unfortunate to duplicate the ns16550 driver (if that is what has happened).
No, the point of this driver (and the similar ones that exist here and elsewhere) is to have something small and seperate that we know is not the cause of the problem.
Please see my other email on this thread. I'm not talking about use the driver in full, just directly calling the driver's init and putc functions from assembler instead of duplicating them. It seems more scaleable to me in that we can support any driver in principle. The cost is that each driver needs to export these two functions with a defined signature.
Regards,
Simon
PATCH v3 6/6 arm: debug: adjust for U-Boot
In reply to Masahiro YamadaBecause 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 v3: None
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
@@ -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
v3 cover Introduce low-level debug for ARM architecture
In reply to Masahiro YamadaHello Masahiro,
Quoted 17 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_ARM64toKconfig.3/6 imports some source files from Linux 3.16 and
5/6 adds theKconfigmenu.
Quoted 7 lines
Masahiro Yamada (6):
vexpress64: kconfig: consolidateCONFIG_TARGET_VEXPRESS_AEMV8A_SEMI
kconfig: armv8: moveCONFIG_ARM64toKconfig
arm: debug: import debug files from Linux 3.16
arm: debug: replace license blocks with SPDX
arm: debug: addKconfigentries for lowlevel debug
arm: debug: adjust for U-Boot
Patches 3 through 6 also applied, to u-boot-arm/master. Thanks!
Amicalement,
Signature · 1 line
Albert.