Code: Select all
ObtainHwLocksBIP(HLB_NONE, HLIO_NONE, HLP_USB);
...
ReleaseHwLocksBIP(HLB_NONE, HLIO_NONE, HLP_USB);
-Panu
Code: Select all
ObtainHwLocksBIP(HLB_NONE, HLIO_NONE, HLP_USB);
...
ReleaseHwLocksBIP(HLB_NONE, HLIO_NONE, HLP_USB);
I will try to get some more stack tracesHello.<LF>
VSOS 3.35 build Oct 01 2016 18:11:47<LF>
VLSI Solution Oy 2012-2016 - www.vlsi.fi<LF>
<LF>
Starting the kernel..<LF>
Starting Devices... <LF>
Internal Flash<LF>
<LF>
Installed system devices:<LF>
S: SPI Flash c213, handled by FAT.<LF>
Load drivers, config 0...<LF>
Driver: INTTRACE... <LF>
Driver: AUOI2SMA... <LF>
Driver: S:MainApplication.ap3... K: SD card in SD mode<LF>
<LF>
VID_0781 PID_5567 SanDisk Cruzer Blade <LF>
1 drive(s).<LF>
U: USB Flash<LF>
E'RTCREAD not found'<LF>
IMEM: only 3400w free!<LF>
IMEM: only 2238w free!<LF>
Close device U:<LF>
No device.<LF>
E'RTCREAD not found'<LF>
<LF>
VID_0781 PID_5567 SanDisk Cruzer Blade <LF>
1 drive(s).<LF>
U: USB Flash<LF>
<LF>
VID_0781 PID_5567 SanDisk Cruzer Blade <LF>
E'RTCREAD not found'<LF>
<LF>
SOF count: 6749 <LF>
Stop at 21277(0x531d): USBHOST::WaitForUsbInt[8]<LF>
SOF count: 3577 <LF>
Task 0x093c, priority 10, in RUNNING, name "DECOD"<LF>
State: 3 (TS_READY)<LF>
Stack: Start 0x0254, size 0x17c, in use 0x7e, max used 0x15f (0x1d free)<LF>
Stack Trace: current PC 0x5ea3, Tasks::main[195]<LF>
Next: PC 0x1e81 @ stack 0x02db, KERNEL::LoadLibraryFile[10]<LF>
Next: PC 0x312f @ stack 0x02d5, IntTrace::IntReguC[47]<LF>
Next: PC 0x0009 @ stack 0x02c7, KERNEL::ZeroPtrCall$0[9]<LF>
Next: PC 0x518c @ stack 0x02bc, USBHOST::UsbSetupReadOperation[11]<LF>
Next: PC 0x52c5 @ stack 0x02b2, USBHOST::OpenUsbDevice[26]<LF>
Next: PC 0x4dc3 @ stack 0x02ae, USBHOST::DevUMassProbe[10]<LF>
Next: PC 0x4d04 @ stack 0x02a6, USBHOST::DevUMassBlockRead[51]<LF>
Next: PC 0x0c55 @ stack 0x029c, KERNEL::FatImageSectorRead[58]<LF>
Next: PC 0x1278 @ stack 0x0293, KERNEL::VoFatReadFile[84]<LF>
Next: PC 0x5851 @ stack 0x0288, AUDIODEC::DefaultCSRead[90]<LF>
Next: PC 0xd6d4 @ stack 0x027c, IROM::CodMpg[244]<LF>
Next: PC 0x5bca @ stack 0x0270, DECMP3::CodMpgDecode[269]<LF>
Next: PC 0x57f0 @ stack 0x0260, AUDIODEC::MyDecodeAudio[16]<LF>
Next: PC 0x3abd @ stack 0x0259, MainAppl::PlayerTask[15]<LF>
<LF>
Task 0x1c01, priority 10, in readyQueue, name "cyclic"<LF>
State: 3 (TS_READY)<LF>
Stack: Start 0x1c10, size 0x100, in use 0x29, max used 0x3d (0xc3 free)<LF>
Stack Trace: current PC 0x918f, IROM::rtos2[231]<LF>
Next: PC 0x2bcb @ stack 0x1c1e, KERNEL::CyclicMainLoop[97]<LF>
Next: PC 0x90b5 @ stack 0x1c11, IROM::exit<LF>
Registers:<LF>
i0:0x1c1f i1:0x0012 i2:0x1fd9 i3:0x1c08<LF>
i4:0x1c1e i5:0x0000 i6:0x1c2b i7:0xfc08<LF>
a2:0x0000 a1:0x0004 a0:0x8000 b2:0x0000 b1:0x0000 b0:0x0000<LF>
c2:0xffff c1:0xffff c0:0xdf2c d2:0x0000 d1:0x0005 d0:0x0004<LF>
p1:0x0000 p0:0x0000 ls:0xebab le:0xffff lc:0x0000 mr0:0x0210 lr0:0x9184<LF>
<LF>
Task 0x1e15, priority 1, in readyQueue, name "Command_Response"<LF>
State: 3 (TS_READY)<LF>
Stack: Start 0x22dc, size 0x800, in use 0x17, max used 0xff (0x701 free)<LF>
Stack Trace: current PC 0x369c, MainAppl::Command_Response_Task[64]<LF>
Next: PC 0x90b5 @ stack 0x22dd, IROM::exit<LF>
Registers:<LF>
i0:0x0e28 i1:0x0c64 i2:0x0c63 i3:0x0e2a<LF>
i4:0x22de i5:0xffe9 i6:0x22e5 i7:0xfc09<LF>
a2:0x0000 a1:0x0c18 a0:0x00ff b2:0x0000 b1:0x0002 b0:0x0008<LF>
c2:0x0000 c1:0x0704 c0:0xffef d2:0xffff d1:0xffff d0:0x0604<LF>
p1:0x0000 p0:0x003c ls:0xebab le:0xffff lc:0x0000 mr0:0x0288 lr0:0x373a<LF>
<LF>
Task 0x0021, priority 1, in readyQueue, name "MainTask"<LF>
State: 3 (TS_READY)<LF>
Stack: Start 0x0030, size 0x200, in use 0x60, max used 0x183 (0x7d free)<LF>
Stack Trace: current PC 0x38c1, MainAppl::main[185]<LF>
Next: PC 0x03c6 @ stack 0x007c, KERNEL::LoadDrivers[204]<LF>
Next: PC 0x048e @ stack 0x003e, KERNEL::main[142]<LF>
Next: PC 0x0087 @ stack 0x0032, KERNEL::startup[7]<LF>
Registers:<LF>
i0:0x0e28 i1:0x3800 i2:0x1f09 i3:0x001e<LF>
i4:0x007c i5:0x0000 i6:0x0082 i7:0x1e15<LF>
a2:0x0000 a1:0x0702 a0:0x0102 b2:0x0000 b1:0x0000 b0:0x0014<LF>
c2:0x0000 c1:0x0001 c0:0x1f09 d2:0x0000 d1:0x0003 d0:0x0b76<LF>
p1:0x0000 p0:0x000e ls:0x03d2 le:0x03dd lc:0x0000 mr0:0x0281 lr0:0x38b1<LF>
<LF>
Timer queue 0x1c1f for task 0x1c01 ("cyclic")<LF>
Tick count: 0x0000<LF>
<LF>
Interrupts:<LF>
INT 0 INT_DAC , pri 2, vector 0x9385= IROM::AudioBufFree[12]<LF>
INT 4 INT_SPI1 , pri 3, vector 0x38fb= MainAppl::Spi1IntAsm<LF>
INT 13 INT_UART_RX , pri 1, vector 0x809b= IROM::monitorVectors[140]<LF>
INT 15 INT_TIMER1 , pri 2, vector 0x020d= KERNEL::SetNextApp[47]<LF>
INT 16 INT_TIMER2 , pri 2, vector 0x29a7= KERNEL::SystemUiMessageCyclic[23]<LF>
INT 25 INT_REGU , pri 1, vector 0x315d= IntTrace::IntReguAsm<LF>
If we are lucky, renaming main() to init() fixes problems. If we are unlucky, it disables some recovery mechanism from hardware failure. We'll see. Sorry that I can't test it right now, I'm not at the office.DEVICE usbFlash[4];
char usbSystemDevices[4] = {0};
int main(char *parameters){
}
int init(char *parameters) {
u_int16 nDisks;
u_int16 i;
nDisks = DevUMassProbe();
...etc...
Code: Select all
st = scsi_request(SCSI_READ_10,epin,epout,data,blocks*512,hw->lun,scp);
if (st == E_AGAIN) {
// Try same request again
debug_printf1("GOT E_AGAIN\n");
continue;
} else if (st == S_ERROR) {
// Try reconfigure usb_bus
if (DevUMassProbe() == S_ERROR) {
dev->flags = __MASK_PRESENT | __MASK_SEEKABLE | __MASK_READABLE | __MASK_WRITABLE;
return S_ERROR;
}
Right, my point is that DevUMassBlockRead and DevUMassBlockWrite have ObtainLocks protection, which ensures that only one copy is running. But main() has not, so if it's a re-entrancy issue then I can only see main() as a possible entry point to the driver that is not protected. Another entry point is DevUMassIoctl, but that only calls BlockRead (and StartFileSystem which also just calls BlockRead) so that route should be protected through the BlockRead ObtainLock.I doubt whether the driver re-intialization as such is happening, in the sense that the main function is getting called again. In DevUMassBlockWrite and DevUMassBlockRead we are re-initializing the device by calling DevUMassProbe if the scsi request return error.
Ok.. have you installed the tracing libraries (INTTRACE, TRACE etc) so that you can get a Power button Stop trace when the device hangs? Please always get a stop trace when the unit hangs. We need to examine all stop locations and add timeout code to all the functions everywhere where it gets stuck. Like in Ison's last trace there'sOn some USB drives, we find that the application gets stuck during fopen(), unlink() and fclose() operations. This is when we observe VID and PID printouts coming from the USB host.
so we should look at the start of WaitForUsbInt if there's still a deadlock possibility (while loop) there. But it's so strange, my current version's WaitForUsbInt isStop at 21277(0x531d): USBHOST::WaitForUsbInt[8]
Code: Select all
u_int16 WaitForUsbInt(u_int16 mask) {
u_int16 timeout = 0;
u_int16 ret;
do {
if (timeout++ > 10000) return 0;
ret = PERIP(USB_STATUS);
} while ((ret&mask) == 0);
PERIP(USB_STATUS) = ret&mask;
return ret;
}
We will do this and post the results.Ok.. have you installed the tracing libraries (INTTRACE, TRACE etc) so that you can get a Power button Stop trace when the device hangs? Please always get a stop trace when the unit hangs. We need to examine all stop locations and add timeout code to all the functions everywhere where it gets stuck. Like in Ison's last trace there's
We checked this already and could not find any issues. Will put the scope on it again just in case we missed something.Maybe it's not a re-entrancy issue at all, maybe it is an electrical failure that triggers reinitialization of the driver and the code gets stuck because something bad is happening electrically, and there's more possible deadlock locations in the startup code than in the block read/write code.
You should have our unit now...perhaps this will help the debug process once you are feeling better.There's still the irritating fact that when I use the Developer Board, the driver basically survives anything that I can throw at it, including power outages, cut signal wires, even with four separate concurrent tasks accessing it. So the bug might be something completely different, or in a completely different location, maybe not even related to USB. So let's keep our minds open to all possibilities.