Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opi3b: fix mainline uboot with vendor kernel and fix uwe5622 bt for rk35xx #7025

Merged
merged 2 commits into from
Sep 13, 2024

Conversation

amazingfate
Copy link
Contributor

@amazingfate amazingfate commented Aug 4, 2024

Description

6.1 vendor kernel is not bootable on opi3b. There is a post in forum: https://forum.armbian.com/topic/36332-orangepi3b-kernel-panic-when-trying-to-boot-with-the-new-vendor-kernel6143/#comment-186436

Opi3b is using mainline uboot for all branches which is not compatibale with vendor kernel's npu, so I use radxa's rockchip uboot instead and limit mainline uboot to branch edge. I find that setting vdd_npu with property regulator-always-on will fix the issue.
There is also a missing uwe5622 patch on rk35xx family, which will cause kernel panic of sprdbt_tty kernel module.

Please describe the tests that you ran to verify your changes. Please also note any relevant details for your test configuration.

  • ./compile.sh BOARD=orangepi3b BRANCH=vendor BUILD_MINIMAL=no DEB_COMPRESS=xz KERNEL_CONFIGURE=no RELEASE=noble KERNEL_GIT=shallow BUILD_DESKTOP=yes DESKTOP_APPGROUPS_SELECTED= DESKTOP_ENVIRONMENT=gnome DESKTOP_ENVIRONMENT_CONFIG_NAME=config_base
  • Opi3b vendor kernel can boot now

Checklist:

Please delete options that are not relevant.

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

@amazingfate amazingfate requested review from a team and igorpecovnik as code owners August 4, 2024 04:03
@github-actions github-actions bot added size/large PR with 250 lines or more Hardware Hardware related like kernel, U-Boot, ... Framework Framework components Patches Patches related to kernel, U-Boot, ... labels Aug 4, 2024
EvilOlaf
EvilOlaf previously approved these changes Aug 4, 2024
Copy link
Member

@EvilOlaf EvilOlaf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@github-actions github-actions bot added size/small PR with less then 50 lines and removed size/large PR with 250 lines or more labels Aug 4, 2024
@amazingfate amazingfate changed the title opi3b: use radxa's uboot for branch vendor and fix uwe5622 bt for rk35xx opi3b: fix mainline uboot with vendor kernel and fix uwe5622 bt for rk35xx Aug 4, 2024
@amazingfate amazingfate marked this pull request as draft August 4, 2024 05:50
chainsx
chainsx previously approved these changes Aug 6, 2024
@amazingfate
Copy link
Contributor Author

This pr is marked draft because I still get npu kernel panic with both mainline and vendor uboot. A bad hacking is disabling npu in kernel's devicetree but I think there is hope to solve this issue.

TheSnowfield
TheSnowfield previously approved these changes Aug 6, 2024
@igorpecovnik igorpecovnik added 08 Milestone: Third quarter release Needs review Seeking for review labels Aug 12, 2024
@Kwiboo
Copy link
Contributor

Kwiboo commented Aug 14, 2024

@amazingfate support for Orange Pi 3B (v1.1 and v2.1) has now been merged to U-Boot master and will be included in v2024.10-rc3 (scheduled for Monday). Please note that U-Boot use a single build target (orangepi-3b-rk3566) and will set fdtfile to match the board revision at runtime, rockchip/rk3566-orangepi-3b-v1.1.dtb or rockchip/rk3566-orangepi-3b-v2.1.dtb, should match the DT that was merged in Linux kernel v6.11-rc1.

Please try with latest U-Boot master and Kwiboo/u-boot-rockchip@4dbfa9f to see if your NPU issue on vendor kernel is resolved.

@amazingfate
Copy link
Contributor Author

@Kwiboo I tried master branch of https://github.com/u-boot/u-boot.git with your vdd_npu patch. But there is still kernel panic.

[   13.513898] Kernel panic - not syncing: panic_on_set_idle set ...
[   13.514482] CPU: 3 PID: 1 Comm: swapper/0 Not tainted 6.1.75-vendor-rk35xx #1
[   13.515146] Hardware name: Rockchip R  13.515624] Call trace:
[   13.515867]  dump_backtrace+0xe0/0x53]  dump_stack_lvl+0x6c/0x88
[   13.516915]  dump_stack+0x18/0ockchip_pmu_set_idle_request+0x10c/0x1d0
[   13.518024]  rockch_on+0x24/0x38
[   13.518816]  _genpd_power_on+0xbc/0x14c
[   1 __genpd_dev_pm_attach+0x1a0/0x274
[   13.519965]  genpd_dev_pm20/0x3c
[   13.520756]  platform_probe+0x58/0xc0
[   13.521114obe_device+0x140/0x158
[   13.521893]  driver_probe_device+0x48[   13.522660]  bus_for_each_dev+0x7c/0xcc

Here is armbian build log: https://paste.armbian.com/cojaxahexo

@Kwiboo
Copy link
Contributor

Kwiboo commented Aug 15, 2024

I tried master branch of https://github.com/u-boot/u-boot.git with your vdd_npu patch. But there is still kernel panic.

Hum, I am not seeing this with a vendor kernel built from the armbian kernel tree.

Is the vdd_npu regulator enabled in U-Boot on your board before linux is booted?

U-Boot 2024.10-rc2 (Aug 15 2024 - 10:31:50 +0000)

[...]

Model: Xunlong Orange Pi 3B v1.1

[...]

=> regulator status
Name                 Enabled            uV         mA Mode       Status
vdd_logic            enabled        900000          - -          0
vdd_gpu              enabled        900000          - -          0
vcc_ddr              enabled        500000          - -          0
vdd_npu              enabled        900000          - -          0
[...]

When vdd_npu is enabled there is no freeze and following can be seen:

[  111.386858] rockchip,bus bus-npu: bin=0
[  111.386901] rockchip,bus bus-npu: Failed to get leakage
[  111.386961] rockchip,bus bus-npu: pvtm = 92720, from nvmem
[  111.386981] rockchip,bus bus-npu: pvtm-volt-sel=2
[  111.390771] rockchip,bus bus-npu: avs=0
[  111.460283] RKNPU fde40000.npu: Adding to iommu group 0
[  111.460685] RKNPU fde40000.npu: RKNPU: rknpu iommu is enabled, using iommu mode
[  111.460888] RKNPU fde40000.npu: can't request region for resource [mem 0xfde40000-0xfde4ffff]
[  111.460931] RKNPU fde40000.npu: error -ENXIO: IRQ npu_irq not found
[  111.461721] RKNPU fde40000.npu: bin=0
[  111.461770] RKNPU fde40000.npu: leakage=6
[  111.461805] RKNPU fde40000.npu: pvtm = 92720, from nvmem
[  111.461820] RKNPU fde40000.npu: pvtm-volt-sel=3
[  111.461830] RKNPU fde40000.npu: soc version=0, speed=3
[  111.462418] RKNPU fde40000.npu: avs=0
[  111.462556] RKNPU fde40000.npu: l=0 h=2147483647 hyst=5000 l_limit=0 h_limit=0 h_table=0

Without the patch and vdd_npu is disabled running regulator status I get following trying to boot:

=> reglator status
Name                 Enabled            uV         mA Mode       Status
vdd_logic            enabled        900000          - -          0
vdd_gpu              enabled        900000          - -          0
vcc_ddr              enabled        500000          - -          0
vdd_npu              disabled       500000          - -          0
[...]
[   26.737686] rockchip-pm-domain fdd90000.power-management:power-controller: failed to get ack on domain 'npu', target_idle = 0, target_ack = 0, val=0x1ee
[   26.737724] Kernel panic - not syncing: panic_on_set_idle set ...
[   26.739443] CPU: 3 PID: 1 Comm: swapper/0 Not tainted 6.1.75 #1
[   26.739982] Hardware name: Rockchip RK3566 OPi 3B (DT)
[   26.740446] Call trace:
[   26.740679]  dump_backtrace+0xd8/0x130
[   26.741036]  show_stack+0x1c/0x30
[   26.741346]  dump_stack_lvl+0x60/0x78
[   26.741690]  dump_stack+0x14/0x2c
[   26.741996]  panic+0x17c/0x344
[   26.742285]  rockchip_pmu_set_idle_request+0x1f0/0x210
[   26.742759]  rockchip_pd_power+0x3cc/0x720
[   26.743135]  rockchip_pd_power_on+0x28/0x30
[   26.743522]  _genpd_power_on+0x94/0x17c
[   26.743881]  genpd_power_on+0xac/0x164
[   26.744227]  __genpd_dev_pm_attach+0x104/0x2a0
[   26.744636]  genpd_dev_pm_attach+0x60/0x70
[   26.745013]  dev_pm_domain_attach+0x24/0x34
[   26.745406]  platform_probe+0x54/0xc4
[   26.745750]  really_probe+0xc4/0x3e0
[   26.746080]  __driver_probe_device+0x80/0x160
[   26.746480]  driver_probe_device+0x40/0x110

@amazingfate
Copy link
Contributor Author

I can't check uboot shell now, after pressing key to stop auto boot, I can't input anything.

U-Boot 2024.10-rc2-armbian-2024.10-rc2-S4dbf-P0000-H264e-V155b-Bda0a-R448a+ (Aug 16 2024 - 00:18:53 +0800)

Model: Xunlong Orange Pi 3B v1.1
DRAM:  4 GiB
regulator@40: read error for register: 0x3!
Core:  322 devices, 32 uclasses, devicetree: separate
MMC:   mmc@fe2b0000: 1, mmc@fe2c0000: 2, mmc@fe310000: 0
Loading Environment from nowhere... OK
In:    serial@fe660000
Out:   serial@fe660000
Err:   serial@fe660000
Model: Xunlong Orange Pi 3B v1.1
can't get vref-supply: -121
rockchip_dnl_key_pressed: adc_channel_single_shot fail!
Net:   eth0: ethernet@fe010000
Hit any key to stop autoboot:  0 
=>

Maybe I have a broken serial module.

@amazingfate
Copy link
Contributor Author

vdd_npu is disabeld, here is the regulator status from command regulator status I added to /boot/boot.scr:

Name                 Enabled            uV         mA Mode       Status
vdd_logic            disabled            -          - -          -121
vdd_gpu              disabled            -          - -          -121
vcc_ddr              disabled            -          - -          -121
vdd_npu              disabled            -          - -          -121
vcc_1v8              disabled            -          - -          -121
vdda0v9_image        disabled            -          - -          -121
vdda_0v9             disabled            -          - -          -121
vdda0v9_pmu          disabled            -          - -          -121
vccio_acodec         disabled            -          - -          -121
vccio_sd             disabled            -          - -          -121
vcc3v3_pmu           disabled            -          - -          -121
vcca_1v8             disabled            -          - -          -121
vcca1v8_pmu          disabled            -          - -          -121
vcca1v8_image        disabled            -          - -          -121
vcc_3v3              disabled            0          - -          -121
vcc3v3_sd            disabled            0          - -          -121
regulator@40: read error for register: 0x3!
regulator@40: read error for register: 0x0!
vdd_cpu              enabled             -          - -          -5
vcc3v3_pcie30        disabled      3300000          - -          0
vcc3v3_sys           enabled       3300000          - -          0
vcc5v0_sys           enabled       5000000          - -          0
vcc5v0_usb_host      disabled      5000000          - -          0
vcc5v0_usb_otg       disabled      5000000          - -          0

@amazingfate
Copy link
Contributor Author

I tried to run regulator dev vdd_npu; regulator enable; regulator value 850000; in boot.scr, but I got:

Can't get the regulator: vdd_npu!
Error: -121 (Remote I/O error)
First, set the regulator device!
First, set the regulator device!

@Kwiboo
Copy link
Contributor

Kwiboo commented Aug 16, 2024

regulator@40: read error for register: 0x3!

Looks like there is an issue to communicate with the PMIC vdd_cpu over I2C. As a result this seem to also cause the PMIC regulators to fail being probed.

Is there something special regarding your board, is it a dev or pre-production sample, or could Orange Pi have used different PMIC vdd_cpu (with different i2c addr) on different production runs? I have been testing on a v1.1.1 and v2.1 board.

Is it possible to share your U-Boot build artifacts?, I can run a quick test on my board to see if it could be related to the U-Boot build or if it could be an issue/difference with the boards.

Another thought, is the U-Boot SPL also the new mainline version? Or could it be some interoperability issue using vendor U-Boot SPL and mainline U-Boot proper.

@Kwiboo
Copy link
Contributor

Kwiboo commented Aug 16, 2024

@amazingfate looks like there may be some discrepancies in use of part for vdd_cpu.

Schematic mention use of TCS4525 (addr: 0x1Ch) or RK860 (addr: 0x40h), my board has a SYR827 (addr: 0x40h).

Please try with adding following in rk3566-orangepi-3b-u-boot.dtsi:

/delete-node/ &vdd_cpu;

or disable the CONFIG_DM_PMIC_FAN53555 Kconfig option.

@amazingfate
Copy link
Contributor Author

@Kwiboo I'm using a v1.1 board.
Here is the uboot I built with FAN53555 disabled: https://cdn.haguro.top/share/linux-u-boot-orangepi3b-vendor_24.8.0-trunk_arm64__2024.10-rc2-Sd517-P7511-H264e-V155b-Bda0a-R448a.deb

After disabling FAN53555 there is no error of regulator@40, but I still can't enable vdd_npu, same error Error: -121 (Remote I/O error). Maybe I really have a bad board.

@Kwiboo
Copy link
Contributor

Kwiboo commented Aug 16, 2024

Here is the uboot I built with FAN53555 disabled

Thanks, I will test it on my board and get back with results.

After disabling FAN53555 there is no error of regulator@40, but I still can't enable vdd_npu, same error Error: -121 (Remote I/O error).

Very strange, so maybe the vdd_cpu is not at fault and instead there are some unexplained I2C communication issue, causing problem for both vdd_cpu and the PMIC.

there may be some discrepancies in use of part for vdd_cpu.

The linux-orangepi orange-pi-5.10-rk35xx kernel DT reference use of a SYR827 at 0x40h and the v2.1 schematics has changed to reference SYR827 / RK860 to match this, however the u-boot-orangepi v2017.09-rk3588 u-boot DT indicate it has a TCS4525 at 0x1Ch. So the upstream vdd_cpu / regulator@40 is likely correct and I expect it to work in both U-Boot and Linux.

@Kwiboo
Copy link
Contributor

Kwiboo commented Aug 16, 2024

@amazingfate I have now tested your build and it seem to work on my v1.1.1 and v2.1 boards, output from my v1.1.1 board:
Not really sure what the issue could be with your board.

U-Boot SPL 2024.10-rc2-armbian-2024.10-rc2-Sd517-P7511-H264e-V155b-Bda0a-R448a+ (Aug 16 2024 - 19:48:21 +0800)
Trying to boot from MMC2
## Checking hash(es) for config config-2 ... OK
## Checking hash(es) for Image atf-1 ... sha256+ OK
## Checking hash(es) for Image u-boot ... sha256+ OK
## Checking hash(es) for Image fdt-2 ... sha256+ OK
## Checking hash(es) for Image atf-2 ... sha256+ OK
## Checking hash(es) for Image atf-3 ... sha256+ OK
## Checking hash(es) for Image atf-4 ... sha256+ OK
## Checking hash(es) for Image atf-5 ... sha256+ OK
## Checking hash(es) for Image atf-6 ... sha256+ OK
INFO:    Preloader serial: 2
NOTICE:  BL31: v2.3():v2.3-645-g8cea6ab0b:cl, fwver: v1.44
NOTICE:  BL31: Built : 16:36:43, Sep 19 2023
INFO:    GICv3 without legacy support detected.
INFO:    ARM GICv3 driver initialized in EL3
INFO:    pmu v1 is valid 220114
INFO:    l3 cache partition cfg-0
INFO:    dfs DDR fsp_param[0].freq_mhz= 1056MHz
INFO:    dfs DDR fsp_param[1].freq_mhz= 324MHz
INFO:    dfs DDR fsp_param[2].freq_mhz= 528MHz
INFO:    dfs DDR fsp_param[3].freq_mhz= 780MHz
INFO:    Using opteed sec cpu_context!
INFO:    boot cpu mask: 0
INFO:    BL31: Initializing runtime services
WARNING: No OPTEE provided by BL2 boot loader, Booting device without OPTEE initialization. SMC`s destined for OPTEE will return SMC_UNK
ERROR:   Error initializing runtime service opteed_fast
INFO:    BL31: Preparing for EL3 exit to normal world
INFO:    Entry point address = 0xa00000
INFO:    SPSR = 0x3c9


U-Boot 2024.10-rc2-armbian-2024.10-rc2-Sd517-P7511-H264e-V155b-Bda0a-R448a+ (Aug 16 2024 - 19:48:21 +0800)

Model: Xunlong Orange Pi 3B v1.1
DRAM:  4 GiB
PMIC:  RK809 (on=0x40, off=0x00)
Core:  320 devices, 32 uclasses, devicetree: separate
MMC:   mmc@fe2b0000: 1, mmc@fe2c0000: 2, mmc@fe310000: 0
Loading Environment from nowhere... OK
In:    serial@fe660000
Out:   serial@fe660000
Err:   serial@fe660000
Model: Xunlong Orange Pi 3B v1.1
Net:   eth0: ethernet@fe010000
Hit any key to stop autoboot:  0
=> regulator status
Name                 Enabled            uV         mA Mode       Status
vdd_logic            enabled        900000          - -          0
vdd_gpu              enabled        900000          - -          0
vcc_ddr              enabled        500000          - -          0
vdd_npu              enabled        900000          - -          0
vcc_1v8              enabled       1800000          - -          0
vdda0v9_image        disabled       600000          - -          0
vdda_0v9             enabled        900000          - -          0
vdda0v9_pmu          enabled        900000          - -          0
vccio_acodec         enabled       3300000          - -          0
vccio_sd             enabled       3300000          - -          0
vcc3v3_pmu           enabled       3300000          - -          0
vcca_1v8             enabled       1800000          - -          0
vcca1v8_pmu          enabled       1800000          - -          0
vcca1v8_image        disabled       600000          - -          0
vcc_3v3              enabled       3300000          - -          0
vcc3v3_sd            enabled       3300000          - -          0
vcc3v3_pcie30        disabled      3300000          - -          0
vcc3v3_sys           enabled       3300000          - -          0
vcc5v0_sys           enabled       5000000          - -          0
vcc5v0_usb_host      disabled      5000000          - -          0
vcc5v0_usb_otg       disabled      5000000          - -          0

@amazingfate
Copy link
Contributor Author

Here is the uboot I built with FAN53555 disabled: https://cdn.haguro.top/share/linux-u-boot-orangepi3b-vendor_24.8.0-trunk_arm64__2024.10-rc2-Sd517-P7511-H264e-V155b-Bda0a-R448a.deb

@rpardini do you have time testing this uboot with 6.1 vendor kernel? I want to know if this is a issue of my board, or all v1.1 opi3b have this issue.

@rpardini
Copy link
Member

@rpardini do you have time testing this uboot with 6.1 vendor kernel? I want to know if this is a issue of my board, or all v1.1 opi3b have this issue.

My opi3b is away on a mission -- unsure if or when it will come back -- sorry.

@amazingfate
Copy link
Contributor Author

Update uboot to v2024.10-rc3 and add dts patch enabling vdd_gpu at uboot.
@Kwiboo would you mind testing this prebuilt uboot?
https://cdn.haguro.top/share/linux-u-boot-orangepi3b-vendor_24.11.0-trunk_arm64__2024.10-rc3-Sd11a-Pd5fb-H264e-V155b-Bda0a-R448a.deb
It's unfortunate that i2c of my board is broken at uboot. If you can confirm this can fix other version of opi3b, we can just merge it.

@amazingfate amazingfate marked this pull request as ready for review August 27, 2024 07:38
@defencedog
Copy link
Collaborator

@amazingfate @Kwiboo allow me to do all the testing. Please upload .img & i can provide test results. My SBC is OPi3b v2.1

@amazingfate
Copy link
Contributor Author

@amazingfate @Kwiboo allow me to do all the testing. Please upload .img & i can provide test results. My SBC is OPi3b v2.1

You can checkout my branch and build image by yourself.

@defencedog
Copy link
Collaborator

@amazingfate @Kwiboo allow me to do all the testing. Please upload .img & i can provide test results. My SBC is OPi3b v2.1

You can checkout my branch and build image by yourself.

can you please specify link?

@amazingfate
Copy link
Contributor Author

@amazingfate @Kwiboo allow me to do all the testing. Please upload .img & i can provide test results. My SBC is OPi3b v2.1

You can checkout my branch and build image by yourself.

can you please specify link?

https://github.com/amazingfate/build/tree/opi3b-vendor-uboot

@igorpecovnik
Copy link
Member

This ready?

@defencedog
Copy link
Collaborator

defencedog commented Sep 10, 2024

@igorpecovnik partially what is resolved

  • Booting of Armbian kisak images using this new board-config file
    Prepared image / kernel debs / uboot debs on mega.nz

@igorpecovnik
Copy link
Member

Don't have any of those boards and am unable to pay attention to details of all PRs, lost this battle years ago :) ... add "Ready to merge" when / if you think its ready to go.

@amazingfate
Copy link
Contributor Author

Soc of my board is burned and I will get it back tomorrow. I will test this pr and merge it if it is fine.

@amazingfate
Copy link
Contributor Author

My opi3b v1.1 comes back. Just tested on it and vendor kernel boots fine.

@amazingfate amazingfate added the Ready to merge Reviewed, tested and ready for merge label Sep 12, 2024
@amazingfate amazingfate removed the Needs review Seeking for review label Sep 13, 2024
@amazingfate amazingfate merged commit afe644f into armbian:main Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
08 Milestone: Third quarter release Framework Framework components Hardware Hardware related like kernel, U-Boot, ... Patches Patches related to kernel, U-Boot, ... Ready to merge Reviewed, tested and ready for merge size/small PR with less then 50 lines
Development

Successfully merging this pull request may close these issues.

8 participants