Skip to content

Fix compilation for NRF52 chips with a single GPIO port such as NRF52832 - #900

Merged
kriegsman merged 1 commit into
FastLED:masterfrom
projects-land:fix_nrf52_single_port
Jan 29, 2020
Merged

kriegsman merged 1 commit into
FastLED:masterfrom
projects-land:fix_nrf52_single_port

Conversation

@projects-land

Copy link
Copy Markdown
Contributor

nrf52832, nrf52810, and nrf52811 have a single GPIO port, and do not define NRF_P1_BASE. If NRF_P1_BASE is not defined, do not define the generated structures requried to access GPIO port 1.

nrf52832, nrf52810, and nrf52811 have a single GPIO port, and do not define NRF_P1_BASE.  If NRF_P1_BASE is not defined, do not define the generated structures requried to access GPIO port 1.

@henrygab henrygab left a comment •

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.

This looks good to me. Thanks for the PR!
(For nrf boards, I only own boards with nrf52840... so thanks!)

@henrygab

henrygab commented Dec 4, 2019

Copy link
Copy Markdown
Contributor

@etmeister -- this looks like it might resolve your issue in #919.

@henrygab

Copy link
Copy Markdown
Contributor

@focalintent -- FYI, this is hitting multiple folks now. This fix is small and targeted. I strongly support merging this PR.

@kriegsman

Copy link
Copy Markdown
Member

Hi Henry, and thank you very much for your contribution. As you may or may not have heard, we lost Dan @focalintent in a boat fire off the California coast in early September. FastLED will continue; I’m working out how best to proceed and hope to have some things in place in the next couple of weeks. Thank you again for your patience, and for your understanding.

@henrygab

Copy link
Copy Markdown
Contributor

@kriegsman -- I was not aware... I am so sorry to hear that, Mark. 😞 Let me know if there's anything I can do to help.

@gregsqueeb

gregsqueeb commented Jan 3, 2020 •

Copy link
Copy Markdown
Contributor

@maddogjt Hey Jason! I just got a new Adafruit Feather nRF52840 Express and I am attempting to get this to compile. I have edited the /Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52.h file with your changes but I am still getting these same errors:


In file included from /Users/gregmathews/Documents/Arduino/sketch_jan02a/sketch_jan02a.ino:16:0:
/Users/gregmathews/Documents/Arduino/libraries/FastLED/FastLED.h:14:21: note: #pragma message: FastLED version 3.003.002
 #    pragma message "FastLED version 3.003.002"
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52.h:327:0,
                 from /Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastled_arm_nrf52.h:6,
                 from /Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms.h:11,
                 from /Users/gregmathews/Documents/Arduino/libraries/FastLED/FastLED.h:52,
                 from /Users/gregmathews/Documents/Arduino/sketch_jan02a/sketch_jan02a.ino:16:
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:62:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN( 0, 25, 0); // D0  is P0.25 -- UART TX
               ^
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:64:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN( 2, 10, 0); // D2  is P0.10 -- NFC2
               ^
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:65:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN( 3, 47, 1); // D3  is P1.15 -- PIN_LED1 (red)
               ^
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:66:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN( 4, 42, 1); // D4  is P1.10 -- PIN_LED2 (blue)
               ^
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:67:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN( 5, 40, 1); // D5  is P1.08 -- SPI/SS
               ^
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:68:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN( 6,  7, 0); // D6  is P0.07
               ^
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:69:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN( 7, 34, 1); // D7  is P1.02 -- PIN_DFU (Button)
               ^
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:72:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN( 8, 16, 0); // D8  is P0.16 -- PIN_NEOPIXEL
               ^
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:73:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN( 9, 26, 0); // D9  is P0.26
               ^
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:74:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN(10, 27, 0); // D10 is P0.27
               ^
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:75:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN(11,  6, 0); // D11 is P0.06
               ^
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:76:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN(12,  8, 0); // D12 is P0.08
               ^
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:77:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN(13, 41, 1); // D13 is P1.09
               ^
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:78:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN(14,  4, 0); // D14 is P0.04 -- A0
               ^
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:79:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN(15,  5, 0); // D15 is P0.05 -- A1
               ^
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:82:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN(16, 30, 0); // D16 is P0.30 -- A2
               ^
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:83:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN(17, 28, 0); // D17 is P0.28 -- A3
               ^
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:84:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN(18,  2, 0); // D18 is P0.02 -- A4
               ^
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:85:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN(19,  3, 0); // D19 is P0.03 -- A5
               ^
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:88:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN(22, 12, 0); // D22 is P0.12 -- SDA
               ^
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:89:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN(23, 11, 0); // D23 is P0.11 -- SCL
               ^
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:92:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN(24, 15, 0); // D24 is P0.15 -- PIN_SPI_MISO
               ^
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:93:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN(25, 13, 0); // D25 is P0.13 -- PIN_SPI_MOSI
               ^
/Users/gregmathews/Documents/Arduino/libraries/FastLED/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h:94:15: error: expected constructor, destructor, or type conversion before '(' token
     _FL_DEFPIN(26, 14, 0); // D26 is P0.14 -- PIN_SPI_SCK
               ^
Multiple libraries were found for "bluefruit.h"
 Used: /Users/gregmathews/Library/Arduino15/packages/adafruit/hardware/nrf52/0.15.1/libraries/Bluefruit52Lib
Multiple libraries were found for "FastLED.h"
 Used: /Users/gregmathews/Documents/Arduino/libraries/FastLED
Multiple libraries were found for "Adafruit_LittleFS.h"
 Used: /Users/gregmathews/Library/Arduino15/packages/adafruit/hardware/nrf52/0.15.1/libraries/Adafruit_LittleFS
Multiple libraries were found for "InternalFileSystem.h"
 Used: /Users/gregmathews/Library/Arduino15/packages/adafruit/hardware/nrf52/0.15.1/libraries/InternalFileSytem
exit status 1
Error compiling for board Adafruit Bluefruit Feather nRF52840 Express.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

@henrygab

henrygab commented Jan 4, 2020

Copy link
Copy Markdown
Contributor

See #938.

@henrygab henrygab mentioned this pull request Jan 4, 2020
2 tasks done
@henrygab

henrygab commented Jan 5, 2020

Copy link
Copy Markdown
Contributor

Looks like some PRs are being integrated again! 🎉
I would approve this as the "right" fix for the single GPIO port chips such as the nrf52832.

@kriegsman
kriegsman merged commit 42441aa into FastLED:master Jan 29, 2020
@kriegsman

Copy link
Copy Markdown
Member

Thanks for the contributions and help with the FastLED library!

zackees added a commit that referenced this pull request Jul 1, 2026
…#3468) (#3475)

While validating the #3468 harness on real LPC845-BRK silicon
(VID:PID 1FC9:0132 on COM10), three separate blockers prevented
`bash compile lpc845brk --examples AutoResearch --build-flag
-DFASTLED_LPC_PWM_DMA=1` from producing a firmware image. Each is a
legitimate bug fix and lands here together because they are only
observable end-to-end when the LPC compile path actually gets exercised.

## Fix 1 — `ci/boards.py`: nxplpc@ prefix workaround

fbuild 2.3.15 shipped 2026-06-30 20:09 UTC; my platform-matcher fix
FastLED/fbuild#900 merged 2026-06-30 21:47 UTC (after 2.3.15 was cut).
2.3.15's matcher still only substring-matches `nxplpc` (no separator)
and rejects the hyphenated `nxp-lpc` in the raw GitHub URL. Prepending
`nxplpc@` to the platform URL is valid PlatformIO name-at-source
syntax and makes the substring match, unblocking the build under
2.3.15. Once fbuild 2.3.16 ships with #900 the prefix becomes redundant
but stays syntactically valid.

## Fix 2 — `led_sysdefs_arm_lpc.h`: define `FASTLED_HAS_CMSIS`

`src/platforms/arm/common/m0clockless_c.h:51` guards the local
`__get_PRIMASK` / `__enable_irq` / `__disable_irq` stubs with
`#if !defined(FASTLED_HAS_CMSIS)`, and the comment on that guard says
"LPC builds set FASTLED_HAS_CMSIS in led_sysdefs". But the define was
never actually added — so LPC builds got the local stubs plus the
vendor CMSIS versions from `core_cm0plus.h` and gcc rejected the pair
with

    error: redefinition of 'fl::u32 __get_PRIMASK()'

Adding `#define FASTLED_HAS_CMSIS 1` in `led_sysdefs_arm_lpc.h`
immediately after the vendor `<LPC845.h>` / `<LPC804.h>` include
matches the intent of the m0clockless guard and silences the collision.

## Fix 3 — `platforms/shared/bitbang/bus_traits.h`: LPC845 gate

`ChannelEngineLpcSctDma` registers under `BusTraits<Bus::BIT_BANG>`
(see `src/platforms/arm/lpc/drivers/sct_dma/bus_traits.h` — FastLED
#3459 / PR #3460). The shared `BitBangChannelDriver` also specialises
`BusTraits<Bus::BIT_BANG>` unconditionally. On LPC845 both TUs land in
the same translation unit and gcc rejects the pair with

    error: redefinition of 'struct fl::BusTraits<fl::Bus::BIT_BANG>'
    error: redefinition of 'struct fl::BusSupports<fl::Bus::BIT_BANG,
                                                    fl::ClocklessChipset, 0>'

Gate the shared bit-bang specialization on `!FL_IS_ARM_LPC_845` so the
dedicated SCT+DMA engine owns the slot on that platform. Every other
platform continues to use the universal-GPIO fallback.

## Verification

Applied all three fixes and confirmed:

  bash compile lpc845brk --examples AutoResearch \
      --build-flag "-DFASTLED_LPC_PWM_DMA=1"

  Board: NXP LPC845-BRK / LPC845 @ 24MHz
  Toolchain: arm-none-eabi-gcc 15.2.1
  Flash: 53.52KB / 64.00KB (83.6%)
  RAM:   9.07KB / 16.00KB (56.7%)
  Artifact: firmware.elf (159.79KB) / firmware.bin (53.54KB)
  build succeeded in 212.2s

  bash test --cpp → 343/343 passed
  C++ lint → clean

## What's still open on the actual on-wire verification

- fbuild-side: an additional blocker surfaced during this bring-up —
  the FastLED/framework-arduino-lpc8xx tarball SHA256 changed after
  the 2026-06-28 org transfer (`e6bbcc3392…` → `e64f0cb81a…`). This
  needs a fbuild-side update to `ACLPC_CHECKSUM` in
  `crates/fbuild-packages/src/library/arduino_core_lpc8xx.rs`; I filed
  the change on a local fbuild branch during this session and will
  push it as a follow-up PR to the fbuild repo.
- Flash + serial monitoring: `bash autoresearch --pwm-dma-cl` still
  hits pre-existing infrastructure gaps unrelated to #3468 —
  `ci/util/port_utils.py` only recognises the LPCXpresso VCOM
  fingerprint (VID:PID 16C0:0483), not the LPC-Link2 CMSIS-DAP
  variant (1FC9:0132) that ships on this specific LPC845-BRK unit,
  and fbuild's LPC deploy path uses `lpc21isp` which requires ISP-mode
  entry rather than the board's default CMSIS-DAP SWD. Both are
  tracked separately.

The host TX→RX byte-flow readback contract (the #3468 primary
acceptance criterion) is already confirmed in PR #3472
(`tests/fl/channels/lpc_sct_dma_engine.cpp` "#3468: end-to-end TX→RX
readback through engine.show()", passing 343/343). This PR takes the
verification one step further by making the compile path work on the
LPC845 target so any user with an LPC845-BRK can now build and flash
the firmware and run the on-silicon self-loopback via
`pwmDmaClCaptureSelf`.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants