Jump to content

Armbian build - how to modify dts file to change GPIO mapping?


piglet

Recommended Posts

Hi,

 

I have a board Orange Pi Zero with modified PAs for power of WiFi module from PA20 to PA02, by soldering a connection on board. This is done to allow connection of I2C DAC.

 

I see that board definition in 'u-boot/configs/orangepi_zero_defconfig'

It uses dts definition of: 'arch/arm/dts/sun8i-h2-plus-orangepi-zero.dts'

 

I need to modify one section of this dts file from:

reg_vcc_wifi: reg_vcc_wifi {
        compatible = "regulator-fixed";
        regulator-min-microvolt = <3300000>;
        regulator-max-microvolt = <3300000>;
        regulator-name = "vcc-wifi";
        enable-active-high;
        gpio = <&pio 0 20 GPIO_ACTIVE_HIGH>;

to:

reg_vcc_wifi: reg_vcc_wifi {
        compatible = "regulator-fixed";
        regulator-min-microvolt = <3300000>;
        regulator-max-microvolt = <3300000>;
        regulator-name = "vcc-wifi";
        enable-active-high;
        gpio = <&pio 0 2 GPIO_ACTIVE_HIGH>;

 

How can I do this and use armbian build script: compile.sh

 

Thanks,

Michal

 

Link to comment
Share on other sites

There are two ways you can go. Either add a patch and build a new image. Or use official image with a device tree overlay to change that line.

 

If you want to go the first route, run the following command

 

./compile.sh BOARD=orangepizero BRANCH=current uboot-patch

 

It will start the patch mode and then wait for you to make changes. if you are building with docker, you have to open a shell using "docker exec -it <instance_id> /bin/bash". Go to cache/sources/u-boot-sunxi/<version>/ directory and make your changes. Go back to window where you ran ./compile.sh and press enter. It will ask you for few things once you provide those a patch file will be created in output directory. Then you can copy that patch file to patch/u-boot/u-boot-sunxi directory so that the patch applies to the image

 

you have to do the same thing for kernel as well. Most of the workflow will remain the same just command will be kernel-patch instead of uboot-patch and source directory will also be something like cache/sources/linux-something. The patch has to be placed in patch/kernel/archive/sunxi-<kernel_version>/ directory or its corresponding userpatches directory.

 

If you go to device tree overlay route, create a file called sun8i-h3-reg_vcc_wifi.dts with the following content

/dts-v1/;
/plugin/;

&reg_vcc_wifi {
	gpio = <&pio 0 2 GPIO_ACTIVE_HIGH>;
};

 

compile it with "dtc -@ -I dts -O dtb -o sun8i-h3-reg_vcc_wifi.dtb sun8i-h3-reg_vcc_wifi.dts". copy dtb file to /boot/dtb/overlays directory and enable it using armbian-config. It will take affect after reboot

Link to comment
Share on other sites

Thank you for this information.

I still struggle to get it working.

 

a. First approach - patch of uboot and kernel

 

Effect I see: modules of wifi are loaded.

lsmod returns:

xradio_wlan           118784  0
mac80211              606208  1 xradio_wlan
cfg80211              573440  2 mac80211,xradio_wlan

 

However eth1 for wifi is not created.

I couldn't spot what is missing.

 

b. Second approach - dtb overlay

 

It seems to be a simpler solution. I wasn't able to compile proposed file.

It shows an error on 'gpio...' line

I tried to add #include lines from the original board dts file but with no success.

 

I would prefer to use an overlay as it is simpler and quicker.

 

Any suggestions?
Thanks,

Michal

 

Edited by piglet
Link to comment
Share on other sites

Thank you very much for help. The overlay approach is really simple to use.

 

The file that worked is following:

 

/dts-v1/;
/plugin/;

/ {
        compatible = "allwinner,sun8i-h3";

        fragment@0 {
                target = <&reg_vcc_wifi>;
                __overlay__ {
                        gpio = <&pio 0 2 1>;
                };
        };
};

 

I saved it to a file: sun8i-h3-reg_vcc_wifi.dts

Than I added it as an overlay using command

armbian-add-overlay sun8i-h3-reg_vcc_wifi.dts

After reboot it was working.

 

This was done on:

- Orange Pi Zero with soldered connection for wifi supply from another pin

- Armbian 23.11.0 6.1.56-current-sunxi

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines