cancel
Showing results for 
Search instead for 
Did you mean: 

Inemo Dfuse problem

dsouzahansen
Associate II
Posted on August 12, 2011 at 10:23

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?

2 REPLIES 2
dsouzahansen
Associate II
Posted on August 12, 2011 at 11:49

Does anyone know how I can create this structure in vb.net

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 call 

STDFUPRT_CreateMappingFromDevice

dsouzahansen
Associate II
Posted on August 12, 2011 at 12:08

Here are the ways I have tried to do this but wont work

Structure PMAPPING

Dim nAlternate As Byte

Dim name As IntPtr

Dim nbsector As Int32

Dim psector As IntPtr

End Structure

dim m_pMapping as PMAPPING

m_pMapping.name = Marshal.AllocHGlobal(259)

m_pMapping.psector = Marshal.AllocHGlobal(18)

'then call

 

dwRet = STDFUPRT_CreateMappingFromDevice(tmpbuffer, m_pMapping, alt2)

'where tmpbuffer is a byte array of devicelinkstring

dwret = 0x1234000 'no error

Dim teststr As String

teststr = Marshal.PtrToStringAuto(m_pMapping.name)

test returns two or three garbage characters

_______________________________________________________________________

second way

Dim nAlternate As Byte

Dim name1 As byte

Dim name2 As byte

Dim name3 As byte

..

..

.....name260 as byte

Dim nbsector As Int32

Dim psector1 As byte

..

..

..

..  psector18 as byte

This wouldnt work either

Ive tried keeping name as string but that work