4 months ago.

Problem with network support for ARM CM3DS MPS2 board.

Mbed 5.11 release added back network support for ARM CM3DS MPS2 board. Sending and receiving data working fine for small number of times. But when tried to exchange more data, program hangs (recv call never returns).

I tried below logic which sends back data that it receives (512 bytes at a time).

for(i=0;i<100;++i) { printf("Loop %d \n",i); remaining = 0; p = buffer; while(remaining < 512) { r = socket.recv(p, 512); if (r <= 0) { printf("Error! socket.recv() returned: %d\n", r); break; } else { remaining += r; p += r; } }

size= 512; Loop until whole request send p = buffer; while(size) { r = socket.send(p, size); if (r < 0) { printf("Error! socket.connect() returned: %d\n", r); goto DISCONNECT; } size -= r; p+=r; } }

Program hangs in loop 22.

It seems emac driver for CM3DS MPS2 is not freeing up buffer after sending data. This is causing memory allocation error when a new packet is received and it is causing hang in recv() call.

Following fix seems to solve the issue.

diff git a/features/netsocket/emac-drivers/TARGET_ARM_SSG/COMPONENT_SMSC9220/smsc9220_emac.cpp b/features/netsocket/emac-drivers/TARGET_ARM_SSG/COMPONENT_SMSC9220/smsc9220_emac.cpp index 167024e..caf80bf 100644 - a/features/netsocket/emac-drivers/TARGET_ARM_SSG/COMPONENT_SMSC9220/smsc9220_emac.cpp +++ b/features/netsocket/emac-drivers/TARGET_ARM_SSG/COMPONENT_SMSC9220/smsc9220_emac.cpp @@ -168,6 +168,7 @@ bool SMSC9220_EMAC::link_out(emac_mem_buf_t *buf) true, (const char*)_memory_manager->get_ptr(buf), _memory_manager->get_len(buf)); + _memory_manager->free(buf); if (error != SMSC9220_ERROR_NONE) { _TXLockMutex.unlock(); return false;

Comment on this question
Be the first to answer this question.

To post an answer, please log in.