How to make DTS work without building the whole image?

system info:vim3pro ,linux-mainline-5.17,load from SD card

After setup SPI,I found the wifi don’t work,Check ifconfig find no wlan0

so,I try to edit DTS file in mainline linux in /fenix/build/linux-mainline-5.17/arch/arm64/boot/dts/amlogic

to disabled SPI.This time I don’t want to make for a image and reburn it into my SD card.

The whole process took me almost an hour.After a few days of tossing and turning about SPI, I really can’t stand it

In community,I find following steps:

1.edit dtb file
2.make kernel
3.find the Image file in /fenix/linux/arch/arm64/boot
4.rename to zImage
5.cpoy it to the /boot dir to replace on you board.

I did those steps.

And I also move the dtb file(meson-g12b-a311d-khadas-vim3.dtb) from /fenix/build/linux-mainline-5.17/arch/arm64/boot/dts/amlogic to
/boot/dts/amlogic/ and /boot/dts-5.17.0/amlogic/

I don’t know which dts will effect,so I put dtb for both.

BUT,I try to disabled SPI, it doesn’t work at all. Only I rebuild the image and reburn it into SD card.It changed,the SPI was disabled.

SO, How to make DTS work without building the whole image?Is it a problem with the use of mainline uboot and mainline kernels?

fred@vim3a:/boot$ ls
aml_autoscript      dtb              initrd.img           uInitrd
aml_autoscript.txt  dtb-4.9.241      initrd.img-4.9.241   vmlinuz-4.9.241
aml_autoscript.zip  dtb-4.9.241.old  remote.conf          zImage
boot.ini            dtb.img          s905_autoscript
boot.scr            env.txt          s905_autoscript.cmd
config-4.9.241      env.txt.backup   System.map-4.9.241
fred@vim3a:/boot$ sudo nano env.txt
[sudo] password for fred: 
fred@vim3a:/boot$ 

Change the line:

overlays=spi1,watchdog

Pins are multiplexed so read the .txt file and make sure you don’t have any conflicts.

You must reboot after saving the updated file.

1 Like

I can’t change anything via overlays.It don’t work

I also will edit some infos in DTS,It may not appear in overlays config.

So,I just want know how to make edited DTS file works

Hi @DylanMingan

You can follow the steps below to edit and update the dts.

  • Convert dtb to dts source file
$ dtc -I dtb -O dts /boot/dtb.img -o new-dts.dts

new-dts.dts is current dts source file.

  • Modify dts you want
$ vim new-dts.dts
...
  • Convert dts to new dtb
$ dtc -I dts -O dtb  new-dts.dts -o new-dts.dtb

new-dts.dtb is the new dtb.

  • Backup old dtb
$ sudo cp /boot/dtb.img /boot/dtb.img.backup
  • Update to new dtb
$ sudo cp new-dts.dtb /boot/dtb.img
$ sync
  • Reboot to use new dtb
$ sudo reboot

Acorrding to this code:

spi@14000 {
				compatible = "amlogic,meson-gxbb-spifc";
				status = "disabled";
				reg = <0x00 0x14000 0x00 0x80>;
				#address-cells = <0x01>;
				#size-cells = <0x00>;
				clocks = <0x02 0x0a>;
				pinctrl-0 = <0x28>;
				pinctrl-names = "default";
				phandle = <0x125>;

				spi-flash@0 {
					#address-cells = <0x01>;
					#size-cells = <0x01>;
					compatible = "winbond,w25q128fw\0jedec,spi-nor";
					reg = <0x00>;
					spi-max-frequency = <0x632ea00>;
					phandle = <0x126>;
				};
			};

I add SPI node in DTS like that:

spi@15000 {
				compatible = "amlogic,meson-g12a-spicc";
				reg = <0x00 0x15000 0x00 0x44>;
				interrupts = <0x00 0x5a 0x04>;
				clocks = <0x02 0x1d 0x02 0x105>;
				clock-names = "core\0pclk";
				#address-cells = <0x01>;
				//pinctrl-0 = <0x28>; 不知这个值是啥意思

				#size-cells = <0x00>;
				status = "okay";
				pinctrl-names = "default";
				phandle = <0x124>;
				spidev@0 {
					status = "okay";
					compatible = "linux,spidev";
					/* spi default max clock 100Mhz */
					spi-max-frequency = <100000000>;
					reg = <0>; 
					phandle = <0x999>;//任意给了一个值
				};
			};

But no spidev in /dev.I think it was my mistakes in edit DTS files

I don’t know the meanings of phandle and pinctrl-0.Just set a random value.

Please tell how can i do to make spidev in /dev. I use mainline Linux 5.17.Thanks!

I try it.your method works on 4.9 kernel only in emmc.But i use mainline linux 5.17.it fail to load overlays

Might have to wait until then next LTS version is released.

It is extremely time consuming to get it all working on a standard release then have to go back and test all and modify it again. We are stumbling around here trying and we are not kernel / device tree experts. Its best to use the 4.9 for now.