匿名
未登录
登录
百问网嵌入式Linux wiki
搜索
查看“TF-A - How to debug”的源代码
来自百问网嵌入式Linux wiki
名字空间
页面
讨论
更多
更多
页面选项
Read
查看源代码
历史
←
TF-A - How to debug
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
__TOC__ == Article Purpose == This article explains how to debug TF-A firmware.<br> Debug is specifically linked to the TrustZone environment. There are two main ways to debug TF-A, using traces inside the code, or by using JTAG to access the secure world. The focus here is on the solution integrated in OpenSTLinux: debug over gdb (ST-Link or JTAG based) == Debugging == === TF-A Version number === The starting point for debugging is to identify the TF-A version used in the target. Debug and release versions are displayed on the console with the following format:<br> <pre> NOTICE: BL2: v2.0(debug):<tag> </pre> * v2.0 is the TF-A version used. * (debug) : Build mode enable * <tag> : Git reference resulting from the '''git describe''' command at build time === Debug with traces === TF-A allows RELEASE and DEBUG modes to be enabled: * RELEASE mode builds with default LOG_LEVEL to 20, which only prints ERROR and NOTICE traces * DEBUG mode enables the -g build flag (for debug build object), and defaults LOG_LEVEL to 40 With the debug LOG_LEVEL, you can add console traces such as ERROR, NOTICE, WARNING or INFO. Please refer to '''include/common/debug.h'''. {{Warning| You cannot build code with LOG_LEVEL set to 50 (the highest level); there are too many traces and TF-A does not fit in the SYSRAM. If required, change some VERBOSE settings to INFO.}} For both modes, you must ensure that the UART is properly configured: * BL2: UART traces are enabled by default * BL32: UART traces are enabled by default<br> Traces and errors are available on the console defined in the chosen node of the device tree by the stdout-path property: <pre> chosen { stdout-path = "serial0:115200n8"; }; </pre> === Debug with GDB === TF-A runs in SYSRAM and is executed in CPU secure state. One can debug TF-A through JTAG using an ST-Link or the JTAG output, depending on the board. ==== Debug boot sequence ==== The BL2 boot stage is only executed during a boot sequence. To break into BL2, connect to the target and break. Load symbols to the correct offset: <pre> (gdb) add-symbol-file <path_to_build_folder>/tf-a-bl2.elf (or bl2.elf) <load_address> </pre> BL2 and BL32 load addresses can be found in the generated '''tf-a-stm32mp157c-<board>.map''' file: <pre> ... *fill* 0x000000002ffce000 0x5000 0x000000002ffd3000 __BL2_IMAGE_START__ = . -> BL2 Load address *(.bl2_image*) .bl2_image 0x000000002ffd3000 0x1166c build/stm32mp1/stm32mp1.o 0x000000002ffe466c __BL2_IMAGE_END__ = . 0x0000000000024b00 . = 0x24b00 *fill* 0x000000002ffe466c 0x2994 0x000000002ffe7000 __BL32_IMAGE_START__ = . -> BL32 Load address *(.bl32_image*) .bl32_image 0x000000002ffe7000 0x1744c build/stm32mp1/stm32mp1.o 0x000000002fffe44c __BL32_IMAGE_END__ = . 0x000000002fffe44c __DATA_END__ = . 0x000000002fffe44c __TF_END__ = . ... </pre> In this example: * BL2 load address is 0x2ffd3000. * BL32 load address is 0x2ffe7000. You can load all your symbols directly: <pre> (gdb) add-symbol-file <path_to_build_folder>/tf-a-bl2.elf 0x2ffd3000 (gdb) add-symbol-file <path_to_build_folder>/tf-a-bl32.elf 0x2ffe7000 </pre> Set your hardware breakpoint and reset: <pre> (gdb) hb bl2_early_platform_setup (gdb) monitor reset halt </pre> ==== Debugging during runtime execution ==== Once [[U-Boot overview|U-Boot]] or the Linux kernel is running, you cannot access secure memory or regions, but you can break, set a hardware breakpoint into SMC handler (in BL32). [[GDB]] breaks once it has switched into the secure world and reached the break instruction. Once halted in the secure monitor, [[GDB]] can access secure resources as IPs or memory. For example, one can break into kernel: <pre> (gdb) hb stm32mp1_svc_smc_handler (gdb) continue </pre> On the first SMC call occurence [[GDB]] breaks the stm32mp1_svc_smc_handler() entry in BL32. <noinclude> {{PublicationRequestId | 9776 | 2018-11-22 | PhilipeS}} [[Category:Trusted Firmware-A (TF-A)]] [[Category:Tracing tools]] [[Category:Debugging tools]] </noinclude>
该页面使用的模板:
模板:STPink
(
查看源代码
)
模板:Warning
(
查看源代码
)
返回至
TF-A - How to debug
。
导航
导航
WIKI首页
官方店铺
资料下载
交流社区
所有页面
所有产品
MPU-Linux开发板
MCU-单片机开发板
Linux开发系列视频
单片机开发系列视频
所有模块配件
Wiki工具
Wiki工具
特殊页面
页面工具
页面工具
用户页面工具
更多
链入页面
相关更改
页面信息
页面日志