Strange things happening with E.compiledC
#5682
Replies: 1 comment
-
Posted at 2023-01-21 by @fanoush No need to reflash firmware, just rebooting is enough (E.reboot or holding btn1+2), firmware is in flash not ram so you cannot corrupt it by changing ram. btw you don't need the variable to be volatile. from the sequence it looks like it is incrementing but sometimes the highest byte of the a variable is corrupted. Oh, I think I remember this bug, try to declare it with initialized value like
that should be safe. Uninitialized variables go to .bss section and that one is not part of the preallocated binary array in RAM so it will corrupt something after the array. It is a bug (or feature) of the compiler. Or you can put global variables to .text segment, that will work too and will even generate a bit smaller code
Posted at 2023-01-22 by !evil Thanks, good to know about the reset. Was using a custom build to try things, so reflashing wasn't wasted effort at least :) Regarding initialized or not, I tried a few variations and it seems that I'll keep the optimization in mind :) Posted at 2023-01-22 by @fanoush Oh, forgot that initialization to zero goes to bss segment too, so either the attribute or try Posted at 2023-01-22 by !evil You are right, and I was wrong. When I removed volatile in the actual application, the issue was still there. After that, initializing with 1 did fix it in the example as well as in the application (... I hope). Thanks a lot!! Probably worth to mention somewhere xd Posted at 2023-01-22 by @fanoush
It is a bug so I reported it as gfwilliams/EspruinoCompiler#15 Posted at 2023-01-23 by @gfwilliams Thanks - I'll get a fix in for this soon |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2023-01-21 by !evil
Hi,
I tried
E.compiledC
on my Bangle 1 2v16 and see weird things happening. After "Resetting without loading any code", the followinggives me
Prior to that I ran code which wrote to RAM locations where it shouldn't have. So I rebooted and reflashed the firmware hoping it would reset the device and resolve the issues I see. Is there anything I can do? Its a bit scary to run code that might modify any RAM location at any point.
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions