Thursday, December 30, 2010

We were trying to extract the MinGW compatible library for FTDI driver DLL, this is part of the d2xx Project for PyUSB - Python Based FT232 Bit Banging Tutorial. This was part of upgrading the PyUSB package for Python 2.7 Compatibility.

Here are the steps to get the pexports working for MinGW:

[1] Download the pexports Package
The package pexports is available as an utility in the MinGW Sourceforge FRS. Here is a link:
http://sourceforge.net/projects/mingw/files/MinGW/pexports/pexports-0.44-1/
http://sourceforge.net/projects/mingw/files/MinGW/pexports/pexports-0.44-1/pexports-0.44-1-mingw32-bin.tar.lzma/download
In case you are unable to find it you can go to the Main FRS by clicking on "files" in the MinGW project page : http://sourceforge.net/projects/mingw

Then Files->MinGW->pexports->pexports-{Most Recent Version}

Download the peexports-0.44-1-mingw32-bin.tar.lzma file.

[2] Extracting the File
Now the downloaded file needs to be located in the MinGW directory.
Bassically the LZMA file contains an exe file called as pexports.exe which is to be placed in
/bin Directory.

To extract the LZMA file there are two ways
> You can can download the Tar for Windows utility located at : http://gnuwin32.sourceforge.net/packages/gtar.htm
> Use the msys system that comes with the MinGW auto installer.

After you have the tar.exe available either in "Windows Path" or directly in the same directory as the LZMA file. Execute the following commeand:
tar -x --lzma -f peexports-0.44-1-mingw32-bin.tar.lzma

This would unzip the pexports.exe file into ./bin directory.

[3] Generating the Verbose output from pexports.exe 
Just locate your "dll" file that you wish to see the Function Exports for and give the following command.
pexports -v <DLL FileName>.dll



We generate the full output for the ftd2xx.dll package from FTDI:

; .text   : RVA: 00001000, File offset: 00001000
; .rdata  : RVA: 00027000, File offset: 00027000
; .data   : RVA: 0002c000, File offset: 0002c000
; .rsrc   : RVA: 00030000, File offset: 0002e000
; .reloc  : RVA: 00031000, File offset: 0002f000
; Reading exports from section: .rdata
; Export table: FTD2XX.dll
; Ordinal base: 1
; Ordinal table RVA: 0002b784
; Name table RVA: 002b648
; Export address table RVA: 0002b508
LIBRARY FTD2XX.dll
EXPORTS
FT_Close ; .text ; RVA 00002550
FT_ClrDtr ; .text ; RVA 00002820
FT_ClrRts ; .text ; RVA 00002880
FT_CreateDeviceInfoList ; .text ; RVA 00005820
FT_CyclePort ; .text ; RVA 00003450
FT_EE_Program ; .text ; RVA 000046c0
FT_EE_ProgramEx ; .text ; RVA 00004f40
FT_EE_Read ; .text ; RVA 00002c00
FT_EE_ReadEx ; .text ; RVA 00002e50
FT_EE_UARead ; .text ; RVA 00002f90
FT_EE_UASize ; .text ; RVA 00002e90
FT_EE_UAWrite ; .text ; RVA 00004f80
FT_EraseEE ; .text ; RVA 00002bc0
FT_GetBitMode ; .text ; RVA 00003140
FT_GetComPortNumber ; .text ; RVA 00003f80
FT_GetDeviceInfo ; .text ; RVA 000031e0
FT_GetDeviceInfoDetail ; .text ; RVA 00003ad0
FT_GetDeviceInfoList ; .text ; RVA 00003a70
FT_GetDriverVersion ; .text ; RVA 00003b80
FT_GetEventStatus ; .text ; RVA 00002a10
FT_GetLatencyTimer ; .text ; RVA 000030d0
FT_GetLibraryVersion ; .text ; RVA 00003bb0
FT_GetModemStatus ; .text ; RVA 000028b0
FT_GetQueueStatus ; .text ; RVA 000029a0
FT_GetStatus ; .text ; RVA 00002a40
FT_IoCtl ; .text ; RVA 00002660
FT_ListDevices ; .text ; RVA 00004450
FT_Open ; .text ; RVA 00004010
FT_OpenEx ; .text ; RVA 00004270
FT_Purge ; .text ; RVA 00002930
FT_Read ; .text ; RVA 000025a0
FT_ReadEE ; .text ; RVA 00002b50
FT_Reload ; .text ; RVA 00003ee0
FT_Rescan ; .text ; RVA 00003ed0
FT_ResetDevice ; .text ; RVA 000026d0
FT_ResetPort ; .text ; RVA 00003420
FT_RestartInTask ; .text ; RVA 000033c0
FT_SetBaudRate ; .text ; RVA 00002700
FT_SetBitMode ; .text ; RVA 00003100
FT_SetBreakOff ; .text ; RVA 00002ac0
FT_SetBreakOn ; .text ; RVA 00002a90
FT_SetChars ; .text ; RVA 000028e0
FT_SetDataCharacteristics ; .text ; RVA 00002770
FT_SetDeadmanTimeout ; .text ; RVA 000031b0
FT_SetDivisor ; .text ; RVA 00002740
FT_SetDtr ; .text ; RVA 000027f0
FT_SetEventNotification ; .text ; RVA 000029d0
FT_SetFlowControl ; .text ; RVA 000027b0
FT_SetLatencyTimer ; .text ; RVA 000030a0
FT_SetResetPipeRetryCount ; .text ; RVA 000033f0
FT_SetRts ; .text ; RVA 00002850
FT_SetTimeouts ; .text ; RVA 00002960
FT_SetUSBParameters ; .text ; RVA 00003170
FT_SetWaitMask ; .text ; RVA 00002af0
FT_StopInTask ; .text ; RVA 00003390
FT_W32_CancelIo ; .text ; RVA 00003590
FT_W32_ClearCommBreak ; .text ; RVA 000035b0
FT_W32_ClearCommError ; .text ; RVA 000035e0
FT_W32_CloseHandle ; .text ; RVA 00003480
FT_W32_CreateFile ; .text ; RVA 00005340
FT_W32_EscapeCommFunction ; .text ; RVA 00003640
FT_W32_GetCommMask ; .text ; RVA 00003900
FT_W32_GetCommModemStatus ; .text ; RVA 00003780
FT_W32_GetCommState ; .text ; RVA 000037b0
FT_W32_GetCommTimeouts ; .text ; RVA 00003810
FT_W32_GetLastError ; .text ; RVA 00003840
FT_W32_GetOverlappedResult ; .text ; RVA 00003550
FT_W32_PurgeComm ; .text ; RVA 00003850
FT_W32_ReadFile ; .text ; RVA 000034d0
FT_W32_SetCommBreak ; .text ; RVA 000038a0
FT_W32_SetCommMask ; .text ; RVA 000038d0
FT_W32_SetCommState ; .text ; RVA 00003930
FT_W32_SetCommTimeouts ; .text ; RVA 00003980
FT_W32_SetupComm ; .text ; RVA 000039d0
FT_W32_WaitCommEvent ; .text ; RVA 000039f0
FT_W32_WriteFile ; .text ; RVA 00003510
FT_WaitOnMask ; .text ; RVA 00002b20
FT_Write ; .text ; RVA 00002600
FT_WriteEE ; .text ; RVA 00002b80

You can also generate the .Def File needed for MinGW:
pexports -v ./win32/i386/ftd2xx.dll > ftd2xx.def

Next we would need to compile a lib file (.a file) to be used with MinGW.
Fortunately the dlltool utility comes bundled with the MinGW package.
dlltool -A --dllname <DLL File Name>.dll --def <DEF File Name>.def --output-lib <LIB File Name>.a

Eg: We used for generating the libftd2xx.a by
dlltool -A --dllname ftd2xx.dll --def ftd2xx.def --output-lib libftd2xx.a

Hope that you can add more to this process, please feel free to comment.

Warm Regards,
Boseji

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Welcome to Boseji's Blog

Popular Post

Blogger templates

Welcome

Creation by Electronics Hobbyists from Bharat(India) to encourage & help people. This blog hosts the numerous innovations, discoveries and projects we provide.
Our Research Wing Adhar Labs
Contact Form | Email Address
We Support Open Source Hardware Definition v1.0
Creative Commons License
All works on this blog are licensed under a
Creative Commons Attribution-ShareAlike 3.0 Unported License.
Based on a work at forbharat.wordpress.com and m8051.blogspot.com.

Permissions beyond the scope of this license may be available at http://forbharat.wordpress.com/permissions/.
Thank you for all your support.

© A.D.H.A.R Labs Research 2008-2013 . Powered by Blogger.

Follow by Email

Followers

PCB Unit Converter

mils
mm

- Copyright © Electronics for Bharat -Robotic Notes- Powered by Blogger - Designed by Johanes Djogan -