0

I want to run a .cmm file in TRACE32 ICD ARM32 SIM using python

and I use the following way and it doesn't seem to work、

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")

I want to run offline cmm using trace32. You can now open the TRACE32 ICD ARM32 SIM, but using T32_Cmd to execute cmm has no effect.

Kindly help me with the procedure to do so

hsz
  • 1
  • 2
  • What kind of error messages are you getting? – Reez0 Jul 21 '22 at 08:29
  • I have a dump file that needs to be decompressed with lz4 and then run cmm to parse, so I want to encode a .py and run cmm directly under the "TRACE32 ICD ARM32 SIM" GUI after the decompress is complete – hsz Jul 21 '22 at 08:41
  • I use this command `t32api.T32_Cmd(b"CD.DO ~~/demo/arm/compiler/arm/cortexm.cmm")`, but in "TRACE32 ICD ARM32 SIM" GUI no effect – hsz Jul 21 '22 at 08:42

1 Answers1

1

Do you only need to run one CMM Script? Then the easiest solution would be to use the t32marm.exe -s <script> argument. No Remote API required.


Second, if you have a recent version of TRACE32 (at least 2020.09), I'd suggest to use the Python package that comes with the installation. Using ctypes is possible but harder. Furter information: https://www2.lauterbach.com/pdf/app_python.pdf


Last if you want to use ctypes and the Remote API, you need some initialization code. Please also make sure to check and handle the return values.

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"))

More information can be found here: https://www2.lauterbach.com/pdf/api_remote_c.pdf

dev15
  • 665
  • 3
  • 14