Skip to content

raspberrypi-4b/i2c: Support for NOSTOP/NOSTART flags and better examples#19181

Open
linguini1 wants to merge 4 commits into
apache:masterfrom
linguini1:rpi4b-i2c-merge
Open

raspberrypi-4b/i2c: Support for NOSTOP/NOSTART flags and better examples#19181
linguini1 wants to merge 4 commits into
apache:masterfrom
linguini1:rpi4b-i2c-merge

Conversation

@linguini1

Copy link
Copy Markdown
Contributor

Summary

List of patches:

raspberrypi-4b/bmp280: Include optional registration of BMP280 driver

This commit includes BMP280 driver registration on I2C1 in the RPi4B
bringup logic if the user selects the board-level configuration option
(so as to not interfere with any user's custom implementation of
interfacing with this sensor). A configuration is added with the BMP280
registration, example program and uorb_listener that is also
documented.

raspberrypi-4b/i2c: Added I2C configuration

Includes a new I2C configuration (and documentation for it) to use the
I2C1 bus on the Raspberry Pi 4B.

rpi4b/bringup: Use correct CONFIG option for I2C char driver

Change the I2C character device registration to depend on the correct
CONFIG option for enabling character drivers.

bcm2711/i2c: Support I2C_M_NOSTOP/I2C_M_NOSTART properly

This commit adds support for I2C transfers spread across multiple
messages using the I2C_M_NOSTOP/I2C_M_NOSTART. The approach greedily
merges as many sequential I2C messages together as possible and
considers them as a single transfer.

Related issues

This is part of the GSoC project #18507; milestone 1 item 1 (I2C improvement).

Impact

  1. BCM2711 I2C driver is improved to support flags required for many I2C
    devices, as per the discussion in [FEATURE] Complete RPi 4B I2C driver #16937.

  2. An I2C configuration for the most commonly used bus (I2C1) is provided with
    the i2ctool for users to play with.

  3. A BMP280 configuration is supplied for users to play with a breakout board if
    they wish.

Testing

I tested using the raspberrypi-4b:bmp280 configuration supplied in this patch.
It includes all the functionality of raspberrypi-4b:i2c1 and tests the I2C
logic patch for supporting NO_STOP/NO_START flags. Here is the output of the
bmp280 program being run on the device:

sh> - Ready to Boot Primary CPU
- Boot from EL2
- Boot from EL1
- Boot to C runtime for OS Initialize

NuttShell (NSH) NuttX-12.13.0
nsh> 
nsh> 
nsh> ls /dev
/dev:
 console
 i2c1
 null
 uorb/
 usensor
 zero
nsh> bmp280
Absolute pressure [hPa] = 697.700012
Temperature [C] = 27.520000
nsh> bmp280
Absolute pressure [hPa] = 970.929993
Temperature [C] = 26.040001
nsh> bmp280
Absolute pressure [hPa] = 970.969971
Temperature [C] = 26.059999
nsh> bmp280
Absolute pressure [hPa] = 970.989990
Temperature [C] = 26.070000

And the I2C scanner:

nsh> i2c dev -b 1 00 77
NOTE: Some devices may not appear with this scan.
You may also try a scan with the -z flag to discover more devices using a zero-byte wri.
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- 77                         
nsh> 

Everything works as expected.

This commit adds support for I2C transfers spread across multiple
messages using the I2C_M_NOSTOP/I2C_M_NOSTART. The approach greedily
merges as many sequential I2C messages together as possible and
considers them as a single transfer.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
Change the I2C character device registration to depend on the correct
CONFIG option for enabling character drivers.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
@github-actions github-actions Bot added Area: Documentation Improvements or additions to documentation Arch: arm64 Issues related to ARM64 (64-bit) architecture Size: M The size of the change in this PR is medium Board: arm64 labels Jun 20, 2026
@github-actions

github-actions Bot commented Jun 20, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

Includes a new I2C configuration (and documentation for it) to use the
I2C1 bus on the Raspberry Pi 4B.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
This commit includes BMP280 driver registration on I2C1 in the RPi4B
bringup logic _if_ the user selects the board-level configuration option
(so as to not interfere with any user's custom implementation of
interfacing with this sensor). A configuration is added with the BMP280
registration, example program and `uorb_listener` that is also
documented.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
static int bcm2711_i2c_receive(struct bcm2711_i2cdev_s *priv, FAR void *buf,
size_t n);
static int bcm2711_i2c_send(struct bcm2711_i2cdev_s *priv,
FAR struct i2c_msg_s *msgs, size_t n);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove all FAR from code base

#endif

#ifdef CONFIG_RPI4B_BMP280
#include "bcm2711_i2c.h"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move after line 50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm64 Issues related to ARM64 (64-bit) architecture Area: Documentation Improvements or additions to documentation Board: arm64 Size: M The size of the change in this PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants