-
Notifications
You must be signed in to change notification settings - Fork 636
Description
Hello,
I'm reporting an issue encountered while trying to use the rpi_ws281x library with the rp1_ws281x_pwm driver on a Raspberry Pi 5.
This issue seems related to the discussions happening in issue #528 regarding RP1 support on the Raspberry Pi 5. Specifically, I've seen similar problems potentially discussed, such as in this comment, which mentions kernel configuration variations affecting RP1.
Problem Background:
My project requires using a specific camera for which the manufacturer only provides a driver compatible with kernel configurations that do not use 16KB page size. This means I cannot use the standard kernel configuration on the Raspberry Pi 5 which typically uses 16KB pages (PAGE_SIZE = 16384).
Therefore, I had to configure my Raspberry Pi 5 to boot using a particular kernel image (e.g., specifying kernel=kernel8.img or another kernel in config.txt) that results in a different PAGE_SIZE value (e.g., 8192 bytes (8KB), or possibly others depending on the exact kernel configuration) instead of the standard 16384 bytes (16KB).
On my Raspberry Pi 5, when using this required kernel configuration where PAGE_SIZE is not 16384 (as required by the camera driver), the rp1_ws281x_pwm driver seems to have issues.
This issue appears to be related to differences in memory addressing, device tree mappings, and possibly kernel module function signatures depending on the kernel's configuration and PAGE_SIZE on the Raspberry Pi 5's RP1 chip. These differences might be influenced by settings like kernel_address as described in the Raspberry Pi documentation: https://www.raspberrypi.com/documentation/computers/config_txt.html#kernel
Symptoms:
When running on my Raspberry Pi 5 with the kernel configuration where getconf PAGE_SIZE returns a value other than 16384 (due to the required kernel for the camera), the rp1_ws281x_pwm kernel module fails to build.
Environment:
Hardware: Raspberry Pi 5
Operating System/Kernel: Custom/older kernel configuration (e.g., kernel=kernel8.img in config.txt) required for camera driver compatibility, resulting in PAGE_SIZE != 16384 (e.g., 8192 (8KB)). (Please provide uname -a and getconf PAGE_SIZE output if possible for your specific environment where the issue occurs).
Proposed Solution/Workaround:
I've found that applying a patch to the driver source files (rp1_ws281x_pwm.c and rp1_ws281x_pwm.dts) specifically when PAGE_SIZE is not 16384 resolves the issue and allows the driver to build successfully in my required environment on the Raspberry Pi 5.
The patch script I used does the following:
Checks if PAGE_SIZE is different from 16384.
Modifies rp1_ws281x_pwm.c:
Changes the return type and signature of the rp1_ws281x_pwm_remove function from int to void.
Explicitly adds forward declarations (prototypes) for various functions after the #include statement.
Modifies rp1_ws281x_pwm.dts:
Changes the target-path for the RP1 PCIe device from "/axi/pcie@120000/rp1" to "/axi/pcie@1000120000/rp1". This seems to correct the hardware address mapping for these kernel configurations on the RP1 chip.
Here is the script snippet that applies these changes:
#!/bin/bash
# Check the system's page size
PAGE_SIZE=$(getconf PAGE_SIZE)
if [ "$PAGE_SIZE" -ne 16384 ]; then
echo "Detected PAGE_SIZE is not 16384 ($PAGE_SIZE). Applying patch for non-16KB page size kernels on RPi 5..."
# Patch rp1_ws281x_pwm.c:
# 1. Change rp1_ws281x_pwm_remove signature and return type
# 2. Add missing function prototypes
sed -i \
-e '/^int rp1_ws281x_pwm_remove(struct platform_device \*pdev) {$/,/^}$/ {' \
-e 's/^int rp1_ws281x_pwm_remove/void rp1_ws281x_pwm_remove/;' \
-e 's/return 0;/return;/ }' \
-e '/#include "rp1_ws281x_pwm.h"/a \
\
//---\
void rp1_ws281x_pwm_chan(int channel, int invert);\
void rp1_ws281x_pwm_init(int channel, int invert);\
void rp1_ws281x_pwm_cleanup(void);\
int rp1_ws281x_pwm_open(struct inode *inode, struct file *file);\
int rp1_ws281x_pwm_release(struct inode *inode, struct file *file);\
long rp1_ws281x_pwm_ioctl(struct file *file, unsigned int cmd, unsigned long arg);\
void rp1_ws281x_dma_callback(void *param);\
ssize_t rp1_ws281x_dma(const char *buf, ssize_t len);\
ssize_t rp1_ws281x_pwm_write(struct file *file, const char *buf, size_t total, loff_t *loff);\
int rp1_ws281x_pwm_probe(struct platform_device *pdev);\
void rp1_ws281x_pwm_remove(struct platform_device *pdev);\
//---' \
rp1_ws281x_pwm.c
# Patch rp1_ws281x_pwm.dts:
# Fix DTS target-path for RP1 PCIe address mapping
sed -i 's/target-path = "\/axi\/pcie@120000\/rp1";/target-path = "\/axi\/pcie@1000120000\/rp1";/' rp1_ws281x_pwm.dts
echo "Patch applied successfully."
else
echo "Detected PAGE_SIZE is 16384. Patch not needed for this configuration."
fi
After applying this patch before building the module, the driver built successfully and I was able to use the library on my Raspberry Pi 5 in the environment required for my camera.
Given that specific hardware drivers might necessitate using kernel configurations with non-16KB page sizes (e.g., 8KB), could support for these environments on the Raspberry Pi 5 be officially considered? This patch seems to address the build failure I encountered.
Please excuse any awkward phrasing, as this issue report was drafted with the assistance of an AI.
Thank you for your work on this library. Let me know if I can provide any further information or test on specific configurations.