Date   

NRF52 and timing - actual state and what functions to use? #nrf52-pca10040

Martin Kozusky
 

Hi,
I understand that there are some problems because of 32768Hz RTC with NRF52832 as referenced here: https://github.com/zephyrproject-rtos/zephyr/issues/9904  , there are some already merged PRs (like https://github.com/zephyrproject-rtos/zephyr/pull/16782 )  and some waiting to merge, so what is the actual state at 2.1.0?

I want to ask:

 1 - what is the best solution to call my function every 1ms (or will it be 1.007ms?), is it ok just to use k_timer? Is "next expiration time" calculated just by adding period to current time (that would make a big time diff after many calls)  or does it use k_uptime_get*number of expirations to calculate next expiration time?

 2 -  what is the best solution for most precise long-term time keeping?  Let's say i don't want more that 1 minute diff in 20 days. Can I just use k_uptime_get? I would like to make my HW design without aditional external RTC, which can be almost as expensive as another NRF52832 - is it even possible somehow? Or do you have any tip for some cheap low-power RTC?

 3 - would using external 16MHz/32MHz (or another frequency) oscilator solve anything?

 4 - as someone already wrote here: https://lists.zephyrproject.org/g/users/topic/28021125  would it be possible to use timer peripheral (with external osc.) to generate better timing (as I would normaly do with bare-metal sources)?


Thanks.


Re: Failure of CMD0 sending using STM32F769 + SPI2 for [samples/subsys/fs/fat_fs] #spi #fatfs

@yasokada
 

Instead of adding k_usleep(30),
I changed the SPI clock from 210kHz to 406kHz for STM32F769.

Then, the problems of A and B are gone.
Still I have the problem of C.
I receive 0x07 instead of 0x01.



From what I read throught the internet, the CRC for CMD is 0x95. But in Zephyr, the CRC is 0x94.
I wonder whether this difference cause some problem. However, for STM32L476, this works.

I will check further on this. 


Re: Failure of CMD0 sending using STM32F769 + SPI2 for [samples/subsys/fs/fat_fs] #spi #fatfs

@yasokada
 

From what I checked:

- A. 74 clocks stop with a change in CS without sufficient delay
- B. CMD0 (0x40 0x00 0x00 0x00 0x00 0x94) fails to send 0x40... (instead send 0x20...)
- C. CMD0 fails to receive 0x01

I added `k_usleep(30); // usec` before sdhc_spi_set_cs(data, 0); in sdhc_spi_go_idle() of disk_access_spi_sdhc.c.
Then, the above A and B are solved.
However, I still have the problem of C.
This may be caused without sufficient delay after sending 0x94. I am checking how to add delay after 0x94.

I also checked the clock frequency.
- STM32L476: 312kHz
- STM32F768: 210kHz

I am not sure whether this difference in the frequency makes the failure and success of the process.


Re: "in-tree" builds > its meaning

@yasokada
 

Dear Marti

Thank you very much for your reply.
I can understand the difference now.

Best regards

Yasuhiko Okada


NRF 802.15.4 driver without networking?

axel+zephyr@...
 

Hi,

I should probably start by saying that I’m brand new to Zephyr and that I’m pretty sure I’m missing something obvious or just overlooked parts of the (great!) documentation.

I’m trying to configure my project to use the NRF 802.15.4 radio driver coming with Zephyr (in the modules/hal/nordic/drivers/nrf_radio_802154) without any of the other Zephyr networking support, but I can’t figure out a project config that would help me achieve this. I played with various configs, and the most promising seems to be

CONFIG_NETWORKING=n
CONFIG_IEEE802154=y
CONFIG_IEEE802154_NRF5=y
CONFIG_IEEE802154_RAW_MODE=n
CONFIG_HAS_NORDIC_DRIVERS=y

but Kconfig won’t let me set CONFIG_HAS_NORDIC_DRIVERS manually (which is required to include the drivers subfolder, see modules/hal/nordic/CMakeLists.txt).

As a desperate measure I tried to set every CONFIG_IEEE802154_xxx config flag to no and instead include the driver as an extra module via

set(ZEPHYR_EXTRA_MODULES [some_directory]/modules/hal/nordic/drivers/nrf_radio_802154)

but no luck either.

Any ideas what else I could try?

Thanks,
Axel


NRF 802.15.4 driver without networking?

Axel Schlueter <axel@...>
 

Hi,

I should probably start by saying that I’m brand new to Zephyr and that I’m pretty sure I’m missing something obvious or just overlooked parts of the (great!) documentation.

I’m trying to configure my project to use the NRF 802.15.4 radio driver coming with Zephyr (in the modules/hal/nordic/drivers/nrf_radio_802154) without any of the other Zephyr networking support, but I can’t figure out a project config that would help me achieve this. I played with various configs, and the most promising seems to be

CONFIG_NETWORKING=n
CONFIG_IEEE802154=y
CONFIG_IEEE802154_NRF5=y
CONFIG_IEEE802154_RAW_MODE=n
CONFIG_HAS_NORDIC_DRIVERS=y

but Kconfig won’t let me set CONFIG_HAS_NORDIC_DRIVERS manually (which is required to include the drivers subfolder, see modules/hal/nordic/CMakeLists.txt).

As a desperate measure I tried to set every CONFIG_IEEE802154_xxx config flag to no and instead include the driver as an extra module via

set(ZEPHYR_EXTRA_MODULES [some_directory]/modules/hal/nordic/drivers/nrf_radio_802154)

but no luck either.

Any ideas what else I could try?

Thanks,
Axel


Re: cannot find "__device_[device name]" #api

Bolivar, Marti
 

Hi Justin,

"Justin Huang via Lists.Zephyrproject.Org"
<justin.y.huang=live.com@lists.zephyrproject.org> writes:

Hi,

I am building a device driver for Zephyr and when calling the macro, DEVICE_GET(), like DEVICE_GET(my_dev), I get a build error complaining about undefined __device_my_dev.
I tried to locate where the variable is assembled during the build process but have no luck so far.
DEVICE_GET() might not be the right thing here. Are you trying to get a
pointer to your device from the device driver C file itself, or from
some other file?

If you're trying to get a pointer to your device from some application
source code, you should probably be using device_get_binding() instead of
DEVICE_GET().


I have placed the following in the driver source code:

DEVICE_INIT(my_dev, CONFIG_MYDEV_NAME, my_dev_init,
my_dev_device_ctrl, NULL,
APPLICATION, CONFIG_MYDEV_INIT_PRIORITY);

Could you please shed some light on where to look for what might go
wrong?
If (and only if) the DEVICE_GET() line is in the same file as the above
DEVICE_INIT(), then it should work properly when paired with
DEVICE_DECLARE(), as shown with example code in this documentation page:

https://docs.zephyrproject.org/latest/reference/drivers/index.html#single-driver-multiple-instances

However, note that DEVICE_INIT allocates a static struct device, so you
can't use DEVICE_GET() to access that device from another file.

If you're trying to get a pointer to your struct device from another
C file, you need to use something like this instead:

struct device *mydev = device_get_binding(CONFIG_MYDEV_NAME);

BR,
Martí


Thanks,
Justin


Re: "in-tree" builds > its meaning

Bolivar, Marti
 

Hello,

"yasokada via Lists.Zephyrproject.Org"
<yasokada=gmail.com@lists.zephyrproject.org> writes:

Application Development
https://docs.zephyrproject.org/latest/application/index.html
at several lines above the Source Tree Structure ( https://docs.zephyrproject.org/latest/application/index.html#source-tree-structure )

Zephyr does not support “in-tree” builds.
The "in-tree" and "out-of-tree" may be used in linux as being part of the system or not, I think.
Linux kernel: meaning of source-tree, in-tree and out-of-tree ( https://unix.stackexchange.com/questions/208638/linux-kernel-meaning-of-source-tree-in-tree-and-out-of-tree )

In the above sentence for Zephyr, what does the "in-tree" builds mean?

For example, I guess, the "in-tree" builds means that the build can be performed only partly for some module, not for all the application project.
That is not correct.

Am I mistaken?
An "in-tree" build is when build artifacts (object files, generated
code, etc.) are created in the same directories as the source code. E.g.
if CMake places the object file for zephyr/kernel/init.c in the same
directory (zephyr/kernel), that would be an in-tree build, but that is
not supported by the Zephyr build system.

Zephyr's build system requires "out-of-tree" builds, which means that
the build directory is separate from the source directories.

Martí


Thanks in advance


cannot find "__device_[device name]" #api

Justin Huang
 

Hi,

I am building a device driver for Zephyr and when calling the macro, DEVICE_GET(), like DEVICE_GET(my_dev), I get a build error complaining about undefined __device_my_dev.
I tried to locate where the variable is assembled during the build process but have no luck so far.

Could you please shed some light on where to look for what might go wrong?

Thanks,
Justin


cannot find "__device_[device name]" #api

Justin Huang
 

Hi,

I am building a device driver for Zephyr and when calling the macro, DEVICE_GET(), like DEVICE_GET(my_dev), I get a build error complaining about undefined __device_my_dev.
I tried to locate where the variable is assembled during the build process but have no luck so far.

I have placed the following in the driver source code:

  DEVICE_INIT(my_dev, CONFIG_MYDEV_NAME, my_dev_init,                                                                                                                                                                                                                                                                                                                                                                                                                                                
              my_dev_device_ctrl, NULL,                                                                                                                                                                                                                                                                                                                                                                                                                                                         
              APPLICATION, CONFIG_MYDEV_INIT_PRIORITY);

Could you please shed some light on where to look for what might go wrong?

Thanks,
Justin


NVS on flash with erase page size 64k or larger #nvs

Marco
 

Hi there

In my application I try to use NVS on an external SPI flash (M25P16) which has an erase page size of 64k.

As I realised, NVS seems to have some limit on its maximum sector size of just below those 64k, since the variable storing it is an u16_t.

Is there any workaround to get this combination to work anyway, or is even an enhancement planned, to overcome this limit?
Since there are still quite a few memories on the market with page sizes exceeding those 64k it might be interesting generally.

Thanks and regards.


Failure of CMD0 sending using STM32F769 + SPI2 for [samples/subsys/fs/fat_fs] #spi #fatfs

@yasokada
 

My environment:
Ubuntu 18.04 LTS
STM32L476 Nucleo_64 (hereafter STM32L476)
STM32F769 Discovery Kit (hereafter STM32F769)
Zephyr 2.1.0-rc1
Project: `samples/subsys/fs/fat_fs`
Logic Analyzer: Analog Discovery 2
 
### Difference
 
I have tested the sample project for microSD/MMC with FatFs (samples/subsys/fs/fat_fs).
 
The project works on some boards, but does not work on one board.
 
A. STM32L476 + SPI1 : O.K.
B. STM32L476 + SPI2 : O.K.
C. STM32F769 + SPI2 : Fail
 
### Logic capture for STM32L476
 
I have captured the SPI logic using Analog Discovery 2.
 
For STM32L476, the captured logics are shown below.





I can see:
 
1. 74 plus alpha clocks
2. MOSI: 0x40 0x00 0x00 0x00 0x00 0x94 0xFF 0xFF 0xFF
 
It works with STM32L476.
 
### Logic capture for STM32F769
 
I also have captured the SPI logic for STM32F769.





I saw:
 
1. 74 plus alpha clocks
2. MOSI: 0x20 0x00 0x00 0x00 0x00 0x4A ...

The step 2 is mistaken not CMD0 (0x40 0x00 0x00 0x00 0x00 0x94), possibly shifted sending.
 
### Possible cause of the failure
 
It seems that the 74 clocks do not end properly (ChipSelect did not go into low with margin).
This may cause the failure to send the CMD0 (0x40) command using STM32F769.
 
I will check how to solve this. But if anyone can suggest to fix this, it helps.
 
P.S. I will see on this after Jan. 3, 2020.
 


It worked > Re: SPI2 definition is not found for STM32L476 device tree. How to add?

@yasokada
 

Dear Yannis
(I have sent private reply, but for other people, I send this reply again).

Thank you very much.

I added the description for &spi2 in an overlay file.
It worked.

I appreciate it.


Private: Re: [Zephyr-users] SPI2 definition is not found for STM32L476 device tree. How to add?

Yannis Damigos
 

-------- Forwarded Message --------
Subject: Private: Re: [Zephyr-users] SPI2 definition is not found for STM32L476 device tree. How to add?
Date: Fri, 27 Dec 2019 15:40:46 -0800
From: yasokada@gmail.com
To: Yannis Damigos <giannis.damigos@gmail.com>



Dear Yannis


Thank you very much for your quick reply.

It worked!


Re: SPI2 definition is not found for STM32L476 device tree. How to add?

Yannis Damigos
 

Hi,

### How to add?

I may need to add the spi2 definition for STM32L476.

Where should I add the definition?
You don't need to add it. It exists in dts/arm/st/l4/stm32l471.dtsi

A. stm32l4.dtsi
B. nucleo_l476rg.dts> C. <BOARD>.overlay file located in the project directory

I just wonder why there is a definition for SPI2 for the supported board web page, but it is not actually supported by the device tree.
To enable it just add the following in nucleo_l476rg.dts or an overlay file:

&spi2 {
status = "okay";
};

Yannis


SPI2 definition is not found for STM32L476 device tree. How to add?

@yasokada
 
Edited

My environment:
Ubuntu 18.04 LTS
STM32L476 Nucleo_64 (hereafter STM32L476)
STM32F769 Discovery Kit (hereafter STM32F769)
Zephyr 2.1.0-rc1

### SPI2 for STM32L476 

https://docs.zephyrproject.org/latest/boards/arm/nucleo_l476rg/doc/index.html

In the above page, there is the definition of SPI2 (and SPI3).
However, when I west build the project with the SPI_2 set, I have the following errors.

```
zephyr/include/generated/generated_dts_board_fixups.h:199:27: error: 'DT_ST_STM32_SPI_FIFO_40003800_IRQ_0_PRIORITY' undeclared (first use in this function); did you mean 'DT_ST_STM32_SPI_FIFO_40013000_IRQ_0_PRIORITY'?
 #define DT_SPI_2_IRQ_PRI  DT_ST_STM32_SPI_FIFO_40003800_IRQ_0_PRIORITY
```

I found that the above is caused because there is no "spi2" definition in the stm32l4.dtsi.
On the other hand, there is "spi2" definition in stm32f7.dtsi, which is shown below. 

```
spi2: spi@40003800 {
compatible = "st,stm32-spi";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x40003800 0x400>;
clocks = <&rcc STM32_CLOCK_BUS_APB1 0x00004000>;
interrupts = <36 5>;
status = "disabled";
label = "SPI_2";
};
```

### How to add?

I may need to add the spi2 definition for STM32L476.

Where should I add the definition?

A. stm32l4.dtsi
B. nucleo_l476rg.dts
C. <BOARD>.overlay file located in the project directory

I just wonder why there is a definition for SPI2 for the supported board web page, but it is not actually supported by the device tree.



Multiple device with different GPIO chip selects on SPI2

armand@...
 

Good day,

I have decided to dive head first into Zephyr with a project of mine.

I have a LIS2DH and a W25Q128JV Flash on the same SPI bus, with two GPIOs to control the chip selects. I have a STM32F413VGT6 microcontroller, and the Zephyr version is

However, I am having some trouble. When the FLASH SPI is initialized (in function spi_nor_read_id called by  spi_not_configure) to read the JEDEC ID, the LIS2DH chip select is still not initialised, ie its low, so I have two devices selected at the same time. This results in an incorrect JEDEC ID.

Later when I try to use the LIS2DH, no chip selects are being controlled, leading to a problem in getting data from the LIS2DH.

I cannot find any place in the code where the cs-gpios from the dts file is used. In fact I have been able to ascertain that the chip select list is not initialized with the following test:

static inline void spi_context_cs_control(struct spi_context *ctx, bool on)
{
if (ctx)
{
printf("Test0 %d\n",(int)on);

if (ctx->config)
{
printf("Test1 %p\n",ctx->config);

if (ctx->config->cs)
{
printf("Test2 %p\n",ctx->config->cs);

if (ctx->config->cs->gpio_dev)
{
printf("Test3 %p,%s,%08X\n",ctx->config->cs->gpio_dev,
ctx->config->cs->gpio_dev->config->name,
ctx->config->cs->gpio_dev->config->init);
}
}
}
}

_spi_context_cs_control(ctx, on, false);
printf("Setting CS End");
}

At the time the SPI NOR flash is initialised the output from the above function is:
Test0 1
Test1 0x20000f78
Test2 0x20000f84
Test3 0x200050fc,GPIOD
Setting CS End
Test0 0
Test1 0x20000f78
Test2 0x20000f84
Test3 0x200050fc,GPIOD
Setting CS End
(And I can see the NOR Flash chip select activated)

but by the time I want to use the LISD2H, the output is:
Test0 1
Test1 0x20000f5c
Setting CS End
Test0 0
Test1 0x20000f5c
Setting CS End
(No chip select activity since the chip select GPIO list ctx->config->cs is NULL)

I have seen the debate on where chip select control is to be done here:
https://github.com/zephyrproject-rtos/zephyr/issues/12698 and
https://github.com/zephyrproject-rtos/zephyr/issues/12226
but none of these really helped my to solve my problem.

Here is an extract from my dts file:

&spi2 {
status = "okay";

cs-gpios = <&gpiob 7 0>, <&gpiod 11 0>;

lis2dh@0 {
compatible = "st,lis2dh";
spi-max-frequency = <1000000>;
reg = <0>;
irq-gpios = <&gpiob 6 0>, <&gpiod 7 0>;
label = "LIS2DH";
};


flash1: flash@1 {
compatible = "jedec,spi-nor";
reg = <1>;
size = <16777216>;
spi-max-frequency = <2000000>;
label = "W25Q128JV";
jedec-id = [ef 40 18];
};
};


Does anyone know of a good working example with multiple Chip selects on a SPI bus where the CS lines are controlled with GPIOs, or can someone point me in the right direction to solve this problem?

Thanks in advance, any help is appreciated.

Greeting from South Africa


Re: Regarding the flash of hci_uart sample app of zephire in nrf52840

Chettimada, Vinayak Kariappa
 

Please follow this, if using hci_uart:

https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/nrf5x-support-within-the-zephyr-project-rtos

 

Else if using hci_usb and the nRF52840’s native USB port, Linux with Bluez will implicitly load the modules on plugging and you can directly using btmgmt tool.

 

 

-Vinayak

 

From: users@... <users@...> On Behalf Of Amit Purwar via Lists.Zephyrproject.Org
Sent: 18 December 2019 11:49
To: users@...
Cc: users@...
Subject: [Zephyr-users] Regarding the flash of hci_uart sample app of zephire in nrf52840

 

I have build and flashed the zephire/sample/bluetooth/hci_uart on nrf52840 board and connected the board with ubuntu but hci interface was not created when checked using hciconfig.

Can you please provide the steps for the same . I have used below step

cd zephyr/samples/bluetooth/hci_uart

mkdir nrf_build

cmake -DBOARD=nrf52840_pca10056 ../

make

make flash

hciconfig

But no hci interface created


Regarding the flash of hci_uart sample app of zephire in nrf52840

Amit Purwar <amit.purwar@...>
 

I have build and flashed the zephire/sample/bluetooth/hci_uart on nrf52840 board and connected the board with ubuntu but hci interface was not created when checked using hciconfig.

Can you please provide the steps for the same . I have used below step

cd zephyr/samples/bluetooth/hci_uart

mkdir nrf_build

cmake -DBOARD=nrf52840_pca10056 ../

make

make flash

hciconfig

But no hci interface created


How to implement a simple SPI-Slave function on nRF52 PCA10040 board.

robin@...
 

I am attempting to create a simple SPI-Slave implementation for the nRF52 PCA10040 board.  
My project’s source code is at https://github.com/foldedtoad/spi_slave.
 
While I am able to receive events whenever the SPI-Master (host) sends data, the receive buffers are empty. 
A logic analyzer trace shows good SPI protocol from the SPI-Master.

I have looked for examples which might shed some light on how to implement an starter version of a SPI-Slave on the nRF52 series. 

Any guidance or suggestions as to what prevents my code from receiving data would be appreciated.

Cheers,
Robin

961 - 980 of 2790