You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mynewt.apache.org by WangJiacheng <ji...@icloud.com> on 2017/01/08 06:48:19 UTC

How to change the CPU time frequency of mynewt and nimble stack

Hi, 

The default CPU time frequency of Mynewt OS and Nimble stack is 1 MHz, I try to change the CPU time frequency to be 2 MHz, I modified the related 2 config files:
configure file “hw/bsp/nrf52dk/syscfg.yml” as
    CLOCK_FREQ:
        description: 'TBD'
        value:  2000000 
configure file “kernel/os/syscfg.yml” as
    OS_CPUTIME_FREQ:
        description: 'Frequency of os cputime'
        value: 2000000

The app “bleperiph" is running and the CPU time frequency is 2 MHz, also the BLE “nimble-bleprph” peripheral  can be scanned by LightBlue of iOS APP, and show 1 service is there. However, when I try to connect it ,an error massage “Connection Alert: Timeout interrogating the peripheral”

When change back above 2 syscfg parameters to 1000000, it can be connected.

And app “bletiny” is the same.

Is there any  missed config setting in my test? How to change the CPU time frequency to 2 Mhz and Nimble device can be connected?

Thanks,

Jiacheng 



Re: How to change the CPU time frequency of mynewt and nimble stack

Posted by will sanfilippo <wi...@runtime.io>.
You should be able to do exactly what you tried to do; that was one of the intents with os_cputime. Hopefully I will have an answer soon regarding why this does not work.

Regarding timers:

The nimble stack on the nrf52 currently uses Timer 0 for cputime (and thus for the controller BLE timing). It either uses RTC1 or TIMER1 for the os tick, depending on the syscfg variable XTAL_32768 in your bsp syscfg.yml file.


> On Jan 8, 2017, at 6:20 PM, WangJiacheng <ji...@icloud.com> wrote:
> 
> Hi, Will,
> 
> Thanks a lot for your reply.
> 
> Yes,the hardwear processor clock frequency of nRF52 (Cortex M4F) is 64 MHz and can not be changed.
> 
> The reason of changing CLOCK_FREQ is that I want re-use the internal timing of mynewt already there with more accurate timing, by calling function "os_cputime_get32()”.  I’m trying to implement a (soft) IC card reader by nRF52 with mynewt OS and nimble stack running.
> 
> I am also considering to use an independent timer (NRF_TIMER3 or  NRF_TIMER4) at the cost of about 0.1mA current. I already use NRF_TIMER2 to provide a 4 MHz clock signal output from GPIO of nRF52. By reading the source code of apache-mynewt-core, my understanding is that NRF_TIMER0 and NRF_TIMER1 is already used by mynewt OS and nimble stack, is my understanding correct?
> 
> Thanks,
> 
> Jiacheng
> 
>> 在 2017年1月9日,01:10,will sanfilippo <wi...@runtime.io> 写道:
>> 
>> Those should be the only two parameters you need to configure. Must be a bug in the controller :-)
>> 
>> I think it is worthwhile to point out that CLOCK_FREQ only changes the units of os cputime; it does not affect the speed at which the processor runs. At least, I could not see any other uses of CLOCK_FREQ. So, these settings only affect the nimble stack and the controller specifically (internal controller timing).
>> 
>> I am curious why you wanted to change this variable; what were you trying to achieve?
>> 
>> Thanks for pointing this out; I will take a look to see why it is not working.
>> 
>>> On Jan 7, 2017, at 10:48 PM, WangJiacheng <ji...@icloud.com> wrote:
>>> 
>>> Hi, 
>>> 
>>> The default CPU time frequency of Mynewt OS and Nimble stack is 1 MHz, I try to change the CPU time frequency to be 2 MHz, I modified the related 2 config files:
>>> configure file “hw/bsp/nrf52dk/syscfg.yml” as
>>>  CLOCK_FREQ:
>>>      description: 'TBD'
>>>      value:  2000000 
>>> configure file “kernel/os/syscfg.yml” as
>>>  OS_CPUTIME_FREQ:
>>>      description: 'Frequency of os cputime'
>>>      value: 2000000
>>> 
>>> The app “bleperiph" is running and the CPU time frequency is 2 MHz, also the BLE “nimble-bleprph” peripheral  can be scanned by LightBlue of iOS APP, and show 1 service is there. However, when I try to connect it ,an error massage “Connection Alert: Timeout interrogating the peripheral”
>>> 
>>> When change back above 2 syscfg parameters to 1000000, it can be connected.
>>> 
>>> And app “bletiny” is the same.
>>> 
>>> Is there any  missed config setting in my test? How to change the CPU time frequency to 2 Mhz and Nimble device can be connected?
>>> 
>>> Thanks,
>>> 
>>> Jiacheng 
>>> 
>>> 
>> 
> 


Re: How to change the CPU time frequency of mynewt and nimble stack

Posted by WangJiacheng <ji...@icloud.com>.
Thanks, Will.

By updating the develop code, both 2-MHz and 4-MHz CPU frequency are working now.

Best Regards,

Jiacheng


> 在 2017年1月11日,14:03,will sanfilippo <wi...@runtime.io> 写道:
> 
> Jiacheng:
> 
> OK, there were some more issues with setting a non-1MHz clock. I tested this with 1, 2 and 4 MHz using LightBlue (ios). I pushed the changes to develop so it should work now (one hopes).
> 
> 
>> On Jan 10, 2017, at 6:47 PM, WangJiacheng <ji...@icloud.com> wrote:
>> 
>> Thanks, Chris,
>> 
>> It’s working now.
>> 
>> More information about nimble stack with 2 MHz CPU frequency. nimble-bleprph can be connected by LightBlue, but after several seconds, it is disconnected with message “Disconnected Alert: The peripheral has disconnected.”  With 4 MHz CPU frequency, nimble-bleprph can not be scanned by LightBlue.
>> 
>> I’m trying to get higher timing resolution, to make my ISO/IEC 7816 stack (UICC-terminal interface) co-exist with nimble stack. 
>> 
>> Best Regards,
>> 
>> Jiacheng
>> 
>> 
>>> 在 2017年1月11日,09:26,Christopher Collins <cc...@apache.org> 写道:
>>> 
>>> Hi Jiacheng,
>>> 
>>> I think your version of newt is still slightly out of date.  You can
>>> install the latest as follows:
>>> 
>>>  cd $GOPATH/src/mynewt.apache.org/newt/newt &&
>>>     git checkout develop                    &&
>>>     git pull origin develop                 &&
>>>     go install                              ;
>>>     cd -
>>> 
>>> 
>>> Thanks,
>>> Chris
>>> 
>>> On Wed, Jan 11, 2017 at 09:04:05AM +0800, WangJiacheng wrote:
>>>> Sterling,
>>>> 
>>>> Thanks.
>>>> 
>>>> Yes, the newt is already updated. “newt version” has return "Apache Newt (incubating) version: 1.0.0-dev”.
>>>> 
>>>> Best Regards,
>>>> 
>>>> Jiacheng
>>>> 
>>>>> 在 2017年1月11日,08:58,Sterling Hughes <st...@apache.org> 写道:
>>>>> 
>>>>> Hi Jiacheng,
>>>>> 
>>>>> You need to update your newt tool along with the new develop.
>>>>> 
>>>>> Best,
>>>>> 
>>>>> Sterling
>>>>> 
>>>>> On 10 Jan 2017, at 16:46, WangJiacheng wrote:
>>>>> 
>>>>>> Hi, Will,
>>>>>> 
>>>>>> I need more help, I have an error message when compile the target.
>>>>>> 
>>>>>> I’m currently working on the release branch, so upgrade to dev branch by:
>>>>>> 1. change file project.yml from "vers: 0-latest” to "vers: 0-dev”
>>>>>> 2. upgrade to dev branch “newt upgrade”
>>>>>> 
>>>>>> Then compile the target by “newt build nrf52_boot”, an error message as:
>>>>>> ================================================================================
>>>>>> Building target targets/nrf52_boot
>>>>>> Compiling boot.c
>>>>>> Archiving boot.a
>>>>>> Compiling bootutil_misc.c
>>>>>> Compiling image_ec.c
>>>>>> Compiling image_ec256.c
>>>>>> Compiling image_rsa.c
>>>>>> Compiling image_validate.c
>>>>>> Compiling loader.c
>>>>>> Archiving bootutil.a
>>>>>> Error: In file included from aes.c:29:0:
>>>>>> /Users/jiachengwang/dev/myproj/repos/apache-mynewt-core/crypto/mbedtls/include/mbedtls/config.h:2522:10: error: #include expects "FILENAME" or <FILENAME>
>>>>>> #include MBEDTLS_USER_CONFIG_FILE
>>>>>>       ^
>>>>>> ================================================================================
>>>>>> it seems the config file "mbedtls/config_mynewt.h” define in “crypto/mbedtls/pkg.yml” is missed.
>>>>>> 
>>>>>> Thanks,
>>>>>> 
>>>>>> Jiacheng
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>>> 在 2017年1月10日,11:06,WangJiacheng <ji...@icloud.com> 写道:
>>>>>>> 
>>>>>>> Thanks, Will.
>>>>>>> 
>>>>>>> There is an Internet connection issue to GitHub.com currently, I’ll update the code later.
>>>>>>> 
>>>>>>> Best Regards,
>>>>>>> 
>>>>>>> Jiacheng
>>>>>>> 
>>>>>>> 
>>>>>>>> 在 2017年1月10日,10:10,will sanfilippo <wi...@runtime.io> 写道:
>>>>>>>> 
>>>>>>>> Hello:
>>>>>>>> 
>>>>>>>> This issue should now be fixed in the latest development branch. Note that this is not working on the nrf51 platforms but since you were using nrf52 it should work.
>>>>>>>> 
>>>>>>>> Let me know if you see any issues with it.
>>>>>>>> 
>>>>>>>> 
>>>>>>>>> On Jan 8, 2017, at 6:20 PM, WangJiacheng <ji...@icloud.com> wrote:
>>>>>>>>> 
>>>>>>>>> Hi, Will,
>>>>>>>>> 
>>>>>>>>> Thanks a lot for your reply.
>>>>>>>>> 
>>>>>>>>> Yes,the hardwear processor clock frequency of nRF52 (Cortex M4F) is 64 MHz and can not be changed.
>>>>>>>>> 
>>>>>>>>> The reason of changing CLOCK_FREQ is that I want re-use the internal timing of mynewt already there with more accurate timing, by calling function "os_cputime_get32()”.  I’m trying to implement a (soft) IC card reader by nRF52 with mynewt OS and nimble stack running.
>>>>>>>>> 
>>>>>>>>> I am also considering to use an independent timer (NRF_TIMER3 or  NRF_TIMER4) at the cost of about 0.1mA current. I already use NRF_TIMER2 to provide a 4 MHz clock signal output from GPIO of nRF52. By reading the source code of apache-mynewt-core, my understanding is that NRF_TIMER0 and NRF_TIMER1 is already used by mynewt OS and nimble stack, is my understanding correct?
>>>>>>>>> 
>>>>>>>>> Thanks,
>>>>>>>>> 
>>>>>>>>> Jiacheng
>>>>>>>>> 
>>>>>>>>>> 在 2017年1月9日,01:10,will sanfilippo <wi...@runtime.io> 写道:
>>>>>>>>>> 
>>>>>>>>>> Those should be the only two parameters you need to configure. Must be a bug in the controller :-)
>>>>>>>>>> 
>>>>>>>>>> I think it is worthwhile to point out that CLOCK_FREQ only changes the units of os cputime; it does not affect the speed at which the processor runs. At least, I could not see any other uses of CLOCK_FREQ. So, these settings only affect the nimble stack and the controller specifically (internal controller timing).
>>>>>>>>>> 
>>>>>>>>>> I am curious why you wanted to change this variable; what were you trying to achieve?
>>>>>>>>>> 
>>>>>>>>>> Thanks for pointing this out; I will take a look to see why it is not working.
>>>>>>>>>> 
>>>>>>>>>>> On Jan 7, 2017, at 10:48 PM, WangJiacheng <ji...@icloud.com> wrote:
>>>>>>>>>>> 
>>>>>>>>>>> Hi,
>>>>>>>>>>> 
>>>>>>>>>>> The default CPU time frequency of Mynewt OS and Nimble stack is 1 MHz, I try to change the CPU time frequency to be 2 MHz, I modified the related 2 config files:
>>>>>>>>>>> configure file “hw/bsp/nrf52dk/syscfg.yml” as
>>>>>>>>>>> CLOCK_FREQ:
>>>>>>>>>>> description: 'TBD'
>>>>>>>>>>> value:  2000000
>>>>>>>>>>> configure file “kernel/os/syscfg.yml” as
>>>>>>>>>>> OS_CPUTIME_FREQ:
>>>>>>>>>>> description: 'Frequency of os cputime'
>>>>>>>>>>> value: 2000000
>>>>>>>>>>> 
>>>>>>>>>>> The app “bleperiph" is running and the CPU time frequency is 2 MHz, also the BLE “nimble-bleprph” peripheral  can be scanned by LightBlue of iOS APP, and show 1 service is there. However, when I try to connect it ,an error massage “Connection Alert: Timeout interrogating the peripheral”
>>>>>>>>>>> 
>>>>>>>>>>> When change back above 2 syscfg parameters to 1000000, it can be connected.
>>>>>>>>>>> 
>>>>>>>>>>> And app “bletiny” is the same.
>>>>>>>>>>> 
>>>>>>>>>>> Is there any  missed config setting in my test? How to change the CPU time frequency to 2 Mhz and Nimble device can be connected?
>>>>>>>>>>> 
>>>>>>>>>>> Thanks,
>>>>>>>>>>> 
>>>>>>>>>>> Jiacheng
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>> 
>> 
> 


Re: How to change the CPU time frequency of mynewt and nimble stack

Posted by will sanfilippo <wi...@runtime.io>.
Jiacheng:

OK, there were some more issues with setting a non-1MHz clock. I tested this with 1, 2 and 4 MHz using LightBlue (ios). I pushed the changes to develop so it should work now (one hopes).


> On Jan 10, 2017, at 6:47 PM, WangJiacheng <ji...@icloud.com> wrote:
> 
> Thanks, Chris,
> 
> It’s working now.
> 
> More information about nimble stack with 2 MHz CPU frequency. nimble-bleprph can be connected by LightBlue, but after several seconds, it is disconnected with message “Disconnected Alert: The peripheral has disconnected.”  With 4 MHz CPU frequency, nimble-bleprph can not be scanned by LightBlue.
> 
> I’m trying to get higher timing resolution, to make my ISO/IEC 7816 stack (UICC-terminal interface) co-exist with nimble stack. 
> 
> Best Regards,
> 
> Jiacheng
> 
> 
>> 在 2017年1月11日,09:26,Christopher Collins <cc...@apache.org> 写道:
>> 
>> Hi Jiacheng,
>> 
>> I think your version of newt is still slightly out of date.  You can
>> install the latest as follows:
>> 
>>   cd $GOPATH/src/mynewt.apache.org/newt/newt &&
>>      git checkout develop                    &&
>>      git pull origin develop                 &&
>>      go install                              ;
>>      cd -
>> 
>> 
>> Thanks,
>> Chris
>> 
>> On Wed, Jan 11, 2017 at 09:04:05AM +0800, WangJiacheng wrote:
>>> Sterling,
>>> 
>>> Thanks.
>>> 
>>> Yes, the newt is already updated. “newt version” has return "Apache Newt (incubating) version: 1.0.0-dev”.
>>> 
>>> Best Regards,
>>> 
>>> Jiacheng
>>> 
>>>> 在 2017年1月11日,08:58,Sterling Hughes <st...@apache.org> 写道:
>>>> 
>>>> Hi Jiacheng,
>>>> 
>>>> You need to update your newt tool along with the new develop.
>>>> 
>>>> Best,
>>>> 
>>>> Sterling
>>>> 
>>>> On 10 Jan 2017, at 16:46, WangJiacheng wrote:
>>>> 
>>>>> Hi, Will,
>>>>> 
>>>>> I need more help, I have an error message when compile the target.
>>>>> 
>>>>> I’m currently working on the release branch, so upgrade to dev branch by:
>>>>>  1. change file project.yml from "vers: 0-latest” to "vers: 0-dev”
>>>>>  2. upgrade to dev branch “newt upgrade”
>>>>> 
>>>>> Then compile the target by “newt build nrf52_boot”, an error message as:
>>>>> ================================================================================
>>>>> Building target targets/nrf52_boot
>>>>> Compiling boot.c
>>>>> Archiving boot.a
>>>>> Compiling bootutil_misc.c
>>>>> Compiling image_ec.c
>>>>> Compiling image_ec256.c
>>>>> Compiling image_rsa.c
>>>>> Compiling image_validate.c
>>>>> Compiling loader.c
>>>>> Archiving bootutil.a
>>>>> Error: In file included from aes.c:29:0:
>>>>> /Users/jiachengwang/dev/myproj/repos/apache-mynewt-core/crypto/mbedtls/include/mbedtls/config.h:2522:10: error: #include expects "FILENAME" or <FILENAME>
>>>>> #include MBEDTLS_USER_CONFIG_FILE
>>>>>        ^
>>>>> ================================================================================
>>>>> it seems the config file "mbedtls/config_mynewt.h” define in “crypto/mbedtls/pkg.yml” is missed.
>>>>> 
>>>>> Thanks,
>>>>> 
>>>>> Jiacheng
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>>> 在 2017年1月10日,11:06,WangJiacheng <ji...@icloud.com> 写道:
>>>>>> 
>>>>>> Thanks, Will.
>>>>>> 
>>>>>> There is an Internet connection issue to GitHub.com currently, I’ll update the code later.
>>>>>> 
>>>>>> Best Regards,
>>>>>> 
>>>>>> Jiacheng
>>>>>> 
>>>>>> 
>>>>>>> 在 2017年1月10日,10:10,will sanfilippo <wi...@runtime.io> 写道:
>>>>>>> 
>>>>>>> Hello:
>>>>>>> 
>>>>>>> This issue should now be fixed in the latest development branch. Note that this is not working on the nrf51 platforms but since you were using nrf52 it should work.
>>>>>>> 
>>>>>>> Let me know if you see any issues with it.
>>>>>>> 
>>>>>>> 
>>>>>>>> On Jan 8, 2017, at 6:20 PM, WangJiacheng <ji...@icloud.com> wrote:
>>>>>>>> 
>>>>>>>> Hi, Will,
>>>>>>>> 
>>>>>>>> Thanks a lot for your reply.
>>>>>>>> 
>>>>>>>> Yes,the hardwear processor clock frequency of nRF52 (Cortex M4F) is 64 MHz and can not be changed.
>>>>>>>> 
>>>>>>>> The reason of changing CLOCK_FREQ is that I want re-use the internal timing of mynewt already there with more accurate timing, by calling function "os_cputime_get32()”.  I’m trying to implement a (soft) IC card reader by nRF52 with mynewt OS and nimble stack running.
>>>>>>>> 
>>>>>>>> I am also considering to use an independent timer (NRF_TIMER3 or  NRF_TIMER4) at the cost of about 0.1mA current. I already use NRF_TIMER2 to provide a 4 MHz clock signal output from GPIO of nRF52. By reading the source code of apache-mynewt-core, my understanding is that NRF_TIMER0 and NRF_TIMER1 is already used by mynewt OS and nimble stack, is my understanding correct?
>>>>>>>> 
>>>>>>>> Thanks,
>>>>>>>> 
>>>>>>>> Jiacheng
>>>>>>>> 
>>>>>>>>> 在 2017年1月9日,01:10,will sanfilippo <wi...@runtime.io> 写道:
>>>>>>>>> 
>>>>>>>>> Those should be the only two parameters you need to configure. Must be a bug in the controller :-)
>>>>>>>>> 
>>>>>>>>> I think it is worthwhile to point out that CLOCK_FREQ only changes the units of os cputime; it does not affect the speed at which the processor runs. At least, I could not see any other uses of CLOCK_FREQ. So, these settings only affect the nimble stack and the controller specifically (internal controller timing).
>>>>>>>>> 
>>>>>>>>> I am curious why you wanted to change this variable; what were you trying to achieve?
>>>>>>>>> 
>>>>>>>>> Thanks for pointing this out; I will take a look to see why it is not working.
>>>>>>>>> 
>>>>>>>>>> On Jan 7, 2017, at 10:48 PM, WangJiacheng <ji...@icloud.com> wrote:
>>>>>>>>>> 
>>>>>>>>>> Hi,
>>>>>>>>>> 
>>>>>>>>>> The default CPU time frequency of Mynewt OS and Nimble stack is 1 MHz, I try to change the CPU time frequency to be 2 MHz, I modified the related 2 config files:
>>>>>>>>>> configure file “hw/bsp/nrf52dk/syscfg.yml” as
>>>>>>>>>> CLOCK_FREQ:
>>>>>>>>>> description: 'TBD'
>>>>>>>>>> value:  2000000
>>>>>>>>>> configure file “kernel/os/syscfg.yml” as
>>>>>>>>>> OS_CPUTIME_FREQ:
>>>>>>>>>> description: 'Frequency of os cputime'
>>>>>>>>>> value: 2000000
>>>>>>>>>> 
>>>>>>>>>> The app “bleperiph" is running and the CPU time frequency is 2 MHz, also the BLE “nimble-bleprph” peripheral  can be scanned by LightBlue of iOS APP, and show 1 service is there. However, when I try to connect it ,an error massage “Connection Alert: Timeout interrogating the peripheral”
>>>>>>>>>> 
>>>>>>>>>> When change back above 2 syscfg parameters to 1000000, it can be connected.
>>>>>>>>>> 
>>>>>>>>>> And app “bletiny” is the same.
>>>>>>>>>> 
>>>>>>>>>> Is there any  missed config setting in my test? How to change the CPU time frequency to 2 Mhz and Nimble device can be connected?
>>>>>>>>>> 
>>>>>>>>>> Thanks,
>>>>>>>>>> 
>>>>>>>>>> Jiacheng
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>>>> 
>>> 
> 


Re: How to change the CPU time frequency of mynewt and nimble stack

Posted by WangJiacheng <ji...@icloud.com>.
Hi Chris,

My iOS is the latest 10.2, and the test devices are iPAD mini2, iPhone 6P, iPhone SE, both have the same disconnection issue (after several seconds).

With "BLE_LL_CFG_FEAT_DATA_LEN_EXT: 0”, the disconnection issue is still there.

Thanks,

Jiacheng



> 在 2017年1月11日,11:06,Christopher Collins <cc...@apache.org> 写道:
> 
> Hi Jiacheng,
> 
> On Wed, Jan 11, 2017 at 10:47:24AM +0800, WangJiacheng wrote:
>> More information about nimble stack with 2 MHz CPU frequency. nimble-bleprph can be connected by LightBlue, but after several seconds, it is disconnected with message “Disconnected Alert: The peripheral has disconnected.”  With 4 MHz CPU frequency, nimble-bleprph can not be scanned by LightBlue.
> 
> Could you tell me more about the device running LightBlue?  At one
> point, CoreBluetooth (the Apple Bluetooth library) had a bug that was
> triggered when the NimBLE controller initiated the data length extension
> procedure.  When this happened, the Apple device would send a bad
> response, and the NimBLE device would disconnect.  If you are using an
> older version of MacOS or iOS, then this could be the problem.
> 
> You can try disabling the data length extension feature to see if that
> is the problem.  Do this by adding the following text to
> targets/<target-name>/syscfg.yml:
> 
>    syscfg.vals:
>      BLE_LL_CFG_FEAT_DATA_LEN_EXT: 0
> 
> Thanks,
> Chris


Re: How to change the CPU time frequency of mynewt and nimble stack

Posted by Christopher Collins <cc...@apache.org>.
Hi Jiacheng,

On Wed, Jan 11, 2017 at 10:47:24AM +0800, WangJiacheng wrote:
> More information about nimble stack with 2 MHz CPU frequency. nimble-bleprph can be connected by LightBlue, but after several seconds, it is disconnected with message \u201cDisconnected Alert: The peripheral has disconnected.\u201d  With 4 MHz CPU frequency, nimble-bleprph can not be scanned by LightBlue.

Could you tell me more about the device running LightBlue?  At one
point, CoreBluetooth (the Apple Bluetooth library) had a bug that was
triggered when the NimBLE controller initiated the data length extension
procedure.  When this happened, the Apple device would send a bad
response, and the NimBLE device would disconnect.  If you are using an
older version of MacOS or iOS, then this could be the problem.

You can try disabling the data length extension feature to see if that
is the problem.  Do this by adding the following text to
targets/<target-name>/syscfg.yml:

    syscfg.vals:
      BLE_LL_CFG_FEAT_DATA_LEN_EXT: 0

Thanks,
Chris

Re: How to change the CPU time frequency of mynewt and nimble stack

Posted by WangJiacheng <ji...@icloud.com>.
Thanks, Chris,

It’s working now.

More information about nimble stack with 2 MHz CPU frequency. nimble-bleprph can be connected by LightBlue, but after several seconds, it is disconnected with message “Disconnected Alert: The peripheral has disconnected.”  With 4 MHz CPU frequency, nimble-bleprph can not be scanned by LightBlue.

I’m trying to get higher timing resolution, to make my ISO/IEC 7816 stack (UICC-terminal interface) co-exist with nimble stack. 

Best Regards,

Jiacheng


> 在 2017年1月11日,09:26,Christopher Collins <cc...@apache.org> 写道:
> 
> Hi Jiacheng,
> 
> I think your version of newt is still slightly out of date.  You can
> install the latest as follows:
> 
>    cd $GOPATH/src/mynewt.apache.org/newt/newt &&
>       git checkout develop                    &&
>       git pull origin develop                 &&
>       go install                              ;
>       cd -
> 
> 
> Thanks,
> Chris
> 
> On Wed, Jan 11, 2017 at 09:04:05AM +0800, WangJiacheng wrote:
>> Sterling,
>> 
>> Thanks.
>> 
>> Yes, the newt is already updated. “newt version” has return "Apache Newt (incubating) version: 1.0.0-dev”.
>> 
>> Best Regards,
>> 
>> Jiacheng
>> 
>>> 在 2017年1月11日,08:58,Sterling Hughes <st...@apache.org> 写道:
>>> 
>>> Hi Jiacheng,
>>> 
>>> You need to update your newt tool along with the new develop.
>>> 
>>> Best,
>>> 
>>> Sterling
>>> 
>>> On 10 Jan 2017, at 16:46, WangJiacheng wrote:
>>> 
>>>> Hi, Will,
>>>> 
>>>> I need more help, I have an error message when compile the target.
>>>> 
>>>> I’m currently working on the release branch, so upgrade to dev branch by:
>>>>   1. change file project.yml from "vers: 0-latest” to "vers: 0-dev”
>>>>   2. upgrade to dev branch “newt upgrade”
>>>> 
>>>> Then compile the target by “newt build nrf52_boot”, an error message as:
>>>> ================================================================================
>>>> Building target targets/nrf52_boot
>>>> Compiling boot.c
>>>> Archiving boot.a
>>>> Compiling bootutil_misc.c
>>>> Compiling image_ec.c
>>>> Compiling image_ec256.c
>>>> Compiling image_rsa.c
>>>> Compiling image_validate.c
>>>> Compiling loader.c
>>>> Archiving bootutil.a
>>>> Error: In file included from aes.c:29:0:
>>>> /Users/jiachengwang/dev/myproj/repos/apache-mynewt-core/crypto/mbedtls/include/mbedtls/config.h:2522:10: error: #include expects "FILENAME" or <FILENAME>
>>>> #include MBEDTLS_USER_CONFIG_FILE
>>>>         ^
>>>> ================================================================================
>>>> it seems the config file "mbedtls/config_mynewt.h” define in “crypto/mbedtls/pkg.yml” is missed.
>>>> 
>>>> Thanks,
>>>> 
>>>> Jiacheng
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>>> 在 2017年1月10日,11:06,WangJiacheng <ji...@icloud.com> 写道:
>>>>> 
>>>>> Thanks, Will.
>>>>> 
>>>>> There is an Internet connection issue to GitHub.com currently, I’ll update the code later.
>>>>> 
>>>>> Best Regards,
>>>>> 
>>>>> Jiacheng
>>>>> 
>>>>> 
>>>>>> 在 2017年1月10日,10:10,will sanfilippo <wi...@runtime.io> 写道:
>>>>>> 
>>>>>> Hello:
>>>>>> 
>>>>>> This issue should now be fixed in the latest development branch. Note that this is not working on the nrf51 platforms but since you were using nrf52 it should work.
>>>>>> 
>>>>>> Let me know if you see any issues with it.
>>>>>> 
>>>>>> 
>>>>>>> On Jan 8, 2017, at 6:20 PM, WangJiacheng <ji...@icloud.com> wrote:
>>>>>>> 
>>>>>>> Hi, Will,
>>>>>>> 
>>>>>>> Thanks a lot for your reply.
>>>>>>> 
>>>>>>> Yes,the hardwear processor clock frequency of nRF52 (Cortex M4F) is 64 MHz and can not be changed.
>>>>>>> 
>>>>>>> The reason of changing CLOCK_FREQ is that I want re-use the internal timing of mynewt already there with more accurate timing, by calling function "os_cputime_get32()”.  I’m trying to implement a (soft) IC card reader by nRF52 with mynewt OS and nimble stack running.
>>>>>>> 
>>>>>>> I am also considering to use an independent timer (NRF_TIMER3 or  NRF_TIMER4) at the cost of about 0.1mA current. I already use NRF_TIMER2 to provide a 4 MHz clock signal output from GPIO of nRF52. By reading the source code of apache-mynewt-core, my understanding is that NRF_TIMER0 and NRF_TIMER1 is already used by mynewt OS and nimble stack, is my understanding correct?
>>>>>>> 
>>>>>>> Thanks,
>>>>>>> 
>>>>>>> Jiacheng
>>>>>>> 
>>>>>>>> 在 2017年1月9日,01:10,will sanfilippo <wi...@runtime.io> 写道:
>>>>>>>> 
>>>>>>>> Those should be the only two parameters you need to configure. Must be a bug in the controller :-)
>>>>>>>> 
>>>>>>>> I think it is worthwhile to point out that CLOCK_FREQ only changes the units of os cputime; it does not affect the speed at which the processor runs. At least, I could not see any other uses of CLOCK_FREQ. So, these settings only affect the nimble stack and the controller specifically (internal controller timing).
>>>>>>>> 
>>>>>>>> I am curious why you wanted to change this variable; what were you trying to achieve?
>>>>>>>> 
>>>>>>>> Thanks for pointing this out; I will take a look to see why it is not working.
>>>>>>>> 
>>>>>>>>> On Jan 7, 2017, at 10:48 PM, WangJiacheng <ji...@icloud.com> wrote:
>>>>>>>>> 
>>>>>>>>> Hi,
>>>>>>>>> 
>>>>>>>>> The default CPU time frequency of Mynewt OS and Nimble stack is 1 MHz, I try to change the CPU time frequency to be 2 MHz, I modified the related 2 config files:
>>>>>>>>> configure file “hw/bsp/nrf52dk/syscfg.yml” as
>>>>>>>>> CLOCK_FREQ:
>>>>>>>>>  description: 'TBD'
>>>>>>>>>  value:  2000000
>>>>>>>>> configure file “kernel/os/syscfg.yml” as
>>>>>>>>> OS_CPUTIME_FREQ:
>>>>>>>>>  description: 'Frequency of os cputime'
>>>>>>>>>  value: 2000000
>>>>>>>>> 
>>>>>>>>> The app “bleperiph" is running and the CPU time frequency is 2 MHz, also the BLE “nimble-bleprph” peripheral  can be scanned by LightBlue of iOS APP, and show 1 service is there. However, when I try to connect it ,an error massage “Connection Alert: Timeout interrogating the peripheral”
>>>>>>>>> 
>>>>>>>>> When change back above 2 syscfg parameters to 1000000, it can be connected.
>>>>>>>>> 
>>>>>>>>> And app “bletiny” is the same.
>>>>>>>>> 
>>>>>>>>> Is there any  missed config setting in my test? How to change the CPU time frequency to 2 Mhz and Nimble device can be connected?
>>>>>>>>> 
>>>>>>>>> Thanks,
>>>>>>>>> 
>>>>>>>>> Jiacheng
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>> 
>> 


Re: How to change the CPU time frequency of mynewt and nimble stack

Posted by Christopher Collins <cc...@apache.org>.
Hi Jiacheng,

I think your version of newt is still slightly out of date.  You can
install the latest as follows:

    cd $GOPATH/src/mynewt.apache.org/newt/newt &&
       git checkout develop                    &&
       git pull origin develop                 &&
       go install                              ;
       cd -


Thanks,
Chris

On Wed, Jan 11, 2017 at 09:04:05AM +0800, WangJiacheng wrote:
> Sterling,
> 
> Thanks.
> 
> Yes, the newt is already updated. \u201cnewt version\u201d has return "Apache Newt (incubating) version: 1.0.0-dev\u201d.
> 
> Best Regards,
> 
> Jiacheng
> 
> > \u5728 2017\u5e741\u670811\u65e5\uff0c08:58\uff0cSterling Hughes <st...@apache.org> \u5199\u9053\uff1a
> > 
> > Hi Jiacheng,
> > 
> > You need to update your newt tool along with the new develop.
> > 
> > Best,
> > 
> > Sterling
> > 
> > On 10 Jan 2017, at 16:46, WangJiacheng wrote:
> > 
> >> Hi, Will,
> >> 
> >> I need more help, I have an error message when compile the target.
> >> 
> >> I\u2019m currently working on the release branch, so upgrade to dev branch by:
> >>    1. change file project.yml from "vers: 0-latest\u201d to "vers: 0-dev\u201d
> >>    2. upgrade to dev branch \u201cnewt upgrade\u201d
> >> 
> >> Then compile the target by \u201cnewt build nrf52_boot\u201d, an error message as:
> >> ================================================================================
> >> Building target targets/nrf52_boot
> >> Compiling boot.c
> >> Archiving boot.a
> >> Compiling bootutil_misc.c
> >> Compiling image_ec.c
> >> Compiling image_ec256.c
> >> Compiling image_rsa.c
> >> Compiling image_validate.c
> >> Compiling loader.c
> >> Archiving bootutil.a
> >> Error: In file included from aes.c:29:0:
> >> /Users/jiachengwang/dev/myproj/repos/apache-mynewt-core/crypto/mbedtls/include/mbedtls/config.h:2522:10: error: #include expects "FILENAME" or <FILENAME>
> >> #include MBEDTLS_USER_CONFIG_FILE
> >>          ^
> >> ================================================================================
> >> it seems the config file "mbedtls/config_mynewt.h\u201d define in \u201ccrypto/mbedtls/pkg.yml\u201d is missed.
> >> 
> >> Thanks,
> >> 
> >> Jiacheng
> >> 
> >> 
> >> 
> >> 
> >> 
> >>> \u5728 2017\u5e741\u670810\u65e5\uff0c11:06\uff0cWangJiacheng <ji...@icloud.com> \u5199\u9053\uff1a
> >>> 
> >>> Thanks, Will.
> >>> 
> >>> There is an Internet connection issue to GitHub.com currently, I\u2019ll update the code later.
> >>> 
> >>> Best Regards,
> >>> 
> >>> Jiacheng
> >>> 
> >>> 
> >>>> \u5728 2017\u5e741\u670810\u65e5\uff0c10:10\uff0cwill sanfilippo <wi...@runtime.io> \u5199\u9053\uff1a
> >>>> 
> >>>> Hello:
> >>>> 
> >>>> This issue should now be fixed in the latest development branch. Note that this is not working on the nrf51 platforms but since you were using nrf52 it should work.
> >>>> 
> >>>> Let me know if you see any issues with it.
> >>>> 
> >>>> 
> >>>>> On Jan 8, 2017, at 6:20 PM, WangJiacheng <ji...@icloud.com> wrote:
> >>>>> 
> >>>>> Hi, Will,
> >>>>> 
> >>>>> Thanks a lot for your reply.
> >>>>> 
> >>>>> Yes\uff0cthe hardwear processor clock frequency of nRF52 (Cortex M4F) is 64 MHz and can not be changed.
> >>>>> 
> >>>>> The reason of changing CLOCK_FREQ is that I want re-use the internal timing of mynewt already there with more accurate timing, by calling function "os_cputime_get32()\u201d.  I\u2019m trying to implement a (soft) IC card reader by nRF52 with mynewt OS and nimble stack running.
> >>>>> 
> >>>>> I am also considering to use an independent timer (NRF_TIMER3 or  NRF_TIMER4) at the cost of about 0.1mA current. I already use NRF_TIMER2 to provide a 4 MHz clock signal output from GPIO of nRF52. By reading the source code of apache-mynewt-core, my understanding is that NRF_TIMER0 and NRF_TIMER1 is already used by mynewt OS and nimble stack, is my understanding correct?
> >>>>> 
> >>>>> Thanks,
> >>>>> 
> >>>>> Jiacheng
> >>>>> 
> >>>>>> \u5728 2017\u5e741\u67089\u65e5\uff0c01:10\uff0cwill sanfilippo <wi...@runtime.io> \u5199\u9053\uff1a
> >>>>>> 
> >>>>>> Those should be the only two parameters you need to configure. Must be a bug in the controller :-)
> >>>>>> 
> >>>>>> I think it is worthwhile to point out that CLOCK_FREQ only changes the units of os cputime; it does not affect the speed at which the processor runs. At least, I could not see any other uses of CLOCK_FREQ. So, these settings only affect the nimble stack and the controller specifically (internal controller timing).
> >>>>>> 
> >>>>>> I am curious why you wanted to change this variable; what were you trying to achieve?
> >>>>>> 
> >>>>>> Thanks for pointing this out; I will take a look to see why it is not working.
> >>>>>> 
> >>>>>>> On Jan 7, 2017, at 10:48 PM, WangJiacheng <ji...@icloud.com> wrote:
> >>>>>>> 
> >>>>>>> Hi,
> >>>>>>> 
> >>>>>>> The default CPU time frequency of Mynewt OS and Nimble stack is 1 MHz, I try to change the CPU time frequency to be 2 MHz, I modified the related 2 config files:
> >>>>>>> configure file \u201chw/bsp/nrf52dk/syscfg.yml\u201d as
> >>>>>>> CLOCK_FREQ:
> >>>>>>>   description: 'TBD'
> >>>>>>>   value:  2000000
> >>>>>>> configure file \u201ckernel/os/syscfg.yml\u201d as
> >>>>>>> OS_CPUTIME_FREQ:
> >>>>>>>   description: 'Frequency of os cputime'
> >>>>>>>   value: 2000000
> >>>>>>> 
> >>>>>>> The app \u201cbleperiph" is running and the CPU time frequency is 2 MHz, also the BLE \u201cnimble-bleprph\u201d peripheral  can be scanned by LightBlue of iOS APP, and show 1 service is there. However, when I try to connect it ,an error massage \u201cConnection Alert: Timeout interrogating the peripheral\u201d
> >>>>>>> 
> >>>>>>> When change back above 2 syscfg parameters to 1000000, it can be connected.
> >>>>>>> 
> >>>>>>> And app \u201cbletiny\u201d is the same.
> >>>>>>> 
> >>>>>>> Is there any  missed config setting in my test? How to change the CPU time frequency to 2 Mhz and Nimble device can be connected?
> >>>>>>> 
> >>>>>>> Thanks,
> >>>>>>> 
> >>>>>>> Jiacheng
> >>>>>>> 
> >>>>>>> 
> >>>>>> 
> >>>>> 
> >>>> 
> >>> 
> 

Re: How to change the CPU time frequency of mynewt and nimble stack

Posted by WangJiacheng <ji...@icloud.com>.
Sterling,

Thanks.

Yes, the newt is already updated. “newt version” has return "Apache Newt (incubating) version: 1.0.0-dev”.

Best Regards,

Jiacheng

> 在 2017年1月11日,08:58,Sterling Hughes <st...@apache.org> 写道:
> 
> Hi Jiacheng,
> 
> You need to update your newt tool along with the new develop.
> 
> Best,
> 
> Sterling
> 
> On 10 Jan 2017, at 16:46, WangJiacheng wrote:
> 
>> Hi, Will,
>> 
>> I need more help, I have an error message when compile the target.
>> 
>> I’m currently working on the release branch, so upgrade to dev branch by:
>>    1. change file project.yml from "vers: 0-latest” to "vers: 0-dev”
>>    2. upgrade to dev branch “newt upgrade”
>> 
>> Then compile the target by “newt build nrf52_boot”, an error message as:
>> ================================================================================
>> Building target targets/nrf52_boot
>> Compiling boot.c
>> Archiving boot.a
>> Compiling bootutil_misc.c
>> Compiling image_ec.c
>> Compiling image_ec256.c
>> Compiling image_rsa.c
>> Compiling image_validate.c
>> Compiling loader.c
>> Archiving bootutil.a
>> Error: In file included from aes.c:29:0:
>> /Users/jiachengwang/dev/myproj/repos/apache-mynewt-core/crypto/mbedtls/include/mbedtls/config.h:2522:10: error: #include expects "FILENAME" or <FILENAME>
>> #include MBEDTLS_USER_CONFIG_FILE
>>          ^
>> ================================================================================
>> it seems the config file "mbedtls/config_mynewt.h” define in “crypto/mbedtls/pkg.yml” is missed.
>> 
>> Thanks,
>> 
>> Jiacheng
>> 
>> 
>> 
>> 
>> 
>>> 在 2017年1月10日,11:06,WangJiacheng <ji...@icloud.com> 写道:
>>> 
>>> Thanks, Will.
>>> 
>>> There is an Internet connection issue to GitHub.com currently, I’ll update the code later.
>>> 
>>> Best Regards,
>>> 
>>> Jiacheng
>>> 
>>> 
>>>> 在 2017年1月10日,10:10,will sanfilippo <wi...@runtime.io> 写道:
>>>> 
>>>> Hello:
>>>> 
>>>> This issue should now be fixed in the latest development branch. Note that this is not working on the nrf51 platforms but since you were using nrf52 it should work.
>>>> 
>>>> Let me know if you see any issues with it.
>>>> 
>>>> 
>>>>> On Jan 8, 2017, at 6:20 PM, WangJiacheng <ji...@icloud.com> wrote:
>>>>> 
>>>>> Hi, Will,
>>>>> 
>>>>> Thanks a lot for your reply.
>>>>> 
>>>>> Yes,the hardwear processor clock frequency of nRF52 (Cortex M4F) is 64 MHz and can not be changed.
>>>>> 
>>>>> The reason of changing CLOCK_FREQ is that I want re-use the internal timing of mynewt already there with more accurate timing, by calling function "os_cputime_get32()”.  I’m trying to implement a (soft) IC card reader by nRF52 with mynewt OS and nimble stack running.
>>>>> 
>>>>> I am also considering to use an independent timer (NRF_TIMER3 or  NRF_TIMER4) at the cost of about 0.1mA current. I already use NRF_TIMER2 to provide a 4 MHz clock signal output from GPIO of nRF52. By reading the source code of apache-mynewt-core, my understanding is that NRF_TIMER0 and NRF_TIMER1 is already used by mynewt OS and nimble stack, is my understanding correct?
>>>>> 
>>>>> Thanks,
>>>>> 
>>>>> Jiacheng
>>>>> 
>>>>>> 在 2017年1月9日,01:10,will sanfilippo <wi...@runtime.io> 写道:
>>>>>> 
>>>>>> Those should be the only two parameters you need to configure. Must be a bug in the controller :-)
>>>>>> 
>>>>>> I think it is worthwhile to point out that CLOCK_FREQ only changes the units of os cputime; it does not affect the speed at which the processor runs. At least, I could not see any other uses of CLOCK_FREQ. So, these settings only affect the nimble stack and the controller specifically (internal controller timing).
>>>>>> 
>>>>>> I am curious why you wanted to change this variable; what were you trying to achieve?
>>>>>> 
>>>>>> Thanks for pointing this out; I will take a look to see why it is not working.
>>>>>> 
>>>>>>> On Jan 7, 2017, at 10:48 PM, WangJiacheng <ji...@icloud.com> wrote:
>>>>>>> 
>>>>>>> Hi,
>>>>>>> 
>>>>>>> The default CPU time frequency of Mynewt OS and Nimble stack is 1 MHz, I try to change the CPU time frequency to be 2 MHz, I modified the related 2 config files:
>>>>>>> configure file “hw/bsp/nrf52dk/syscfg.yml” as
>>>>>>> CLOCK_FREQ:
>>>>>>>   description: 'TBD'
>>>>>>>   value:  2000000
>>>>>>> configure file “kernel/os/syscfg.yml” as
>>>>>>> OS_CPUTIME_FREQ:
>>>>>>>   description: 'Frequency of os cputime'
>>>>>>>   value: 2000000
>>>>>>> 
>>>>>>> The app “bleperiph" is running and the CPU time frequency is 2 MHz, also the BLE “nimble-bleprph” peripheral  can be scanned by LightBlue of iOS APP, and show 1 service is there. However, when I try to connect it ,an error massage “Connection Alert: Timeout interrogating the peripheral”
>>>>>>> 
>>>>>>> When change back above 2 syscfg parameters to 1000000, it can be connected.
>>>>>>> 
>>>>>>> And app “bletiny” is the same.
>>>>>>> 
>>>>>>> Is there any  missed config setting in my test? How to change the CPU time frequency to 2 Mhz and Nimble device can be connected?
>>>>>>> 
>>>>>>> Thanks,
>>>>>>> 
>>>>>>> Jiacheng
>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>> 


Re: How to change the CPU time frequency of mynewt and nimble stack

Posted by Sterling Hughes <st...@apache.org>.
Hi Jiacheng,

You need to update your newt tool along with the new develop.

Best,

Sterling

On 10 Jan 2017, at 16:46, WangJiacheng wrote:

> Hi, Will,
>
> I need more help, I have an error message when compile the target.
>
> I’m currently working on the release branch, so upgrade to dev 
> branch by:
>     1. change file project.yml from "vers: 0-latest” to "vers: 
> 0-dev”
>     2. upgrade to dev branch “newt upgrade”
>
> Then compile the target by “newt build nrf52_boot”, an error 
> message as:
> ================================================================================
> Building target targets/nrf52_boot
> Compiling boot.c
> Archiving boot.a
> Compiling bootutil_misc.c
> Compiling image_ec.c
> Compiling image_ec256.c
> Compiling image_rsa.c
> Compiling image_validate.c
> Compiling loader.c
> Archiving bootutil.a
> Error: In file included from aes.c:29:0:
> /Users/jiachengwang/dev/myproj/repos/apache-mynewt-core/crypto/mbedtls/include/mbedtls/config.h:2522:10: 
> error: #include expects "FILENAME" or <FILENAME>
>  #include MBEDTLS_USER_CONFIG_FILE
>           ^
> ================================================================================
> it seems the config file "mbedtls/config_mynewt.h” define in 
> “crypto/mbedtls/pkg.yml” is missed.
>
> Thanks,
>
> Jiacheng
>
>
>
>
>
>> 在 2017年1月10日,11:06,WangJiacheng 
>> <ji...@icloud.com> 写道:
>>
>> Thanks, Will.
>>
>> There is an Internet connection issue to GitHub.com currently, I’ll 
>> update the code later.
>>
>> Best Regards,
>>
>> Jiacheng
>>
>>
>>> 在 2017年1月10日,10:10,will sanfilippo <wi...@runtime.io> 
>>> 写道:
>>>
>>> Hello:
>>>
>>> This issue should now be fixed in the latest development branch. 
>>> Note that this is not working on the nrf51 platforms but since you 
>>> were using nrf52 it should work.
>>>
>>> Let me know if you see any issues with it.
>>>
>>>
>>>> On Jan 8, 2017, at 6:20 PM, WangJiacheng <ji...@icloud.com> 
>>>> wrote:
>>>>
>>>> Hi, Will,
>>>>
>>>> Thanks a lot for your reply.
>>>>
>>>> Yes,the hardwear processor clock frequency of nRF52 (Cortex M4F) 
>>>> is 64 MHz and can not be changed.
>>>>
>>>> The reason of changing CLOCK_FREQ is that I want re-use the 
>>>> internal timing of mynewt already there with more accurate timing, 
>>>> by calling function "os_cputime_get32()”.  I’m trying to 
>>>> implement a (soft) IC card reader by nRF52 with mynewt OS and 
>>>> nimble stack running.
>>>>
>>>> I am also considering to use an independent timer (NRF_TIMER3 or  
>>>> NRF_TIMER4) at the cost of about 0.1mA current. I already use 
>>>> NRF_TIMER2 to provide a 4 MHz clock signal output from GPIO of 
>>>> nRF52. By reading the source code of apache-mynewt-core, my 
>>>> understanding is that NRF_TIMER0 and NRF_TIMER1 is already used by 
>>>> mynewt OS and nimble stack, is my understanding correct?
>>>>
>>>> Thanks,
>>>>
>>>> Jiacheng
>>>>
>>>>> 在 2017年1月9日,01:10,will sanfilippo <wi...@runtime.io> 
>>>>> 写道:
>>>>>
>>>>> Those should be the only two parameters you need to configure. 
>>>>> Must be a bug in the controller :-)
>>>>>
>>>>> I think it is worthwhile to point out that CLOCK_FREQ only changes 
>>>>> the units of os cputime; it does not affect the speed at which the 
>>>>> processor runs. At least, I could not see any other uses of 
>>>>> CLOCK_FREQ. So, these settings only affect the nimble stack and 
>>>>> the controller specifically (internal controller timing).
>>>>>
>>>>> I am curious why you wanted to change this variable; what were you 
>>>>> trying to achieve?
>>>>>
>>>>> Thanks for pointing this out; I will take a look to see why it is 
>>>>> not working.
>>>>>
>>>>>> On Jan 7, 2017, at 10:48 PM, WangJiacheng 
>>>>>> <ji...@icloud.com> wrote:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> The default CPU time frequency of Mynewt OS and Nimble stack is 1 
>>>>>> MHz, I try to change the CPU time frequency to be 2 MHz, I 
>>>>>> modified the related 2 config files:
>>>>>> configure file “hw/bsp/nrf52dk/syscfg.yml” as
>>>>>> CLOCK_FREQ:
>>>>>>    description: 'TBD'
>>>>>>    value:  2000000
>>>>>> configure file “kernel/os/syscfg.yml” as
>>>>>> OS_CPUTIME_FREQ:
>>>>>>    description: 'Frequency of os cputime'
>>>>>>    value: 2000000
>>>>>>
>>>>>> The app “bleperiph" is running and the CPU time frequency is 2 
>>>>>> MHz, also the BLE “nimble-bleprph” peripheral  can be scanned 
>>>>>> by LightBlue of iOS APP, and show 1 service is there. However, 
>>>>>> when I try to connect it ,an error massage “Connection Alert: 
>>>>>> Timeout interrogating the peripheral”
>>>>>>
>>>>>> When change back above 2 syscfg parameters to 1000000, it can be 
>>>>>> connected.
>>>>>>
>>>>>> And app “bletiny” is the same.
>>>>>>
>>>>>> Is there any  missed config setting in my test? How to change the 
>>>>>> CPU time frequency to 2 Mhz and Nimble device can be connected?
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> Jiacheng
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>

Re: How to change the CPU time frequency of mynewt and nimble stack

Posted by WangJiacheng <ji...@icloud.com>.
Hi, Will,

I need more help, I have an error message when compile the target.

I’m currently working on the release branch, so upgrade to dev branch by: 
    1. change file project.yml from "vers: 0-latest” to "vers: 0-dev”
    2. upgrade to dev branch “newt upgrade”

Then compile the target by “newt build nrf52_boot”, an error message as:
================================================================================
Building target targets/nrf52_boot
Compiling boot.c
Archiving boot.a
Compiling bootutil_misc.c
Compiling image_ec.c
Compiling image_ec256.c
Compiling image_rsa.c
Compiling image_validate.c
Compiling loader.c
Archiving bootutil.a
Error: In file included from aes.c:29:0:
/Users/jiachengwang/dev/myproj/repos/apache-mynewt-core/crypto/mbedtls/include/mbedtls/config.h:2522:10: error: #include expects "FILENAME" or <FILENAME>
 #include MBEDTLS_USER_CONFIG_FILE
          ^
================================================================================
it seems the config file "mbedtls/config_mynewt.h” define in “crypto/mbedtls/pkg.yml” is missed.

Thanks,

Jiacheng





> 在 2017年1月10日,11:06,WangJiacheng <ji...@icloud.com> 写道:
> 
> Thanks, Will.
> 
> There is an Internet connection issue to GitHub.com currently, I’ll update the code later.
> 
> Best Regards,
> 
> Jiacheng
> 
> 
>> 在 2017年1月10日,10:10,will sanfilippo <wi...@runtime.io> 写道:
>> 
>> Hello:
>> 
>> This issue should now be fixed in the latest development branch. Note that this is not working on the nrf51 platforms but since you were using nrf52 it should work.
>> 
>> Let me know if you see any issues with it.
>> 
>> 
>>> On Jan 8, 2017, at 6:20 PM, WangJiacheng <ji...@icloud.com> wrote:
>>> 
>>> Hi, Will,
>>> 
>>> Thanks a lot for your reply.
>>> 
>>> Yes,the hardwear processor clock frequency of nRF52 (Cortex M4F) is 64 MHz and can not be changed.
>>> 
>>> The reason of changing CLOCK_FREQ is that I want re-use the internal timing of mynewt already there with more accurate timing, by calling function "os_cputime_get32()”.  I’m trying to implement a (soft) IC card reader by nRF52 with mynewt OS and nimble stack running.
>>> 
>>> I am also considering to use an independent timer (NRF_TIMER3 or  NRF_TIMER4) at the cost of about 0.1mA current. I already use NRF_TIMER2 to provide a 4 MHz clock signal output from GPIO of nRF52. By reading the source code of apache-mynewt-core, my understanding is that NRF_TIMER0 and NRF_TIMER1 is already used by mynewt OS and nimble stack, is my understanding correct?
>>> 
>>> Thanks,
>>> 
>>> Jiacheng
>>> 
>>>> 在 2017年1月9日,01:10,will sanfilippo <wi...@runtime.io> 写道:
>>>> 
>>>> Those should be the only two parameters you need to configure. Must be a bug in the controller :-)
>>>> 
>>>> I think it is worthwhile to point out that CLOCK_FREQ only changes the units of os cputime; it does not affect the speed at which the processor runs. At least, I could not see any other uses of CLOCK_FREQ. So, these settings only affect the nimble stack and the controller specifically (internal controller timing).
>>>> 
>>>> I am curious why you wanted to change this variable; what were you trying to achieve?
>>>> 
>>>> Thanks for pointing this out; I will take a look to see why it is not working.
>>>> 
>>>>> On Jan 7, 2017, at 10:48 PM, WangJiacheng <ji...@icloud.com> wrote:
>>>>> 
>>>>> Hi, 
>>>>> 
>>>>> The default CPU time frequency of Mynewt OS and Nimble stack is 1 MHz, I try to change the CPU time frequency to be 2 MHz, I modified the related 2 config files:
>>>>> configure file “hw/bsp/nrf52dk/syscfg.yml” as
>>>>> CLOCK_FREQ:
>>>>>    description: 'TBD'
>>>>>    value:  2000000 
>>>>> configure file “kernel/os/syscfg.yml” as
>>>>> OS_CPUTIME_FREQ:
>>>>>    description: 'Frequency of os cputime'
>>>>>    value: 2000000
>>>>> 
>>>>> The app “bleperiph" is running and the CPU time frequency is 2 MHz, also the BLE “nimble-bleprph” peripheral  can be scanned by LightBlue of iOS APP, and show 1 service is there. However, when I try to connect it ,an error massage “Connection Alert: Timeout interrogating the peripheral”
>>>>> 
>>>>> When change back above 2 syscfg parameters to 1000000, it can be connected.
>>>>> 
>>>>> And app “bletiny” is the same.
>>>>> 
>>>>> Is there any  missed config setting in my test? How to change the CPU time frequency to 2 Mhz and Nimble device can be connected?
>>>>> 
>>>>> Thanks,
>>>>> 
>>>>> Jiacheng 
>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> 


Re: How to change the CPU time frequency of mynewt and nimble stack

Posted by WangJiacheng <ji...@icloud.com>.
Thanks, Will.

There is an Internet connection issue to GitHub.com currently, I’ll update the code later.

Best Regards,

Jiacheng
 

> 在 2017年1月10日,10:10,will sanfilippo <wi...@runtime.io> 写道:
> 
> Hello:
> 
> This issue should now be fixed in the latest development branch. Note that this is not working on the nrf51 platforms but since you were using nrf52 it should work.
> 
> Let me know if you see any issues with it.
> 
> 
>> On Jan 8, 2017, at 6:20 PM, WangJiacheng <ji...@icloud.com> wrote:
>> 
>> Hi, Will,
>> 
>> Thanks a lot for your reply.
>> 
>> Yes,the hardwear processor clock frequency of nRF52 (Cortex M4F) is 64 MHz and can not be changed.
>> 
>> The reason of changing CLOCK_FREQ is that I want re-use the internal timing of mynewt already there with more accurate timing, by calling function "os_cputime_get32()”.  I’m trying to implement a (soft) IC card reader by nRF52 with mynewt OS and nimble stack running.
>> 
>> I am also considering to use an independent timer (NRF_TIMER3 or  NRF_TIMER4) at the cost of about 0.1mA current. I already use NRF_TIMER2 to provide a 4 MHz clock signal output from GPIO of nRF52. By reading the source code of apache-mynewt-core, my understanding is that NRF_TIMER0 and NRF_TIMER1 is already used by mynewt OS and nimble stack, is my understanding correct?
>> 
>> Thanks,
>> 
>> Jiacheng
>> 
>>> 在 2017年1月9日,01:10,will sanfilippo <wi...@runtime.io> 写道:
>>> 
>>> Those should be the only two parameters you need to configure. Must be a bug in the controller :-)
>>> 
>>> I think it is worthwhile to point out that CLOCK_FREQ only changes the units of os cputime; it does not affect the speed at which the processor runs. At least, I could not see any other uses of CLOCK_FREQ. So, these settings only affect the nimble stack and the controller specifically (internal controller timing).
>>> 
>>> I am curious why you wanted to change this variable; what were you trying to achieve?
>>> 
>>> Thanks for pointing this out; I will take a look to see why it is not working.
>>> 
>>>> On Jan 7, 2017, at 10:48 PM, WangJiacheng <ji...@icloud.com> wrote:
>>>> 
>>>> Hi, 
>>>> 
>>>> The default CPU time frequency of Mynewt OS and Nimble stack is 1 MHz, I try to change the CPU time frequency to be 2 MHz, I modified the related 2 config files:
>>>> configure file “hw/bsp/nrf52dk/syscfg.yml” as
>>>> CLOCK_FREQ:
>>>>     description: 'TBD'
>>>>     value:  2000000 
>>>> configure file “kernel/os/syscfg.yml” as
>>>> OS_CPUTIME_FREQ:
>>>>     description: 'Frequency of os cputime'
>>>>     value: 2000000
>>>> 
>>>> The app “bleperiph" is running and the CPU time frequency is 2 MHz, also the BLE “nimble-bleprph” peripheral  can be scanned by LightBlue of iOS APP, and show 1 service is there. However, when I try to connect it ,an error massage “Connection Alert: Timeout interrogating the peripheral”
>>>> 
>>>> When change back above 2 syscfg parameters to 1000000, it can be connected.
>>>> 
>>>> And app “bletiny” is the same.
>>>> 
>>>> Is there any  missed config setting in my test? How to change the CPU time frequency to 2 Mhz and Nimble device can be connected?
>>>> 
>>>> Thanks,
>>>> 
>>>> Jiacheng 
>>>> 
>>>> 
>>> 
>> 
> 


Re: How to change the CPU time frequency of mynewt and nimble stack

Posted by will sanfilippo <wi...@runtime.io>.
Hello:

This issue should now be fixed in the latest development branch. Note that this is not working on the nrf51 platforms but since you were using nrf52 it should work.

Let me know if you see any issues with it.


> On Jan 8, 2017, at 6:20 PM, WangJiacheng <ji...@icloud.com> wrote:
> 
> Hi, Will,
> 
> Thanks a lot for your reply.
> 
> Yes,the hardwear processor clock frequency of nRF52 (Cortex M4F) is 64 MHz and can not be changed.
> 
> The reason of changing CLOCK_FREQ is that I want re-use the internal timing of mynewt already there with more accurate timing, by calling function "os_cputime_get32()”.  I’m trying to implement a (soft) IC card reader by nRF52 with mynewt OS and nimble stack running.
> 
> I am also considering to use an independent timer (NRF_TIMER3 or  NRF_TIMER4) at the cost of about 0.1mA current. I already use NRF_TIMER2 to provide a 4 MHz clock signal output from GPIO of nRF52. By reading the source code of apache-mynewt-core, my understanding is that NRF_TIMER0 and NRF_TIMER1 is already used by mynewt OS and nimble stack, is my understanding correct?
> 
> Thanks,
> 
> Jiacheng
> 
>> 在 2017年1月9日,01:10,will sanfilippo <wi...@runtime.io> 写道:
>> 
>> Those should be the only two parameters you need to configure. Must be a bug in the controller :-)
>> 
>> I think it is worthwhile to point out that CLOCK_FREQ only changes the units of os cputime; it does not affect the speed at which the processor runs. At least, I could not see any other uses of CLOCK_FREQ. So, these settings only affect the nimble stack and the controller specifically (internal controller timing).
>> 
>> I am curious why you wanted to change this variable; what were you trying to achieve?
>> 
>> Thanks for pointing this out; I will take a look to see why it is not working.
>> 
>>> On Jan 7, 2017, at 10:48 PM, WangJiacheng <ji...@icloud.com> wrote:
>>> 
>>> Hi, 
>>> 
>>> The default CPU time frequency of Mynewt OS and Nimble stack is 1 MHz, I try to change the CPU time frequency to be 2 MHz, I modified the related 2 config files:
>>> configure file “hw/bsp/nrf52dk/syscfg.yml” as
>>>  CLOCK_FREQ:
>>>      description: 'TBD'
>>>      value:  2000000 
>>> configure file “kernel/os/syscfg.yml” as
>>>  OS_CPUTIME_FREQ:
>>>      description: 'Frequency of os cputime'
>>>      value: 2000000
>>> 
>>> The app “bleperiph" is running and the CPU time frequency is 2 MHz, also the BLE “nimble-bleprph” peripheral  can be scanned by LightBlue of iOS APP, and show 1 service is there. However, when I try to connect it ,an error massage “Connection Alert: Timeout interrogating the peripheral”
>>> 
>>> When change back above 2 syscfg parameters to 1000000, it can be connected.
>>> 
>>> And app “bletiny” is the same.
>>> 
>>> Is there any  missed config setting in my test? How to change the CPU time frequency to 2 Mhz and Nimble device can be connected?
>>> 
>>> Thanks,
>>> 
>>> Jiacheng 
>>> 
>>> 
>> 
> 


Re: How to change the CPU time frequency of mynewt and nimble stack

Posted by WangJiacheng <ji...@icloud.com>.
Hi, Will,

Thanks a lot for your reply.

Yes,the hardwear processor clock frequency of nRF52 (Cortex M4F) is 64 MHz and can not be changed.

The reason of changing CLOCK_FREQ is that I want re-use the internal timing of mynewt already there with more accurate timing, by calling function "os_cputime_get32()”.  I’m trying to implement a (soft) IC card reader by nRF52 with mynewt OS and nimble stack running.

I am also considering to use an independent timer (NRF_TIMER3 or  NRF_TIMER4) at the cost of about 0.1mA current. I already use NRF_TIMER2 to provide a 4 MHz clock signal output from GPIO of nRF52. By reading the source code of apache-mynewt-core, my understanding is that NRF_TIMER0 and NRF_TIMER1 is already used by mynewt OS and nimble stack, is my understanding correct?

Thanks,

Jiacheng

> 在 2017年1月9日,01:10,will sanfilippo <wi...@runtime.io> 写道:
> 
> Those should be the only two parameters you need to configure. Must be a bug in the controller :-)
> 
> I think it is worthwhile to point out that CLOCK_FREQ only changes the units of os cputime; it does not affect the speed at which the processor runs. At least, I could not see any other uses of CLOCK_FREQ. So, these settings only affect the nimble stack and the controller specifically (internal controller timing).
> 
> I am curious why you wanted to change this variable; what were you trying to achieve?
> 
> Thanks for pointing this out; I will take a look to see why it is not working.
> 
>> On Jan 7, 2017, at 10:48 PM, WangJiacheng <ji...@icloud.com> wrote:
>> 
>> Hi, 
>> 
>> The default CPU time frequency of Mynewt OS and Nimble stack is 1 MHz, I try to change the CPU time frequency to be 2 MHz, I modified the related 2 config files:
>> configure file “hw/bsp/nrf52dk/syscfg.yml” as
>>   CLOCK_FREQ:
>>       description: 'TBD'
>>       value:  2000000 
>> configure file “kernel/os/syscfg.yml” as
>>   OS_CPUTIME_FREQ:
>>       description: 'Frequency of os cputime'
>>       value: 2000000
>> 
>> The app “bleperiph" is running and the CPU time frequency is 2 MHz, also the BLE “nimble-bleprph” peripheral  can be scanned by LightBlue of iOS APP, and show 1 service is there. However, when I try to connect it ,an error massage “Connection Alert: Timeout interrogating the peripheral”
>> 
>> When change back above 2 syscfg parameters to 1000000, it can be connected.
>> 
>> And app “bletiny” is the same.
>> 
>> Is there any  missed config setting in my test? How to change the CPU time frequency to 2 Mhz and Nimble device can be connected?
>> 
>> Thanks,
>> 
>> Jiacheng 
>> 
>> 
> 


Re: How to change the CPU time frequency of mynewt and nimble stack

Posted by will sanfilippo <wi...@runtime.io>.
Those should be the only two parameters you need to configure. Must be a bug in the controller :-)

I think it is worthwhile to point out that CLOCK_FREQ only changes the units of os cputime; it does not affect the speed at which the processor runs. At least, I could not see any other uses of CLOCK_FREQ. So, these settings only affect the nimble stack and the controller specifically (internal controller timing).

I am curious why you wanted to change this variable; what were you trying to achieve?

Thanks for pointing this out; I will take a look to see why it is not working.

> On Jan 7, 2017, at 10:48 PM, WangJiacheng <ji...@icloud.com> wrote:
> 
> Hi, 
> 
> The default CPU time frequency of Mynewt OS and Nimble stack is 1 MHz, I try to change the CPU time frequency to be 2 MHz, I modified the related 2 config files:
> configure file “hw/bsp/nrf52dk/syscfg.yml” as
>    CLOCK_FREQ:
>        description: 'TBD'
>        value:  2000000 
> configure file “kernel/os/syscfg.yml” as
>    OS_CPUTIME_FREQ:
>        description: 'Frequency of os cputime'
>        value: 2000000
> 
> The app “bleperiph" is running and the CPU time frequency is 2 MHz, also the BLE “nimble-bleprph” peripheral  can be scanned by LightBlue of iOS APP, and show 1 service is there. However, when I try to connect it ,an error massage “Connection Alert: Timeout interrogating the peripheral”
> 
> When change back above 2 syscfg parameters to 1000000, it can be connected.
> 
> And app “bletiny” is the same.
> 
> Is there any  missed config setting in my test? How to change the CPU time frequency to 2 Mhz and Nimble device can be connected?
> 
> Thanks,
> 
> Jiacheng 
> 
>