To make creating a consistent Device Tree overlay easier for the Beagle Bone Black, I’ve created a small helper. It can:
- Read the contents of the various pinmux files, and display a combined output
- Generate a template DTS file
To display the current pin configuration, just run the utility without any parameters:
$ ./bb-pins.py Header P8_25 Name: GPIO1_0 Number: 0 GPIO: 1 0x800/000 Mode: mmc1_dat0 (1) Direction: in PUD: pull-up (Allocated: group: pinmux_emmc2_pins) Header P8_24 Name: GPIO1_1 Number: 1 GPIO: 33 0x804/004 Mode: mmc1_dat1 (1) Direction: in PUD: pull-up (Allocated: group: pinmux_emmc2_pins) Header P8_05 Name: GPIO1_2 Number: 2 GPIO: 34 0x808/008 Mode: mmc1_dat2 (1) Direction: in PUD: pull-up (Allocated: group: pinmux_emmc2_pins) Header P8_06 Name: GPIO1_3 Number: 3 GPIO: 35 0x80c/00c Mode: mmc1_dat3 (1) Direction: in PUD: pull-up (Allocated: group: pinmux_emmc2_pins) Header P8_23 Name: GPIO1_4 Number: 4 GPIO: 36 0x810/010 Mode: mmc1_dat4 (1) Direction: in PUD: pull-up (Allocated: group: pinmux_emmc2_pins) Header P8_22 Name: GPIO1_5 Number: 5 GPIO: 37 0x814/014 Mode: mmc1_dat5 (1) Direction: in PUD: pull-up (Allocated: group: pinmux_emmc2_pins) Header P8_03 Name: GPIO1_6 Number: 6 GPIO: 38 0x818/018 Mode: mmc1_dat6 (1) Direction: in PUD: pull-up (Allocated: group: pinmux_emmc2_pins) Header P8_04 Name: GPIO1_7 Number: 7 GPIO: 39 0x81c/01c Mode: mmc1_dat7 (1) Direction: in PUD: pull-up (Allocated: group: pinmux_emmc2_pins) Header P8_19 Name: EHRPWM2A Number: 8 GPIO: 22 0x820/020 Mode: gpio0[22] (7) Direction: in PUD: pull-down Header P8_13 Name: EHRPWM2B Number: 9 GPIO: 23 0x824/024 Mode: gpio0[23] (7) Direction: in PUD: pull-down Header P8_14 Name: GPIO0_26 Number: 10 GPIO: 26 0x828/028 Mode: gpio0[26] (7) Direction: in PUD: pull-down ...
But more interestingly, to generate a DTS file just specify the various pin-functions you would like to enable, the pin direction and any pull-up/pull-down you want:
$ ./bb-pins.py 'gpio2[2],out' 'gpio2[3],out' 'gpio2[5],out' 'gpio2[4],out' 'gpio1[13],out' 'gpio1[12],out' 'gpio0[23],in,pullup' 'gpio0[26],in,pullup' 'gpio1[15],in,pullup'
This will dump the following DTS to stdio.
/dts-v1/; /plugin/; /{ compatible = "ti,beaglebone", "ti,beaglebone-black"; board-name = "CustomizeThis"; part-number = "CustomizeThis"; version = "00A0"; exclusive-use = "P8.07" /* gpio2_2 */, "P8.08" /* gpio2_3 */, "P8.09" /* gpio2_5 */, "P8.10" /* gpio2_4 */, "P8.11" /* gpio1_13 */, "P8.12" /* gpio1_12 */, "P8.13" /* gpio0_23 */, "P8.14" /* gpio0_26 */, "P8.15" /* gpio1_15 */, "gpio2_2", "gpio2_3", "gpio2_5", "gpio2_4", "gpio1_13", "gpio1_12", "gpio0_23", "gpio0_26", "gpio1_15"; fragment@0 { target = < &am33xx_pinmux>; __overlay__ { pinctrl_generated: RNS_Generated_Pins { pinctrl-single,pins = < 0x090 0x0f /* P8_07 36 GPIO 66 out Mode: 7 */ 0x094 0x0f /* P8_08 37 GPIO 67 out Mode: 7 */ 0x09c 0x0f /* P8_09 39 GPIO 69 out Mode: 7 */ 0x098 0x0f /* P8_10 38 GPIO 68 out Mode: 7 */ 0x034 0x0f /* P8_11 13 GPIO 45 out Mode: 7 */ 0x030 0x0f /* P8_12 12 GPIO 44 out Mode: 7 */ 0x024 0x37 /* P8_13 9 GPIO 23 in Mode: 7 */ 0x028 0x37 /* P8_14 10 GPIO 26 in Mode: 7 */ 0x03c 0x37 /* P8_15 15 GPIO 47 in Mode: 7 */ >; }; }; }; fragment@1 { target = < &ocp>; __overlay__ { test_helper: helper { compatible = "bone-pinmux-helper"; pinctrl-names = "default"; pinctrl-0 = < &pinctrl_generated>; status = "okay"; }; }; }; };
The generated file has some comments to make it easier to understand the various ports, functions, modes and pin configuration.
This utility was inspired by a small perl script someone else had written.
You can get the tool via GitHub.
You must log in to post a comment.