The 5ms timeout change to 50ms has certainly improved matters, but I'm not quite out of the woods.
I can run the sdiotest command from the shell as many times as you like, and it succeeds every time without needing to retry.
I have a function that opens a file on the SD card, reads and parses the contents. If I add this function as a callable shell command, and run it from the prompt, it works every time.
I'd like the system to run the command automatically, so in the main loop I added;
Code: Select all
if (!lwip_th_p && fs_ready) {
if (read_opts((BaseSequentialStream *)&SDU1) == 0) {
lwip_th_p = chThdCreateStatic(wa_lwip_thread,
LWIP_THREAD_STACK_SIZE,
NORMALPRIO + 2,
lwip_thread, &opts);
start_server();
}
}
Here read_opts is my function that works when called from the shell prompt.
Called from the main loop, however, it hangs the processor reliably on f_open. Even calling it from the Blinker thread, it hangs the processor, though at least after opening the file, but before reading it.
Trying to run from the blinker thread, the processor isn't sitting in the ResetHandler(), it's caught in an OS loop doing;
87 do {
88 cp = cp->p_next;
89 } while (cp->p_prio >= tp->p_prio);
(gdb) p cp
$5 = (Thread *) 0x20000a80
(gdb) p *cp
$6 = {p_next = 0x20000a80, p_prev = 0x20000a80, p_prio = 0, p_ctx = {r13 = 0x0}, p_newer = 0x20000a28,
p_older = 0x2000bbf0, p_name = 0x20000968 "\200\n", p_state = 48 '0', p_flags = 191 '\277',
p_refs = 0 '\000', p_preempt = 32 ' ', p_time = 536985600, p_u = {rdymsg = 0, exitcode = 0,
wtobjp = 0x0, ewmask = 0}, p_waiting = {p_next = 0x8003581}, p_msgqueue = {p_next = 0x0,
p_prev = 0x2000bd28}, p_msg = 0, p_epending = 536873656, p_mtxlist = 0x20000ab8, p_realprio = 0,
p_mpool = 0x0}
Pointing to itself?
Regards,
James.