Device tree customization to support leds and buttons in imx6ull

Hello,

I am trying to customize the default Device Tree in order to support LEDs and button handling from sys/class/leds and also receive button when pressed via GPIO polling, or interrupt including also debounce.

I have tried modifiying the imx6ull-colibri-aster.dts, to include the SODIMM numbers related to it, but there are still some SODIMM pins I cannot find.

This is my dts file so far:

/*
 * Copyright 2017 Toradex AG
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

/dts-v1/;

#include "imx6ull-colibri-nonwifi.dtsi"
#include "imx6ull-colibri-aster.dtsi"

/ {
	model = "Toradex Colibri iMX6ULL 256MB on Colibri Aster";
	compatible = "toradex,colibri_imx6ull-aster", "fsl,imx6ull";
	
	gpio-keys{
		compatible = "gpio-keys";
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_gpio_keys>;

		btn0 {
			label = "btn0";
			gpios = <&gpio4 11 GPIO_ACTIVE_LOW>;
			linux,code = <BTN_0>;
			debounce-interval = <10>;
		};
	};

	leds {
		compatible = "gpio-leds";
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_gpio_leds>;

		led0: rled0 {
			label = "rled0";
			gpios = <&gpio5 1 GPIO_ACTIVE_LOW>;
			default-state = "off";
			linux,default-trigger = "heartbeat";
		};

		led1: rled1 {
			label = "rled1";
			gpios = <&gpio2 6 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};
		
		led2: rled2 {
			label = "rled2";
			gpios = <&gpio4 14 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};
		
		led3: rled3 {
			label = "rled3";
			gpios = <&gpio4 16 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};
		
		led4: rled4 {
			label = "rled4";
			gpios = <&gpio2 5 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};
		
		led5: rled5 {
			label = "rled5";
			gpios = <&gpio2 0 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};
		
		led6: rled6 {
			label = "rled6";
			gpios = <&gpio2 1 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};
	};
	
	&iomuxc {
	imx6dl-colibri {
		pinctrl_gpio_leds: gpio_leds {
			fsl,pins = <
				MX6ULL_PAD_SNVS_TAMPER1__GPIO5_IO01	0x130b0	
				//pending GPIO2_IO06
				MX6UL_PAD_NAND_CE1_B__GPIO4_IO14        0x14 /* SODIMM 133 */
				//pending GPIO4_IO16
				//pending GPIO2_IO05
				MX6UL_PAD_ENET1_RX_DATA0__GPIO2_IO00    0x74 /* SODIMM 55 */
				//pending GPIO2_IO01							
				>;
		};	

		pinctrl_gpio_keys: gpio_keys {
			fsl,pins = <
				//pending GPIO4_IO11
			>;
		};
	};
};

Please let me know where can I get the lines marked with //pending, and if there is something else I need in order to make this work.

Thanks.
Gaston

Hi @gasmbas!

You can find all pin definitions in the imx6ul-pinfunc.h and imx6ull-pinfunc.h files inside the same dts directory. E.g.:

$ grep -nrie "GPIO2_IO06"
imx6ul-pinfunc.h:362:#define MX6UL_PAD_ENET1_TX_CLK__GPIO2_IO06		0x00dc 0x0368 0x0000 5 0

Just search for the pins you’re using and double-check them with the pins you’re going to use on the module’s datasheet.

Hello @gustavo.tx

Ok, I did that on my dts file:

/*
 * Copyright 2017 Toradex AG
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

/dts-v1/;

#include "imx6ull-colibri-nonwifi.dtsi"
#include "imx6ull-colibri-aster.dtsi"

/ {
	model = "Toradex Colibri iMX6ULL 256MB on Colibri Aster";
	compatible = "toradex,colibri_imx6ull-aster", "fsl,imx6ull";
	
	gpio-keys{
		compatible = "gpio-keys";
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_gpio_keys>;

		btn0 {
			label = "btn0";
			gpios = <&gpio4 11 GPIO_ACTIVE_LOW>;
			linux,code = <BTN_0>;
			debounce-interval = <10>;
		};
	};

	leds {
		compatible = "gpio-leds";
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_gpio_leds>;

		led0: rled0 {
			label = "rled0";
			gpios = <&gpio5 1 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};

		led1: rled1 {
			label = "rled1";
			gpios = <&gpio2 6 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};
		
		led2: rled2 {
			label = "rled2";
			gpios = <&gpio4 14 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};
		
		led3: rled3 {
			label = "rled3";
			gpios = <&gpio4 16 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};
		
		led4: rled4 {
			label = "rled4";
			gpios = <&gpio2 5 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};
		
		led5: rled5 {
			label = "rled5";
			gpios = <&gpio2 0 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};
		
		led6: rled6 {
			label = "rled6";
			gpios = <&gpio2 1 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};
	};
};
	
&iomuxc {
	imx6ull-colibri {
		pinctrl_gpio_leds: gpio_leds {
			fsl,pins = <
				MX6ULL_PAD_SNVS_TAMPER1__GPIO5_IO01		0x130b0	
				MX6UL_PAD_ENET1_TX_CLK__GPIO2_IO06		0x00dc 0x0368 0x0000 5 0 
				MX6UL_PAD_NAND_CE1_B__GPIO4_IO14        0x14 /* SODIMM 133 */
				MX6UL_PAD_NAND_DQS__GPIO4_IO16			0x01b8 0x0444 0x0000 5 0
				MX6UL_PAD_ENET1_TX_EN__GPIO2_IO05		0x00d8 0x0364 0x0000 5 0
				MX6UL_PAD_ENET1_RX_DATA0__GPIO2_IO00    0x74 /* SODIMM 55 */
				MX6UL_PAD_ENET1_RX_DATA1__GPIO2_IO01		0x00c8 0x0354 0x0000 5 0
				>;
		};	

		pinctrl_gpio_keys: gpio_keys {
			fsl,pins = <
				MX6UL_PAD_NAND_WP_B__GPIO4_IO11			0x01a4 0x0430 0x0000 5 0
			>;
		};
	};
};

However, in the board filesystem, when I do cat /sys/kernel/debug/gpio this is the output:

gpiochip0: GPIOs 0-31, parent: platform/209c000.gpio, 209c000.gpio:
 gpio-2   (                    |VCC_USB[1-4]        ) out lo    
 gpio-11  (                    |enable              ) out hi    

gpiochip1: GPIOs 32-63, parent: platform/20a0000.gpio, 20a0000.gpio:
 gpio-32  (                    |sysfs               ) out hi    

gpiochip2: GPIOs 64-95, parent: platform/20a4000.gpio, 20a4000.gpio:
 gpio-90  (                    |spi_imx             ) out hi    

gpiochip3: GPIOs 96-127, parent: platform/20a8000.gpio, 20a8000.gpio:
 gpio-107 (                    |btn0                ) in  lo IRQ
 gpio-124 (                    |spi_imx             ) out hi    

gpiochip4: GPIOs 128-159, parent: platform/20ac000.gpio, 20ac000.gpio:
 gpio-129 (                    |Wake-Up             ) in  hi IRQ
 gpio-130 (                    |id                  ) in  hi IRQ

As you can see, btn0 is now there, but when I press it, the value doesn’t change.
Q1: What else do I have to do or change?
Q2: How should I handle btn states?

Regarding LEDs:

root@colibri-imx6ull:~# ll /sys/class/leds/
lrwxrwxrwx    1 root     root           0 Dec  5 14:10 mmc0:: -> ../../devices/soc0/soc/2100000.aips-bus/2190000.usdhc/leds/mmc0::/

Q2: What should I do regarding this?

The GPIO section should look like this, e.g.:

&iomuxc {
     imx6ull-colibri {
         pinctrl_gpio_leds: gpio_leds {
             fsl,pins = <
                 MX6ULL_PAD_SNVS_TAMPER1__GPIO5_IO01        0x130b0    
                 MX6UL_PAD_ENET1_TX_CLK__GPIO2_IO06        0x130b0 
                 MX6UL_PAD_NAND_CE1_B__GPIO4_IO14        0x14 /* SODIMM 133 */
                 MX6UL_PAD_NAND_DQS__GPIO4_IO16            0x130b0
                 MX6UL_PAD_ENET1_TX_EN__GPIO2_IO05        0x130b0
                 MX6UL_PAD_ENET1_RX_DATA0__GPIO2_IO00    0x74 /* SODIMM 55 */
                 MX6UL_PAD_ENET1_RX_DATA1__GPIO2_IO01        0x130b0
                 >;
         };    
 
         pinctrl_gpio_keys: gpio_keys {
             fsl,pins = <
                 MX6UL_PAD_NAND_WP_B__GPIO4_IO11            0x130b0
             >;
         };
     };
 };

The MX6UL_PAD[…] name is a shorthand for what you had put there. The correct way to do it is to put the pin identifier and the register configuration as I shown before.

Try the device tree with these changes.

The gpio-keys driver maps the gpios as they were keyboard buttons, so you have to check if the BTN_0 is detected by using any means available.

If they’re mapped correctly, all of your leds should show up in /sys/class/leds. Inside each of the LED’s folder, there will be a file named brightness. Write to it to control the brightness.

Hi @gasmbas

There was a wrong pin configuration, which is corrected. Please check these two patches: Patch1 and patch2.

Best regards,
Jaski

Hello @jaski.tx,

I followed the steps and applied the differences in the patches -patch2 complete and patch1 only the pins I need to use-. That makes the compilation to fail:

make colibri-imx6ull-aster.dtb                           
  CHK     scripts/mod/devicetable-offsets.h
make[1]: *** No rule to make target 'arch/arm/boot/dts/colibri-imx6ull-aster.dtb'.  Stop.
arch/arm/Makefile:336: recipe for target 'colibri-imx6ull-aster.dtb' failed
make: *** [colibri-imx6ull-aster.dtb] Error 2

After all, the files I modify were these 2:
modified files

And the other files consumed by those are the following:
other files original from git

git branch: toradex_4.9-2.3.x-imx. If I upload to toradex_4.14-2.0.x-imx-next I have issues with the rest of the yocto build.

Before I applied Patch1, I compiled ok (with the mods @gustavo.tx said and with Patch2 applied and the mods on the link -wrong pin configuration-). The result on my board is the following:

  1. Nothing on /sys/class/leds (Unexpected: FAIL)

    root@colibri-imx6ull:/sys/class/gpio# ll /sys/class/leds/
    lrwxrwxrwx    1 root     root           0 Dec  6 13:37 mmc0:: -> ../../devices/soc0/soc/2100000.aips-bus/2190000.usdhc/leds/mmc0::/
    
  2. No wake-up pin on gpio129 (Expected: OK)

  3. After exporting all pins: (Why aren’t them exported automatically?)

    root@colibri-imx6ull:/sys/class/gpio# cat /sys/kernel/debug/gpio
    gpiochip0: GPIOs 0-31, parent: platform/209c000.gpio, 209c000.gpio:
    gpio-2 ( |VCC_USB[1-4] ) out lo
    gpio-11 ( |enable ) out hi

            gpiochip1: GPIOs 32-63, parent: platform/20a0000.gpio, 20a0000.gpio:
             gpio-32  (                    |sysfs               ) out hi    
             gpio-33  (                    |sysfs               ) out lo    
             gpio-37  (                    |sysfs               ) out lo    
             gpio-38  (                    |sysfs               ) out lo    
            
            gpiochip2: GPIOs 64-95, parent: platform/20a4000.gpio, 20a4000.gpio:
             gpio-90  (                    |spi_imx             ) out hi    
            
            gpiochip3: GPIOs 96-127, parent: platform/20a8000.gpio, 20a8000.gpio:
             gpio-107 (                    |sysfs               ) in  lo    
             gpio-110 (                    |sysfs               ) out lo    
             gpio-112 (                    |sysfs               ) out lo    
             gpio-124 (                    |spi_imx             ) out hi    
            
            gpiochip4: GPIOs 128-159, parent: platform/20ac000.gpio, 20ac000.gpio:
             gpio-128 (                    |cd                  ) in  hi IRQ
             gpio-129 (                    |sysfs               ) out lo    
             gpio-130 (                    |id                  ) in  hi IRQ
    
  4. Button entry doesn’t change port read value when I press it.

  5. Some GPIO can be turned on and some others not. Or some of them remains in the same state despite I send the order to change their value (gpio90 for instance throw error when trying to change value)

HI @gasmbas

Sorry for the delayed answer.

make colibri-imx6ull-aster.dtb

The correct command is make colibri-imx6ull-aster.dtb.

Thanks for the files. I compiled the Bsp 2.8 (kernel branach 4.9.2.3) with your changes and this worked fine.

git branch: toradex_4.9-2.3.x-imx. If I upload to toradex_4.14-2.0.x-imx-next I have issues with the rest of the yocto build.

If you want to compile the new kernel branch, then you need to update to Bsp 3.0 in your yocto build.

After exporting all pins: (Why aren’t them exported automatically?)

If you check the dmesg log, there are iomux errors. You need to correct them first. Did you flash the correct devicetree file? You need to change this value in the image.json file of the image to be flashed.

Please correct these iomuxing errors and come back if you still see some issues.

Best regards,
Jaski

Hi @jaski.tx,

Thanks for the response. Alright, now I could pass through some obstacles but there are some left.

Here are my modified files in branch 4.9-2.3.

Now I have the leds subsystem OK

Q1: I have no longer VGA video out -after the disablings I had to perform to get the GPIOs pins-. Is there sth I can do here to keep both things?

Q2: rled2 is always on and rled5 is always off and I can’t understand why.

Q3: Is there a way to flash just the dtb file? I am using recovery mode + Toradex Easy Installer with image.json for the uploading and that also uploads the rootfs.

Q4: btn0 doesn’t appear in the gpio-keys subsytem.

My dmesg:

root@colibri-imx6ull:~# dmesg
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.14.126-00877-gbaa7eae49e3f (gaston@ssd-gbassi) (gcc version 8.2.0 (GCC)) #2 SMP Mon Dec 9 13:55:44 -03 2019
[    0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: Toradex Colibri iMX6ULL 256MB on Colibri Aster
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] Reserved memory: created CMA memory pool at 0x98000000, size 128 MiB
[    0.000000] OF: reserved mem: initialized node linux,cma, compatible id shared-dma-pool
[    0.000000] On node 0 totalpages: 131072
[    0.000000] free_area_init_node: node 0, pgdat 80d7de80, node_mem_map 97bb8000
[    0.000000]   Normal zone: 1024 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 131072 pages, LIFO batch:31
[    0.000000] percpu: Embedded 16 pages/cpu s34892 r8192 d22452 u65536
[    0.000000] pcpu-alloc: s34892 r8192 d22452 u65536 alloc=16*4096
[    0.000000] pcpu-alloc: [0] 0 
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 130048
[    0.000000] Kernel command line: user_debug=30 ubi.mtd=ubi root=ubi0:rootfs rw rootfstype=ubifs ubi.fm_autoconvert=1 console=tty1 console=ttymxc0,115200n8 consoleblank=0 video=mxsfb:640x480M-16@60
[    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Memory: 375028K/524288K available (8192K kernel code, 506K rwdata, 2268K rodata, 1024K init, 384K bss, 18188K reserved, 131072K cma-reserved)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
[    0.000000]     vmalloc : 0xa0800000 - 0xff800000   (1520 MB)
[    0.000000]     lowmem  : 0x80000000 - 0xa0000000   ( 512 MB)
[    0.000000]     modules : 0x7f000000 - 0x80000000   (  16 MB)
[    0.000000]       .text : 0x80008000 - 0x80900000   (9184 kB)
[    0.000000]       .init : 0x80c00000 - 0x80d00000   (1024 kB)
[    0.000000]       .data : 0x80d00000 - 0x80d7eaa0   ( 507 kB)
[    0.000000]        .bss : 0x80d80000 - 0x80de0148   ( 385 kB)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] Hierarchical RCU implementation.
[    0.000000]  RCU event tracing is enabled.
[    0.000000]  RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=1.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] Switching to timer-based delay loop, resolution 333ns
[    0.000016] sched_clock: 32 bits at 3000kHz, resolution 333ns, wraps every 715827882841ns
[    0.000060] clocksource: mxc_timer1: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 637086815595 ns
[    0.003800] Console: colour dummy device 80x30
[    0.004758] console [tty1] enabled
[    0.004814] Calibrating delay loop (skipped), value calculated using timer frequency.. 6.00 BogoMIPS (lpj=30000)
[    0.004888] pid_max: default: 32768 minimum: 301
[    0.005182] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.005247] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.006610] CPU: Testing write buffer coherency: ok
[    0.008083] Setting up static identity map for 0x80100000 - 0x80100060
[    0.008470] Hierarchical SRCU implementation.
[    0.009786] smp: Bringing up secondary CPUs ...
[    0.009846] smp: Brought up 1 node, 1 CPU
[    0.009889] SMP: Total of 1 processors activated (6.00 BogoMIPS).
[    0.009926] CPU: All CPU(s) started in SVC mode.
[    0.011605] devtmpfs: initialized
[    0.029493] random: get_random_u32 called from bucket_table_alloc+0x108/0x238 with crng_init=0
[    0.030615] VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
[    0.031232] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.031329] futex hash table entries: 256 (order: 2, 16384 bytes)
[    0.042210] pinctrl core: initialized pinctrl subsystem
[    0.044164] NET: Registered protocol family 16
[    0.057704] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.059660] cpuidle: using governor menu
[    0.072384] vdd3p0: supplied by regulator-dummy
[    0.073574] cpu: supplied by regulator-dummy
[    0.074729] vddsoc: supplied by regulator-dummy
[    0.095360] hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
[    0.095438] hw-breakpoint: maximum watchpoint size is 8 bytes.
[    0.097118] imx6ul-pinctrl 20e0000.iomuxc: initialized IMX pinctrl driver
[    0.099087] imx6ul-pinctrl 2290000.iomuxc-snvs: initialized IMX pinctrl driver
[    0.143026] soc_in: supplied by +V3.3
[    0.143814] eth_phy: supplied by +V3.3
[    0.145888] VCC_USB[1-4]: supplied by 5V
[    0.148408] SCSI subsystem initialized
[    0.148967] usbcore: registered new interface driver usbfs
[    0.149126] usbcore: registered new interface driver hub
[    0.149393] usbcore: registered new device driver usb
[    0.151840] i2c i2c-0: IMX I2C adapter registered
[    0.151921] i2c i2c-0: can't use DMA, using PIO instead.
[    0.153327] i2c i2c-1: IMX I2C adapter registered
[    0.153404] i2c i2c-1: can't use DMA, using PIO instead.
[    0.153932] Linux video capture interface: v2.00
[    0.154111] pps_core: LinuxPPS API ver. 1 registered
[    0.154154] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.154260] PTP clock support registered
[    0.154903] Advanced Linux Sound Architecture Driver Initialized.
[    0.157266] clocksource: Switched to clocksource mxc_timer1
[    0.157568] VFS: Disk quotas dquot_6.6.0
[    0.157766] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    0.178543] NET: Registered protocol family 2
[    0.179930] TCP established hash table entries: 4096 (order: 2, 16384 bytes)
[    0.180084] TCP bind hash table entries: 4096 (order: 3, 32768 bytes)
[    0.180268] TCP: Hash tables configured (established 4096 bind 4096)
[    0.180490] UDP hash table entries: 256 (order: 1, 8192 bytes)
[    0.180581] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
[    0.180949] NET: Registered protocol family 1
[    0.181881] RPC: Registered named UNIX socket transport module.
[    0.181947] RPC: Registered udp transport module.
[    0.181983] RPC: Registered tcp transport module.
[    0.182018] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.186914] Bus freq driver module loaded
[    0.189724] workingset: timestamp_bits=30 max_order=17 bucket_order=0
[    0.201568] NFS: Registering the id_resolver key type
[    0.201684] Key type id_resolver registered
[    0.201725] Key type id_legacy registered
[    0.201784] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[    0.203067] ntfs: driver 2.1.32 [Flags: R/W].
[    0.203758] fuse init (API version 7.26)
[    0.222634] io scheduler noop registered
[    0.222700] io scheduler deadline registered
[    0.223068] io scheduler cfq registered (default)
[    0.223123] io scheduler mq-deadline registered
[    0.223163] io scheduler kyber registered
[    0.226180] mxsfb 21c8000.lcdif: 21c8000.lcdif supply lcd not found, using dummy regulator
[    0.226729] fbcvt: 640x480@60: CVT Name - .307M3
[    0.226793] mxsfb 21c8000.lcdif: Using timings from kernel parameters
[    0.338843] Console: switching to colour frame buffer device 80x30
[    0.358445] mxsfb 21c8000.lcdif: initialized
[    0.365735] mxs-dma 1804000.dma-apbh: initialized
[    0.373196] 2020000.serial: ttymxc0 at MMIO 0x2020000 (irq = 19, base_baud = 5000000) is a IMX
[    1.056489] console [ttymxc0] enabled
[    1.065718] 21e8000.serial: ttymxc1 at MMIO 0x21e8000 (irq = 57, base_baud = 5000000) is a IMX
[    1.083143] 21f4000.serial: ttymxc4 at MMIO 0x21f4000 (irq = 58, base_baud = 5000000) is a IMX
[    1.118787] loop: module loaded
[    1.133940] random: fast init done
[    1.144361] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xdc
[    1.154600] nand: Macronix MX30LF4G28AC
[    1.162190] nand: 512 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 112
[    1.178130] gpmi-nand 1806000.gpmi-nand: mode:5 ,failed in set feature.
[    1.189501] Bad block table found at page 262080, version 0x01
[    1.200196] Bad block table found at page 262016, version 0x01
[    1.211310] 5 ofpart partitions found on MTD device gpmi-nand
[    1.221344] Creating 5 MTD partitions on "gpmi-nand":
[    1.230586] 0x000000000000-0x000000080000 : "mx6ull-bcb"
[    1.240906] 0x000000080000-0x000000200000 : "u-boot1"
[    1.250897] 0x000000200000-0x000000380000 : "u-boot2"
[    1.260762] 0x000000380000-0x000000400000 : "u-boot-env"
[    1.270825] 0x000000400000-0x000020000000 : "ubi"
[    1.292026] gpmi-nand 1806000.gpmi-nand: driver registered.
[    1.304759] libphy: Fixed MDIO Bus: probed
[    1.316101] pps pps0: new PPS source ptp0
[    1.326348] libphy: fec_enet_mii_bus: probed
[    1.337002] fec 20b4000.ethernet eth0: registered PHC device 0
[    1.348846] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    1.359108] ehci-mxc: Freescale On-Chip EHCI Host driver
[    1.368328] usbcore: registered new interface driver usb-storage
[    1.378172] usbcore: registered new interface driver usbserial
[    1.387635] usbcore: registered new interface driver usbserial_generic
[    1.397753] usbserial: USB Serial support registered for generic
[    1.407142] usbcore: registered new interface driver ftdi_sio
[    1.416320] usbserial: USB Serial support registered for FTDI USB Serial Device
[    1.430143] usbcore: registered new interface driver pl2303
[    1.439094] usbserial: USB Serial support registered for pl2303
[    1.450624] usbmisc_imx 2184800.usbmisc: 2184800.usbmisc supply vbus-wakeup not found, using dummy regulator
[    1.473898] ci_hdrc ci_hdrc.0: EHCI Host Controller
[    1.482520] ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
[    1.517350] ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
[    1.528193] hub 1-0:1.0: USB hub found
[    1.535668] hub 1-0:1.0: 1 port detected
[    1.553174] input: AD7879 Touchscreen as /devices/soc0/soc/2100000.aips-bus/21a4000.i2c/i2c-1/1-002c/input/input0
[    1.574739] snvs_rtc 20cc000.snvs:snvs-rtc-lp: rtc core: registered 20cc000.snvs:snvs-rtc-lp as rtc0
[    1.592311] i2c /dev entries driver
[    1.600857] IR NEC protocol handler initialized
[    1.609647] IR RC5(x/sz) protocol handler initialized
[    1.618666] IR RC6 protocol handler initialized
[    1.627008] IR JVC protocol handler initialized
[    1.635264] IR Sony protocol handler initialized
[    1.643678] IR SANYO protocol handler initialized
[    1.652466] IR Sharp protocol handler initialized
[    1.660948] IR MCE Keyboard/mouse protocol handler initialized
[    1.670551] IR XMP protocol handler initialized
[    1.682478] imx2-wdt 20bc000.wdog: timeout 60 sec (nowayout=0)
[    1.693368] sdhci: Secure Digital Host Controller Interface driver
[    1.703349] sdhci: Copyright(c) Pierre Ossman
[    1.711354] sdhci-pltfm: SDHCI platform and OF driver helper
[    1.722679] sdhci-esdhc-imx 2190000.usdhc: Got CD GPIO
[    1.797922] mmc0: SDHCI controller on 2190000.usdhc [2190000.usdhc] using ADMA
[    1.824892] hidraw: raw HID events driver (C) Jiri Kosina
[    1.834625] usbcore: registered new interface driver usbhid
[    1.844014] usbhid: USB HID core driver
[    1.857182] Netfilter messages via NETLINK v0.30.
[    1.865906] nfnl_acct: registering with nfnetlink.
[    1.874891] nf_conntrack version 0.5.0 (8192 buckets, 32768 max)
[    1.885122] nf_tables: (c) 2007-2009 Patrick McHardy <kaber@trash.net>
[    1.896087] ip_tables: (C) 2000-2006 Netfilter Core Team
[    1.905931] NET: Registered protocol family 10
[    1.916373] Segment Routing with IPv6
[    1.923728] usb 1-1: new high-speed USB device number 2 using ci_hdrc
[    1.934082] ip6_tables: (C) 2000-2006 Netfilter Core Team
[    1.943443] NET: Registered protocol family 17
[    1.952038] Bridge firewalling registered
[    1.959969] 8021q: 802.1Q VLAN Support v1.8
[    1.968038] Key type dns_resolver registered
[    2.007505] Registering SWP/SWPB emulation handler
[    2.015102] registered taskstats version 1
[    2.052110] (NULL device *): hwmon_device_register() is deprecated. Please convert the driver to use hwmon_device_register_with_info().
[    2.068675] imx_thermal 2000000.aips-bus:tempmon: Industrial CPU temperature grade - max:105C critical:105C passive:95C
[    2.084325] ubi0: default fastmap pool size: 200
[    2.091054] ubi0: default fastmap WL pool size: 100
[    2.097869] ubi0: attaching mtd4
[    2.151451] usb-storage 1-1:1.0: USB Mass Storage device detected
[    2.161413] scsi host0: usb-storage 1-1:1.0
[    2.999883] random: crng init done
[    3.220013] scsi 0:0:0:0: Direct-Access              USB Flash Memory 1.00 PQ: 0 ANSI: 4
[    3.243391] sd 0:0:0:0: [sda] 30310400 512-byte logical blocks: (15.5 GB/14.5 GiB)
[    3.260098] sd 0:0:0:0: [sda] Write Protect is off
[    3.266966] sd 0:0:0:0: [sda] Mode Sense: 45 00 00 00
[    3.267925] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[    3.286931]  sda: sda1
[    3.296082] sd 0:0:0:0: [sda] Attached SCSI removable disk
[    4.482900] ubi0: scanning is finished
[    4.520672] ubi0: attached mtd4 (name "ubi", size 508 MiB)
[    4.530278] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[    4.541308] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[    4.552258] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
[    4.563432] ubi0: good PEBs: 4060, bad PEBs: 4, corrupted PEBs: 0
[    4.573646] ubi0: user volume: 4, internal volumes: 1, max. volumes count: 128
[    4.588775] ubi0: max/mean erase counter: 165/64, WL threshold: 4096, image sequence number: 187033344
[    4.606075] ubi0: available PEBs: 0, total reserved PEBs: 4060, PEBs reserved for bad PEB handling: 76
[    4.624335] ubi0: background thread "ubi_bgt0d" started, PID 99
[    4.632931] snvs_rtc 20cc000.snvs:snvs-rtc-lp: setting system clock to 2019-12-10 18:27:25 UTC (1576002445)
[    4.647866] soc_in: disabling
[    4.653064] ALSA device list:
[    4.658224]   No soundcards found.
[    4.666095] UBIFS (ubi0:3): background thread "ubifs_bgt0_3" started, PID 100
[    4.816256] UBIFS (ubi0:3): UBIFS: mounted UBI device 0, volume 3, name "rootfs"
[    4.832080] UBIFS (ubi0:3): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[    4.850581] UBIFS (ubi0:3): FS size: 493936640 bytes (471 MiB, 3890 LEBs), journal size 9023488 bytes (8 MiB, 72 LEBs)
[    4.870291] UBIFS (ubi0:3): reserved for root: 0 bytes (0 KiB)
[    4.880767] UBIFS (ubi0:3): media format: w4/r0 (latest is w5/r0), UUID E44A9EED-072E-42D9-8AA6-3E409632F4B8, small LPT model
[    4.904996] VFS: Mounted root (ubifs filesystem) on device 0:12.
[    4.915991] devtmpfs: mounted
[    4.922746] Freeing unused kernel memory: 1024K
[    6.256873] udevd[122]: starting version 3.2.7
[    6.371619] udevd[122]: specified group 'kvm' unknown
[    6.437195] udevd[123]: starting eudev-3.2.7
[    6.601708] udevd[123]: specified group 'kvm' unknown
[    9.337635] Micrel KSZ8041 20b4000.ethernet-1:02: attached PHY driver [Micrel KSZ8041] (mii_bus:phy_addr=20b4000.ethernet-1:02, irq=POLL)
[    9.366855] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[   12.488418] fec 20b4000.ethernet eth0: Link is Up - 100Mbps/Full - flow control off
[   12.513113] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

Hi @gasmbas

These are good news.

Now I have the leds subsystem OK

Q1: I have no longer VGA video out -after the disablings I had to perform to get the GPIOs pins-. Is there sth I can do here to keep both things?

You should use different pins for GPIOS then the one used for the VGA output.

Q2: rled2 is always on and rled5 is always off and I can’t understand why.

Could you tell which SODIMM pin is rled2 and rled5?

Q3: Is there a way to flash just the dtb file? I am using recovery mode + Toradex Easy Installer with image.json for the uploading and that also uploads the rootfs.

Unfortunately there is no out of box solution for the modules with raw nand flash. You need to flash the complete image.

Q4: btn0 doesn’t appear in the gpio-keys subsytem

What is the output of cat /sys/kernel/debug/gpio?

Best regards,
Jaski

Hi @jaski.tx,

I found out those pins weren’t working because of the mux option, I used 0x130b0 for all of the outputs and now all the leds work ok.

I still have troubles with the button, it is being detected properly to the subsystem but when I press it, sometimes the event ocurrs and sometimes not. I also check the mux value and I cannot make the pull up config work. I want this config: 100 kOhm Pull Up (0x1b0b0) and connect the button without external pullup, this should work, right? Because with no button connected I measure voltage on that pin and has 0V when expected is 3V3.

dts file

/*
 * Copyright 2017 Toradex AG
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

/dts-v1/;

#include "imx6ull-colibri-nonwifi.dtsi"
#include "imx6ull-colibri-aster.dtsi"

/ {
	model = "Toradex Colibri iMX6ULL 256MB on Colibri Aster";
	compatible = "toradex,colibri_imx6ull-aster", "fsl,imx6ull";
	
	     gpio-keys{
         compatible = "gpio-keys";
         pinctrl-names = "default";
         pinctrl-0 = <&pinctrl_gpio_keys>;
 
         btn0 {
             label = "btn0";
             gpios = <&gpio4 11 GPIO_ACTIVE_LOW>;
             linux,code = <BTN_0>;
             debounce-interval = <10>;
         };
     };
 
     .
     .
     .
     .
     .
 };
     
 &iomuxc {
     imx6ull-colibri {
         .
         .
         .
         .
         pinctrl_gpio_keys: gpio_keys {
             fsl,pins = <
                 MX6UL_PAD_NAND_WP_B__GPIO4_IO11            0x1b0b0
             >;
         };
     };
};

Thanks,
Gaston

Hi Gaston

Is the pin exported under Linux and defined as input?
Did you disable the pwm4 in the device-tree?

Could you share the dmesg.log in a text file and the output of cat /sys/kernel/debug/gpio?

Thanks and best regards,
Jaski

Hello @jaski.tx,

Is the pin exported under Linux and defined as input?
Yes

Did you disable the pwm4 in the device-tree?
Yes, you can check in the attached files

Could you share the dmesg.log in a text file and the output of cat /sys/kernel/debug/gpio?

@root@colibri-imx6ull:~# cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-31, parent: platform/209c000.gpio, 209c000.gpio:
 gpio-2   (                    |VCC_USB[1-4]        ) out lo    

gpiochip1: GPIOs 32-63, parent: platform/20a0000.gpio, 20a0000.gpio:
 gpio-33  (                    |rled6               ) out hi    
 gpio-37  (                    |rled4               ) out hi    
 gpio-38  (                    |rled1               ) out hi    

gpiochip2: GPIOs 64-95, parent: platform/20a4000.gpio, 20a4000.gpio:
 gpio-90  (                    |rled5               ) out hi    

gpiochip3: GPIOs 96-127, parent: platform/20a8000.gpio, 20a8000.gpio:
 gpio-107 (                    |btn0                ) in  hi IRQ
 gpio-110 (                    |rled2               ) out hi    
 gpio-112 (                    |rled3               ) out hi    

gpiochip4: GPIOs 128-159, parent: platform/20ac000.gpio, 20ac000.gpio:
 gpio-128 (                    |cd                  ) in  hi IRQ
 gpio-129 (                    |rled0               ) out hi    
 gpio-130 (                    |id                  ) in  hi IRQ

HI @gasmbas

Thanks very much for the information and files. The changes you have done look fine.

I still have troubles with the button, it is being detected properly to the subsystem but when I press it, sometimes the event ocurrs and sometimes not.

Could you check if interrupts are seen at every pressing of the button at cat /proc/interrupts ?

I also check the mux value and I cannot make the pull up config work. I want this config: 100 kOhm Pull Up (0x1b0b0) and connect the button without external pullup, this should work, right? Because with no button connected I measure voltage on that pin and has 0V when expected is 3V3.

How did you measure the voltage?

Best regards,
Jaski

The interrupt counter respond the same way as cat /sys/kernel/debug/gpio

I measure the voltage with a multimeter on the aster connector X18.2 directly.

  1. First of all, nothing connected to it, I measure 3V3.
  2. Then I connect the test propbe of the multimeter and measure again, and reads 0V. (This is unexpected behaviour for me).
  3. I connect the key without external pull-up and the events don’t appear.
  4. I put an external pull-up (and I also tried replying the circuit of Card Detect - which is working ok-) and when I press the key, I have 0V on the pin (this is ok)
  5. When I release the key, I read 1.23V (This is unexpected behaviour for me).

I think there is a problem related with the device tree.
I see that the device tree for card detect is like this:

pinctrl_snvs_cd_usdhc1: snvs-usdhc1-cd-grp {
			fsl,pins = <
				MX6ULL_PAD_SNVS_TAMPER0__GPIO5_IO00	0x1b0b0 /* CD */
			>;
		};

I don’t know what else is missing…

I could finally make it work putting a 4k7 pull-up on the Input pin. Apparently, either the internal 100k or even 22k are not enough to pull the pin to 3V3 when the button is released and only reaches 1.23V.

HI @gasmbas

Perfect that you found a solution.

Sorry I have overseen, that actually between the SoM Pin and the X18.2 Pin, there is a Level Shifter on the carrier board. Thus for pulling up the signal to 3.3V, you need an external Pull-Up on X18.2 Pin Side.

Best regards,
Jaski