- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Kwang
Yes, it's still be an issue.
As I introduced before, we are now developping a cluster tree type network with BCM20736, and when the points(BCM20736) in the network is over 20, the data transmition would be error happened.
Our data transmition flow as below:
1. We declare one 100 layer msg_queue with the function:
Tx_Queue = cfa_mm_Sbrk(sizeof(BLEAPPFIFO_HDR) +
sizeof(void *) * Tx_Queue_Size); // 100 msg_queue
2. Once we get msg which would be bypassed to other points. we would malloc one memory, and copy the msg into the buffer, the buffer addr would be pushed into the msg_queue.
3. In fine_timerout() callback function, we would check the msg_queue, and we would call bleprofile_sendNotification() when the blecm_getAvailableTxBuffers() >=2
In our test, the 100 layers queue never be full. but the buffer malloc for msg storage might be fail in step 2 above.
Our BT TX data function in step 2 as below:
BT_TX_Data()
{
msgPtr = (TX_MSG *)cfa_mm_Alloc(sizeof(TX_MSG));
if( msgPtr )
{
msgPtr->handle = con_handle;
// allocate space for the msg.
msgPtr->len = len ;
msgPtr->dataPtr = cfa_mm_Alloc( msgPtr->len);
if( msgPtr->dataPtr )
{
// copy the msg.
BT_MEMCPY( msgPtr->dataPtr, data, msgPtr->len);
// put the msg into the queue.
if( !bleappfifo_append((BLEAPPFIFO_HDR*)Tx_Queue , msgPtr ) )
{
// we run out of space.
ble_trace0("TX queue out of space");
release_Tx_msg(msgPtr);
msgPtr = NULL;
test_add_disc(0xff);
}
else
{
// we got the msg in.
}
}
else
{
// we can't get the second piece of memory.
// release the first one.
cfa_mm_Free( msgPtr );
ble_trace0("TX queue out of memory");
test_add_disc(0xfe);
}
}
else
{
//
ble_trace0("TX queue out of memory");
test_add_disc(0xfc);
}
}
We believe that, when we do cfa_mm_Alloc() fail in BT_TX_Data() function, the function of bleprofile_sendNotification() would be fail too, which might cause the data loss.
My question:
1. What's the max size for user to malloc the buffer by cfa_mm_Alloc() function ?
2. Could we get bigger memory size with some configuration ?
3. Could you have any good suggestion to us for large data transmition ?
Many thanks...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Kevin,
We had known the relationship between mm_alloc() and cfa_mm_ConfigureMemoryPool(), and we had suceed to increase the RAM size for mm_alloc().
Many thanks...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi lemancai
How large is your application?
Also for data transmission, you can try using long characteristic which is 160 bytes.
-Kevin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In WICED, our APPs after building:
----------------------------------------------------------------------------------------------------------------------
Patches start at 0x00204568 (RAM address)
Patches end at 0x00205504 (RAM address)
Application starts at 0x00205140 (RAM address)
Application ends at 0x00209624 (RAM address)
Patch size (including reused RAM) 3996 bytes
Patch size 3032 bytes
Application size 17636 bytes
----------------------------------
Total RAM footprint 20668 bytes (20.2kiB)
------------------------------------------------------------------------------------------------------------------------
app.hex file size is 42.2KB
app.ota.hex file size is 42.1KB
app.ota file size is 20.5KB
I do not know which size is needed by U.
We never use long characteristic before, is there any guideline ?? We tried to change the MTU before, to increase the maximum SDU size, but failed. seems 20736 do not support this command.
Tks for your quickly reply...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- What's the value of Tx_Queue_Size?
Tx_Queue = cfa_mm_Sbrk(sizeof(BLEAPPFIFO_HDR) +
sizeof(void *) * Tx_Queue_Size);
- What's the size of TX_MSG?
msgPtr = (TX_MSG *)cfa_mm_Alloc(sizeof(TX_MSG));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Max,
- What's the value of Tx_Queue_Size?
Tx_Queue = cfa_mm_Sbrk(sizeof(BLEAPPFIFO_HDR) + sizeof(void *) * Tx_Queue_Size);
--> Leman: hundreds of bytes
- What's the size of TX_MSG?
msgPtr = (TX_MSG *)cfa_mm_Alloc(sizeof(TX_MSG));
--> Leman: TX_MSG size is 30 bytes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- And what's the value of msgPtr->len?
msgPtr->len = len ;
msgPtr->dataPtr = cfa_mm_Alloc( msgPtr->len);
- Did UART print "TX queue out of memory" when the issue occurred?
- Can you check the system free RAM by calling cfa_mm_MemFreeBytes() when the issue occurred?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- And what's the value of msgPtr->len?
msgPtr->len = len ; msgPtr->dataPtr = cfa_mm_Alloc( msgPtr->len);
--> Leman: 30 bytes
- Did UART print "TX queue out of memory" when the issue occurred?
--> Leman: Yes, when error occurred, it would print "TX queue out of memory"
- Can you check the system free RAM by calling cfa_mm_MemFreeBytes() when the issue occurred?
--> about 10K bytes when we call cfa_mm_MemFreeBytes().
If we add more debug code in, the RAM size would be decrease a little.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can find guidelines for using long characteristics within the long characteristic sample application included within the SDK: /WICED-Smart-SDK/Apps/long_characteristic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tks for your info. we would study it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
cfa_mm_Alloc() function return fail
Would function cfa_mm_Alloc() get allocated buffer from heap in stack ??
If the function returns fail, does it mean the left heap's size in stack is 0, and which function we could call to confirm the left heap size?
Could we increase the heap size ?? and by which function ??
tks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not sure it helps but no harm reading this thread...
the return value of cfa_mm_MemFreeBytes can't change after calling cfa_mm_Alloc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Boont,
It's helpless.
Our problem is the mm_alloc() fail, seems the ram for mm_alloc() function is empty. We need to know how to configurate the memory, to increase the RAM for mm_alloc() function.
Could U pls help us or ask some one's help ?
tks...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Instead of using mm_alloc(), try using cfa_mm_ConfigureMemoryPool. There is an example of this in secure_ota_upgrade in the application init function.
-Kevin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Kevin,
We had known the relationship between mm_alloc() and cfa_mm_ConfigureMemoryPool(), and we had suceed to increase the RAM size for mm_alloc().
Many thanks...