Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom DTBO for SPI LCD (BBGW) #304

Open
serpent213 opened this issue Jun 14, 2023 · 0 comments
Open

Custom DTBO for SPI LCD (BBGW) #304

serpent213 opened this issue Jun 14, 2023 · 0 comments

Comments

@serpent213
Copy link

Environment

  • Elixir version (elixir -v):
Erlang/OTP 25 [erts-13.2.2.1] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]
                                            
Elixir 1.14.5 (compiled with Erlang/OTP 25)
  • Nerves environment: (mix nerves.env --info)
==> nerves                                                                                                                                                                        
==> nerves_bbgw                                                                                                                                                                   
|nerves_bootstrap| Environment Package List                                                                                                                                       
                                                                                                                                                                                  
  Pkg:         bbgw_spi                                                                                                                                                           
  Vsn:         2.17.2                                                                                                                                                             
  Type:        system                                                                                                                                                             
  BuildRunner: {Nerves.Artifact.BuildRunners.Local, [make_args: ["source", "all", "legal-info"]]}                                                                                 
                                                                                                                                                                                  
  Pkg:         nerves_system_br                                                                                                                                                   
  Vsn:         1.22.5                                                                                                                                                             
  Type:        system_platform                                                                                                                                                    
  BuildRunner: {nil, []}                                                                                                                                                          

  Pkg:         nerves_toolchain_armv7_nerves_linux_gnueabihf
  Vsn:         1.8.0
  Type:        toolchain
  BuildRunner: {Nerves.Artifact.BuildRunners.Local, []}

  Pkg:         nerves_toolchain_ctng
  Vsn:         1.9.3
  Type:        toolchain_platform
  BuildRunner: {nil, []}

|nerves_bootstrap| Loadpaths Start

|nerves_bootstrap| Precompile Start

==> nerves_toolchain_armv7_nerves_linux_gnueabihf
|nerves_bootstrap| Compile.NervesPackage start

|nerves_bootstrap| Compile.NervesPackage end 

==> bbgw_spi
Generated bbgw_spi app
|nerves_bootstrap| Compile.NervesPackage start

|nerves_bootstrap| Compile.NervesPackage end 

==> nerves_bbgw
|nerves_bootstrap| Precompile End


Nerves environment
  MIX_TARGET:   bbgw_spi
  MIX_ENV:      dev

|nerves_bootstrap| Environment Variable List
  target:     bbgw_spi
  toolchain:  /home/serpent/.nerves/artifacts/nerves_toolchain_armv7_nerves_linux_gnueabihf-linux_x86_64-1.8.0
  system:     /home/serpent/.nerves/artifacts/bbgw_spi-portable-2.17.2
  app:        .

|nerves_bootstrap| Loadpaths End
  • Boot log with additional overlay:
U-Boot 2021.10 (Apr 04 2023 - 02:26:05 +0000)

CPU  : AM335X-GP rev 2.1
Model: TI AM335x BeagleBone Black
DRAM:  512 MiB
Reset Source: Global warm SW reset has occurred.
Reset Source: Power-on reset has occurred.
RTC 32KCLK Source: External.
WDT:   Started with servicing (60s timeout)
MMC:   OMAP SD/MMC: 0, OMAP SD/MMC: 1
Loading Environment from MMC... OK
Board: BeagleBone Black
BeagleBone Black:
Model: SeeedStudio BeagleBone Green Wireless:
BeagleBone Cape EEPROM: no EEPROM at address: 0x54
BeagleBone Cape EEPROM: no EEPROM at address: 0x55
BeagleBone Cape EEPROM: no EEPROM at address: 0x56
BeagleBone Cape EEPROM: no EEPROM at address: 0x57
Net:   Could not get PHY for ethernet@4a100000: addr 0
eth2: ethernet@4a100000
board_name=[A335BNLT] ...
board_rev=[GW1A] ...
loading /zImage.a ...
2860152 bytes read in 253 ms (10.8 MiB/s)
uboot_overlays: [uboot_base_dtb=am335x-bonegreen-wireless-uboot-univ.dtb] ...
uboot_overlays: Switching too: dtb=am335x-bonegreen-wireless-uboot-univ.dtb ...
loading /boot/am335x-bonegreen-wireless-uboot-univ.dtb ...
207617 bytes read in 35 ms (5.7 MiB/s)
uboot_overlays: [fdt_buffer=0x60000] ...
uboot_overlays: loading /lib/firmware/spi0_ili9341_display.dtbo ...
2417 bytes read in 109 ms (21.5 KiB/s)
uboot_overlays: loading /lib/firmware/BB-BONE-eMMC1-01-00A0.dtbo ...
1614 bytes read in 47 ms (33.2 KiB/s)
uboot_overlays: loading /lib/firmware/BB-BBGW-WL1835-00A0.dtbo ...
4289 bytes read in 38 ms (109.4 KiB/s)
debug: [console=ttyS0,115200n8 coherent_pool=1M bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p2 rootfstype=squashfs rootwait coherent_pool=1M net.ifnames=0 omap_wdt.early_enable=1 omap_wdt.timer_margin=120 quiet] ...
debug: [bootz 0x82000000 - 88000000] ...
Kernel image @ 0x82000000 [ 0x000000 - 0x2ba478 ]
## Flattened Device Tree blob at 88000000
   Booting using the fdt blob at 0x88000000
   Loading Device Tree to 8ff69000, end 8fffffff ... OK

Starting kernel ...

[    0.159780] l3-aon-clkctrl:0000:0: failed to disable
[    6.058566] gpio-of-helper ocp:cape-universal: Failed to get gpio property of 'P8_03'
[    6.058589] gpio-of-helper ocp:cape-universal: Failed to create gpio entry
[    6.069856] wkup_m3_ipc 44e11324.wkup_m3_ipc: could not get rproc handle
[    6.378639] pinctrl-single 44e10800.pinmux: pin PIN30 already requested by 481a6000.serial; cannot claim for leds
[    6.389311] pinctrl-single 44e10800.pinmux: pin-30 (leds) status -22
[    6.395742] pinctrl-single 44e10800.pinmux: could not request pin 30 (PIN30) from group pinmux_bt_pins  on device pinctrl-single
[    6.407370] leds-gpio leds: Error applying setting, reverse things back
[    6.424305] omap_voltage_late_init: Voltage driver support not added
Erlang/OTP 25 [erts-13.2] [source] [32-bit] [smp:1:1] [ds:1:1:10] [async-threads:1]

pinctrl errors are exactly the same without overlay. System config is unchanged except for additional BR packages.

Changes in provisioning.conf:

uboot_setenv(uboot-env, "uboot_overlay_addr4", "/lib/firmware/spi0_ili9341_display.dtbo")
#uboot_setenv(uboot-env, "enable_uboot_cape_universal", "1")

Actual U-Boot env on target:

iex(1)> ubootenv(~r/^uboot_/)                                                                  
uboot_base_dtb="am335x-boneblack-uboot.dtb"
uboot_base_dtb_univ="am335x-bonegreen-wireless-uboot-univ.dtb"
uboot_emmc="BB-BONE-eMMC1-01-00A0.dtbo"
uboot_overlay_addr4="/lib/firmware/spi0_ili9341_display.dtbo"
uboot_wireless="BB-BBGW-WL1835-00A0.dtbo"
:ok
iex(2)> ubootenv(~r/^enable_/) 
enable_uboot_overlays="1"
:ok

DTS file package/extra-dts/spi0_ili9341_display.dts:

// run `make extra-dts-rebuild` in Nerves shell to rebuild manually, then `make all` to bundle

/dts-v1/;
/plugin/;

#include <dt-bindings/pinctrl/omap.h>

/ {
  fragment@1 {
    target-path="/";
    __overlay__ {
      compatible = "ti,am335x-bone-green-wireless", "ti,am335x-bone-green", "ti,am335x-bone", "ti,am33xx";

      // /* state the resources this cape uses */
      // exclusive-use =
      //   /* the pin header uses */
      //   /* "P9.17",	/* spi0_cs0 */
      //   "P9.18",	/* spi0_d1 */
      //   "P9.21",	/* spi0_d0 */
      //   "P9.22",	/* spi0_sclk */
      //   "P9.16",  /* backlight LED */
      //   "P9.24",  /* SPI DC (direction) */
      //   "P9.23",  /* reset */
      //   /* the hardware ip uses */
      //   "spi0",
      //   "ehrpwm1B";
    };
  };

  /*
  * Free up the pins used by the cape from the pinmux helpers.
  */
  fragment@2 {
    target = <&ocp>;
    __overlay__ {
      P9_18_pinmux { status = "disabled"; };
      P9_21_pinmux { status = "disabled"; };
      P9_22_pinmux { status = "disabled"; };
      P9_16_pinmux { status = "disabled"; };
      P9_24_pinmux { status = "disabled"; };
      P9_23_pinmux { status = "disabled"; };
    };
  };

  fragment@3 {
    target = <&am33xx_pinmux>;

    __overlay__ {
      backlight_pins_default: backlight_pins_default {
        // P9.16
        pinctrl-single,pins = <
          AM33XX_IOPAD(0x84c, PIN_OUTPUT | MUX_MODE6) /* (T14) gpmc_a3.ehrpwm1B */
        >;
      };

      spi_dc_pins_default: spi_dc_pins_default {
        // P9.24
        pinctrl-single,pins = <
          AM33XX_IOPAD(0x984, PIN_OUTPUT | MUX_MODE7) /* (D15) uart1_txd.gpio0[15] */
        >;
      };

      reset_pins_default: reset_pins_default {
        // P9.23
        pinctrl-single,pins = <
          AM33XX_IOPAD(0x844, PIN_OUTPUT | MUX_MODE7) /* (V14) gpmc_a1.gpio1[17] */
        >;
      };

      spi0_pins_default: spi0_pins_default {
        // P9.22, P9.21, P9.18
        pinctrl-single,pins = <
          AM33XX_IOPAD(0x950, PIN_OUTPUT | MUX_MODE0) /* (A17) spi0_sclk.spi0_sclk */
          AM33XX_IOPAD(0x954, PIN_INPUT | MUX_MODE0) /* (B17) spi0_d0.spi0_d0 */
          AM33XX_IOPAD(0x958, PIN_OUTPUT | MUX_MODE0) /* (B16) spi0_d1.spi0_d1 */
        >;
      };
    };
  };

  fragment@4 {
    target = <&epwmss2>;
    __overlay__ {
      status = "okay";
    };
  };

  fragment@5 {
    target = <&ehrpwm2>;
    __overlay__ {
      status = "okay";
    };
  };

  fragment@6 {
    target = <&ocp>;
    __overlay__ {
      backlight {
        compatible = "pwm-backlight";
        pinctrl-names	= "default";
        pinctrl-0	= <&backlight_pins_default>;
        pwms = <&ehrpwm1 1 500000>;

        brightness-levels = <0 4 8 16 32 64 128 255>;
        default-brightness-level = <6>;
      };
    };
  };

  fragment@7 {
    target = <&spi0>;
    __overlay__ {
      // avoid warning
      #address-cells = <1>;
      #size-cells = <0>;

      status		= "okay";
      pinctrl-names	= "default";
      pinctrl-0	= <&spi0_pins_default>;

      ti,spi-num-cs = <0>;

      /*
      lcd@0 {
        compatible = "ilitek,ili9341";
        reg = <0>;
        buswidth = <8>;
        spi-max-frequency = <24000000>;
        dc-gpios = <&gpio0 15 0>;     // P9_24
        reset-gpios = <&gpio1 17 0>;  // P9_23
        rotation = <270>;
        backlight = <&backlight>;
        status = "okay";
      };
      */
    };
  };
};

Current behavior

  • Universal cape seems always to be loaded
    Even changing uboot_base_dtb and uboot_base_dtb_univ to am335x-bonegreen-wireless.dtb does not make any difference.
  • /sys/class/backlight does not show up
  • DTBO becomes unloadable when enabling the lcd part

Expected behavior

PWM backlight should be available.

I'm fairly new to the whole device tree business, so probably I made some mistakes in my DTS.

Where can I find information about exclusive-use? Is it BeagleBone specific? Some overlays make use of it, others disable the pinmux nodes (like I did for now).

Is <&ehrpwm1 1 x> the right way to address ehrpwm1B? Where can I find this kind of information?

Any pointers appreciated to get this to work.

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

No branches or pull requests

1 participant