[En-Nut-Discussion] AT91 SPI Bus crash.

Harald Kipp harald.kipp at egnite.de
Wed Nov 23 17:11:47 CET 2011


Hi Pierre-Louis,

On 23.11.2011 01:33, Pilou wrote:
> I am new on this mailing so here's my greetings and congrats for the 
> amazing work provided around Nut/OS.

Many thanks for this kind comment, in the name of all contributors.

> I am quizical about the line 318 in spibus0at91.c :
> NutEventWait(&node->node_bus->bus_ready, NUT_WAIT_INFINITE);

More details are explained on this page
http://www.ethernut.de/en/documents/ntn-6_spi.html

spiBus0Gpio.bus_alloc() allocates the bus and semaphore.
spiBus0Gpio.bus_release() releases the bus and the semaphore.

Mutex semaphores are implemented in a very simple way:

The first NutEventPost(&queue) sets the then empty queue to the signaled
state. This means, that the first NutEventWait(&queue, tmo) will be
granted immediately and the queue returns to an empty state. The
following NutEventWait() will add the calling thread to this queue and
put the thread to sleep until the previous threads, that called
NutEventWait() releases the bus by calling NutEventPost().

The nut/apps/events sample demonstrates this.

The SPI bus driver is a bit different, because it calls
NutEventPostFromIrq(). This is almost the same as NutEventPost(), but
the real context switch is delayed (asynchronous). NutEventPost() is not
allowed to be called from interrupts.

> This problem has been mentioned earlier ( here : 
> http://old.nabble.com/SPI-on-Arm7-%28EIR%29-Board-td32415281.html ) 
> <http://old.nabble.com/SPI-on-Arm7-%28EIR%29-Board-td32415281.html>

AFAIR, this was a different problem. Jörg used two devices in different
SPI modes and it turned out, that the driver didn't (and still doesn't?)
support mode switching.

If it still fails, you may try different bus driver modes. Search in the
Configurator for SPIBUS0_POLLING_MODE, SPIBUS0_DOUBLE_BUFFER and
SPIBUS0_DOUBLE_BUFFER_HEURISTIC. Do not forget to rebuild the libraries,
after changing any of these. Also note, that some configuration changes
may require to create (actually update) the sample directory as well.
Don't worry, your changes in the app directory will be preserved.


Regards,

Harald



More information about the En-Nut-Discussion mailing list