Skip to content

power/npzero: Add support to nanopower nPZero and NPZ_G1S_DK board - #21736

Merged
casaroli merged 5 commits into
apache:masterfrom
acassis:npzero
Nov 14, 2026
Merged

casaroli merged 5 commits into
apache:masterfrom
acassis:npzero

Conversation

@acassis

@acassis acassis commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

These patches add support to nPZero chip and its board.
Depends-on: apache/nuttx-apps#4031

Impact

Users will be able to use nPZero chip with NuttX

Testing

NuttShell (NSH)                                                                   
nsh> npzero -s                                                                    
nPZero G1S ID: 0x60                                                               
STA1: 0x01 STA2: 0x00                                                             
nsh> npzero                                                                       
nPZero G1S ID: 0x60                                                               
STA1: 0x01 STA2: 0x00                                                             
Configured, Idle state in 1000 ms                                                 
nsh>                                                                              
NuttShell (NSH)                                                                   
nsh>

@github-actions github-actions Bot added Area: Build system Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. Board: arm labels Nov 11, 2026
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

@github-actions

Copy link
Copy Markdown

🔗 Cross-repo PR dependencies

The read-only Build run reported the following dependent PR(s) and fetched head SHA(s):

CI run: https://github.com/apache/nuttx/actions/runs/43110909801

@acassis
acassis force-pushed the npzero branch 3 times, most recently from 1bf0a52 to cfcd11e Compare November 12, 2026 20:13
@github-actions

Copy link
Copy Markdown

🔗 Cross-repo PR dependencies

The read-only Build run reported the following dependent PR(s) and fetched head SHA(s):

CI run: https://github.com/apache/nuttx/actions/runs/43298213908

@github-actions

Copy link
Copy Markdown

🔗 Cross-repo PR dependencies

The read-only Build run reported the following dependent PR(s) and fetched head SHA(s):

CI run: https://github.com/apache/nuttx/actions/runs/43515015297

@xiaoxiang781216

Copy link
Copy Markdown
Contributor

fixed by #21771.

The nPZero G1S (NPZG1SQ32) from Nanopower Semiconductor switches the
host MCU off and polls up to four I2C or SPI peripherals by itself,
waking the host up on a peripheral, ADC or time-out event.

Add a character driver controlled with ioctl() commands to read the ID,
the status (wake-up reason), the last peripheral and ADC values, to send
the configuration and the SRAM commands, to enter Idle state, to reset
it and to access its registers.  A new ioctl base, _NPZEROIOCBASE, is
added to include/nuttx/fs/ioctl.h.

The driver follows the datasheet NPZ-G1S-DS-V1.0 and applies the
workarounds of the errata NPZ-G1S-ERRATA-V3.0:
* #2: the SRAM is written one byte at a time in the workaround order,
  and NPZEROIOC_WRITEREG refuses the SRAM addresses.
* apache#11: the IREF trim values are corrected at registration, after a
  reset of the nPZero.
The peripheral power switch mode 0, which can lock up the polling, is
refused.

Tested on the nPZero G1S DevKit (STM32L053C8 host, npzero-g1s-dk:nsh):
the ID and status are read, and the example configures the nPZero,
enters Idle state and the host is woken up again.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
Assisted-by: Claude:claude-opus-5-5
Describe the nPZero G1S driver: the configuration options, the board
interface, the ioctl commands and the configuration structures, the
errata handled by the driver and the ones left to the application, and
the differences with the Nanopower driver API.

Document the shared I2C bus: after a reset of the nPZero the peripheral
power switches are off, and an unpowered sensor (the AS6212 board of the
DevKit) slows down SDA so much that the host I2C controller reports an
arbitration loss and npzero_register() fails with -EAGAIN.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
Assisted-by: Claude:claude-opus-5-5
Add support for the STM32L053C8U6 MCU host of the Nanopower nPZero G1S
Development Kit (NPZ-G1S-DK):
* SYSCLK is the 16 MHz HSI (no crystal on the MCU host, and the STM32 I2C
  driver expects a 16 MHz I2C clock).
* USART2 (PA2/PA3) is the console, on the MCU UART connector J19.
* I2C1 (PB6/PB7) is the nPZero bus, the nPZero driver is registered as
  /dev/npzero0 at boot.
* PA12 is the LED.

The host I2C bus is shared with the sensor boards.  After a reset of the
nPZero their power switches are off and the unpowered AS6212 board on
PMOD 4 slows down SDA (about 10 us, 100 us when SCL is low): the STM32
reports an arbitration loss.  The new CONFIG_NPZERO_G1S_DK_PMOD_POWER
option (default y) enables the power switches of PMOD 3 and 4 (PSWCTL,
read-modify-write) with a bit-banged I2C transfer at about 2 kHz before
the I2C driver is initialized.

Configurations:
* nsh: NSH with the npzero example.  The 8 KB of SRAM is the limit: it
  uses CONFIG_DEFAULT_SMALL with ls, cat and echo, a 1792-byte NSH stack
  (ls peaks at about 1.3 KB) and smaller idle and init thread stacks.
* npzero: the npzero example is the entry point, without NSH.

Tested on the DevKit with npzero-g1s-dk:nsh, with the AS6212 board on
PMOD 4, after a reset of the nPZero (S5):

  nsh> npzero -s
  nPZero G1S ID: 0x60
  STA1: 0x01 STA2: 0x00
  nsh> npzero
  nPZero G1S ID: 0x60
  STA1: 0x01 STA2: 0x00
  Configured, Idle state in 1000 ms

The host is then switched off and woken up again by the nPZero.  The
npzero configuration builds but was not run on the board.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
Assisted-by: Claude:claude-opus-5-5
Describe the STM32L053C8 MCU host of the nPZero G1S Development Kit:
the pins, the hardware setup, the flashing (the host must be kept
powered, and OpenOCD loses the core after a reset) and the npzero and
nsh configurations.

Document the I2C issue of the AS6212 board: an unpowered AS6212 on
PMOD 4 blocks the shared I2C bus after a reset of the nPZero (also with
the vendor firmware), the CONFIG_NPZERO_G1S_DK_PMOD_POWER workaround,
and that a sensor board must not be plugged while the host is running.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
Assisted-by: Claude:claude-opus-5-5
Describe the npzero example of the nPZero G1S driver: the sensors of
the DevKit it configures, the wake-up conditions, what it does at each
boot of the host, its usage and its configuration options.

Document that the AS6212 board blocks the shared I2C bus when it is not
powered: the example keeps the sensors powered while the host is on
(pswint) and the npzero-g1s-dk board powers them after a reset of the
nPZero, otherwise /dev/npzero0 is not registered.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
Assisted-by: Claude:claude-opus-5-5
@github-actions

Copy link
Copy Markdown

🔗 Cross-repo PR dependencies

The read-only Build run reported the following dependent PR(s) and fetched head SHA(s):

CI run: https://github.com/apache/nuttx/actions/runs/43588870773

@casaroli
casaroli merged commit 0346c02 into apache:master Nov 14, 2026
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Build system Board: arm Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants