Alfred:

Another thing with the nimble stack. The mbuf block size of 292, which Chris 
shows reduced to 200, is much larger than it needs to be. I am not sure what 
the smallest size actually is, but you can set it to 100 bytes and it should 
work. This can get you more buffers and/or reduce your memory usage quite a 
bit. The amount of buffers you actually need is quite application dependent and 
generally requires some experimentation unfortunately.

And thanks for the kind words regarding the stats, logging and image update 
functionality. We appreciate it!

> On Jun 16, 2017, at 10:39 AM, Christopher Collins <ch...@runtime.io> wrote:
> 
> Hi Alfred,
> 
> On Fri, Jun 16, 2017 at 07:02:47PM +0200, Alfred Schilken wrote:
>> Hello all, I’m experimenting with mynewt for several weeks now and I’m 
>> especially impressed by the statistics, logging and image update 
>> functionality.
>> I’m having problems with getting all the statistics using newtmgr via BLE.
>> 
>> I  took bleprph as base, added ADC and enabled several stats, logs and so on.
>> To reduce flash size I had to switch off debug and reduce the logging.
>> 
>> When I started the program I got an Assert-reboot-loop.
>> The target board is a bbc microbit.
>> 
>> This seems to be cause of the error:
>> ble_att_svr_entry_mem = malloc(
>>    OS_MEMPOOL_BYTES(ble_hs_max_attrs, sizeof (struct ble_att_svr_entry)));
>> if (ble_att_svr_entry_mem == NULL) {
>>    rc = BLE_HS_ENOMEM;
>>    goto err;
>> }
> 
> Fitting BLE and newtmgr into 16kB requires some creativity :).  There
> are certainly some memory and mbuf optimizations that could be made, we
> just need to go through the exercise of scouring the code.
> 
>> I tweaked these four config values to fix the crash-loop.
>> BLE_ACL_BUF_COUNT: 4    # was 4
>> BLE_ACL_BUF_SIZE: 128  # was 255
>> MSYS_1_BLOCK_COUNT: 4  # was 12
>> MSYS_1_BLOCK_SIZE: 292 # was 292
>> 
>> The program boots now, I can see and connect to the BLE services and all 
>> this is fine.
>> 
>> If I use newtmgr via ble transport to read the statistics, some of them are 
>> responding, others return just Error: 2.
>> mpstat and taskstat also don’t work.
>> But „image list“ is working, I could even upload a new image.
>> 
>> 
>> My question is:
>> What are the best config settings to reduce ram usage, so that an app runs 
>> in 16 kb with least impact on functionality? 
> 
> I was able to get mpstats working on a 16kB device with the following
> mbuf settings:
> 
>    MSYS_1_BLOCK_COUNT: 11
>    MSYS_1_BLOCK_SIZE: 200
> 
>> Some hints to reduce flash size would also be appreciated :-) 
> 
> You might want to look into the split image functionality:
> https://mynewt.apache.org/latest/os/modules/split/split.  This allows
> you dedicate more flash space to your application code.  I don't think
> this will help with your immediates issues, however, since BLE and
> newtmgr would both need to go into the loader image.
> 
> Chris

Reply via email to