miksadikov / kvim3TPM

Сonnecting and using the TPM (Trusted Platform Module) on Khadas VIM3 SBC
1 stars 0 forks source link

Trying the same things on Khadas Edge V #1

Open Eznopot opened 3 days ago

Eznopot commented 3 days ago

Hello, I came across your Guide to using a TPM 2.0 module on Khadas VIM3. I'm trying to do the same thing but on a Khadas Edge V. I have no particular knowledge of linux kernel and hardware and having to transpose what you do in your guide, I can't manage to do part 2 of your guide on the Edge V, in particular, I'm trying to do option 2: "make an overlay, which will add the necessary functionality on top of the device tree. See the second option below.". But it doesn't work. I'd be very grateful if you'd take the time to help me or have a look. Thanks in advance

miksadikov commented 2 days ago

Hello, Please write in as much detail as possible about what you did and what didn’t work. Please provide log files, error messages, etc. Now, unfortunately, I don’t have Khadas VIM3 and TPM at hand, but I will try to help.

Eznopot commented 2 days ago

Hello, thank you for your reply. I will try to document as much as possible what we have done.

We have followed your recommendations concerning the linux kernel configuration (Step 1 of your guide):

Screenshot 2024-07-03 at 13 13 33 Screenshot 2024-07-03 at 13 14 38

After that we try the second option of the Step 2 of your guide: We use a Khadas Edge V and kernel 6.0 so we don't have overlay in the directory arch/arm64/boot/dts/rockchip. So we have created the overlays folder and i have created a tpm.dts file:

/dts-v1/;
/plugin/;

/ {
    fragment@0 {
        target = <&spi3>;

        __overlay__ {
            spidev@0 {
                status = "disabled";
            };
        };
    };

    fragment@1 {
        target = <&spi3>;

        __overlay__ {
            status = "okay";

            tpm_tis_spi:tpm@0 {
                status = "okay";
                compatible = "infineon,slb9670", "tcg,tpm_tis_spi";
                reg = <0>;
                spi-max-frequency = <43000000>;
            };
       };
   };
};

I set the target to &spi3 because I didn't find any reference to &spicc1 in other .dts or .dtbfile. Because the folder overlays don't exist I also copy/paste spi3.dts from the 4.4 kernel in the overlays folder:

/dts-v1/;
/plugin/;

/ {
    fragment@0 {
        target = <&spi3>;
        __overlay__ {
            status = "okay";
        };
    };
};

I have modify the Makefile to compile all .dts in the folder overlays.

After we use Fenix to compile an Ubuntu server image by doing make:

***********************PARAMETERS************************
Fenix Version: 1.6.9.1
Khadas Board: Edge1
Uboot Version: mainline
Uboot Configuration: khadas-edge-captain-rk3399_defconfig
Uboot Branch: master
Linux Version: mainline
Linux Configuration: edges_defconfig
Linux DTB: /arch/arm64/boot/dts/rockchip/rk3399-khadas-edge.dtb
Linux Branch: khadas-linux-6.0.y
Distribution: Ubuntu
Distribution Release: focal
Distribution Type: server
Distribution Arch: arm64
Install Type: SD-USB
Final Image: edge1-ubuntu-20.04-server-linux-6.0-fenix-1.6.9.1-240703-develop.img
Compressed Image: edge1-ubuntu-20.04-server-linux-6.0-fenix-1.6.9.1-240703-develop.img.xz
*********************************************************

It generate the image and we flash it on the SD Card. The compilation create these .dtbo in the path:

image (2)

After the first boot we modify the /boot/env.txt and set:

image (1)

But after a reboot, command dmesg | grep -I tpm don't print anything and /dev/tpm0 don't appear.

Note: We actually use this TPM: Asus TPM 2.0 SPI

Thanks in adavance for your help.

miksadikov commented 1 day ago

As far as I understand, the manufacturer (Khadas) already provides a overlay for spi3. This overlay is mentioned in the /boot/env.txt file - Device tree overlays: spi3. You need to decompile overlay for spi3 using a device tree compiler and see how spi3 is described there. Based on this overlay for spi3 you need to prepare an overlay for tpm. There is no need to write your own overlay file for spi3. Search the build system and send me an overlay for spi3. Remove your own overlay for spi3 in build system.

If nothing works with overlays, you can simply edit file rk3399-khadas-edge.dtsi (or something like that) - add tpm node there and disable spidev.