Open teeheee opened 6 years ago
This is what the spi communication looks like when HC05 is connected. And when the HC05 is not connected and the bug not happening.
Looks like a bug in driver. Unfortunately I have no HW to test at the moment. If You can assist in debugging, can You please rerun in wine with wine debugging turned on like this:
env WINEDEBUG=+relay blueflashcmd.exe chipver 2>&1 | grep usbspi
and post the result.
I ran the setup with the following command:
env WINEDBG=+relay wine BlueFlashCmd.exe chipver 2>&1 | grep usbspi
and it gave this output:
=>0 0x7e2a6124 spi_xfer+0xfe() in usbspi (0x0033f704) 1 0x7e2a4897 in usbspi (+0x4896) (0x0033f754) 2 0x7e2a4fcc spifns_stream_sequence+0xe2() in usbspi (0x0033f794) 0x7e2a6124 spi_xfer+0xfe in usbspi: movzwl 0x0(%eax),%eax ELF 7e28e000-7e2ba000 Dwarf usbspi
-PE 7e2a0000-7e2ba000 \ usbspi
I found a solution to fix my error. There was some padding problem in SPISEQ_1_4. I tried to pack the struct but it didn't work so I wrote some ugly code to get it to program. Here is the method I changed:
DLLEXPORT int spifns_stream_sequence(spifns_stream_t stream, SPISEQ_1_4 *_pSequence, int nCount)
{
LOG(DEBUG, "(%d, %p, %d)", stream, _pSequence, nCount);
int nRetval=0;
unsigned short* pshort = (unsigned short*)_pSequence; //save the address in convinient datatype
while (nCount--) {
SPISEQ_1_4 *pSequence = (SPISEQ_1_4 *)pshort;
SPISEQ_1_4 Sequence;
Sequence.nType = pSequence->nType; //first element has no padding
Sequence.rw.nAddress = pshort[2]; //enum is 32 bit so offset is 4 byte
Sequence.rw.nLength = pshort[3];
unsigned short** ppshort = (unsigned short**)pshort;
Sequence.rw.pnData = (unsigned short*)ppshort[2]; // 32 bit address
if(_pSequence->nType==0 || _pSequence->nType==1) //one type is diffrent?
pSequence = &Sequence;
LOG(DEBUG, "command %d", pSequence->nType);
switch (pSequence->nType) {
case SPISEQ_1_4::TYPE_READ:
if (spifns_sequence_read(pSequence->rw.nAddress,pSequence->rw.nLength,pSequence->rw.pnData)==1)
nRetval=1;
break;
case SPISEQ_1_4::TYPE_WRITE:
if (spifns_sequence_write(pSequence->rw.nAddress,pSequence->rw.nLength,pSequence->rw.pnData)==1)
nRetval=1;
break;
case SPISEQ_1_4::TYPE_SETVAR:
if (spifns_sequence_setvar(pSequence->setvar.szName,pSequence->setvar.szValue)==1)
nRetval=1;
break;
default:
LOG(WARN, "Sequence command not implemented: %d", pSequence->nType);
g_nError = SPIFNS_ERROR_INVALID_PARAMETER;
snprintf(g_szErrorString, sizeof(g_szErrorString),
"sequence command %d not implemented", pSequence->nType);
nRetval = 1;
}
pshort+=6; // increment by 6 shorts is 12 byte is one package
}
return nRetval;
}
I do not suggest using this code, but maybe someone who knows the project better can fix the padding problem.
Thanks for your analysis and code! It looks like BlueSuite 2.4 uses SPI API 1.3, but calls spifns_stream_sequence()
, which should support that case.
I added appropriate changes to issue-28 branch. If You still have time and HW, can You please test this branch or the precompiled binaries here: https://github.com/lorf/csr-spi-ftdi/releases/tag/0.5.3-a2 ?
Hello,
I tried this code a year ago and it worked good. Now I wanted to use it again with the same setup but it always breaks when Blueflash communicates with the Module. I tried it on two different PCs with wine-1.6.2, windows7 and windows10 and tried the prebuild version and build it myself. It is always the same behaviour. I also tried different usb Ports.
TLDR: OS: Xubuntu with wine-1.6.2 or windows7 or windows10 Bluesuite: 2.4 usbspi.dll: prebuild-0.5.1, prebuild-0.5.2 and ownbuild-0.5.2 (for all OSs) FTDI-CHIP: probably real FT232RL Problem: Bluesuite crashes when using the usbspi.dll.
Here is the stacktrace I got from wine when using the prebuild version of the dll.