liamhays / rk3566-mcu

Reverse engineering, notes, and example code for the RISC-V MCU inside the RK3566 SoC
GNU General Public License v3.0
17 stars 4 forks source link

System freezes on hello_world example #1

Closed Porro66 closed 9 months ago

Porro66 commented 9 months ago

Hi, Do you know why system might freeze on hello_world example after it has completed? I.e. after 0xdeadbeaf message was shown on screen (dmesg -n 8 applied)? Does MCU require anything to be prepared on u-boot stage in regard on clock or other initialization? My board is Radxa-3a and its u-boot doesn't have MCU support built in yet. Thanks.

liamhays commented 9 months ago

There is no hello_world example, do you mean the hello_mailbox example?

What kernel version and Linux distro are you running?

There is no requirement for u-boot to do anything. It is possible that you're on a different version of ARM TF-A than the one distributed with Plebian for the Quartz64 (the board I have), and that your version of TF-A needs SYSTEM_SRAM to stay intact.

Porro66 commented 9 months ago

Hi, You are right - hello_mailbox is a subject ;-) I'm running

rock@rock-3a:~$ uname -a
Linux rock-3a 5.10.160-1-rk356x #1 SMP Sun Oct 8 11:04:23 UTC 2023 aarch64 GNU/Linux

It's Debian 11 for Radxa Rock-3a I see you point in regard of SYSTEM_SRAM. I'll check what TF-A version is used on ROck-3A and compare it to Quartz64 one. Thank you

Porro66 commented 9 months ago

I've checked what revision of TF-A is used on Quartz64 and on Rock-3A boards. According to rkbin - both use the same flavor - rk35, but surely divverent binaries. I'll try to debug the cause.

liamhays commented 9 months ago

Any luck with this? I haven't had a chance to test again (and I don't have a 5.10 kernel for the Quartz64 anyway). Kernel 5.10 is very old, are you using a vendor-provided distro?

Can you try DietPi or another distro that might have a newer kernel? I made all this code on mainline kernel 6.1 LTS and like I mentioned, the only freezes I got happened when I trampled on PMU_SRAM. I don't actually know that TF-A is the reason for the freezes, but it would make sense since TF-A serves as sort of a supervisor.

Porro66 commented 9 months ago

Hi, No, I haven't moved forward anyhow yet :-(. It's partially my pet project and I work on it when I have time to spare ;-) I like your idea to try another kernel. Definetely we are not limited with 5.10 as a mandatory kernel. This weekend I'll do testing with 6.1 mainline. We will see if this helps on Rock 3A. Unfortunately, currenty we are limited with Rock 3A as a hardware, but softwarewise there are no any restrictions. In regard of TF-A, I think we have to apply some pressure to Rockchip to release TF-A code as an opensource. They promised to do so long time ago, and yet there is nothing.

liamhays commented 9 months ago

I just tested hello_mailbox on Plebian and it didn't freeze. My uname -a is

Linux citrine 6.1.0-13-arm64 #1 SMP Debian 6.1.55-1 (2023-09-29) aarch64 GNU/Linux

Rockchip is working on merging RK3566/RK3568 support in TF-A: https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/16952 but I've looked through it and it doesn't even touch the MCU. However, I also don't really trust that this merge request is actually the same code as the TF-A binaries distributed by Rockchip---that would be too easy :).

Porro66 commented 9 months ago

Hi, I've built hello_mailbox example for the kernel 6.5 - it works fine. Thanks a lot. I.e. kernels 5.x don't fit MCU purpose, something is different there and prevents MCU against proper functioning.