Date   

Re: cmake application project architecture

Sebastian Boe
 

You also need

add_dependencies(DL offsets_h)

________________________________________
From: devel@... <devel@...> on behalf of Florian Fouillet <Florian.Fouillet@...>
Sent: Wednesday, November 28, 2018 3:42:54 PM
To: Hovland, Sigvart; devel@...
Subject: Re: [Zephyr-devel] cmake application project architecture

Hi,

By adding target_link_libraries(DL PRIVATE zephyr_interface)

I still have the following issue

fatal error: syscall_list.h: No such file or directory

From: Hovland, Sigvart [mailto:@siho]
Sent: Wednesday, November 28, 2018 4:26 AM
To: Florian Fouillet <Florian.Fouillet@...>; devel@...
Subject: RE: cmake application project architecture


[External email: Use caution with links and attachments]

________________________________


Maybe adding

target_link_libraries(DL PRIVATE zephyr_interface)


To your 2nd CMake file could help?

From: devel@...<mailto:devel@...> [mailto:devel@...] On Behalf Of Florian Fouillet
Sent: Tuesday, November 27, 2018 9:53 PM
To: devel@...<mailto:devel@...>
Subject: [Zephyr-devel] cmake application project architecture

Hi everyone,

I am currently working on the Zephyr OS with a FDRM_K64f board from NXP.

I want to create my own application using cmake as recommended by the documentation.

However I don’t want to put everything in one CMakeLists.txt. I want to break down my project into libraries (multiple CMakeLists.txt).

Do you know if there is any documentation talking about that?

My top CMakeLists looks like that:

cmake_minimum_required(VERSION 3.8.2)

include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
project(NONE)


add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/DataLinkLayer
${CMAKE_CURRENT_SOURCE_DIR}/build/${BOARD}/DataLinkLayer)

target_sources(app PRIVATE src/main.c)

target_link_libraries(app
PRIVATE DL
)


And my second CMakeLists (under the folder DataLinkLayer) looks like that:

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)

add_library(DL src/DataLinkInterface.c)

target_include_directories(DL
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/Interface)



The issue is I can include the boilerplate.cmake in only one CMakeLists.txt otherwise It’s not working, But, the second CmakeLists doesn’t know the zephyr library..

I tried to add: include_directories(/home/user/zephyr/include) in the second CMakeLists but it is not enough. Do you know what should I do?


Thank you,


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
______________________________________________________________________


Re: cmake application project architecture

Florian Fouillet <Florian.Fouillet@...>
 

Hi,

 

By adding target_link_libraries(DL PRIVATE zephyr_interface)

 

I still have the following issue

 

fatal error: syscall_list.h: No such file or directory

 

From: Hovland, Sigvart [mailto:Sigvart.Hovland@...]
Sent: Wednesday, November 28, 2018 4:26 AM
To: Florian Fouillet <Florian.Fouillet@...>; devel@...
Subject: RE: cmake application project architecture

 

[External email: Use caution with links and attachments]


 

Maybe adding

target_link_libraries(DL PRIVATE zephyr_interface)

To your 2nd CMake file  could help?

 

From: devel@... [mailto:devel@...] On Behalf Of Florian Fouillet
Sent: Tuesday, November 27, 2018 9:53 PM
To: devel@...
Subject: [Zephyr-devel] cmake application project architecture

 

Hi everyone,

 

I am currently working on the Zephyr OS with a FDRM_K64f board from NXP.

 

I want to create my own application using cmake as recommended by the documentation.

 

However I don’t want to put everything in one CMakeLists.txt. I want to break down my project into libraries (multiple CMakeLists.txt).

 

Do you know if there is any documentation talking about that?

 

My top CMakeLists looks like that:

 

cmake_minimum_required(VERSION 3.8.2)

 

include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)

project(NONE)

 

 

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/DataLinkLayer

${CMAKE_CURRENT_SOURCE_DIR}/build/${BOARD}/DataLinkLayer)

 

target_sources(app PRIVATE src/main.c)

 

target_link_libraries(app

PRIVATE DL

)

 

 

And my second CMakeLists (under the folder DataLinkLayer) looks like that:

 

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)

 

add_library(DL src/DataLinkInterface.c)

 

target_include_directories(DL

INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/Interface)

 

 

 

The issue is I can include the boilerplate.cmake in only one CMakeLists.txt otherwise It’s not working, But, the second CmakeLists doesn’t know the zephyr library..

 

I tried to add: include_directories(/home/user/zephyr/include) in the second CMakeLists but it is not enough. Do you know what should I do?

 

 

Thank you,

 


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
______________________________________________________________________


How to print Debug and Error messages on console #nrf52480 #nrf52832

Akash Naidu <akashnaiduece@...>
 

Hi All,
Currently i have been working on "zephyr/samples/bluetooth/ipsp" example, in which i can able to see LOG_INF messages only.
How to print LOG_DBG and LOG_ERR messages on console.

The above example is running on nrf52 DK.
Thanks in Advance

BR
Akash.


Re: checkstack.pl

Benjamin Lindqvist
 

Lol. Mistyped again -- to clarify, I definitely mean checkstack.pl and
not checkpatch.pl, if anyone did not extrapolate successfully
Den ons 28 nov. 2018 kl 13:10 skrev Benjamin Lindqvist
<benjamin.lindqvist@...>:


Hi,

I wanted to try out scripts/checkstack.pl and verified that it
actually works on a vmlinux image by

arm-none-eabi-objdump -d vmlinux | zephyr/scripts/checkpatch.pl arm

but when I do it on build/zephyr/zephyr.elf it just quietly exits,
with no output. Anyone have any idea why it doesn't work?


checkstack.pl

Benjamin Lindqvist
 

Hi,

I wanted to try out scripts/checkstack.pl and verified that it
actually works on a vmlinux image by

arm-none-eabi-objdump -d vmlinux | zephyr/scripts/checkpatch.pl arm

but when I do it on build/zephyr/zephyr.elf it just quietly exits,
with no output. Anyone have any idea why it doesn't work?


Re: [Zephyr-users] Cannot write with i2c NRF52832 (TWI and TWIM)

vikrant8051 <vikrant8051@...>
 

Hi to all,
I renamed driver name from CONFIG_I2C_0_NAME to DT_I2C_0_NAME.
Plus add following Kconfig things in prj.conf. Now everything is working fine.

CONFIG_I2C=y
CONFIG_I2C_NRFX=y
CONFIG_NRFX_TWI=y
CONFIG_I2C_0_NRF_TWI=y
CONFIG_HAS_HW_NRF_TWI0=y
CONFIG_I2C_INIT_PRIORITY=60
CONFIG_I2C_0=y

Thanks & Regards,
vikrant


On Wed, Nov 28, 2018 at 3:03 PM Vikrant More <vikrant8051@...> wrote:
Hi Jamie,
It seen that it is working with 1.12.99 which is your case.

But with latest master branch, it is not.

Issue is in driver name
#define I2C_DEV CONFIG_I2C_0_NAME

Thanks for support !!

On Wed, Nov 28, 2018 at 2:48 PM Jamie Mccrae <Jamie.Mccrae@...> wrote:

Attached

 

From: Vikrant More [mailto:vikrant8051@...]
Sent: 28 November 2018 09:10
To: Jamie Mccrae <Jamie.Mccrae@...>
Subject: Re: [Zephyr-devel] [Zephyr-users] Cannot write with i2c NRF52832 (TWI and TWIM)

 

Hi Jamie,

Please share your .config file to me so that I can compare for

what I've missed.

 

Thanks !!

 

On Wed, Nov 28, 2018 at 2:33 PM lairdjm <jamie.mccrae@...> wrote:

Works fine with those lines added to prj.conf

 

[0/1] Re-running CMake...

CMake Deprecation Warning at C:/test/zephyr/cmake/app/boilerplate.cmake:38 (cmake_policy):

  The OLD behavior for policy CMP0000 will be removed from a future version

  of CMake.

 

  The cmake-policies(7) manual explains that the OLD behaviors of all

  policies are deprecated and that a policy should be set to OLD only under

  specific short-term circumstances.  Projects should be ported to the NEW

  behavior and not rely on setting a policy to OLD.

Call Stack (most recent call first):

  CMakeLists.txt:1 (include)

 

 

-- Selected BOARD nrf52840_pca10056

Zephyr version: 1.12.99

Parsing Kconfig tree in C:/test/zephyr//Kconfig

Using C:/test/zephyr/samples/drivers/i2c_fujitsu_fram/build/zephyr/.config as base

fatal: No tags can describe '02addfff50f936af41dfc71ab2d6140ace86f455'.

Try --always, or create some tags.

-- Generating zephyr/include/generated/generated_dts_board.h

-- Cache files will be written to: C:\Users\jamie.mccrae\AppData\Local/.cache/zephyr

-- Configuring done

-- Generating done

-- Build files have been written to: C:/test/zephyr/samples/drivers/i2c_fujitsu_fram/build

[129/134] Linking C executable zephyr\zephyr_prebuilt.elf

Memory region         Used Size  Region Size  %age Used

           FLASH:       48292 B         1 MB      4.61%

            SRAM:       11220 B       256 KB      4.28%

        IDT_LIST:         136 B         2 KB      6.64%

[134/134] Linking C executable zephyr\zephyr.elf

 


Re: cmake application project architecture

Sigvart Hovland
 

Maybe adding

target_link_libraries(DL PRIVATE zephyr_interface)

To your 2nd CMake file  could help?

 

From: devel@... [mailto:devel@...] On Behalf Of Florian Fouillet
Sent: Tuesday, November 27, 2018 9:53 PM
To: devel@...
Subject: [Zephyr-devel] cmake application project architecture

 

Hi everyone,

 

I am currently working on the Zephyr OS with a FDRM_K64f board from NXP.

 

I want to create my own application using cmake as recommended by the documentation.

 

However I don’t want to put everything in one CMakeLists.txt. I want to break down my project into libraries (multiple CMakeLists.txt).

 

Do you know if there is any documentation talking about that?

 

My top CMakeLists looks like that:

 

cmake_minimum_required(VERSION 3.8.2)

 

include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)

project(NONE)

 

 

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/DataLinkLayer

${CMAKE_CURRENT_SOURCE_DIR}/build/${BOARD}/DataLinkLayer)

 

target_sources(app PRIVATE src/main.c)

 

target_link_libraries(app

PRIVATE DL

)

 

 

And my second CMakeLists (under the folder DataLinkLayer) looks like that:

 

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)

 

add_library(DL src/DataLinkInterface.c)

 

target_include_directories(DL

INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/Interface)

 

 

 

The issue is I can include the boilerplate.cmake in only one CMakeLists.txt otherwise It’s not working, But, the second CmakeLists doesn’t know the zephyr library..

 

I tried to add: include_directories(/home/user/zephyr/include) in the second CMakeLists but it is not enough. Do you know what should I do?

 

 

Thank you,

 


Re: [Zephyr-users] Cannot write with i2c NRF52832 (TWI and TWIM)

lairdjm
 

Works fine with those lines added to prj.conf

 

[0/1] Re-running CMake...

CMake Deprecation Warning at C:/test/zephyr/cmake/app/boilerplate.cmake:38 (cmake_policy):

  The OLD behavior for policy CMP0000 will be removed from a future version

  of CMake.

 

  The cmake-policies(7) manual explains that the OLD behaviors of all

  policies are deprecated and that a policy should be set to OLD only under

  specific short-term circumstances.  Projects should be ported to the NEW

  behavior and not rely on setting a policy to OLD.

Call Stack (most recent call first):

  CMakeLists.txt:1 (include)

 

 

-- Selected BOARD nrf52840_pca10056

Zephyr version: 1.12.99

Parsing Kconfig tree in C:/test/zephyr//Kconfig

Using C:/test/zephyr/samples/drivers/i2c_fujitsu_fram/build/zephyr/.config as base

fatal: No tags can describe '02addfff50f936af41dfc71ab2d6140ace86f455'.

Try --always, or create some tags.

-- Generating zephyr/include/generated/generated_dts_board.h

-- Cache files will be written to: C:\Users\jamie.mccrae\AppData\Local/.cache/zephyr

-- Configuring done

-- Generating done

-- Build files have been written to: C:/test/zephyr/samples/drivers/i2c_fujitsu_fram/build

[129/134] Linking C executable zephyr\zephyr_prebuilt.elf

Memory region         Used Size  Region Size  %age Used

           FLASH:       48292 B         1 MB      4.61%

            SRAM:       11220 B       256 KB      4.28%

        IDT_LIST:         136 B         2 KB      6.64%

[134/134] Linking C executable zephyr\zephyr.elf

 


Re: [Zephyr-users] Cannot write with i2c NRF52832 (TWI and TWIM)

lairdjm
 

Run ninja menuconfig, go through the settings and set the various I2C options up then it should build.


Re: [Zephyr-users] Cannot write with i2c NRF52832 (TWI and TWIM)

vikrant8051 <vikrant8051@...>
 

Hi Rodrigo,
Currently trying to build zephyr/samples/drivers/i2c_fujitsu_fram/ demo eg.
to test i2c for nRF52840_pca10056.

As per your previous email, I added following things in prj.conf

CONFIG_I2C=y
CONFIG_I2C_NRFX=y
CONFIG_I2C_0_NRF_TWI=y
CONFIG_I2C_INIT_PRIORITY=60
CONFIG_I2C_0=y

But still getting following error,

../src/main.c:16:17: error: ‘CONFIG_I2C_0_NAME’ undeclared (first use in this function)
 #define I2C_DEV CONFIG_I2C_0_NAME
                 ^
../src/main.c:84:31: note: in expansion of macro ‘I2C_DEV’
  i2c_dev = device_get_binding(I2C_DEV);
                               ^~~~~~~
../src/main.c:16:17: note: each undeclared identifier is reported only once for each function it appears in
 #define I2C_DEV CONFIG_I2C_0_NAME
                 ^
../src/main.c:84:31: note: in expansion of macro ‘I2C_DEV’
  i2c_dev = device_get_binding(I2C_DEV);
                               ^~~~~~~
[19/141] Building C object zephyr/CMakeFiles/zephyr.dir/lib/mempool/mempool.c.obj
ninja: build stopped: subcommand failed.

Please help me to sort out this issue.

Thank You !!

On Wed, Oct 24, 2018 at 2:01 AM Rodrigo Peixoto <rodrigopex@...> wrote:
Hi,
I am trying to use the i2c on my custom board. I can read data from the devices, but (oddly) I cannot write to any of the 3 devices "attached" to the i2c line. I am using SDA on pin P0.06 and SCL on pin P0.07. Any clue? I have already spent a lot of time trying to fix this and nothing seems to work in this direction. 

Zephyr version: 1.13

i2c configs:
prj file (begin)
...
CONFIG_I2C=y
CONFIG_I2C_NRFX=y
CONFIG_I2C_0_NRF_TWI=y
CONFIG_I2C_INIT_PRIORITY=60
CONFIG_SYS_LOG_I2C_LEVEL=4
CONFIG_I2C_0=y
...
prj file (end)

board.dts (begin)
...
&i2c0 {
status = "ok";
sda-pin = <6>;
scl-pin = <7>;
};
...
board.dts (end)

I am using the commands like: 
error = i2c_burst_read(i2c_dev, ACC_I2C_ADDR, reg, &temp, 1);
error = i2c_burst_read16(i2c_dev, ADE_I2C_ADDR, reg, &buf, 4);

error = i2c_burst_write(i2c_dev, ACC_I2C_ADDR, reg, &setup, 1);
error = i2c_burst_write16(i2c_dev, ADE_I2C_ADDR, reg, &buf, 3);

All the reading commands work and the writing ones do not show an error and seem to make no effect.  


Thank you.
Best regards,
Rodrigo Peixoto
Co-founder and Technical advisor

+55 (82) 98144-8585
http://ayna.tech | Skype: rodrigopex



Re: Leds_demo on nrf52840 #nrf52832 #zephyrbluetoothmesh

frv
 

Hi Akash,

Maybe have also a look at this example:
https://docs.zephyrproject.org/1.13.0/samples/boards/nrf52/mesh/onoff-app/README.html

Best regards,
Frank


uart hardware flow control problem of nrf52_pca10040 #uart #nrf52832

icephyr
 

Hi guys,
     I met a problem here and hop anyone can help. Thanks.

     I enable hardware control in menuconfig, build a firmware of hci_uart sample and burn the firmware into nrf52_pca10040 (nrf52832), 
(top menu) → Device Drivers → Serial Drivers → nRF UART nrfx drivers
                                                                     Zephyr Kernel Configuration
[*] UART Port 0 Driver type (nRF UART 0)  --->
[*] Enable interrupt support on port 0
[ ] Enable parity bit
[*] Enable flow control
 
and then connect it  with my NXP board via uart, tx rx rts cts,
but when I attach the ble with command hciattach, it prints time out and seems the uart cannot communicate.
root~# hciattach /dev/ttymxc2 any 115200
Device setup complete
root:~# Bluetooth: hci0 command 0x1003 tx timeout
root:~# Bluetooth: hci0 command 0x1001 tx timeout
root:~# Bluetooth: hci0 command 0x1009 tx timeout
So I wonder if the hardware flow control works fine with nrf52832 or zephyr ? Or maybe my way to enable hardware flow control is wrong ?

By the way, is there any problems that we use software flow control instead of hardware flow control when  the baudrate of uart is 1M ?

Thanks if someone can give me any advice.


cmake application project architecture

Florian Fouillet <Florian.Fouillet@...>
 

Hi everyone,

 

I am currently working on the Zephyr OS with a FDRM_K64f board from NXP.

 

I want to create my own application using cmake as recommended by the documentation.

 

However I don’t want to put everything in one CMakeLists.txt. I want to break down my project into libraries (multiple CMakeLists.txt).

 

Do you know if there is any documentation talking about that?

 

My top CMakeLists looks like that:

 

cmake_minimum_required(VERSION 3.8.2)

 

include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)

project(NONE)

 

 

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/DataLinkLayer

${CMAKE_CURRENT_SOURCE_DIR}/build/${BOARD}/DataLinkLayer)

 

target_sources(app PRIVATE src/main.c)

 

target_link_libraries(app

PRIVATE DL

)

 

 

And my second CMakeLists (under the folder DataLinkLayer) looks like that:

 

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)

 

add_library(DL src/DataLinkInterface.c)

 

target_include_directories(DL

INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/Interface)

 

 

 

The issue is I can include the boilerplate.cmake in only one CMakeLists.txt otherwise It’s not working, But, the second CmakeLists doesn’t know the zephyr library..

 

I tried to add: include_directories(/home/user/zephyr/include) in the second CMakeLists but it is not enough. Do you know what should I do?

 

 

Thank you,

 


Re: Zephyr BLE Controller Nordic - BLE qualification process

Carles Cufi
 

Hi Frank,

 

Regarding licensing, I have no real information there, I would recommend you check with an expert.

Regarding qualification, yes, the link you sent is correct. Zephyr has a qualified controller and host, and BlueZ has several qualification as someone else pointed out.

 

Regards,

 

Carles

 

From: devel@... <devel@...> On Behalf Of frv
Sent: 21 November 2018 08:49
To: devel@...
Subject: Re: [Zephyr-devel] Zephyr BLE Controller Nordic - BLE qualification process

 

[Edited Message Follows]

Hi Carles,

Probably all is here for the qualification process, correct? : https://www.bluetooth.com/develop-with-bluetooth/qualification-listing

Just wondering do we have extra concerns should we rely on the BlueZ stack at Host side except for the GPL licensing.
Probably when relying on QT which is LGPL and wraps the BlueZ stack we don't have issues around strict GPL licensing?

Update 9h38 21/11/2018 :
Our company has a SIG account, so I have registered for a user account, to be able to fetch documentation and ask questions. 

Best regards,
Frank


Ble mesh stack not compatilbe with c++ #ble #bluetoothmesh

robert.konc@...
 

Hi,

When could we expect that blemesh code will be usable in c++.
Most header files in zephyr are compatible with c++ but not ble mesh headers.
No #ifdef __cplusplus in headers.

Regards,
Robert


Leds_demo on nrf52840 #nrf52832 #zephyrbluetoothmesh

Akash Naidu <akashnaiduece@...>
 

HI All,
Recently i have started working on Zephyr RTOS to explore IPV6 over BLE.And i am totally new this.
I would like to form a mesh network with PCA10059(5 boards) and PCA10040(1 boards) boards, and control the leds on boards.

Now, i have been successfully established connection with nordic board and PC and was getting proper response from device(If i ping from PC).
But i don't know how to control the LEDS.
I have seen a demo example in "net/leds_demo", with this can we make a mesh network and control the LEDS?
could you please help me to form a mesh network on IPV6 over BLE? if possible please suggest reference examples for nrf52 DK.
And i am total new to IPV6 over BLE to form mesh network, so please provide suitable explanation about IPV6 over BLE to form mesh network in Zephyr RTOS.    

Advance in thanks.

BR
Akash.


Re: Looking for help with SAMD2x

Bryan O'Donoghue
 

On 16/11/2018 17:28, Kumar Gala wrote:
Guys,
I’m looking to see if someone (or group) can help with maintenance of the Atmel SAMD2x SoC family. We have a few things that need updating (like the watchdog driver). And need someone I can check in w/from time to time if there are questions or we need testing on a board.
Let me know if you can help in the short term with converting drivers/watchdog/wdt_sam0.c to use the new watchdog API.
[ I also have a question about testing flash support ]
Hi,

Got buried in my inbox. Happy to help.

I'm currently winding down a project on the SAM21 - I was planning on looking at the USB.

I don't mind running some updates/tests/reviews as needed. Here to help, let me know what's required I can make time.


Insufficient space for ccc even after unpair

dhguja@gmail.com <dhguja@...>
 

Hello,

In the current upstream, i face the below problem with BLE and settings.
I am running HID peripheral sample on nRF52832 board. I made a modification to call bt_unpair() before starting the advertisement.
This ensures that unpair is called everytime i reset the device and i am able to connect to next device(since CONFIG_BT_MAX_PAIRED = 1).
This is just to minimize my real application scenario to be able to connect to new host and also to reproduce this issue.

1) connect board to first android phone. device is connected and bonded.
2) Now i restart the device and also switch off BLE in the first phone.
3) connect board to second android phone. device is connected and bonded.
4) Now i restart the device and also switch off BLE in the second phone.
5) connect board to third phone. device is connected and bonded.
6) Now a warning is printed in the logs as below
   "<wrn> bt_gatt: bt_gatt_attr_write_ccc: No space to store CCC cfg"
7) This happens when host subscribes for HID service. CCC is not updated. This affects the ability to send data to this third host.

I also saw that bt_gatt_clear_ccc() is called inside bt_unpair(). Hence i made sure to call so that i will have clear space for the new host i want to connect to. But still i get this warning everytime on the third host i want to connect.

Is this a bug or should i call a different API than bt_unpair() to clear the space for the new host i want to connect to? 

Dhananjay GJ


Re: HCI Host Not enough space in buffer #hci

Johan Hedberg
 

Hi,


On 23 Nov 2018, at 20.37, @abaska wrote:
I have a HCI host and controller setup. When the host starts, and the controller had already been running, it sometimes begins reading in the middle of a HCI message from the controller. It reads the wrong HCI message type and length. This causes the buffer to completely fill where it errors out in h4.c, read_payload(), BT_ERR("Not enough space in buffer"). After this the host application does not recover and a power cycle is needed.

I found a quick fix for this is to remove a line in h4.c read_payload(). I think it was meant to discard the rest of a message data if the buffer is full, but it looks like its assuming rx.remaining is valid. In this case, rx.remaining is invalid because it read the wrong byte as the length when it jumped into the middle of a HCI message.
if (rx.remaining > net_buf_tailroom(rx.buf)) {
BT_ERR("Not enough space in buffer");
//rx.discard = rx.remaining; // fixes issue. it was discarding thousands of bytes
reset_rx();
return;
}
I don't know what other consequences this quick fix will have. Is there a better way to fix this issue? Maybe check the message validity before it fills up the buffer?
Basically the code is assuming that the packet is valid, but the buffer sizes have simply been defined too small to fit the packet. In such a case discarding the rx.remaining bytes would be the correct thing since then the driver skips a valid but too long packet. In the case that you’re getting corrupt data (starting in the middle of a packet) it’s all a guessing game. You could discard everything indicated, like it does now, or try again with the next byte (in which case you’ll be repeating this until you get something that makes sense). Since the code needs to read (i.e. jump forward) at least the H4 + ACL/event headers, you don’t have any guarantee that you’ll ever hit a clean packet boundary.

I’m not sure there’s any correct answer in how the host should behave, since either way this is an unreliable setup: you should ideally design your device so that you can force a reset of the controller (e.g. by power-cycling it) so that you know you start off in a known state.

Johan


HCI Host Not enough space in buffer #hci

@abaska
 

Hi,

I have a HCI host and controller setup. When the host starts, and the controller had already been running, it sometimes begins reading in the middle of a HCI message from the controller. It reads the wrong HCI message type and length. This causes the buffer to completely fill where it errors out in h4.c, read_payload(), BT_ERR("Not enough space in buffer"). After this the host application does not recover and a power cycle is needed.

I found a quick fix for this is to remove a line in h4.c read_payload(). I think it was meant to discard the rest of a message data if the buffer is full, but it looks like its assuming rx.remaining is valid. In this case, rx.remaining is invalid because it read the wrong byte as the length when it jumped into the middle of a HCI message.
    if (rx.remaining > net_buf_tailroom(rx.buf)) {
      BT_ERR("Not enough space in buffer");
      //rx.discard = rx.remaining; // fixes issue. it was discarding thousands of bytes
      reset_rx();
      return;
    }
I don't know what other consequences this quick fix will have. Is there a better way to fix this issue? Maybe check the message validity before it fills up the buffer?

Thanks