带有ARM Bare-metal的Gem5中的UART通信 [英] UART communication in Gem5 with ARM Bare-metal

查看:238
本文介绍了带有ARM Bare-metal的Gem5中的UART通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用Gem5,并且必须通过UART从主机访问ARMv8裸机选件,所以我尝试了很多方法,但是我仍然有库存.

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.

请让我知道,我如何在裸机类型编程中将主机的串行端口映射到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.

任何帮助将不胜感激

推荐答案

工作设置

此存储库包含一个高度自动化的工作示例.功能:

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

关键实现点如下所述.

https://github.com/tukl-msd/gem5.bare-metal 包含另一种有效的设置,虽然设置最少,但目前功能较少.

https://github.com/tukl-msd/gem5.bare-metal contains another working setup and is more minimal, but it has less features currently.

手臂

ARM没有什么特别的,您只需要找出与QEMU完全相同的UART地址和入口点地址,然后将--bare-metal选项传递给fs.py:

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:

fs.py --bare-metal

可以在gem5源代码上找到UART地址

The UART address can be found on the gem5 source code 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)

直接从ELF推论入口点,但是TODO某些值无效.我只是一步调试,直到找到这些值:

The entry point is deduced from the ELF directly, but TODO some values are not valid. 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

类似于arm,但需要一些额外的步骤.

Similar to arm, but requires a few extra steps.

首先,如果您想要Newlib,则必须自己构建工具链,因为Ubuntu没有aarch64软件包.我已经调整了现有的手臂配置,并达到了配置.

First you must build your toolchain yourself if you want Newlib since Ubuntu does not have the aarch64 package. I've adapted the existing arm config and reached this working config.

然后,从6fa49382ef22e1b01fb24503e3bbe5ab3556750a开始,您必须传递CLI选项:

Then, as of 6fa49382ef22e1b01fb24503e3bbe5ab3556750a you must pass the CLI options:

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

(auto_reset_addr_64在6fa49382ef22e1b01fb24503e3bbe5ab3556750a之前),否则将失败,并显示以下信息:

(auto_reset_addr_64 before 6fa49382ef22e1b01fb24503e3bbe5ab3556750a) otherwise it fails with:

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

另一个关键补丁是: https://github.com/gem5/gem5/commit/3c3ca64b5f0dd9eef7b1ce1c65cc6e8e9147dd38

或者,您也可以将fs.py修补为:

Alternatively, you could also patch fs.py as:

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)

半主机部分是可选的,但超级方便,请参阅:如何启用gem5中的ARM半主机吗?其他选项是必需的.

The semihosting part is optional, but super convenient, see: How to enable ARM semihosting in gem5? The other options are mandatory.

在Ubuntu 18.04主机上进行了测试.

Tested in Ubuntu 18.04 host.

这篇关于带有ARM Bare-metal的Gem5中的UART通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆