Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

Smart Bluetooth Forum Discussions

LeCa_2156671
Level 4
Level 4
First like received First like given

Dear Kwang

     Per  maxsong  boont  j.t

   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...

0 Likes
1 Solution

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...

View solution in original post

0 Likes
13 Replies
Anonymous
Not applicable

Hi lemancai

How large is your application?

Also for data transmission, you can try using long characteristic which is 160 bytes.


-Kevin

0 Likes

Hi Kevin, kwangmaxsongboont

    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...

0 Likes
Anonymous
Not applicable
  • 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));

0 Likes

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

0 Likes
Anonymous
Not applicable
  • 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?
0 Likes
  • 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.

0 Likes

You can find guidelines for using long characteristics within the long characteristic sample application included within the SDK: /WICED-Smart-SDK/Apps/long_characteristic

0 Likes

Tks for your info. we would study it

0 Likes
LeCa_2156671
Level 4
Level 4
First like received First like given

Dear maxsongj.tkwangmwf_mmfae


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

0 Likes

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

0 Likes

Dear Boont,

maxsong

     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...

0 Likes
Anonymous
Not applicable

lemancai

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

0 Likes

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...

0 Likes