Hi,
I’m setting up a project with FreeRTOS+TCP v4.3.1 and Kernel v10.6.2 using a SAMV71Q21B and a KSZ8795 5 port switch.
While I do use the default MDIO interface I had to make some changes to the SAM drivers and networkinterface.c since they are designed with an SAME70 in mind and I use RMII instead of MII.
The setup and initialization seems to work great as far as I can tell but the moment I try to connect I run into:
/* Cannot block if the scheduler is suspended. */
#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
{
configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );
}
#endif
from queue.c.
After some debugging I found out that FreeRTOS_Sockets.c
static FreeRTOS_Socket_t * prvAcceptWaitClient( FreeRTOS_Socket_t * pxParentSocket,
struct freertos_sockaddr * pxAddress,
socklen_t * pxAddressLength )
{
FreeRTOS_Socket_t * pxClientSocket = NULL;
/* Is there a new client? */
vTaskSuspendAll();
is suspending the scheduler and while the scheduler is suspended,
NetworkBufferDescriptor_t * pxGetNetworkBufferWithDescriptor( size_t xRequestedSizeBytes,
TickType_t xBlockTimeTicks )
from BufferAllocation_2.c is called which in turn runs
if( ( xIntegerOverflowed == pdFALSE ) && ( xAllocatedBytes <= uxMaxAllowedBytes ) && ( xNetworkBufferSemaphore != NULL ) )
{
/* If there is a semaphore available, there is a network buffer available. */
if( xSemaphoreTake( xNetworkBufferSemaphore, xBlockTimeTicks ) == pdPASS )
I already worked my way through Debugging-Hard-Faults-On-Cortex-M-Microcontrollers and ARM-Cortex/RTOS-Cortex-M3-M4 but I could not find any errors through that. (Would have added the links but I am to new a user for it to be allowed)
I set
#define configMAX_LIBRARY_INTERRUPT_PRIORITY ( 5 )
#define configMAC_INTERRUPT_PRIORITY ( configMAX_LIBRARY_INTERRUPT_PRIORITY )
while having
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
and ensured it’s not a hard fault. I tried to change the priorities up and down against each other and changed the priorities of the task calling prvAcceptWaitClient
and the IP config task prvIPTask
to no avail.
The only way to fix it so far was to either add an FreeRTOS_printf(("\r\n"));
after usGenerateProtocolChecksum( pucBuffer, uxLength, pdTRUE );
in void vGMACGenerateChecksum( uint8_t * pucBuffer, size_t uxLength )
or remove the FreeRTOS_printf( ( "prvAcceptWaitClient: client %p parent %p\n", ( void * ) pxClientSocket, ( void * ) pxParentSocket ) );
in static FreeRTOS_Socket_t * prvAcceptWaitClient( FreeRTOS_Socket_t * pxParentSocket, struct freertos_sockaddr * pxAddress, socklen_t * pxAddressLength )
.
The latter is my current way to go since I don’t see the necessity of the print either way and I want to generate my checksums with the much more efficient hardware module of my V71.
In any case I am not too happy with the solution since I expect it to be some kind of configuration error or whatnot but I don’t really know what to check now or how to find my root cause and fix it.
Any help would be appreciated!