pylink icon indicating copy to clipboard operation
pylink copied to clipboard

Option to set RTT Search Range

Open j0ntraust1 opened this issue 1 year ago • 1 comments

Hi,

would it be possible to add to the input of the rtt_start() a option to set the search range. Similarly to the option in the Rtt-viewer or the rtt command SetRTTSearchRanges .

image

--

We are using chipset that doesn't work well with the auto detection and the placement in the ram is not always a exact number. We are currently doing workaround by having a while loop that searches for the block address but it seems way slower then it needs to be.

j0ntraust1 avatar Aug 22 '24 15:08 j0ntraust1

We are using chipset that doesn't work well with the auto detection and the placement in the ram is not always a exact number. We are currently doing workaround by having a while loop that searches for the block address but it seems way slower then it needs to be.

Here is a temporary workaround : You can use elftools in python to find out exactly what the rtt address is. This way you know where to connect to.

def get_symbol_address(elf_file_path, symbol_name):
    try:
        with open(elf_file_path, 'rb') as f:
            elf = ELFFile(f)
            
            # Iterate through all sections in the ELF file
            for section in elf.iter_sections():
                if section['sh_type'] == 'SHT_SYMTAB':
                    # Iterate through all symbols in the section
                    for symbol in section.iter_symbols():
                        if symbol.name == symbol_name:
                            return symbol['st_value']
    except Exception as e:
        print(f"Error reading ELF file: {e}")
        return None

    print(f"Symbol '{symbol_name}' not found")
    return None

get_symbol_address("abc.elf", "_SEGGER_RTT")

ephraim71 avatar Oct 17 '24 03:10 ephraim71

It seems that JLinkARM.dll does not provide the relevant functions, so it may not be feasible to expect pylink to implement this directly.

As a workaround, maybe we can manually search the specified memory area and find the address of the "_SEGGER_RTT" structure and pass it to the DLL?

arrio464 avatar Apr 30 '25 03:04 arrio464

Thank you ! I did something similar, searching the .map file for SEGGER_RTT.

Image

j0ntraust1 avatar Apr 30 '25 08:04 j0ntraust1

Yes, we could implement this by reading the memory. Maybe as a separate method (e.g. rtt_get_block_address()). If someone wants to implement that, we would gladly accept it, otherwise we can look into it when time permits. The .map file is likely the fastest approach, but that would be done outside of pylink; for inside pylink, we would want to read the target memory to search for the symbol (magic string).

hkpeprah avatar Apr 30 '25 17:04 hkpeprah