Seeing “Invalid ROM Table” errors when trying to debug Cortex-M1 chips using a ULINK2 debugger can be incredibly frustrating. This article will dive into the technical details behind these errors to help you understand why they occur and how to resolve them.
What Causes Invalid ROM Table Errors?
The Cortex-M1 processor contains a ROM table that maps interrupt and exception vectors to their handler addresses. The ULINK2 debugger needs this table to properly insert breakpoints and track execution flow. An “Invalid ROM Table” error occurs when the debugger reads an invalid table that doesn’t match the actual ROM layout of the chip.
There are a few key reasons why the ROM table can become invalid:
- Flashing the wrong firmware binary – If the firmware flashed to the chip does not match the hardware, the vector table can be incorrect.
- Corrupt flash memory – Errors during flashing can lead to corruption of the ROM table data.
- Remapped exceptions – Some firmware modifications remap exceptions to different addresses, invalidating the default ROM table.
In essence, anytime the ROM table in the debugger is out of sync with the actual chip’s layout, errors will occur. The key is identifying why and how the two have diverged.
How to Fix Invalid ROM Table Errors
When encountering invalid ROM table errors, there are a few steps you can take to resolve them:
- Validate the firmware binary – Make absolutely sure the firmware matched the target hardware. If they are incompatible, flashing the proper firmware will resolve the issue.
- Check for corrupt flash – Read back the flash memory and verify no corruption. Re-flash firmware if necessary.
- Scan for remapped vectors – Use ULINK2 commands to scan the flash memory and identify any remapped vectors. Update the ROM table accordingly.
- Force a ROM table update – Some ULINK2 software allows you to load and force a ROM table update which could re-sync it with the chip.
- Consult chip errata – Check errata documentation for the chip version to see if any ROM table bugs are known.
Additionally, you may need to work with the firmware developers to understand what modifications were made that could invalidate the ROM table. Having full insight into the firmware and chip initialization is key.
Technical Details of the Cortex-M1 ROM Table
To dig a bit deeper, it helps to understand the technical format and layout of the Cortex-M1 ROM table and how the ULINK2 debugger utilizes it:
- The ROM table consists of 8 pointers, each 4 bytes long, residing at addresses 0x00000000 to 0x0000001C.
- The pointers give the address of the 8 exception handler functions in the flash memory.
- Upon reset, the ULINK2 reads this table to map exception vectors to flash addresses.
- ULINK2 inserts breakpoint instructions at these addresses for features like halt-at-reset.
- The table must exactly match the core’s exception layout, or errors occur.
Knowing this layout, you can use ULINK2 commands to examine the table being used by the debugger and compare it to the actual flash content to identify discrepancies causing issues.
Common Cortex-M1 Exception Handler Remapping
As mentioned previously, one cause of invalid ROM tables is the remapping of exception handlers by the firmware. For example, firmware will often remap the following exceptions:
- Reset Handler – Remapped to perform early chip initialization before jumping to the core firmware reset.
- NMI Handler – Remapped to handle interrupts during debug halt.
- HardFault Handler – Remapped to include more robust fault reporting.
The ULINK2 will not be aware of these remappings, so it is crucial to identify them and update the ROM table accordingly. Advanced ULINK2 debug probes provide commands to view and patch the ROM table, which greatly helps in resolving these scenarios.
Resolving ULINK2 “Memory Access Error” Symptoms
Invalid ROM tables can also cause ULINK2 to report “Memory Access Error” when trying to access flash. This is because the debugger relies on the table to properly access exception handler locations.
To resolve these access errors, it is best to focus on identifying and correcting the root ROM table issue as outlined in previous sections. Once the table accurately reflects the flash layout, the access errors should disappear. You may need to do a reset and re-initialize debugging after updating the table.
Advanced Debugging of ROM Table Issues
For advanced troubleshooting of ROM table issues, ULINK2 users can leverage powerful commands and scripts to gain insight. Here are some examples:
- readmem – Read back and parse full flash memory contents looking for mismatches vs ROM table.
- dumpromtable – Dump the full ROM table contents being used by the debugger.
- verifymem – Verify memory against a known good firmware binary.
- Scripts – Run pre-built scripts to automate scanning for common issues.
Making use of these advanced commands requires detailed knowledge of ULINK2 scripting. Fortunately, SEGGER provides extensive documentation and support to assist. The time investment is well worth it for troubleshooting difficult ROM table scenarios.
Summary
Invalid ROM table errors when debugging Cortex-M1 chips using ULINK2 can certainly be frustrating. However, armed with the knowledge of what the ROM table is and how to resynchronize it with the flash memory, these issues can be systematically resolved. Validating the firmware binary, checking for memory corruption, identifying exception remapping, and leveraging advanced ULINK2 commands are the keys to success.