OTP Code Patching via Invalid Opcode Exception
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing methods for patching code in one time programmable (OTP) memory are not applicable, as OTP memory cannot be reprogrammed, and existing techniques for read-only memory (ROM) require extra code and RAM space, which is unnecessary for FLASH-based systems.
Innovation Solution
A method that involves writing an invalid opcode at the beginning of a modified function in OTP memory, causing an exception that triggers an exception handler to search a RAM dictionary for the patch address, allowing the processing unit to jump to the modified function in volatile memory.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Ease of manufacture
If OTP memory is used in network devices, then cost is reduced, but the ability to apply patches and updates after device delivery is lost
Solution Approach 1:
The system segments the code storage into two parts: OTP memory for storing the original code ( providing cost advantage) and RAM for storing patch dictionaries and loaded patches (enabling update capability). This segmentation allows the system to leverage the cost benefit of OTP while maintaining patchability through the supplementary RAM storage.
Solution Approach 2:
A patch dictionary stored in RAM acts as an intermediary between the OTP memory and the execution environment. The dictionary contains mappings from original code addresses to patched code addresses, enabling the system to redirect execution to updated code without modifying the OTP memory itself.
2Adaptability or versatility
If jump tables are used in RAM for ROM patching, then patching capability is achieved, but extra code space and RAM space are required
Solution Approach 1:
Instead of implementing a comprehensive jump table mechanism that would require extensive RAM space and code modifications, the patent applies a partial approach by only storing address mappings for patched functions in a compact dictionary structure. This reduces the space requirement compared to a full jump table implementation while maintaining essential patching capability.
3Ease of manufacture
If different SDKs are maintained for FLASH-based and OTP-based devices, then device-specific optimization is achieved, but development effort and maintenance complexity increase
Solution Approach 1:
The patent implements a universal patching mechanism that works across both FLASH-based and OTP-based devices. By using a standardized approach of inserting invalid opcodes and resolving them through RAM-based dictionaries, the same SDK can serve multiple device types, eliminating the need for separate SDK maintenance while achieving device-specific functionality through the unified interface.
Data Source
AI summary
Methods of performing updates to a software image that is disposed in a one time programmable (OTP) memory device are disclosed. The method includes writing an invalid opcode at the beginning of a function that has been modified. This invalid opcode causes an exception. The exception handler determines the address where the invalid opcode was located and searches a random access memory (RAM) dictionary. This RAM dictionary contains entries that each have an original address in the OTP Memory and the patch address in a volatile memory. The exception handler then causes the processing unit to jump to the patch address, where a modified function is located.


