Writing to a Memory Window with different values for each bytes

29-Nov-2024

Occasionally, we want to fill a certain amount of memory with different values for each byte.

If the memory that we want to fill is not larger than the maximum display size (8B), we can do this by utilizing the Fill operation in the Memory window.


For example, we can fill 8B from the location 0xFFFF'FF60 with the pattern 0x123456789ABCDEF, by right-clicking the Memory view and then selecting Fill.



This pattern can be repeated an arbitrary number of times (within the limit of the target memory), by changing the Size parameter in the Fill dialogue. 

However, if the size of the memory that we want to fill with arbitrary content (not repeated pattern) is larger, e.g. 256B, the Fill operation is no longer usable.


Possible solutions

Using a Python script

1. Write a short Python script, where you define (hard code) an array of bytes that represent the desired pattern.

2. Use the appropriate API calls to write this array to the memory (e.g. CDataController) starting at the required memory address.


Using Target download with a dummy file

1. Prepare a dummy file, in a format supported by winIDEA, which contains the required pattern (e.g. .s19, .hex, .abs). Make sure it is linked to the start address where you want to write your pattern.

Alternatively write the desired pattern manually, through the Memory window only ONCE, and then use Right-click | Saveto dump the contents of the memory to the dummy file.

2. In winIDEA, go to Debug | Configure Session | SoC, select the SoC, and click Edit.

3. Go to the Target Files page, and add the dummyFile created previously.

4. Now, whenever we want to write the pattern, we can do that by clicking Debug | Target Download | dummyFile.



More resources in winIDEA Help

Was this answer helpful?