我想使用python在TRACE32 ICD ARM32 SIM中运行一个ARM32文件。
我使用了下面的方法,它似乎不工作,、
import ctypes # module for C data types
import enum # module for C data types
import os # module for paths and directories
import subprocess # module to create an additional process
import time # time module
t32_exe = os.path.join('C:' + os.sep, 'T32','bin', 'windows64', 't32marm.exe')
config_file = os.path.join('C:' + os.sep, 'T32', 'configsim.t32')
start_up = os.path.join('C:' + os.sep, 'T32', 'demo', 'arm', 'compiler', 'arm', 'cortexm.cmm')
command = [t32_exe, '-c', config_file, '-s', start_up]
process = subprocess.Popen(command)
time.sleep(5)
# Load TRACE32 Remote API
t32api64 = os.path.join('C:' + os.sep, 'T32','demo', 'api', 'capi', 'dll', 't32api64.dll')
t32api = ctypes.cdll.LoadLibrary(t32api64)
t32api.T32_Cmd(b"CD.DO ~~/demo/arm/compiler/arm/cortexm.cmm")
我想使用trace32运行离线cmm。您现在可以打开TRACE32 ICD ARM32 SIM,但是使用T32_Cmd执行cmm没有任何效果。
请帮我办理手续。
发布于 2022-07-28 09:13:03
您只需要运行一个CMM脚本吗?那么最简单的解决方案就是使用t32marm.exe -s <script>
参数。不需要远程API。
其次,如果您有一个最新版本的TRACE32 (至少2020.09),我建议使用安装时附带的package。使用ctypes
是可能的,但更难。信息:https://www2.lauterbach.com/pdf/app_python.pdf
最后,如果您想使用ctypes
和远程API,您需要一些初始化代码。也请确保检查和处理返回值。
def check_error(error):
"""Raises a ValueError if error is not zero."""
if error != 0:
raise ValueError(f"{error}")
# Load TRACE32 Remote API
t32api64 = os.path.join('C:' + os.sep, 'T32','demo', 'api', 'capi', 'dll', 't32api64.dll')
t32api = ctypes.cdll.LoadLibrary(t32api64)
check_error(t32api.T32_Init())
check_error(t32api.T32_Attach(1))
check_error(t32api.T32_Cmd(b"CD.DO ~~/demo/arm/compiler/arm/cortexm.cmm"))
更多信息可以在这里找到:https://www2.lauterbach.com/pdf/api_remote_c.pdf
https://stackoverflow.com/questions/73062919
复制相似问题