Jump to content

zaibot.w

Members
  • Posts

    4
  • Joined

  • Last visited

  1. Hi everyone, I'm struggling to get gpio_keys working. I'm trying to use the overlay, which I have attached below, but after reboot there is no event node listed in "/dev/input/". (There is only one node named mice.) Inspecting dmesg, I found the following error messages: [ 1.529891] sun50i-h616-pinctrl 300b000.pinctrl: pin PC8 already requested by gpio-keys-user; cannot claim for 300b000.pinctrl:72 [ 1.529917] gpio-keys gpio-keys-user: failed to get gpio: -22 [ 1.529926] gpio-keys: probe of gpio-keys-user failed with error -22 Inspecting the dts file of my board (orange pi zero 2), I found that PC5,PC6 and PC8 are already listed as mmc2-pins, but mmc2 is disabled, so I don't think that this is the issue. However, I have no idea what else might be wrong. Any help? Attachements: custom-keys.dts Overlay: /dts-v1/; /plugin/; / { compatible = "allwinner,sun50i-h616"; fragment@0 { target = <&pio>; __overlay__ { custom-buttons: custom-buttons { pins = "PC5","PC6","PC8"; function = "gpio_in"; bias-pull-up; }; }; }; fragment@1 { target-path = "/"; __overlay__ { gpio-keys-user { compatible = "gpio-keys"; pinctrl-names = "default"; pinctrl-0 = <&custom-buttons>; play_button { label = "GPIO Key 1"; linux,code = <25>; gpios = <&pio 0 69 1>; }; vol_up_button { label = "GPIO Key 2"; linux,code = <22>; gpios = <&pio 0 70 1>; }; vol_down_button { label = "GPIO Key 3"; linux,code = <32>; gpios = <&pio 0 72 1>; }; }; }; }; };
  2. OK. I don't really get what work is left to be done, but I'm totally new to the whole topic and I'm already happy that I got SPI working on my board. Just out of curiosity: You have the source code (fixup script and dts/dtbo files) that I've posted above, which could be directly (and without any further modification) included into an Armbian Image just like all the other overlays for other boards. What is there that still needs to be done and that has not been tested yet?
  3. OK, so I got SPI working on Armbian 22.05.3 Jammy (edge). In the end, the above DTS files weren't of much use (to me). Here's what I did: 1. I installed the Debian bullseye stock image (provided by Xunlong), which has SPI support. 2. I located the spi-spidev dtob files and the fixup script for sun50i-h616 in the boot folder and just copied them from the stock image over to a (newly installed) Armbian 22.05.3 Jammy (edge) image. Don't worry that the dtbo files are byte compiled and therefore not human readable. They can still be decompiled and so they are open source (although I don't know if they are legally licensed with an Open Source license, but what I mean is that the source can be viewed by anyone). You can decompile the dtbo with the following command: dtc -I dtb -O dts -o devicetree.dts devicetree.dtb 3. I activated SPI in armbianEnv.txt. Be warned that I had to use SPI bus 1. I haven't yet fully understood whether or not there is such a thing like SPI bus 0 on the Orange Pi Zero 2, as - on one hand - the documentation says that there is only one SPI on the 26 pins header, but, on the other hand, the original dtbo and fixup script require you to specify param_spi_bus in the orangepiEnv.txt file and no error is thrown when you select bus 0. I'll post the decompiled dtbo and the fixup scripts here, although the fixup script wasn't surprising at all. /dts-v1/; / { compatible = "allwinner,sun50i-h616"; fragment@0 { target-path = "/aliases"; __overlay__ { spi0 = "/soc/spi@5010000"; spi1 = "/soc/spi@5011000"; }; }; fragment@1 { target = <0xffffffff>; __overlay__ { #address-cells = <0x01>; #size-cells = <0x00>; spidev@0 { compatible = "rohm,dh2228fv"; status = "disabled"; reg = <0x00>; spi-max-frequency = <0xf4240>; }; }; }; fragment@2 { target = <0xffffffff>; __overlay__ { #address-cells = <0x01>; #size-cells = <0x00>; spidev@0 { compatible = "rohm,dh2228fv"; status = "disabled"; reg = <0x00>; spi-max-frequency = <0xf4240>; }; }; }; __fixups__ { spi0 = "/fragment@1:target:0"; spi1 = "/fragment@2:target:0"; }; }; (The fixup script has some gibberish bytecode at the beginning. I believe that's of no importance, but not sure...) 'V<\99\8Db\F0\9A\EF\00\00+\00\00\00\00\00\00\00\00fpq\A3\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00#\00\00\00\00# overlays fixup script # implements (or rather substitutes) overlay arguments functionality # using u-boot scripting, environment variables and "fdt" command # setexpr test_var ${tmp_bank} - A # works only for hex numbers (A-F) setenv decompose_pin 'setexpr tmp_bank sub "P(C|G|H|I)\\d+" "\\1"; setexpr tmp_pin sub "P\\S(\\d+)" "\\1"; test "${tmp_bank}" = "C" && setenv tmp_bank 2; test "${tmp_bank}" = "G" && setenv tmp_bank 6' test "${tmp_bank}" = "H" && setenv tmp_bank 7; test "${tmp_bank}" = "I" && setenv tmp_bank 8; if test -n "${param_spinor_spi_bus}"; then test "${param_spinor_spi_bus}" = "0" && setenv tmp_spi_path "spi@5010000" test "${param_spinor_spi_bus}" = "1" && setenv tmp_spi_path "spi@5011000" fdt set /soc/${tmp_spi_path} status "okay" fdt set /soc/${tmp_spi_path}/spiflash@0 status "okay" if test -n "${param_spinor_max_freq}"; then fdt set /soc/${tmp_spi_path}/spiflash@0 spi-max-frequency "<${param_spinor_max_freq}>" fi if test "${param_spinor_spi_cs}" = "1"; then fdt set /soc/${tmp_spi_path}/spiflash@0 reg "<1>" fi env delete tmp_spi_path fi if test -n "${param_spidev_spi_bus}"; then test "${param_spidev_spi_bus}" = "0" && setenv tmp_spi_path "spi@5010000" test "${param_spidev_spi_bus}" = "1" && setenv tmp_spi_path "spi@5011000" fdt set /soc/${tmp_spi_path} status "okay" fdt set /soc/${tmp_spi_path}/spidev status "okay" if test -n "${param_spidev_max_freq}"; then fdt set /soc/${tmp_spi_path}/spidev spi-max-frequency "<${param_spidev_max_freq}>" fi if test "${param_spidev_spi_cs}" = "1"; then fdt set /soc/${tmp_spi_path}/spidev reg "<1>" fi env delete tmp_spi_path fi if test -n "${param_pps_pin}"; then setenv tmp_bank "${param_pps_pin}" setenv tmp_pin "${param_pps_pin}" run decompose_pin fdt set /soc/pinctrl@300b000/pps_pins pins "${param_pps_pin}" fdt get value tmp_phandle /soc/pinctrl@300b000 phandle fdt set /pps@0 gpios "<${tmp_phandle} ${tmp_bank} ${tmp_pin} 0>" env delete tmp_pin tmp_bank tmp_phandle fi if test "${param_pps_falling_edge}" = "1"; then fdt set /pps@0 assert-falling-edge fi for f in ${overlays}; do if test "${f}" = "pwm34"; then setenv bootargs_new "" for arg in ${bootargs}; do if test "${arg}" = "console=ttyS0,115200"; then echo "Warning: Disabling ttyS0 console due to enabled PWM3 and PWM4 overlay" else setenv bootargs_new "${bootargs_new} ${arg}" fi done setenv bootargs "${bootargs_new}" fi done if test -n "${param_w1_pin}"; then setenv tmp_bank "${param_w1_pin}" setenv tmp_pin "${param_w1_pin}" run decompose_pin fdt set /soc/pinctrl@300b000/w1_pins pins "${param_w1_pin}" fdt get value tmp_phandle /soc/pinctrl@300b000 phandle fdt set /onewire@0 gpios "<${tmp_phandle} ${tmp_bank} ${tmp_pin} 0>" env delete tmp_pin tmp_bank tmp_phandle fi if test "${param_w1_pin_int_pullup}" = "1"; then fdt set /soc/pinctrl@300b000/w1_pins bias-pull-up fi if test "${param_uart1_rtscts}" = "1"; then fdt get value tmp_phandle1 /soc/pinctrl@300b000/uart1-pins phandle fdt get value tmp_phandle2 /soc/pinctrl@300b000/uart1-rts-cts-pins phandle fdt set /soc/serial@5000400 pinctrl-names "default" "default" fdt set /soc/serial@5000400 pinctrl-0 "<${tmp_phandle1}>" fdt set /soc/serial@5000400 pinctrl-1 "<${tmp_phandle2}>" env delete tmp_phandle1 tmp_phandle2 fi if test "${param_uart2_rtscts}" = "1"; then fdt get value tmp_phandle1 /soc/pinctrl@300b000/uart2-pins phandle fdt get value tmp_phandle2 /soc/pinctrl@300b000/uart2-rts-cts-pins phandle fdt set /soc/serial@5000800 pinctrl-names "default" "default" fdt set /soc/serial@5000800 pinctrl-0 "<${tmp_phandle1}>" fdt set /soc/serial@5000800 pinctrl-1 "<${tmp_phandle2}>" env delete tmp_phandle1 tmp_phandle2 fi if test "${param_uart3_rtscts}" = "1"; then fdt get value tmp_phandle1 /soc/pinctrl@300b000/uart3-pins phandle fdt get value tmp_phandle2 /soc/pinctrl@300b000/uart3-rts-cts-pins phandle fdt set /soc/serial@5000c00 pinctrl-names "default" "default" fdt set /soc/serial@5000c00 pinctrl-0 "<${tmp_phandle1}>" fdt set /soc/serial@5000c00 pinctrl-1 "<${tmp_phandle2}>" env delete tmp_phandle1 tmp_phandle2 fi And I use these parameters in armbianEnv.txt: overlay_prefix=sun50i-h616 overlays=spi-spidev param_spidev_spi_bus=1
  4. Very interesting! Any idea how to make this work? I have naively created a file /boot/overlay-user/spi.dts with the following contents (as i only need one spi interface): /dts-v1/; /plugin/; / { compatible = "allwinner,sun50i-h616"; fragment@0 { target-path = "/aliases"; __overlay__ { spi0 = "/soc/spi@5010000"; }; }; fragment@1 { target = <&spi0>; __overlay__ { #address-cells = <1>; #size-cells = <0>; spidev@0 { compatible = "spidev"; status = "disabled"; reg = <0>; spi-max-frequency = <1000000>; }; }; }; }; Afterwards, I have enabled the overlay using `armbian-add-overlay spi`, but unfortunately, even after a reboot I don't have an spi device in /dev. I'm running a fresh copy of Armbian 22.05 with all upgrades (including upgrade of armbian-{config,firmware,zsh} to 22.08.0). # uname -a Linux xxx 5.15.48-sunxi64 #22.05.3 SMP Wed Jun 22 07:33:24 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux # dmesg | grep spi [ 1.242938] sun6i-spi 5010000.spi: Failed to request TX DMA channel [ 1.242959] sun6i-spi 5010000.spi: Failed to request RX DMA channel [ 1.243556] spi-nor spi0.0: supply vdd not found, using dummy regulator [ 1.257585] spi-nor spi0.0: mx25l1606e (2048 Kbytes) # cat /boot/armbianEnv.txt verbosity=1 bootlogo=false console=serial disp_mode=1920x1080p60 rootdev=UUID=f3d154d3-f330-4f4c-8700-e85ffc6a9066 rootfstype=ext4 user_overlays=spi usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u In desperate search for a solution, I have also replaced "disabled" with "enabled" in the dts file and installed armbian-firmware-full, without any success. Any help would be appreciated!
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines