Torizoncode builder not working

Hello,

I have an Apalis iMX6 with an Ixora dev board.
I want to change the functions of several pins. First I wanted to use GPIO1 9 and PWM as a GPIO pin and I did the following steps:

  • On your (Linux) host machine, download the TorizonCore Builder setup script if you haven’t done so:
mkdir -p ~/tcbdir/ && cd ~/tcbdir/
wget https://raw.githubusercontent.com/toradex/tcb-env-setup/master/tcb-env-setup.sh
  • Source the script to initialize TorizonCore Builder:
cd ~/tcbdir/
source tcb-env-setup.sh
  • Inside ~/tcbdir, clone Linux and the overlay repositories for TorizonCore 6:
git clone -b linux-6.0.y git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
git clone -b master git://git.toradex.com/device-tree-overlays.git device-trees
  • Inside ~/tcbdir create a directory named images. Download TorizonCore 6.2 and put the .tar file in the images directory.
  • Inside ~/tcbdir create a file named apalis-imx6_enable_gpio1_2_overlay.dts with the following content:
/dts-v1/;
/plugin/;

#include <arch/arm/boot/dts/imx6q-pinfunc.h>

/ {
	compatible = "toradex,apalis_imx6q";
};

&reg_pcie_switch {
	status = "disabled";
};

&pwm1 {
	status = "disabled";
};

&iomuxc {
	pinctrl-0 = <&pinctrl_apalis_gpio1 &pinctrl_apalis_gpio2
			&pinctrl_apalis_gpio3 &pinctrl_apalis_gpio4
			&pinctrl_apalis_gpio5 &pinctrl_apalis_gpio6
			&pinctrl_apalis_gpio7 &pinctrl_apalis_gpio8
			&pinctrl_apalis_gpio1_9
		>;
	pinctrl_apalis_gpio1_9: apalisgpio1_9_grp {
		fsl,pins = <
			MX6QDL_PAD_GPIO_9__GPIO1_IO09 0x130b0
		>;
	};
};
  • Inside ~/tcbdir create a file named tcbuild.yaml with the following content:
input:
  easy-installer:
    local: images/torizon-core-docker-apalis-imx6-Tezi_6.2.0+build.2.tar

customization:
  device-tree:
    include-dirs:
      - linux/
    overlays:
      clear: false
      add:
        - apalis-imx6_enable_gpio1_2_overlay.dts

output:
  easy-installer:
    local: apalis_imx6_tc6.2_enable_gpio1_2
 # >> Information used by Toradex Easy Installer:
    name: "TorizonCore (UPSTREAM)"
    description: "TorizonCore with GPIO1 pin 2 (MXM3 pin 15) enabled in Userspace"

Inside ~/tcbdir run torizoncore-builder build . It will generate a directory named apalis_imx6_tc6.2_enable_gpio1_2 . Copy this directory to a USB stick, plug it to your module then load the latest release of Toradex Easy Installer on your module

That worked and I was able to use the two pins as GPIO pins.
But now I have to also use PWM 2 and 3 as GPIOs so I tried adding the pins the following way in the dts file:

/dts-v1/;
/plugin/;

#include <arch/arm/boot/dts/imx6q-pinfunc.h>

/ {
	compatible = "toradex,apalis_imx6q";
};

&reg_pcie_switch {
	status = "disabled";
};

&pwm1 {
	status = "disabled";
};
&pwm2 {
	status = "disabled";
};
&pwm3 {
	status = "disabled";
};

&iomuxc {
	pinctrl-0 = <&pinctrl_apalis_gpio1 &pinctrl_apalis_gpio2
			&pinctrl_apalis_gpio3 &pinctrl_apalis_gpio4
			&pinctrl_apalis_gpio5 &pinctrl_apalis_gpio6
			&pinctrl_apalis_gpio7 &pinctrl_apalis_gpio8
			&pinctrl_apalis_gpio1_9
		>;
	pinctrl_apalis_gpio1_9: apalisgpio1_9_grp {
		fsl,pins = <
			MX6QDL_PAD_GPIO_9__GPIO1_IO09 0x130b0
		>;};
	pinctrl_apalis_gpio2_9: apalisgpio2_9_grp {
		fsl,pins = <
			MX6QDL_PAD_GPIO_9__GPIO2_IO09 0x130b0
		>;};
	pinctrl_apalis_gpio1_1: apalisgpio1_1_grp {
		fsl,pins = <
			MX6QDL_PAD_GPIO_1__GPIO1_IO01 0x130b0
		>;
	};
};

With the same yaml file. But when I run torizoncore-builder build I get the following error:

torizoncore-builder build
Building image as per configuration file 'tcbuild.yaml'...

=>> Handling input section
Unpacking Toradex Easy Installer image.
An unexpected Exception occured. Please provide the following stack trace to
the Toradex TorizonCore support team:


Traceback (most recent call last):
  File "/builder/torizoncore-builder", line 221, in <module>
    mainargs.func(mainargs)
  File "/builder/tcbuilder/cli/build.py", line 479, in do_build
    build(args.config_fname, args.storage_directory,
  File "/builder/tcbuilder/cli/build.py", line 446, in build
    handle_input_section(config["input"], storage_dir=storage_dir)
  File "/builder/tcbuilder/cli/build.py", line 98, in handle_input_section
    handle_easy_installer_input(props["easy-installer"], **kwargs)
  File "/builder/tcbuilder/cli/build.py", line 119, in handle_easy_installer_input
    images_cli.images_unpack(
  File "/builder/tcbuilder/cli/images.py", line 139, in images_unpack
    images.import_local_image(image_dir, dir_list[0], dir_list[1], dir_list[2])
  File "/builder/tcbuilder/backend/images.py", line 282, in import_local_image
    subprocess.check_output(tarcmd, shell=True, stderr=subprocess.STDOUT)
  File "/usr/lib/python3.9/subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'cat /workdir/images/torizon-core-docker-apalis-imx6-Tezi_6.2.0+build.2.tar | cat | tar -xf - -C /storage/tezi.tmp' returned non-zero exit status 2.

How can this be fixed?

Greetings @Svetoslav,

Judging by the error given it seems for whatever reason the TorizonCore Builder tool can’t unpack torizon-core-docker-apalis-imx6-Tezi_6.2.0+build.2.tar. This could be because, this file doesn’t exist, or it’s not in the relative path it should be. In your yaml file you specify that the file is located at images/torizon-core-docker-apalis-imx6-Tezi_6.2.0+build.2.tar. This path is relative to where ever you execute the command.

Perhaps you’re executing the build command from a different directory location compared to the first time you ran it.

Best Regards,
Jeremias

Yes, that was the issue, thank you.
But now I’m getting a syntax error:

Building image as per configuration file 'tcbuild.yaml'...

=>> Handling input section
Unpacking Toradex Easy Installer image.
Copying Toradex Easy Installer image.
Unpacking TorizonCore Toradex Easy Installer image.
Importing OSTree revision 4fddb93bd1e436b3a504d1afccf621fcae4dab9854c58cfdefd6fbac3a80233f from local repository...
855 metadata, 8869 content objects imported; 472.0 MB content written
Unpacked OSTree from Toradex Easy Installer image:
  Commit checksum: 4fddb93bd1e436b3a504d1afccf621fcae4dab9854c58cfdefd6fbac3a80233f
  TorizonCore Version: 6.2.0+build.2

=>> Handling customization section

=> Handling device-tree subsection
Not testing overlay because base image does not have a device-tree set!

=> Adding device-tree overlay 'apalis-imx6_enable_gpio1_2_overlay.dts'
Error: apalis-imx6_enable_gpio1_2_overlay.dts:41.13-14 syntax error
FATAL ERROR: Unable to parse input tree
error: cannot apply apalis-imx6_enable_gpio1_2_overlay.dts.

I think it’s sommething wrong with this definitions:

	pinctrl_apalis_gpio2_9: apalisgpio2_9_grp {
		fsl,pins = <
			MX6QDL_PAD_GPIO_9__GPIO2_IO09 0x130b0
		>;};
	pinctrl_apalis_gpio1_1: apalisgpio1_1_grp {
		fsl,pins = <
			MX6QDL_PAD_GPIO_1__GPIO1_IO01 0x130b0
		>;
	};

But I am not sure if this is the way to define them or not.

Dear @Svetoslav,

The syntax error is most probably thrown from the usage of MX6QDL_PAD_GPIO_9__GPIO2_IO09. This is not defined in our device tree files for apalis i.MX6Q. Could you please recheck?

Hello @rudhi.tx ,

I am trying to initialize these 3 pins as GPIOs:


Isn’t this the way to define GPIO2_IO09 because I am not sure how else.
Or if you could give me a clue how or from where to check how because I’m not sure.

As Rudhi said the macro MX6QDL_PAD_GPIO_9__GPIO2_IO09 does not exist anywhere in the pinfunc file: linux/imx6q-pinfunc.h at v6.0 · torvalds/linux · GitHub

Perhaps you meant MX6QDL_PAD_GPIO_9__GPIO1_IO09 instead? Looking at the snippet of the datasheet you shared this would be the correct value as well. If you want to reference GPIO2_IO09 then the correct ball name for that pin is MX6QDL_PAD_SD4_DAT1 not MX6QDL_PAD_GPIO_9.

Best Regards,
Jeremias

Thank you, that’s what wasn’t clear for me.

Glad I was able to help clarify things!