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

AGSI DLL and banking

Hi,

I've been following the example in App Note 154 to develop a simulator DLL.
The result works fine with "simple and small" (un-banked) target firmware (uP is SDA5550).
The problem is, when I have to use code banking in the target firmware, I cannot get my AGSI DLL to work with banking. Keil debugger always show "Access Violation" on the first jumping (LJMP) to other bank during initialization (even before going to main() ).

I checked the SFR PC always be in "C:xxxx", it never change to "B0:xxxx" or "B1:xxxx" as it should be.
However, the banked firmware works fine on a real system (with real uP onboard) without AGSI DLL.

Is there any extra banking stuff I need to handle in my AGSI DLL during initialization? Please advice. Thanks!

Parents
  • The D500.DLL shipped with Keil can not deal with banking properly. You shall handle it within your AGSI DLL. Except for banking issue in the simulation, you will face on the banking issue in the real firmware if it becomes more compilicated. For example, if you happen to use a large switch/case statement, Keil C sometimes will generate wrong code: the jump table will be located in current bank, which may cause fatal error if MEX2 does not point to current bank.

    I had implemented the simulator for SDA5550, supporting all MEX1, MEX2, MEX3 and DPSEL. A lot lot lot of work need to do if you are going to implement a full functional DLL. It can not be easy to describe here. In short, you have to interpet all key opecodes by yourself, like MOVC, ACALL, LCALL, LJMP, RET, IRET, etc..

Reply
  • The D500.DLL shipped with Keil can not deal with banking properly. You shall handle it within your AGSI DLL. Except for banking issue in the simulation, you will face on the banking issue in the real firmware if it becomes more compilicated. For example, if you happen to use a large switch/case statement, Keil C sometimes will generate wrong code: the jump table will be located in current bank, which may cause fatal error if MEX2 does not point to current bank.

    I had implemented the simulator for SDA5550, supporting all MEX1, MEX2, MEX3 and DPSEL. A lot lot lot of work need to do if you are going to implement a full functional DLL. It can not be easy to describe here. In short, you have to interpet all key opecodes by yourself, like MOVC, ACALL, LCALL, LJMP, RET, IRET, etc..

Children
  • Thanks!

    I don't see any AGSI api can be used to trap a specific opcode, e.g. 'LJMP'(0x02).
    AgsiSetWatchOnMemory() can set a watch on "memory range" acces, but not OpCode.

    How did you intercept all key opecodes ( like MOVC, ACALL, LCALL, LJMP, RET, IRET, etc.. ) in AGSI DLL?

  • Currently I'm using a Timer:

    static void OpecodeStart(void)
    {
        ......
        Agsi.SetTimer(OpecodeTimer, 1);
    }
    bool TSDATool::AddWatch(void)
    {
        ......
        OpecodeTimer = Agsi.CreateTimer(OpecodeStart);
        ......
    }
    
    In the OpecodeStart, you can do anything, like reading code or data, changing SFR, changing PC etc..
    But it is slow. :-( Now I'm asking Keil to provide a new interface so that I can intercept any opecode by myself without using a timer. You may push them also. :-)

  • Thanks a lot!

    But I don't see any API to change PC(ProgramCounter), only AgsiGetProgramCounter() can be used to read current PC value. Is there any AGSI API can change PC? or maybe AgsiDefineVTR("PC", ...) can handle this?

  • Hi,

    I tried to use
    AgsiExecuteCommand("$ = xxxx");
    to change PC.
    But it doesn't work in the timer function OpecodeStart().

    I cannot change PC in timer function, however,
    other debug command is ok...

    Is there anything wrong??

    Example 1: this is ok:

    static void OpecodeStart(void)
    {
        ......
        AgsiExecuteCommand("DIR VTREG"); // THIS IS OK
        Agsi.SetTimer(OpecodeTimer, 1);
    }
    ======================================
    Example 2: this doesn't work:
    static void OpecodeStart(void)
    {
        ......
        AgsiExecuteCommand("$ = C:0000"); // this doesn't work, why???
        Agsi.SetTimer(OpecodeTimer, 1);
    }

  • You can use:

    AgsiExecuteCommand("G XXXX");