Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By rhaenel
#23741 I'm still working on this thing, it doesn't really seem to be trivial...

As of now, I have not been successful on installing my on vecbase. Even if I generate a trivial vecbase that just jumps to the code in the original vecbase, it does not work.

The following code crashes if an NMI happens after my vecbase is installed. Any ideas?

Code: Select all   __asm__ __volatile__ (
         "j function_entry\n"                    // jump over the vecbase

         ".align 16\n"
         "vecbase_mod:\n"                         // root of the modified vecbase
         "nop\n"

         ".align 16\n"              // vecbase + 0x10 - debug exception
         "debug_exception_mod:\n"
         "j 0x40100010\n"

         ".align 16\n"
         "nmi_exception_mod:\n"                   // vecbase + 0x20 - NMI exception
         "j 0x40100020\n"

         ".align 16\n"                          // vecbase + 0x30 - kernel exception
         "kernel_exception_mod:\n"
         "j 0x40100030\n"

         ".align 16\n"      
         "nop\n"
         ".align 16\n"                    // vecbase + 0x50 - user exception
         "user_exception_mod:\n"
         "j 0x40100050\n"

         ".align 16\n"                        // vecbase + 0x70 - user exception
         "nop\n"
         ".align 16\n"
         "double_exception_mod:\n"
         "j 0x40100070\n"

         ".align 16\n"                   // vecbase + 0x90 - reset vector (?)
         "nop\n"
         ".align 16\n"
         "panic_exception_mod:\n"
         "j 0x40100090\n"

         "function_entry:\n"
         "movi a2, vecbase_mod\n"
         "wsr.vecbase a2"                         // install modified vecbase
         :
         :
         : "a2", "memory"
   );
User avatar
By jcmvbkbc
#23744
rhaenel wrote:I'm still working on this thing, it doesn't really seem to be trivial...

As of now, I have not been successful on installing my on vecbase. Even if I generate a trivial vecbase that just jumps to the code in the original vecbase, it does not work.

The following code crashes if an NMI happens after my vecbase is installed. Any ideas?

Code: Select all...
         "nmi_exception_mod:\n"                   // vecbase + 0x20 - NMI exception
         "j 0x40100020\n"
...

You jump to the default NMI handler, not to the one that was in the vecbase that you've overwritten.
User avatar
By rhaenel
#23745
eriksl wrote:Tunnel vision guys...

It's in the SDK documentation that the new PWM implementation uses NMI's. Maybe other code as well.

If you want precise PWM, use the PWM implementation in the SDK, that's precise BECAUSE it's use NMI's.


Thanks!

Well, I'm not trying to do PWM at the end, but I wasn't aware that there is now some kind of "hardware timers" in the SDK which seem to be NMI related. It seems as if this can be tweaked to execute code within the NMI exception state - which is exactly the thing I need.

I'll give that a try.
User avatar
By rhaenel
#23749
jcmvbkbc wrote:You jump to the default NMI handler, not to the one that was in the vecbase that you've overwritten.


Before I overwrote the vecbase, it was 0x40100000. So to test my newly installed vecbase, I'm just jumping to the original locations (default handlers) here (to make sure it's not my handlers that screw up here). That should work, shouldn't it?