Jump to content

Recommended Posts

Posted

Hello,

 

In a GOLANG based, RPi 3B+ project I am using the https://github.com/stianeikeland/go-rpio package to read the state of the GPIO-s. I am planning to set up some Banana Pi M2 Berries with the same software. The package - as it was expected - doesn't work with the M2 Berry. I could adapt the package for the Berry, but I don't know which peripheral chip is used in it. Does anyone know which peripheral chip is used in the Berry? (The schematic diagram on BPI's page is useless).

 

Thanks,

 

G.

Posted

Hi!

 

Most consistent interface to GPIO across different devices is probably the sysfs gpio interface (yes, deprecated, but very widely used).

 

sinovoip published a patched fork of Wiring Pi for all their Banana Pi products: BPI-WiringPi2 (deep link to: pin mappings for the m2u).

Wiring Pi is built around the sysfs gpio interface.

 

A usage guide was published here: https://forum.banana-pi.org/t/how-to-get-working-wiringpi-on-raspbian/3696

An additional step for armbian users might be needed: https://forum.banana-pi.org/t/banana-pi-bpi-m2-ultra-m2u-wiringpi-gpio-demo/3027/10

 

Then, using e.g. the go-wiringpi bindings you should be able to use the M2berry GPIOs in golang.

 

I did not try any of the steps above but hope that at least some of it will help you.

Let us know of your results!

 

Sincerely,

kerel

 

PS: New userspace applications are supposed to use the character device GPIO, see https://lloydrochester.com/post/hardware/libgpiod-intro-rpi/

Go library: https://github.com/warthog618/gpiod

 

I can confirm that there are 288 lines exposed via this new interface:

 

root@m2berry:~# gpiodetect 
gpiochip0 [1c20800.pinctrl] (288 lines)

 

 

Device Tree:

Spoiler
root@m2berry:~# dtc -I fs -O dts /sys/firmware/devicetree/base > /tmp/mydts
root@m2berry:~# cat /tmp/mydts
[...]
	pinctrl@1c20800 {
			vcc-pf-supply = <0x15>;
			compatible = "allwinner,sun8i-r40-pinctrl";
			clocks = <0x02 0x4f 0x21 0x22 0x00>;
			vcc-pe-supply = <0x26>;
			clock-names = "apb\0hosc\0losc";
			gpio-controller;
			vcc-pd-supply = <0x15>;
			#interrupt-cells = <0x03>;
			interrupts = <0x00 0x1c 0x04>;
			vcc-pc-supply = <0x15>;
			phandle = <0x16>;
			reg = <0x1c20800 0x400>;
			#gpio-cells = <0x03>;
			pinctrl-0 = <0x24>;
			vcc-pa-supply = <0x25>;
			vcc-pg-supply = <0x19>;
			pinctrl-names = "default";
			interrupt-controller;

			can-ph-pins {
				pins = "PH20\0PH21";
				function = "can";
			};

			mmc1-pg-pins {
				pins = "PG0\0PG1\0PG2\0PG3\0PG4\0PG5";
				drive-strength = <0x1e>;
				phandle = <0x17>;
				function = "mmc1";
				bias-pull-up;
			};

			uart3-rts-cts-pg-pins {
				pins = "PG8\0PG9";
				phandle = <0x2c>;
				function = "uart3";
			};

			i2c4-pins {
				pins = "PI2\0PI3";
				phandle = <0x32>;
				function = "i2c4";
			};

			can-pa-pins {
				pins = "PA16\0PA17";
				function = "can";
			};

			mmc2-pins {
				pins = "PC5\0PC6\0PC7\0PC8\0PC9\0PC10\0PC11\0PC12\0PC13\0PC14\0PC15\0PC24";
				drive-strength = <0x1e>;
				phandle = <0x1b>;
				function = "mmc2";
				bias-pull-up;
			};

			i2c3-pins {
				pins = "PI0\0PI1";
				phandle = <0x31>;
				function = "i2c3";
			};

			i2c2-pins {
				pins = "PB20\0PB21";
				phandle = <0x30>;
				function = "i2c2";
			};

			mmc0-pins {
				pins = "PF0\0PF1\0PF2\0PF3\0PF4\0PF5";
				drive-strength = <0x1e>;
				phandle = <0x14>;
				function = "mmc0";
				bias-pull-up;
			};

			gmac-rgmii-pins {
				pins = "PA0\0PA1\0PA2\0PA3\0PA4\0PA5\0PA6\0PA7\0PA8\0PA10\0PA11\0PA12\0PA13\0PA15\0PA16";
				drive-strength = <0x28>;
				phandle = <0x33>;
				function = "gmac";
			};

			i2c1-pins {
				pins = "PB18\0PB19";
				phandle = <0x2f>;
				function = "i2c1";
			};

			clk-out-a-pin {
				pins = "PI12";
				phandle = <0x24>;
				function = "clk_out_a";
			};

			i2c0-pins {
				pins = "PB0\0PB1";
				phandle = <0x2d>;
				function = "i2c0";
			};

			uart0-pb-pins {
				pins = "PB22\0PB23";
				phandle = <0x2a>;
				function = "uart0";
			};

			ir1-pins {
				pins = "PB23";
				phandle = <0x28>;
				function = "ir1";
			};

			uart3-pg-pins {
				pins = "PG6\0PG7";
				phandle = <0x2b>;
				function = "uart3";
			};

			mmc3-pins {
				pins = "PI4\0PI5\0PI6\0PI7\0PI8\0PI9";
				drive-strength = <0x1e>;
				phandle = <0x1c>;
				function = "mmc3";
				bias-pull-up;
			};

			ir0-pins {
				pins = "PB4";
				phandle = <0x27>;
				function = "ir0";
			};
		};

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines