Skip to content

Conversation

@Gadgetoid
Copy link
Member

@Gadgetoid Gadgetoid commented Nov 8, 2023

This PR upgrades the packaging to our latest boilerplate and ports additional pins to gpiod/gpiodevice. Part of an effort to bring enviro up to speed with Raspberry Pi 5 - pimoroni/enviroplus-python#126

Note: This library uses SPI and requires this patch - raspberrypi/linux@686fe77 - to function without raising a TimeoutError on Pi 5.

Pi 5 / Raspberry Pi OS

Make sure your user is in the group spi and enable SPI with dtparam=spi=on or via raspi-config

Rock 5B / Armbian

On ROCK5B and possibly other modern platforms, it needs a custom dtoverlay to remove control of MISO from the spi driver, otherwise the data/command pin cannot be asserted by gpiod.

In /etc/udev/rules.d/60-spidev.rules:

SUBSYSTEM=="spidev", GROUP="gpio", MODE="0660"

Then:

sudo udevadm control --reload-rules
sudo udevadm trigger

Make sure your user is in the gpio group:

sudo usermod -a -G gpio $USER

Create a new file rk3588-spi0-m2-cs1-nomiso-spidev.dts with the dts code below.

Install with: sudo armbian-add-overlay rk3588-spi0-m2-cs1-nomiso-spidev.dts

/dts-v1/;
/plugin/;

/ {
	fragment@0 {
		target = <&spi0>;

		__overlay__ {
			status = "okay";
			#address-cells = <1>;
			#size-cells = <0>;
			pinctrl-names = "default";
			pinctrl-0 = <&spi0m2_cs1 &spi0m2_nomiso_pins>;
			max-freq = <50000000>;

			spidev@1 {
				compatible = "rockchip,spidev";
				status = "okay";
				reg = <1>;
				spi-max-frequency = <50000000>;
			};
		};
	};
	fragment@1 {
		target = <&pinctrl>;

		__overlay__ {

			spi0 {

				spi0m2_nomiso_pins: spi0m2-nomiso-pins {
					rockchip,pins =
						/* spi0_clk_m2 */
						<1 11 8 &pcfg_pull_up_drv_level_6>,
						/* spi0_miso_m2 */
						/*<1 9 8 &pcfg_pull_up_drv_level_6>,*/
						/* spi0_mosi_m2 */
						<1 10 8 &pcfg_pull_up_drv_level_6>;
				};
			};
		};
	};
};

@coveralls
Copy link

coveralls commented Nov 8, 2023

Pull Request Test Coverage Report for Build 6796461761

  • 70 of 70 (100.0%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.4%) to 98.428%

Totals Coverage Status
Change from base Build 5784058181: 0.4%
Covered Lines: 313
Relevant Lines: 318

💛 - Coveralls

@Gadgetoid Gadgetoid merged commit 1a07965 into master Nov 8, 2023
@Gadgetoid Gadgetoid deleted the repackage branch November 15, 2023 10:23
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.

3 participants