2011-08-12 01:23 AM
Hi,
I am currently developing a PC application for STM32 using Inemo board.The PC application will be able to upgrade the firmware of the STM32 using Dfu mode. Iam using Visual studio Vb.net for the PC side application. I have succedded in enemurating my device and getting a symbolic link to the device and Im able to read the DFU Functional descriptor. However Iam unable to do upgrade because the variables used in VB are quite different somehow from the C++ ones.And since I cannot really have byte arrays in structure I have to create consequtive memory regions by placing many bytes one after each other Has anyone linked the dlls using vb.net? Iam facing problem with ''STDFUPRT_CreateMappingFromDevice'' to this function I have passed a string of symbolic device link as the first parameter and for the second parameter Iam passing a reference to a structure which has 283 bytes.On return I get a no-error response but my structure values are all corrupted and doesnot indicate any useful information.The third parameter is simply a reference to a integer and its filled with a value one so i guess this is right I have also tried filling name[] array with device symbolic link but it always returns corrupt values. After calling the function the bytes of the mapping structure are affected as under The first byte is A8 The first byte is 9a The third byte is 92 Also in the manual ''UM0384 Dfuse application programming interface'' the MAPPING structure shows that pointer to structure has 18 bytes.Whereas MAPPING SECTOR has 19 bytes in total is this a typo?2011-08-12 02:49 AM
typedef struct {
DWORD dwStartAddress;
DWORD dwAliasedAddress;
DWORD dwSectorIndex;
DWORD dwSectorSize;
BYTE bSectorType;
BOOL UseForOperation;
} MAPPINGSECTOR, *PMAPPINGSECTOR;
typedef struct {
BYTE nAlternate;
char Name[MAX_PATH];
DWORD NbSectors;
PMAPPINGSECTOR pSectors;
} MAPPING, *PMAPPING;
inorder to callSTDFUPRT_CreateMappingFromDevice
2011-08-12 03:08 AM
Here are the ways I have tried to do this but wont work
Structure PMAPPINGDim nAlternate As Byte
Dim name As IntPtr
Dim nbsector As Int32
Dim psector As IntPtr
End Structure
dim m_pMapping as PMAPPINGm_pMapping.name = Marshal.AllocHGlobal(259)
m_pMapping.psector = Marshal.AllocHGlobal(18)
'then calldwRet = STDFUPRT_CreateMappingFromDevice(tmpbuffer, m_pMapping, alt2)
'where tmpbuffer is a byte array of devicelinkstring dwret = 0x1234000 'no errorDim teststr As String
teststr = Marshal.PtrToStringAuto(m_pMapping.name)
test returns two or three garbage characters
_______________________________________________________________________ second wayDim nAlternate As Byte
Dim name1 As byte
Dim name2 As byte Dim name3 As byte .. .. .....name260 as byte Dim nbsector As Int32Dim psector1 As byte
.. .. .. .. psector18 as byte This wouldnt work either Ive tried keeping name as string but that work