When not in debugging, device may slow down

In case you are using TinyCLR 1.0 ( you should use 2.0) here is a patch that you must add to all of your projects.

static void Patch()
        {
            // G80
            const int MODE_ADDRESS = 0x20002998;
            const int EVENT_ADDRESS = 0x20003278;
            const int OFFSET = 0;

            // UC5550
            //const int MODE_ADDRESS = 0x20013ab0;
            //const int EVENT_ADDRESS = 0x20014390;
            //const int OFFSET = 0;

            // UC2550
            //const int MODE_ADDRESS = 0x20003050;
            //const int EVENT_ADDRESS = 0x20003930;
            //const int OFFSET = 0;

            // BrainPad, FEZCLR
            //const int MODE_ADDRESS = 0x20001438;
            //const int EVENT_ADDRESS = 0x20001ef8;
            //const int OFFSET = 0;

            // G30
            //const int MODE_ADDRESS = 0x20001a68;
            //const int EVENT_ADDRESS = 0x20002348;
            //const int OFFSET = 0;

            // G120
            //const int MODE_ADDRESS = 0x200446F9; 
            //const int EVENT_ADDRESS = 0x20044FD9; 
            //const int OFFSET = int.MaxValue;

            // G400
            //const int MODE_ADDRESS = 0x2060bd10;
            //const int EVENT_ADDRESS = 0x2060c5f0;
            //const int OFFSET = 0;

            var isUsbDebugMode = Marshal.ReadInt32(IntPtr.Add(new IntPtr(OFFSET), MODE_ADDRESS)) != 0 ? true : false;
            var value = Marshal.ReadInt32(IntPtr.Add(new IntPtr(OFFSET), (EVENT_ADDRESS))) | (isUsbDebugMode ? 512 : 256);
            Marshal.WriteInt32(IntPtr.Add(new IntPtr(OFFSET), EVENT_ADDRESS), value);                 
        }
1 Like

Found a bug somewhere? How did you detect it?

This is a very old known issue that people keep running into. This post should help.

2 Likes

Thanks Gus to put it in forum. Before that it was in docs, but I have always to dig in it. Now it’s much easier to find it.

A link from the known issues page to this would be good. :slight_smile:

Getting 2.0 out may be even better?

which address should be for discovery or CERB (patch for TinyClr 1.0)

are they using custom firmware or from GHI?

Cerb stm32f405

i belive it should be

        //CERB
        //const int MODE_ADDRESS = 0x20002488;
        //const int EVENT_ADDRESS = 0x20002f48;
        //const int OFFSET = 0;

or should be other values ?