简体   繁体   English

Gem5 中的 UART 通信与 ARM 裸机

[英]UART communication in Gem5 with ARM Bare-metal

I am currently working with Gem5 and I have to access via UART from my Host to ARMv8 bare-metal option, so i tried lots way but i stocked yet.我目前正在使用 Gem5,我必须通过 UART 从我的主机访问 ARMv8 裸机选项,所以我尝试了很多方法,但我还没有库存。

could you please let me know, how can i map my host's Serial port to ARMv8's Serial Port in bare-metal type programming.您能否让我知道,如何在裸机类型编程中将主机的串行端口映射到 ARMv8 的串行端口。

Any help would be appreciated任何帮助,将不胜感激

Working setups工作设置

This repository contains a highly automated working example . 这个存储库包含一个高度自动化的工作示例 Features:特征:

  • works on both QEMU and gem5适用于 QEMU 和 gem5
  • works on both arm and aarch64适用于 arm 和 aarch64
  • newlib allows using the standard C library optionally newlib 允许选择使用标准 C 库
  • semihosting exemplified以半主机为例
  • works on both RealViewPBX and VExpress_GEM5_V1 .适用于RealViewPBXVExpress_GEM5_V1 You should prefer VExpress_GEM5_V1 as it is a more modern platform.您应该更喜欢VExpress_GEM5_V1因为它是一个更现代的平台。
  • pristine toolchain built with crosstool-NG使用 crosstool-NG 构建的原始工具链

Key implementation points are described below.关键实施点如下所述。

https://github.com/tukl-msd/gem5.bare-metal contains another working setup and is more minimal, but it has less features currently. https://github.com/tukl-msd/gem5.bare-metal包含另一个工作设置并且更小,但它目前的功能较少。

arm手臂

There is nothing special for ARM, you just need to find out the UART address and entry point address, exactly as for QEMU, and then pass the --bare-metal option to fs.py : ARM 没有什么特别的,你只需要找出 UART 地址和入口点地址,就像 QEMU 一样,然后将--bare-metal选项传递给fs.py

fs.py --bare-metal

The UART address can be found on the gem5 source code src/dev/arm/RealView.py : UART 地址可以在 gem5 源代码src/dev/arm/RealView.py

class RealViewPBX(RealView):
    uart = Pl011(pio_addr=0x10009000, int_num=44)

class VExpress_GEM5_V1(RealView):
    uart0 = Pl011(pio_addr=0x1c090000, int_num=37)

The entry point is deduced from the ELF directly, but TODO some values are not valid.入口点是直接从 ELF 推导出来的,但是 TODO 有些值是无效的。 I just step debugged until I found these values :我只是逐步调试,直到找到这些值

    if common.machine == 'VExpress_GEM5_V1':
        entry_address = 0x80000000
    elif common.machine == 'RealViewPBX':
        entry_address = 0x10000

aarch64 aarch64

Similar to arm , but requires a few extra steps.类似于arm ,但需要一些额外的步骤。

First you must build your toolchain yourself if you want Newlib since Ubuntu does not have the aarch64 package.首先,如果你想要 Newlib,你必须自己构建你的工具链,因为 Ubuntu 没有 aarch64 包。 I've adapted the existing arm config and reached this working config .我已经调整了现有的 arm 配置并达到了这个工作配置

Then, as of 6fa49382ef22e1b01fb24503e3bbe5ab3556750a you must pass the CLI options:然后,从 6fa49382ef22e1b01fb24503e3bbe5ab3556750a 开始,您必须传递 CLI 选项:

fs.py --param 'system.highest_el_is_64 = True' \
      --param 'system.auto_reset_addr = True' \
      --bare-metal

( auto_reset_addr_64 before 6fa49382ef22e1b01fb24503e3bbe5ab3556750a) otherwise it fails with: auto_reset_addr_64之前的 auto_reset_addr_64 )否则失败:

fatal: Kernel is mapped to invalid location (not memory). kernelStart 0x(400000) - kernelEnd 0x(0) 0x400000:0

The other key patch is: https://github.com/gem5/gem5/commit/3c3ca64b5f0dd9eef7b1ce1c65cc6e8e9147dd38另一个关键补丁是: https : //github.com/gem5/gem5/commit/3c3ca64b5f0dd9eef7b1ce1c65cc6e8e9147dd38

Alternatively, you could also patch fs.py as:或者,您也可以将fs.py修补为:

diff --git a/configs/example/fs.py b/configs/example/fs.py
index 3997ed76c..286e0bca6 100644
--- a/configs/example/fs.py
+++ b/configs/example/fs.py
@@ -376,5 +376,9 @@ if buildEnv['TARGET_ISA'] == "arm" and options.generate_dtb:
             sys = getattr(root, sysname)
             sys.dtb_filename = create_dtb_for_system(sys, '%s.dtb' % sysname)

+from m5.objects import ArmSemihosting
+test_sys.semihosting = ArmSemihosting()
+test_sys.highest_el_is_64 = True
+test_sys.auto_reset_addr_64 = True
 Simulation.setWorkCountOptions(test_sys, options)
 Simulation.run(options, root, test_sys, FutureClass)

The semihosting part is optional, but super convenient, see: How to enable ARM semihosting in gem5?半主机部分是可选的,但是超级方便,参见: 如何在 gem5 中启用 ARM 半主机? The other options are mandatory.其他选项是强制性的。

Tested in Ubuntu 18.04 host.在 Ubuntu 18.04 主机上测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM