This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

uVision5 still skips codes under -O0 optimization level

Hi,

I am new to Keil and I am implementing some crypto algorithms on a platform using ARM cortex M23. The platform has 3KB RAM and 30KB ROM.

When I debug, if the plain text size is small (2048bytes), everything is fine. But if I increase the size of plain text to 3072 or 4096, the encryption will be skipped and I cannot see the result.

I added breakpoint right before and after the encryption function call but it doesn't stop. It goes back to the beginning of the whole program directly after I click "step over" before function call.

It seems like the text is too large to be encrypted correctly, maybe there is an overflow? But the builder did not report any error, the RO/RW size does not exceed 30KB/3KB either.

I saw many people suggest to lower the optimization level of Keil, but I am always at -O0, why this still happens?

Thanks in advance.

Parents
  • I am new to Keil and I am implementing some crypto algorithms on a platform using ARM cortex M23. The platform has 3KB RAM and 30KB ROM.

    3 KB RAM is very less. You need to be careful when you define the stack and maybe heap.

    When I debug, if the plain text size is small (2048bytes), everything is fine. But if I increase the size of plain text to 3072 or 4096, the encryption will be skipped and I cannot see the result.

    Do you keep the strings that should be encrypted in RAM? Did you check your map file if your application does not allocate more than 3 KB? I could imagine that the original string, as well as the encrypted string, needs to be stored in RAM. If this is the case, 3 KB RAM would be way too less.

    I added breakpoint right before and after the encryption function call but it doesn't stop. It goes back to the beginning of the whole program directly after I click "step over" before function call.

    This looks like a reset or exception which is caused by your encryption algorithm. You should see the reason when you single step through your encryption algorithm and if you watch the Exceptions dialog. I'm sure that no code is skipped or not translated.

Reply
  • I am new to Keil and I am implementing some crypto algorithms on a platform using ARM cortex M23. The platform has 3KB RAM and 30KB ROM.

    3 KB RAM is very less. You need to be careful when you define the stack and maybe heap.

    When I debug, if the plain text size is small (2048bytes), everything is fine. But if I increase the size of plain text to 3072 or 4096, the encryption will be skipped and I cannot see the result.

    Do you keep the strings that should be encrypted in RAM? Did you check your map file if your application does not allocate more than 3 KB? I could imagine that the original string, as well as the encrypted string, needs to be stored in RAM. If this is the case, 3 KB RAM would be way too less.

    I added breakpoint right before and after the encryption function call but it doesn't stop. It goes back to the beginning of the whole program directly after I click "step over" before function call.

    This looks like a reset or exception which is caused by your encryption algorithm. You should see the reason when you single step through your encryption algorithm and if you watch the Exceptions dialog. I'm sure that no code is skipped or not translated.

Children