Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Porting driver from Raspberry Pi zero to Banana Pi M2 Zero

Featured Replies

Hi all,

 

I'm trying to port a driver built for Raspberry Zero to Banana Pi M2 Zero. The original driver is here : https://github.com/pguyot/tagtagtag-ears (it's supposed to drive the ears of a Nabaztag, which recently got resurected thanks to an Ulule campaign).

 

My understanding is that at least half of the problem is to adapt the device tree overlay for the BPI M2 Zero. If it"s not half of the work, it's definitely required. So far I've been unsuccessful.

 

The original DTS overlay is like this :

/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2708";

	fragment@0 {
		target = <&gpio>;
		__overlay__ {
			gpio_encoder_left_pin: gpio_encoder_left_pin@24 {
				brcm,pins = <24>;
				brcm,function = <0>;	// in
			};
			gpio_encoder_right_pin: gpio_encoder_right_pin@23 {
				brcm,pins = <23>;
				brcm,function = <0>;	// in
			};
                        // left: when looking at the rabbit (matching hardware spec)
                        // forward: for the rabbit's left ear (right), counter-clock-wise
                        // for the rabbit's right ear (left below), clock-wise
			gpio_motor_left_forward_pin: gpio_motor_left_forward_pin@12 {
				brcm,pins = <12>;
				brcm,function = <1>;	// out
			};
			gpio_motor_left_backward_pin: gpio_motor_left_backward_pin@11 {
				brcm,pins = <11>;
				brcm,function = <1>;	// out
			};
			gpio_motor_right_forward_pin: gpio_motor_right_forward_pin@10 {
				brcm,pins = <10>;
				brcm,function = <1>;	// out
			};
			gpio_motor_right_backward_pin: gpio_motor_right_backward_pin@9 {
				brcm,pins = <9>;
				brcm,function = <1>;	// out
			};
		};
	};
    fragment@1 {
        target-path="/";
        __overlay__ {
            tagtagtag_ears: tagtagtag-ears {
                compatible = "linux,tagtagtag-ears";
                left-encoder-gpio = <&gpio 24 0>;
                left-motor-gpios = <&gpio 12 0 &gpio 11 0>;
                right-encoder-gpio = <&gpio 23 0>;
                right-motor-gpios = <&gpio 10 0 &gpio 9 0>;

                // Declare a single pinctrl state (referencing the one declared above) and name it
                // default, so it is activated automatically.
                pinctrl-names = "default";
                pinctrl-0 = <&gpio_encoder_left_pin &gpio_motor_left_forward_pin &gpio_motor_left_backward_pin &gpio_encoder_right_pin &gpio_motor_right_forward_pin &gpio_motor_right_backward_pin>;
            };
        };
    };
};

 

I tried to adapt it following what I understand from the schematics of the device and the documentation of the BPI M2 Zero board. It resulted in the version below :

/dts-v1/;
/plugin/;

/ {
    compatible = "sinovoip,bpi-m2-zero\0allwinner,sun8i-h2-plus";

	fragment@0 {
		target = <&pio>;
		__overlay__ {
			gpio_encoder_left_pin: gpio_encoder_left_pin@24 {
				//pins = <24>;
				pins = "PC4";
				function = <0>;	// in
			};
			gpio_encoder_right_pin: gpio_encoder_right_pin@23 {
				//pins = <23>;
				pins = "PA15";
				function = <0>;	// in
			};
                        // left: when looking at the rabbit (matching hardware spec)
                        // forward: for the rabbit's left ear (right), counter-clock-wise
                        // for the rabbit's right ear (left below), clock-wise
			gpio_motor_left_forward_pin: gpio_motor_left_forward_pin@12 {
				//pins = <12>;
				pins = "PA2";
				function = <1>;	// out
			};
			gpio_motor_left_backward_pin: gpio_motor_left_backward_pin@11 {
				//pins = <11>;
				pins = "PC2";
				function = <1>;	// out
			};
			gpio_motor_right_forward_pin: gpio_motor_right_forward_pin@10 {
				//pins = <10>;
				pins = "PC0";
				function = <1>;	// out
			};
			gpio_motor_right_backward_pin: gpio_motor_right_backward_pin@9 {
				//pins = <9>;
				pins = "PC1";
				function = <1>;	// out
			};
		};
	};
    fragment@1 {
        target-path="/";
        __overlay__ {
            tagtagtag_ears: tagtagtag-ears {
                compatible = "linux,tagtagtag-ears";
                //left-encoder-gpio = <&gpio 24 0>;
				left-encoder-gpio = <&gpio 24 0>;
                left-motor-gpios = <&gpio 12 0 &gpio 11 0>;
                right-encoder-gpio = <&gpio 23 0>;
                right-motor-gpios = <&gpio 10 0 &gpio 9 0>;

                // Declare a single pinctrl state (referencing the one declared above) and name it
                // default, so it is activated automatically.
                pinctrl-names = "default";
                pinctrl-0 = <&gpio_encoder_left_pin &gpio_motor_left_forward_pin &gpio_motor_left_backward_pin &gpio_encoder_right_pin &gpio_motor_right_forward_pin &gpio_motor_right_backward_pin>;
            };
        };
    };
};

 

I just changed the compatible clause and the pins definition trying to follow the indications in the documentation here https://docs.armbian.com/User-Guide_Allwinner_overlays/#using-custom-overlays without much success.

 

Would someone have an idea or more useful, an example of such portage ? I already looked at the Device Tree for dummies but I think I need some more directions to look at.

 

Thanks in advance for your help,

 

Benoît

 

 

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.