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

Custom debug DLL in Keil for 8051 processor

Hi,

I am trying to develop a custom debug DLL for debugging  a custom board based on 8051 processor. The idea here is to create a debug environment for our board.

I connected FTDI chip which has USB-JTAG interface which can be used as debugger.

I have taken the  example agdi project(apntex_145) provided by Keil ,which can help develop the custom dll, which can be built in visual c++ 6.0 and dll can be created.

Since I'll have the dependency on the FTDI JTAG drivers, I am using FTCJTAG.dll provided by FTDI, internally in the example project which I took, and then I created the custom.dll. So far so good. It compiled properly and I got the DLL.

I loaded the DLL to the keil and I am able to see the the custom debugger available in the debug options for target in Keil IDE. I selected my custom debugger.

I added some debug prints in AG_Init function in the project of the DLL so that when I click start/stop debug, I can see the debug prints.

Now, When I just click start/stop debug button, the control went to AGDI functions to the custom dll which I created and I got the debug prints.

But when we try to create some JTAG traffic by calling JTag APIs which are exposed by FTDI, and try to debug, I am getting an error saying, "*** Error: 'custom.dll' not found".

And now When I try to load the dll which I created by pressing settings button right next to the debug options, it says, cant load the dll . And the possible reasons:

1) driver dll could not be found in the specified path

2) driver dll requires additional dll's which are not installed

3) Required hardware drivers are not installed.

Its not the first reason, since the dll is still present in the specified path.

I feel the second reason might be the one responsible for this error, as my dll depends on the FTCJTAG.dll which is given by FTDI.

Since my DLL file has the dependency with the FTDI dll, should I combine or bundle both the dlls together and then create a new merged DLL which can then be used as debugger dll?

Or is there any other way of solving this?

Can you help me resolve this issue?

Parents
  • Dear Saratchandra,
    >I connected FTDI chip which has USB-JTAG interface which can be used as debugger.
     
    Yes, this is an approach which was used by other chip vendors as well.
     
    >I have taken the example agdi project(apntex_145) provided by Keil ,which can help develop the custom dll, which can be built in
    >Visual C++ 6.0 and dll can be created.
     
    Yes, this is the right starting point. You can convert this project easily to use it under Microsoft Visual Studio 2015 for example.

    >Since I'll have the dependency on the FTDI JTAG drivers, I am using FTCJTAG.dll provided by FTDI, internally in the example project which I took,
    >and then I created the custom.dll. So far so good. It compiled properly and I got the DLL.
    >I loaded the DLL to the keil and I am able to see the the custom debugger available in the debug options for target in Keil IDE. I selected my custom debugger.
     
    So you successfully entered your AGDI driver into the Tools.ini file.
     
    >I added some debug prints in AG_Init function in the project of the DLL so that when I click start/stop debug, I can see the debug prints.
    >Now, When I just click start/stop debug button, the control went to AGDI functions to the custom dll which I created and I got the debug prints.
     
    This is a good starting point.
     
    >But when we try to create some JTAG traffic by calling JTag APIs which are exposed by FTDI, and try to debug, I am getting an error saying,
    >"*** Error: 'custom.dll' not found".
    >1) driver dll could not be found in the specified path
    >2) driver dll requires additional dll's which are not installed
    >3) Required hardware drivers are not installed.
    >Its not the first reason, since the dll is still present in the specified path.
    >I feel the second reason might be the one responsible for this error, as my dll depends on the FTCJTAG.dll which is given by FTDI.
     
    Yes, most likely reason number 2 causes this error.
     
    >Since my DLL file has the dependency with the FTDI dll, should I combine or bundle both the dlls together and then create a new merged DLL
    >which can then be used as debugger dll?

    As far as I know, you cannot combine two dlls to one dll. Microsoft provides two different ways to load the FTDI dll from your AGDI dll:
    1) In your Visual Studio project you could specify the FTDI.lib as an external reference, so that the FTDI dll is automatically loaded when your AGDI dll is loaded by uVision. This Microsoft document describes Load-Time Dynamic Linking: docs.microsoft.com/.../using-load-time-dynamic-linking
    Sometimes it is hard to find out where this DLL is searched. If you copy the FTDI dll into the same folder as your AGDI dll, it should be found. You could use the Microsoft Process Monitor (docs.microsoft.com/.../procmon) to see where the Microsoft library searches for the FDTI dll.
    2) An alternative way to load another DLL is to explicitly call the function LoadLibrary( ), then call GetProcAddress ( ) to get the function addresses of this DLL. This way you can specify in which path the FTDI.dll will be searched.
    This Microsoft document describes Run-Time Dynamic Linking: docs.microsoft.com/.../using-run-time-dynamic-linking
    I hope you can solve this issue that way.
    Thanks
    Hans
Reply
  • Dear Saratchandra,
    >I connected FTDI chip which has USB-JTAG interface which can be used as debugger.
     
    Yes, this is an approach which was used by other chip vendors as well.
     
    >I have taken the example agdi project(apntex_145) provided by Keil ,which can help develop the custom dll, which can be built in
    >Visual C++ 6.0 and dll can be created.
     
    Yes, this is the right starting point. You can convert this project easily to use it under Microsoft Visual Studio 2015 for example.

    >Since I'll have the dependency on the FTDI JTAG drivers, I am using FTCJTAG.dll provided by FTDI, internally in the example project which I took,
    >and then I created the custom.dll. So far so good. It compiled properly and I got the DLL.
    >I loaded the DLL to the keil and I am able to see the the custom debugger available in the debug options for target in Keil IDE. I selected my custom debugger.
     
    So you successfully entered your AGDI driver into the Tools.ini file.
     
    >I added some debug prints in AG_Init function in the project of the DLL so that when I click start/stop debug, I can see the debug prints.
    >Now, When I just click start/stop debug button, the control went to AGDI functions to the custom dll which I created and I got the debug prints.
     
    This is a good starting point.
     
    >But when we try to create some JTAG traffic by calling JTag APIs which are exposed by FTDI, and try to debug, I am getting an error saying,
    >"*** Error: 'custom.dll' not found".
    >1) driver dll could not be found in the specified path
    >2) driver dll requires additional dll's which are not installed
    >3) Required hardware drivers are not installed.
    >Its not the first reason, since the dll is still present in the specified path.
    >I feel the second reason might be the one responsible for this error, as my dll depends on the FTCJTAG.dll which is given by FTDI.
     
    Yes, most likely reason number 2 causes this error.
     
    >Since my DLL file has the dependency with the FTDI dll, should I combine or bundle both the dlls together and then create a new merged DLL
    >which can then be used as debugger dll?

    As far as I know, you cannot combine two dlls to one dll. Microsoft provides two different ways to load the FTDI dll from your AGDI dll:
    1) In your Visual Studio project you could specify the FTDI.lib as an external reference, so that the FTDI dll is automatically loaded when your AGDI dll is loaded by uVision. This Microsoft document describes Load-Time Dynamic Linking: docs.microsoft.com/.../using-load-time-dynamic-linking
    Sometimes it is hard to find out where this DLL is searched. If you copy the FTDI dll into the same folder as your AGDI dll, it should be found. You could use the Microsoft Process Monitor (docs.microsoft.com/.../procmon) to see where the Microsoft library searches for the FDTI dll.
    2) An alternative way to load another DLL is to explicitly call the function LoadLibrary( ), then call GetProcAddress ( ) to get the function addresses of this DLL. This way you can specify in which path the FTDI.dll will be searched.
    This Microsoft document describes Run-Time Dynamic Linking: docs.microsoft.com/.../using-run-time-dynamic-linking
    I hope you can solve this issue that way.
    Thanks
    Hans
Children
No data