Date   

Re: Drift through k_sleep or k_msleep #api

Erik Englund
 

I guess the internals of this uses a semaphore aswell to get realtime performance.

If you control the semaphore yourself as per my example, you can check the status of the semaphore in the end of the function to see if the timer has expired while the work was running, if so, you have a realtime problem.
We use this technique in Zephyr within a few PLC-type controller products, using 1000 ticks/second rate and cycletime of 10ms.

Med vänlig hälsning
Erik Englund

Innoware Development AB
Hyttvägen 13
73338 SALA


Org.nr. 556790-2977
www.innoware.se


Den ons 3 feb. 2021 kl 21:10 skrev Michael Rosen <michael.r.rosen@...>:

Nick,

 

The design pattern Ive seen for this kind of thing uses the Timer API instead of sleep:

 

struct k_timer timer;

k_timer_init(&timer, NULL, NULL);

k_timer_start(&timer, 0, K_MSEC(1000));

while (1) {

  k_timer_status_sync(&timer);

  …

}

 

This lets the body of the main loop run only when the timer expires, and the periodic timer avoid drift from resetting the timer at the top of each loop.

 

Mike

 

From: users@... <users@...> On Behalf Of Erik Englund
Sent: Wednesday, February 3, 2021 2:38 PM
To: Nikolaus Huber <nikolaus.huber@...>
Cc: users@...
Subject: Re: [Zephyr-users] Drift through k_sleep or k_msleep #api

 

One possible solution is to create a periodic timer and post to a semaphore in the timer callback.

A thread could simply wait on the semaphore in an endless loop.

 

Linux clock_nanosleep (mostly used togheter with Preempt-rt patch) would be a nice addition to Zephyr, that would solve these kinds of tasks.


Med vänlig hälsning

Erik Englund


Innoware Development AB
Hyttvägen 13
73338 SALA


Org.nr. 556790-2977
www.innoware.se

 

 

Den ons 3 feb. 2021 kl 20:31 skrev Nikolaus Huber <nikolaus.huber@...>:

Hi all, 

I was recently wondering about the correct usage of k_sleep or k_msleep for implementing periodic tasks. In FreeRTOS for example there is a function vTaskDelayUntil which takes a timestamp and a number of ticks to delay. By taking the timestamp at the beginning of the execution of a task we can then make sure that its release time does not slowly drift. So far I have not seen anything similar in Zephyr. Am I missing something, or do I have to somehow create a similar mechanism on my own by measuring the uptime at the release of a periodic task and then again just before using any sleep function to calculate the exact sleep time I want?

Thank you very much in advance,
Nick


Re: Drift through k_sleep or k_msleep #api

Michael Rosen
 

Nick,

 

The design pattern Ive seen for this kind of thing uses the Timer API instead of sleep:

 

struct k_timer timer;

k_timer_init(&timer, NULL, NULL);

k_timer_start(&timer, 0, K_MSEC(1000));

while (1) {

  k_timer_status_sync(&timer);

  …

}

 

This lets the body of the main loop run only when the timer expires, and the periodic timer avoid drift from resetting the timer at the top of each loop.

 

Mike

 

From: users@... <users@...> On Behalf Of Erik Englund
Sent: Wednesday, February 3, 2021 2:38 PM
To: Nikolaus Huber <nikolaus.huber@...>
Cc: users@...
Subject: Re: [Zephyr-users] Drift through k_sleep or k_msleep #api

 

One possible solution is to create a periodic timer and post to a semaphore in the timer callback.

A thread could simply wait on the semaphore in an endless loop.

 

Linux clock_nanosleep (mostly used togheter with Preempt-rt patch) would be a nice addition to Zephyr, that would solve these kinds of tasks.


Med vänlig hälsning

Erik Englund


Innoware Development AB
Hyttvägen 13
73338 SALA


Org.nr. 556790-2977
www.innoware.se

 

 

Den ons 3 feb. 2021 kl 20:31 skrev Nikolaus Huber <nikolaus.huber@...>:

Hi all, 

I was recently wondering about the correct usage of k_sleep or k_msleep for implementing periodic tasks. In FreeRTOS for example there is a function vTaskDelayUntil which takes a timestamp and a number of ticks to delay. By taking the timestamp at the beginning of the execution of a task we can then make sure that its release time does not slowly drift. So far I have not seen anything similar in Zephyr. Am I missing something, or do I have to somehow create a similar mechanism on my own by measuring the uptime at the release of a periodic task and then again just before using any sleep function to calculate the exact sleep time I want?

Thank you very much in advance,
Nick


Re: Drift through k_sleep or k_msleep #api

Lawrence King
 

When I need work to operate on a regular basis and not drift I create a work queue and a timer that is setup to submit the work to the queue on a regular basis. This way it doesn’t matter how long it takes to finish the work, the next work run will still start at exactly the right time. main() calls  clock_init() to get this started…

 

 

#include <stdio.h>

#include <stddef.h>

#include <stdint.h>

#include <zephyr.h>

#include <zephyr/types.h>

 

#define TIME_INC_FREQUENCY      10      // in secs

 

void my_work_handler(struct k_work *work)

{

     // do whatever here

}

 

K_WORK_DEFINE(my_work, my_work_handler);

 

void my_timer_handler(struct k_timer *dummy)

{

    k_work_submit(&my_work);

}

 

K_TIMER_DEFINE(my_timer, my_timer_handler, NULL);

 

void clock_init(void) {

    k_timer_start(&my_timer, K_SECONDS(TIME_INC_FREQUENCY), K_SECONDS(TIME_INC_FREQUENCY));

}

 

Lawrence King

Principal Developer

+1(416)627-7302

 

From: users@... <users@...> On Behalf Of Erik Englund
Sent: Wednesday, February 3, 2021 2:38 PM
To: Nikolaus Huber <nikolaus.huber@...>
Cc: users@...
Subject: Re: [Zephyr-users] Drift through k_sleep or k_msleep #api

 

One possible solution is to create a periodic timer and post to a semaphore in the timer callback.

A thread could simply wait on the semaphore in an endless loop.

 

Linux clock_nanosleep (mostly used togheter with Preempt-rt patch) would be a nice addition to Zephyr, that would solve these kinds of tasks.


Med vänlig hälsning

Erik Englund


Innoware Development AB
Hyttvägen 13
73338 SALA


Org.nr. 556790-2977
www.innoware.se

 

 

Den ons 3 feb. 2021 kl 20:31 skrev Nikolaus Huber <nikolaus.huber@...>:

Hi all, 

I was recently wondering about the correct usage of k_sleep or k_msleep for implementing periodic tasks. In FreeRTOS for example there is a function vTaskDelayUntil which takes a timestamp and a number of ticks to delay. By taking the timestamp at the beginning of the execution of a task we can then make sure that its release time does not slowly drift. So far I have not seen anything similar in Zephyr. Am I missing something, or do I have to somehow create a similar mechanism on my own by measuring the uptime at the release of a periodic task and then again just before using any sleep function to calculate the exact sleep time I want?

Thank you very much in advance,
Nick


Re: Drift through k_sleep or k_msleep #api

Erik Englund
 

One possible solution is to create a periodic timer and post to a semaphore in the timer callback.
A thread could simply wait on the semaphore in an endless loop.

Linux clock_nanosleep (mostly used togheter with Preempt-rt patch) would be a nice addition to Zephyr, that would solve these kinds of tasks.

Med vänlig hälsning
Erik Englund

Innoware Development AB
Hyttvägen 13
73338 SALA


Org.nr. 556790-2977
www.innoware.se


Den ons 3 feb. 2021 kl 20:31 skrev Nikolaus Huber <nikolaus.huber@...>:

Hi all, 

I was recently wondering about the correct usage of k_sleep or k_msleep for implementing periodic tasks. In FreeRTOS for example there is a function vTaskDelayUntil which takes a timestamp and a number of ticks to delay. By taking the timestamp at the beginning of the execution of a task we can then make sure that its release time does not slowly drift. So far I have not seen anything similar in Zephyr. Am I missing something, or do I have to somehow create a similar mechanism on my own by measuring the uptime at the release of a periodic task and then again just before using any sleep function to calculate the exact sleep time I want?

Thank you very much in advance,
Nick


Drift through k_sleep or k_msleep #api

Nikolaus Huber
 

Hi all, 

I was recently wondering about the correct usage of k_sleep or k_msleep for implementing periodic tasks. In FreeRTOS for example there is a function vTaskDelayUntil which takes a timestamp and a number of ticks to delay. By taking the timestamp at the beginning of the execution of a task we can then make sure that its release time does not slowly drift. So far I have not seen anything similar in Zephyr. Am I missing something, or do I have to somehow create a similar mechanism on my own by measuring the uptime at the release of a periodic task and then again just before using any sleep function to calculate the exact sleep time I want?

Thank you very much in advance,
Nick


Re: Azure MQTT with GSM modem over PPP #mqtt #modem #ppp #nrf52840

Jukka Rissanen
 

Hi Jurgens,

have you tried to connect to Azure using for example qemu, this way we could rule out issues in modem config?

I did not spot anything obviously wrong in your main.c, but as you have noticed, there are lot of moving parts when connecting to azure using mqtt, so it can be challenging to get things right.


Cheers,
Jukka



On Wed, 2021-02-03 at 03:00 -0800, petrus.vanderwalt@... wrote:
Hi everyone,

I am really struggling to get the mqtt_azure sample working.  It just does not want to connect to IoT hub.

Thank you once again for your assistance @Jukka.  Can anyone help me to get this working?  I am not sure if the issue is related to Azure details that are different from what is recommended by Microsoft or if it is an issue due to using a modem overlay.  

I would really appreciate it if someone could help me get this working.  I have added the project files that have changed.

Regards,
Jurgens


Re: Azure MQTT with GSM modem over PPP #mqtt #modem #ppp #nrf52840

petrus.vanderwalt@...
 

Hi everyone,

I am really struggling to get the mqtt_azure sample working.  It just does not want to connect to IoT hub.

Thank you once again for your assistance @Jukka.  Can anyone help me to get this working?  I am not sure if the issue is related to Azure details that are different from what is recommended by Microsoft or if it is an issue due to using a modem overlay.  

I would really appreciate it if someone could help me get this working.  I have added the project files that have changed.

Regards,
Jurgens


Re: undefined reference to `__bswapdi2' when trying to link tinycbor for RISC-V

Kumar Gala
 

On Jan 29, 2021, at 1:42 PM, Stefan Hristozov <stefan.hristozov@aisec.fraunhofer.de> wrote:

I am getting undefined reference to `__bswapdi2' when I am trying to link tinycbor for RISC-V (west build -b=hifive1)
stefan@t460s:~/workspaces/oscore-edhoc/test$ west build -b=hifive1
[1/5] Linking C executable zephyr/zephyr_prebuilt.elf
FAILED: zephyr/zephyr_prebuilt.elf
: && ccache /opt/zephyr-sdk-0.11.3/riscv64-zephyr-elf/bin/riscv64-zephyr-elf-gcc zephyr/CMakeFiles/zephyr_prebuilt.dir/misc/empty_file.c.obj -o zephyr/zephyr_prebuilt.elf -Wl,-T zephyr/linker.cmd -Wl,-Map=/home/stefan/workspaces/oscore-edhoc/test/build/zephyr/zephyr_prebuilt.map -Wl,--whole-archive app/libapp.a zephyr/libzephyr.a zephyr/arch/common/libarch__common.a zephyr/arch/arch/riscv/core/libarch__riscv__core.a zephyr/lib/libc/minimal/liblib__libc__minimal.a zephyr/lib/posix/liblib__posix.a zephyr/boards/riscv/hifive1/libboards__riscv__hifive1.a zephyr/subsys/testsuite/ztest/libsubsys__testsuite__ztest.a zephyr/drivers/gpio/libdrivers__gpio.a zephyr/drivers/spi/libdrivers__spi.a zephyr/drivers/serial/libdrivers__serial.a -Wl,--no-whole-archive zephyr/kernel/libkernel.a zephyr/CMakeFiles/offsets.dir/arch/riscv/core/offsets/offsets.c.obj -L"/opt/zephyr-sdk-0.11.3/riscv64-zephyr-elf/bin/../lib/gcc/riscv64-zephyr-elf/9.2.0" -L/home/stefan/workspaces/oscore-edhoc/test/build/zephyr -lgcc -Wl,--print-memory-usage ../build_lib_test/libtest.a -mabi=ilp32 -march=rv32ima -Wl,--gc-sections -Wl,--build-id=none -Wl,--sort-common=descending -Wl,--sort-section=alignment -Wl,-u,_OffsetAbsSyms -Wl,-u,_ConfigAbsSyms -nostdlib -static -no-pie -Wl,-X -Wl,-N -Wl,--orphan-handling=warn && :
Memory region Used Size Region Size %age Used
ROM: 73756 B 12 MB 0.59%
RAM: 15600 B 16 KB 95.21%
IDT_LIST: 553 B 2 KB 27.00/opt/zephyr-sdk-0.11.3/riscv64-zephyr-elf/bin/../lib/gcc/riscv64-zephyr-elf/9.2.0/../../../../riscv64-zephyr-elf/bin/ld: ../build_lib_test/libtest.a(cborencoder.o): in function `put64':
/home/stefan/workspaces/oscore-edhoc/test/lib_test/../../externals/tinycbor/src/cborencoder.c:255: undefined reference to `__bswapdi2'
collect2: error: ld returned 1 exit status
%
ninja: build stopped: subcommand failed.
With grep I can see that this function is available in libgcc.a for RISC-V
stefan@t460s:/opt/zephyr-sdk-0.11.3/riscv64-zephyr-elf$ grep -nrw '__bswapdi2'
Binary file lib/gcc/riscv64-zephyr-elf/9.2.0/rv32i/ilp32/libgcc.a matches
Binary file lib/gcc/riscv64-zephyr-elf/9.2.0/rv32iac/ilp32/libgcc.a matches
Binary file lib/gcc/riscv64-zephyr-elf/9.2.0/libgcc.a matches
Binary file lib/gcc/riscv64-zephyr-elf/9.2.0/rv32imac/ilp32/libgcc.a matches
Binary file lib/gcc/riscv64-zephyr-elf/9.2.0/rv64imafdc/lp64d/medany/libgcc.a matches
Binary file lib/gcc/riscv64-zephyr-elf/9.2.0/rv64imafdc/lp64d/libgcc.a matches
Binary file lib/gcc/riscv64-zephyr-elf/9.2.0/rv32imafc/ilp32f/libgcc.a matches
Binary file lib/gcc/riscv64-zephyr-elf/9.2.0/rv32im/ilp32/libgcc.a matches
Binary file lib/gcc/riscv64-zephyr-elf/9.2.0/rv64imac/lp64/medany/libgcc.a matches
Binary file lib/gcc/riscv64-zephyr-elf/9.2.0/rv64imac/lp64/libgcc.a matches
Binary file libexec/gcc/riscv64-zephyr-elf/9.2.0/lto1 matches
Binary file libexec/gcc/riscv64-zephyr-elf/9.2.0/cc1 matches
Binary file libexec/gcc/riscv64-zephyr-elf/9.2.0/cc1plus matches
How to tell my zephyr project to use libgcc?
Based on the gcc line, you are getting libgcc pulled in via -L"/opt/zephyr-sdk-0.11.3/riscv64-zephyr-elf/bin/../lib/gcc/riscv64-zephyr-elf/9.2.0” and -lgcc.

What version of zephyr are you using? Have you tried running the link with a -Wl,--start-group …. -Wl,—end-group?

- k


API meeting cancelled today

Carles Cufi
 

Hi all,

I am cancelling the API meeting today due to a conflict and the fact that there were no scheduled discussions to take place besides going over the current open GitHub issues to fix for 2.5.

If you did have something you wanted to bring up, please let me know and I'll schedule it for next week.

Thanks,

Carles


Network forum agenda

Jukka Rissanen
 


undefined reference to `__bswapdi2' when trying to link tinycbor for RISC-V

Stefan Hristozov
 

I am getting undefined reference to `__bswapdi2' when I am trying to link tinycbor for RISC-V (west build -b=hifive1)
stefan@t460s:~/workspaces/oscore-edhoc/test$ west build -b=hifive1
[1/5] Linking C executable zephyr/zephyr_prebuilt.elf
FAILED: zephyr/zephyr_prebuilt.elf
: && ccache /opt/zephyr-sdk-0.11.3/riscv64-zephyr-elf/bin/riscv64-zephyr-elf-gcc    zephyr/CMakeFiles/zephyr_prebuilt.dir/misc/empty_file.c.obj  -o zephyr/zephyr_prebuilt.elf  -Wl,-T  zephyr/linker.cmd  -Wl,-Map=/home/stefan/workspaces/oscore-edhoc/test/build/zephyr/zephyr_prebuilt.map  -Wl,--whole-archive  app/libapp.a  zephyr/libzephyr.a  zephyr/arch/common/libarch__common.a  zephyr/arch/arch/riscv/core/libarch__riscv__core.a  zephyr/lib/libc/minimal/liblib__libc__minimal.a  zephyr/lib/posix/liblib__posix.a  zephyr/boards/riscv/hifive1/libboards__riscv__hifive1.a  zephyr/subsys/testsuite/ztest/libsubsys__testsuite__ztest.a  zephyr/drivers/gpio/libdrivers__gpio.a  zephyr/drivers/spi/libdrivers__spi.a  zephyr/drivers/serial/libdrivers__serial.a  -Wl,--no-whole-archive  zephyr/kernel/libkernel.a  zephyr/CMakeFiles/offsets.dir/arch/riscv/core/offsets/offsets.c.obj  -L"/opt/zephyr-sdk-0.11.3/riscv64-zephyr-elf/bin/../lib/gcc/riscv64-zephyr-elf/9.2.0"  -L/home/stefan/workspaces/oscore-edhoc/test/build/zephyr  -lgcc  -Wl,--print-memory-usage  ../build_lib_test/libtest.a  -mabi=ilp32  -march=rv32ima  -Wl,--gc-sections  -Wl,--build-id=none  -Wl,--sort-common=descending  -Wl,--sort-section=alignment  -Wl,-u,_OffsetAbsSyms  -Wl,-u,_ConfigAbsSyms  -nostdlib  -static  -no-pie  -Wl,-X  -Wl,-N  -Wl,--orphan-handling=warn && :
Memory region         Used Size  Region Size  %age Used
             ROM:       73756 B        12 MB      0.59%
             RAM:       15600 B        16 KB     95.21%
        IDT_LIST:         553 B         2 KB     27.00/opt/zephyr-sdk-0.11.3/riscv64-zephyr-elf/bin/../lib/gcc/riscv64-zephyr-elf/9.2.0/../../../../riscv64-zephyr-elf/bin/ld: ../build_lib_test/libtest.a(cborencoder.o): in function `put64':
/home/stefan/workspaces/oscore-edhoc/test/lib_test/../../externals/tinycbor/src/cborencoder.c:255: undefined reference to `__bswapdi2'
collect2: error: ld returned 1 exit status
%
ninja: build stopped: subcommand failed.
With grep I can see that this function is available in libgcc.a for RISC-V
stefan@t460s:/opt/zephyr-sdk-0.11.3/riscv64-zephyr-elf$ grep -nrw '__bswapdi2'
Binary file lib/gcc/riscv64-zephyr-elf/9.2.0/rv32i/ilp32/libgcc.a matches
Binary file lib/gcc/riscv64-zephyr-elf/9.2.0/rv32iac/ilp32/libgcc.a matches
Binary file lib/gcc/riscv64-zephyr-elf/9.2.0/libgcc.a matches
Binary file lib/gcc/riscv64-zephyr-elf/9.2.0/rv32imac/ilp32/libgcc.a matches
Binary file lib/gcc/riscv64-zephyr-elf/9.2.0/rv64imafdc/lp64d/medany/libgcc.a matches
Binary file lib/gcc/riscv64-zephyr-elf/9.2.0/rv64imafdc/lp64d/libgcc.a matches
Binary file lib/gcc/riscv64-zephyr-elf/9.2.0/rv32imafc/ilp32f/libgcc.a matches
Binary file lib/gcc/riscv64-zephyr-elf/9.2.0/rv32im/ilp32/libgcc.a matches
Binary file lib/gcc/riscv64-zephyr-elf/9.2.0/rv64imac/lp64/medany/libgcc.a matches
Binary file lib/gcc/riscv64-zephyr-elf/9.2.0/rv64imac/lp64/libgcc.a matches
Binary file libexec/gcc/riscv64-zephyr-elf/9.2.0/lto1 matches
Binary file libexec/gcc/riscv64-zephyr-elf/9.2.0/cc1 matches
Binary file libexec/gcc/riscv64-zephyr-elf/9.2.0/cc1plus matches
How to tell my zephyr project to use libgcc?


NRF52832 - LPCOMP wakeup example

Martin Kozusky
 

Hello,
does anybody have working example of using LPCOMP in NRF52832 to wakeup MCU from sleep mode (when input voltage gets above setup voltage) and then read somewhere that it has been woken by LPCOMP interrupt (and if possible, also the voltage of analog input when it was triggered, but I don't see register for this value in datasheet)

I see there is NRFX_LPCOMP config, but how can I use that?

Thank you,
Martin


Re: Azure MQTT with GSM modem over PPP #mqtt #modem #ppp #nrf52840

petrus.vanderwalt@...
 

Hi Jukka,

I only had to add a board overlay for my nRF52840 in order to get the gsm_modem sample up and running.  Drivers specifically for the Quectell BG 96 and Sara 412 are available in Zephyr.

I actually want to connect to azure on both methods, MQTT and HTTPS post.  I will try to use TagoIO as a base and see if it works with Azure configs and let you know if it works.

Thanks for telling me where to find the errors.  I was searching for them in the errorno.h.

Have a great day,
Jurgens 


Re: Azure MQTT with GSM modem over PPP #mqtt #modem #ppp #nrf52840

Jukka Rissanen
 

Hi Petrus,

On Thu, 2021-01-28 at 03:49 -0800, petrus.vanderwalt@... wrote:
Hi, Zephyr community.  I am trying to add Azure MQTT functionality to my project.  I am using an nRF52840 with a Quectel BG96/Sara R412M-02B.  I would also like to use the modem functionality to communicate to cellular towers over PPP.

Currently, I have the gsm_modem sample up and running for my Quectel BG96 and U-Blox SARA R412.  I also have the tagio_http_post sample up and running.  I would also want to adapt the tagio_http_post sample to work for Azure.  Would this be easy to do?  Have anyone tried to do this?

Did you need to do any changes to generic gsm modem in order to get the BG96 or SARA modem working. I do not have these modems, so would be interested to know if they worked ok without any special modifications.

To you other question, do you want to connect to azure without using mqtt? Then probably you could use the tagio as a base and change it according to relevant configs found in azure sample. If you get this working, it would be nice to have a separate sample for this.


I am now playing around with the mqtt_azure sample.  I have added PPP support by adding a modem overlay.  I had to disable the DHCPV4 and use a static IP address.  The sample
[00:00:13.283,172] <inf> modem_gsm: Manufacturer: u-blox
[00:00:13.362,243] <inf> modem_gsm: Model: SARA-R412M-02B
[00:00:13.442,871] <inf> modem_gsm: Revision: M0.10.00 [Mar 28 2019 17:13:41]
[00:00:13.523,864] <inf> modem_gsm: IMSI: 655014150468485
[00:00:13.604,797] <inf> modem_gsm: ICCID: 89415000000004684852
[00:00:13.685,394] <inf> modem_gsm: IMEI: 354679092855504
[00:00:13.847,473] <inf> modem_gsm: Attached to packet service!
[00:00:13.880,706] <inf> net_ppp: Initializing PPP to use UART_1
[00:00:13.904,815] <inf> net_config: Interface 1 (0x20000544) coming up
[00:00:13.931,030] <inf> net_config: IPv4 address: 192.0.2.1
[00:00:13.954,803] <dbg> mqtt_azure.main: Waiting for network to setup...
[00:00:15.979,888] <err> mqtt_azure: DNS not resolved for WCM.azure-devices.net:
[00:00:16.744,842] <inf> mqtt_azure: DNS resolved for WCM.azure-devices.net:8883
[00:00:16.770,294] <dbg> mqtt_azure.try_to_connect: attempting to connect...
[00:00:19.802,642] <err> mqtt_azure: mqtt_connect failed -116
[00:00:22.833,923] <err> mqtt_azure: mqtt_connect failed -116
[00:00:25.865,234] <err> mqtt_azure: mqtt_connect failed -116

I can not seem to find the definition of error -116.  Does anyone have an idea what this error is referring to?

The 116 errno is ETIMEDOUT and comes from newlib which can be found in Zephyr SDK.



Cheers,
Jukka


Azure MQTT with GSM modem over PPP #mqtt #modem #ppp #nrf52840

petrus.vanderwalt@...
 

Hi, Zephyr community.  I am trying to add Azure MQTT functionality to my project.  I am using an nRF52840 with a Quectel BG96/Sara R412M-02B.  I would also like to use the modem functionality to communicate to cellular towers over PPP.

Currently, I have the gsm_modem sample up and running for my Quectel BG96 and U-Blox SARA R412.  I also have the tagio_http_post sample up and running.  I would also want to adapt the tagio_http_post sample to work for Azure.  Would this be easy to do?  Have anyone tried to do this?

I am now playing around with the mqtt_azure sample.  I have added PPP support by adding a modem overlay.  I had to disable the DHCPV4 and use a static IP address.  The sample successfully resolves the DNS for azure.  The issue comes thereafter.  The sample fails to connect.  The following is the output I get:
[00:00:13.283,172] <inf> modem_gsm: Manufacturer: u-blox
[00:00:13.362,243] <inf> modem_gsm: Model: SARA-R412M-02B
[00:00:13.442,871] <inf> modem_gsm: Revision: M0.10.00 [Mar 28 2019 17:13:41]
[00:00:13.523,864] <inf> modem_gsm: IMSI: 655014150468485
[00:00:13.604,797] <inf> modem_gsm: ICCID: 89415000000004684852
[00:00:13.685,394] <inf> modem_gsm: IMEI: 354679092855504
[00:00:13.847,473] <inf> modem_gsm: Attached to packet service!
[00:00:13.880,706] <inf> net_ppp: Initializing PPP to use UART_1
[00:00:13.904,815] <inf> net_config: Interface 1 (0x20000544) coming up
[00:00:13.931,030] <inf> net_config: IPv4 address: 192.0.2.1
[00:00:13.954,803] <dbg> mqtt_azure.main: Waiting for network to setup...
[00:00:15.979,888] <err> mqtt_azure: DNS not resolved for WCM.azure-devices.net:
[00:00:16.744,842] <inf> mqtt_azure: DNS resolved for WCM.azure-devices.net:8883
[00:00:16.770,294] <dbg> mqtt_azure.try_to_connect: attempting to connect...
[00:00:19.802,642] <err> mqtt_azure: mqtt_connect failed -116
[00:00:22.833,923] <err> mqtt_azure: mqtt_connect failed -116
[00:00:25.865,234] <err> mqtt_azure: mqtt_connect failed -116

I can not seem to find the definition of error -116.  Does anyone have an idea what this error is referring to?

This is my Azure config:
#define CONFIG_SAMPLE_CLOUD_AZURE_USERNAME "XXX.azure-devices.net/Device-01/?api-version=2018-06-30"
#define CONFIG_SAMPLE_CLOUD_AZURE_PASSWORD "1XbHvFPxHZq1cD380GqCcCxUOAv3SXtecBRGGIXXXXg="
#define CONFIG_SAMPLE_CLOUD_AZURE_CLIENT_ID "Device-01"
#define CONFIG_SAMPLE_CLOUD_AZURE_HOSTNAME "XXX.azure-devices.net"
#define CONFIG_SAMPLE_CLOUD_AZURE_SERVER_ADDR "XXX.61.54.255"
#define CONFIG_SAMPLE_CLOUD_AZURE_SERVER_PORT 8883

My project config as follows:
CONFIG_NETWORKING=y
 
# Disable IPv6 support
CONFIG_NET_IPV6=n
 
# Enable IPv4 support
CONFIG_NET_IPV4=y
CONFIG_NET_IF_MAX_IPV4_COUNT=2
CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=3
 
# Enable TCP support
CONFIG_NET_TCP=y
 
# Enable Sockets support
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_SOCKOPT_TLS=y
 
# Disable DHCPv4 and use static address
CONFIG_NET_DHCPV4=n
 
# Use local DNS server on host
CONFIG_DNS_SERVER1="192.0.2.2"
 
# Configure static addresses
CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
CONFIG_NET_CONFIG_MY_IPV4_GW="192.0.2.2"
 
# Enable SOCKS5 proxy support
CONFIG_SOCKS=n
 
# Enable MQTT Lib support
CONFIG_MQTT_LIB=y
CONFIG_MQTT_LIB_TLS=y
 
# Enable Mbed TLS configuration
CONFIG_MBEDTLS=y
CONFIG_MBEDTLS_BUILTIN=y
CONFIG_MBEDTLS_ENABLE_HEAP=y
CONFIG_MBEDTLS_HEAP_SIZE=100000
CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=10240
CONFIG_MBEDTLS_PEM_CERTIFICATE_FORMAT=y
 
# Network configuration
CONFIG_NET_CONFIG_SETTINGS=y
 
# Network connection manager
CONFIG_NET_CONNECTION_MANAGER=y
 
CONFIG_NET_MGMT_EVENT_STACK_SIZE=1024
CONFIG_NET_MGMT_EVENT_QUEUE_SIZE=5
CONFIG_NET_MGMT_EVENT_LOG_LEVEL_DBG=n
 
CONFIG_DNS_RESOLVER=y
CONFIG_DNS_SERVER_IP_ADDRESSES=y
CONFIG_DNS_SERVER1="8.8.8.8"
CONFIG_DNS_RESOLVER_ADDITIONAL_BUF_CTR=2
CONFIG_NEWLIB_LIBC=y
 
CONFIG_INIT_STACKS=y
CONFIG_NET_SHELL=y
 
CONFIG_MAIN_STACK_SIZE=4096
 
# Enable Logging support
CONFIG_LOG_IMMEDIATE=y
CONFIG_NET_LOG=y
CONFIG_NET_TCP_LOG_LEVEL_DBG=n
CONFIG_NET_SOCKETS_LOG_LEVEL_DBG=n
CONFIG_MQTT_LOG_LEVEL_DBG=n
CONFIG_NET_DHCPV4_LOG_LEVEL_INF=y
CONFIG_NET_IF_LOG_LEVEL_DBG=n
CONFIG_MBEDTLS_DEBUG=n
#CONFIG_MBEDTLS_DEBUG_LEVEL=4
CONFIG_SOCKS_LOG_LEVEL_DBG=n
CONFIG_NET_CONFIG_LOG_LEVEL_DBG=y
CONFIG_NET_CONNECTION_MANAGER_LOG_LEVEL_DBG=n
CONFIG_DNS_RESOLVER_LOG_LEVEL_DBG=n
CONFIG_NET_CONTEXT_LOG_LEVEL_DBG=n

My modem overlay:
# UART support
CONFIG_SERIAL=y
 
# GSM modem support
CONFIG_MODEM=y
CONFIG_MODEM_SHELL=y
CONFIG_MODEM_CMD_HANDLER_MAX_PARAM_COUNT=20
CONFIG_MODEM_GSM_PPP=y
CONFIG_MODEM_GSM_RX_STACK_SIZE=1024
CONFIG_MODEM_GSM_UART_NAME="UART_1"
CONFIG_MODEM_GSM_APN="internet"
 
# Network management events
CONFIG_NET_CONNECTION_MANAGER=y
 
# PPP networking support
CONFIG_NET_NATIVE=y
CONFIG_NET_PPP=y
CONFIG_NET_L2_PPP=y
CONFIG_NET_L2_PPP_TIMEOUT=10000
 
CONFIG_DNS_RESOLVER_MAX_SERVERS=1
CONFIG_DNS_SERVER_IP_ADDRESSES=y
CONFIG_DNS_SERVER1="8.8.8.8"

My main.c stayed unchanged.  I am hoping someone in the community has done something similar and can maybe help me out.  Any help would be appreciated.

Thanks,
Jurgens


Re: Query regarding Bluetooth Controller Porting

Pankaj Singh <PANKAJ.SINGH@...>
 

Hi Carles,

Thanks for sharing the information. We are planning to use uart-H4 protocol and it’s a dual mode controller.

My understanding is that H4tl module on controller side will be interacting with Zephyr BT host over uart and hence there needs to be zephyr based hci driver needed in the controller as well. Please correct me if my understanding is wrong. The hci driver needs to register via bt_hci_driver_register(const struct bt_hci_driver *drv) to send/receive payload with zephyr bt host.
Zephyr Host -> custom controller payload flow :
bt_send() -> struct bt_hci_driver: h4_send() -> h4: net_buf_put() -> uart_tx_queue -> hci driver controller: struct bt_hci_driver drv: send() ->h4 custom controller for further processing.

Controller -> host payload flow :
H4 of custom controller -> hci driver controller: bt_buf_get_rx() -> bt_recv() -> bt_dev.rx_queue -> bt host: hci_rx_thread().

-thanks

-----Original Message-----
From: Cufi, Carles <Carles.Cufi@nordicsemi.no>
Sent: Wednesday, December 9, 2020 3:14 PM
To: kumar.gala@linaro.org; Pankaj Singh <PANKAJ.SINGH@onsemi.com>; devel@lists.zephyrproject.org
Cc: users@lists.zephyrproject.org
Subject: RE: [Zephyr-users] Query regarding Bluetooth Controller Porting

[External Email]: This email arrived from an external source - Please exercise caution when opening any attachments or clicking on links.

+ devel list

Pankaj,

If you are using a dual-chip solution, then as long as you controller complies with standard HCI there is no "porting" to do whatsoever.
In order to better understand what you need, can you let us know which transport do you plan on using (UART/H4, 3-wire/H3 or SPI) and whether it is a single-mode or dual-mode controller?

Unless your controllers has special requirements it should all be a matter of configuring the right Kconfig options and Devicetree nodes.

Carles

-----Original Message-----
From: users@lists.zephyrproject.org <users@lists.zephyrproject.org> On
Behalf Of Kumar Gala via lists.zephyrproject.org
Sent: 08 December 2020 15:08
To: Pankaj Singh <PANKAJ.SINGH@onsemi.com>
Cc: users@lists.zephyrproject.org
Subject: Re: [Zephyr-users] Query regarding Bluetooth Controller
Porting

You may want to ask this question on the devel list.
(devel@lists.zephyrproject.org)

- k

On Dec 8, 2020, at 12:02 AM, Pankaj Singh <PANKAJ.SINGH@onsemi.com>
wrote:

Hi,

We want to port our custom Bluetooth controller to run on Zephyr
RTOS
(not using the default zephyr ble controller support). I went through
the Bluetooth documentation
https://urldefense.proofpoint.com/v2/url?u=https-3A__eur03.safelinks.p
rotection.outlook.com_-3Furl-3Dhttps-253A-252F-252Fdocs.zep&d=DwIGaQ&c
=MHZppzMdXMt3JYjCV71UsQ&r=D1ATefx54IThv9ORLOcugPTkb_DOEyRHRjojSRtEnrU&
m=ZO-WCaqOoEicxTN4fmmF7-u-hHTdbZr5jne77OIy4Jw&s=QnUBxuLAcWGdBjnd5kZF9a
QHR7Sye63KYcAkpY4B_NQ&e=
hyrproject.org%2Flatest%2Fguides%2Fbluetooth%2Findex.html&amp;data=04%
7C01
%7Ccarles.cufi%40nordicsemi.no%7Cc35438a7065845415d0708d89b82c771%7C28
e5af
a2bf6f419a8cf6b31c6e9e5e8d%7C0%7C0%7C637430333288501659%7CUnknown%7CTW
FpbG
Zsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%
3D%7
C1000&amp;sdata=6J8jWeiNRxk3NPbnu1uQq0g01EaUG8wCYsQK58AFk6w%3D&amp;res
erve
d=0
,https://urldefense.proofpoint.com/v2/url?u=https-3A__eur03.safelinks.
protection.outlook.com_-3Furl-3Dhttps-253A-252F-252Fdocs.ze&d=DwIGaQ&c
=MHZppzMdXMt3JYjCV71UsQ&r=D1ATefx54IThv9ORLOcugPTkb_DOEyRHRjojSRtEnrU&
m=ZO-WCaqOoEicxTN4fmmF7-u-hHTdbZr5jne77OIy4Jw&s=8zzMc7KWKKqqJAICGpPLCZ
SdvQVNjcruY_9-MvJourM&e=
phyrproject.org%2Flatest%2Fguides%2Fbluetooth%2Fbluetooth-
arch.html&amp;data=04%7C01%7Ccarles.cufi%40nordicsemi.no%7Cc35438a7065
8454
15d0708d89b82c771%7C28e5afa2bf6f419a8cf6b31c6e9e5e8d%7C0%7C0%7C6374303
3328
8501659%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLC
JBTi
I6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=pzOa7iuR0SSOR59u4s5VE3LgNF5M
eoXR ku7XtLCnOWo%3D&amp;reserved=0. The link’s talks about Bluetooth
host in detail and it was helpful. We want to use Dual Chip
configuration mode (use Zephyr Bluetooth host + custom Bluetooth
controller support) .

From link it talks about various host only build configuration
o CONFIG_BT =y
o CONFIG_BT_HCI =y
o CONFIG_BT_CTLR =n


My query is in order to port custom controller what steps, build
configuration we need to take care of. If there is a link/document
that helps to describe porting of custom Bluetooth controller to
Zephyr it will be helpful.

-thanks




API meeting: agenda

Carles Cufi
 


SDK 0.12.2 Release

Kumar Gala
 

Hi,

Latest version of the SDK can be found here:

https://github.com/zephyrproject-rtos/sdk-ng/releases/tag/v0.12.2

Please download and try things out and report any issues.

[ I skipped the release announcement on SDK 0.12.1 so including the changes since 0.12.0 ]

* Add support for MIPS
* Enable EFI binary generation for x86_64 binutils
* Fix to Kconfig version

Thanks to all that contributed fixes and enhancements to this version of the SDK.

- k


CANopen error message

Cristian Anceschi
 

Hi all

I'm developing a CANOPEN node based on an nRF52DK nRF52832 (PCA10040) board  wired to a MCP2515 and a MCP2551 devices.
So far, through a CAN Interface for USB plugged to a PC, I can receive and transmit packets and command from and to the board

When I compile the project and launch the Zephyr debug, the first message received by the PC over the CAN bus is an error message (hex string). Received only once, at reset.

08A 00 61 01 2A 00 00 00 00 00

which means that the system it is unable to allocate memory for object (CO_EM_MEMORY_ALLOCATION_ERROR).
The log file at the boot is

  *** Booting Zephyr OS build v2.4.0-ncs1  ***
[00:00:02.737,579] [0m<inf> fs_nvs: 6 Sectors of 4096 bytes [0m
[00:00:02.737,579] [0m<inf> fs_nvs: alloc wra: 1, e90 [0m
[00:00:02.737,579] [0m<inf> fs_nvs: data wra: 1, 210 [0m
[00:00:02.739,776] [0m<dbg> canopen_storage.canopen_settings_set: restored object dictionary EEPROM entries [0m
[00:00:02.739,807] [0m<dbg> canopen_driver.CO_CANmodule_init: rxSize = 13, txSize = 9 [0m
[00:00:02.740,814] [1;31m<err> canopen_driver: failed to attach CAN rx isr, no free filter [0m
[00:00:02.740,875] [1;31m<err> canopen_driver: failed to attach CAN rx isr, no free filter [0m
[00:00:02.740,905] [1;31m<err> canopen_driver: failed to attach CAN rx isr, no free filter [0m

[00:00:02.740,966] [0m<inf> app: CANopen stack initialized [0m
 
After this a guard message (hex string) , every 1 second,  is received over the CAN bus

70A 7F

The node appears in pre-operational state.
No other error messages are shown by the PC via the Zephyr debug system.

In this condition, sending NMT commands, it is possible to force the node to:
  • Enter in STOP mode
  • Enter in Pre-operational mode (from STOP mode)
  • Reset node
  • Reset communication
The node however doesn't enter in operational mode.

Might the reason for this latest fact be, that there is an error at reset, so that the node won't enter in operational mode because of this?
What can be the cause of the error? Is there a THREAD STACK SIZE or some other parameter I have to change to solve the problem?

Or can I suppose that the error message can be overlooked because the node has to start and then everything works as expected? I mean, the node after all IS receiving commands like I said above.

In any case I believe that the node has to be moved away from the error condition in order to proceed. What should be the best way to do this?                                                                                                                                                                                                                            Thanks in advance for any hints and support                                                                                                                                                                                                                                    Kind regards

Cristian                                                                                           


Problem with ARP source address #ethernet #stm32

tobias.roehmel@...
 

Hi,

I am using an STM32F4 board with an ENC28J60 (Ethernet over SPI chip) and am trying to get the net/sockets/http_get sample to work. To make it easier I use a static IP of google instead of DNS. The Problem I am seeing, by using Wireshark, is that the first Ethernet packet is lost somewhere on the ENC28J60. I know that the driver received the packet but it never arrives on the other side of the ethernet cable. The network stack tries to resend the packet but now the Sender protocol address is set to all 0s (This happens in the function arp_prepare in arp.c). The ARP request is answered but sent with Target protocol address 0.0.0.0 and Zephyr seems to refuse to reply to IPs other than their own. I found 2 solutions to this, first adding a delay before accessing the socket, second changing the code in arp.c to not fill in 0s.
Am I doing something wrong? Is there a configuration I could change instead? Is this the intended behavior?

Kind regards,
Tobias Röhmel

181 - 200 of 2607