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

BigTreeTech CB2/Pi2 config #6860

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

JohnTheCoolingFan
Copy link
Contributor

@JohnTheCoolingFan JohnTheCoolingFan commented Jul 1, 2024

Description

Added patches and config for BigTreeTech CB2/Pi2

GitHub issue reference:
Jira reference number AR-2332

How Has This Been Tested?

Build and load on BTT Pi 2, test peripherals and see how it runs for 5 minutes

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

@github-actions github-actions bot added size/large PR with 250 lines or more Hardware Hardware related like kernel, U-Boot, ... Patches Patches related to kernel, U-Boot, ... labels Jul 1, 2024
@ColorfulRhino
Copy link
Collaborator

ColorfulRhino commented Jul 1, 2024

Not sure which board you used as template for the board config, but you don't need most of this stuff. Try using this as an example:

https://github.com/armbian/build/blob/main/config/boards/nanopi-r5c.csc (minus the asound and extlinux line, use BOOTBRANCH="tag:v2024.07-rc5" and BOOTCONFIG="generic-rk3568_defconfig" it works well for rk3568/rk3566)

Also, you have put your patches into rockchip instead of rockchip64 😉

And to prevent duplication, you could use a symlink for the dts file to point from one to the other if they're exactly the same, so you only have one dts and the other one is just a symlink (example: https://github.com/armbian/build/tree/main/patch/kernel/rockchip-rk3588-collabora/dt)

@rpardini
Copy link
Member

rpardini commented Jul 2, 2024

@JohnTheCoolingFan please pick armsurvivors@779b4ee -- you told me the other day I could drop it, but you seem to have forgotten?

@ColorfulRhino that addresses most of your comments, I think?

@rpardini rpardini added the Work in progress Unfinished / work in progress label Jul 2, 2024
@JohnTheCoolingFan
Copy link
Contributor Author

@JohnTheCoolingFan please pick armsurvivors@779b4ee -- you told me the other day I could drop it, but you seem to have forgotten?

@ColorfulRhino that addresses most of your comments, I think?

I did pick it, just didn't push onto a remote branch and it's not used in this branch. This is subject to change during the development of the PR. Pushed it to btt-cb2-rpardini. I have a number of branches for btt cb2 and cb1 and was organizing them yesterday, deleting unneeded ones. Will have to reevaluate branch this PR currently uses vs others I have.

@rpardini
Copy link
Member

rpardini commented Jul 2, 2024

it's not used in this branch

Yeah, but reviews are costly -- please don't waste our time, it's precious. Thanks.

@JohnTheCoolingFan
Copy link
Contributor Author

Yeah, but reviews are costly -- please don't waste our time, it's precious. Thanks.

When the PR is ready for review, I'll mark it as such. For now - it's a draft.

@rpardini
Copy link
Member

rpardini commented Jul 2, 2024

Well I sent #6874 (also draft) - I don't (or plan to) have the board

@JohnTheCoolingFan
Copy link
Contributor Author

Switched it to the @rpardini config. The built image does boot but there is no hdmi output, no ethernet connection and I still can't get proper input via UART pins. I don't have dedicated usb-to-uart converters yet and have been using a chinese arduino nano clone with a ch340 chip and the MCU reset pin tied to ground. I can get board's output butt can't input anything.

@JohnTheCoolingFan
Copy link
Contributor Author

Noticed that BTT had a custom armbianEnv.txt and there was overlay=hdmi, tried setting this in the image, didn't make the hdmi work.

I'm getting out of ideas. The device tree is same, based on the same kernel, so why is it not giving any output? The config is set to have output on both serial and display. And also Ethernet doesn't work even though it probably uses the same exact driver (based on 6.6 kernel).
Some help would really be appreciated. I can probably safely use an arduino to read serial output but not send until a proper usb-uart adapter comes in.

@JohnTheCoolingFan
Copy link
Contributor Author

Tried vendor's image, a minimal Armbian build. It had a lot of additional device tree overlays, including hdmi, which did get me a working hdmi output, but simply putting overlays=hdmi doesn't enable that output on the armbian build of this commit.
Also, I couldn't get any hardware UART from it even with a dedicated USB to UART adapter bases on a FT232RL chip. It didn't work on the vendor image and didn't work on the PR's commit build, even trying different UARTs and speeds (25000000, 15000000, 1500000, 115200, 9600).

@igorpecovnik
Copy link
Member

but simply putting overlays=hdmi doesn't enable that output on the armbian build of this commit.

What if you put HDMI to device tree?

@JohnTheCoolingFan
Copy link
Contributor Author

Ok, I finally got some progress with getting a tty. I shouldn't have traced down the gpio pins from rk3566 datasheet, the tx/rx pins are the same as in Btt Pi (CB1) or CM4. The pins are not marked as uart in the official manual, which just makes it extremely confusing. I now have a fully functional tty and can debug problems further.

Alright, so now I would like to first set up ethernet so I don't have to use uart as often. In the current config, the board is having problems setting up ethernet:

[   23.648519] rk_gmac-dwmac fe010000.ethernet eth0: Register MEM_TYPE_PAGE_POOL RxQ-0
[   23.650924] rk_gmac-dwmac fe010000.ethernet eth0: PHY [stmmac-0:00] driver [YT8531 Gigabit Ethernet] (irq=POLL)
[   24.651122] rk_gmac-dwmac fe010000.ethernet: Failed to reset the dma
[   24.651145] rk_gmac-dwmac fe010000.ethernet eth0: stmmac_hw_setup: DMA engine initialization failed
[   24.651152] rk_gmac-dwmac fe010000.ethernet eth0: __stmmac_open: Hw setup failed
[   25.189408] rk_gmac-dwmac fe010000.ethernet eth0: Register MEM_TYPE_PAGE_POOL RxQ-0
[   25.191615] rk_gmac-dwmac fe010000.ethernet eth0: PHY [stmmac-0:00] driver [YT8531 Gigabit Ethernet] (irq=POLL)
[   26.195094] rk_gmac-dwmac fe010000.ethernet: Failed to reset the dma
[   26.195115] rk_gmac-dwmac fe010000.ethernet eth0: stmmac_hw_setup: DMA engine initialization failed
[   26.195122] rk_gmac-dwmac fe010000.ethernet eth0: __stmmac_open: Hw setup failed

@JohnTheCoolingFan
Copy link
Contributor Author

Putting the boot log gist here just for the record: https://gist.github.com/JohnTheCoolingFan/5df87cc4b87298d6bc21e046bfcff5f6

@rpardini
Copy link
Member

  • current using vendor u-boot due to "magic gremlins" but otherwise board works fine (Ethernet, serial, nvme, emmc, etc)
  • edge is left for experiments on trying to get mainline u-boot working.

I'd say having a current (with vendor u-boot and mainline kernel) that enables people to get going is good enough to merge, if you're willing to squash some/most of those 28 commits ;-) And yes you can keep on working on edge calmly.

It's really important to send the contributions upstream, as there are way more people who can help on the kernel/u-boot mailing lists.

@JohnTheCoolingFan
Copy link
Contributor Author

I've sent the current 6.6 kernel device tree to the linux-rockchip mailing list as a patch and subscribed to the mailing list. I did not receive any replies on it, but the patch did get posted, so I have no idea whether it will get accepted or not. I will continue improving the device tree, benefitting all branches, both current and edge. There is some stuff missing compared to the vendor's image based on 4.19. There are some features I can't test, like csi and dsi interfaces, but most of the stuff is not problematic. I will squash some of the patches and commits.

@JohnTheCoolingFan
Copy link
Contributor Author

Alright, a person on Discord messaged me about his usage of bigtreetech pi 2 6.11 with an image based on orangepi 3b. I've tried his dtb, and it works without the freezing issue. I will work on adding the proper dts.

@JohnTheCoolingFan
Copy link
Contributor Author

Oh, just realized adding the device tree files would be helpful:
rk3566-bigtreetech-pi2.dtb.gz
rk3566-bigtreetech-pi2-by-Cowboy-full.dts.txt

@JohnTheCoolingFan
Copy link
Contributor Author

JohnTheCoolingFan commented Nov 20, 2024

With the diff I was provided, I could make a raw-ish device tree from a kernel 6.6 orangepi-3b device tree:
rk3566-bigtreetech-pi2-by-Cowboy-from-diff.dts.txt
and rk3566-orangepi-3b-full.dts.txt for reference

These device trees are pretty raw and as such are not suitable to be put into the patch folder I think, so I am working on a proper device tree, that is using the includes and labels instead of raw phandles.
I still had no good results from this, any help with this is appreciated.

@JohnTheCoolingFan JohnTheCoolingFan added Work in progress Unfinished / work in progress and removed Needs review Seeking for review labels Nov 21, 2024
@JohnTheCoolingFan
Copy link
Contributor Author

JohnTheCoolingFan commented Dec 4, 2024

Finally got around to making a more meaningful and human-readable "diff" of the patch, so that it can be used to use an existing orangepi 3b device tree and patched. No actual patch right now, just a human-readable summary. But I wish I could have some program that automatically resolves phandles at least.

  • CPU voltage regulator vcc_cpu:
    • renamed syr837@40 --> tcs4525@1c
    • reg: <0x40> --> <0x1c>
    • compatible: silergy,syr827 --> tcs,tcs452x (should be tsc,tsc4525 in 6.6)
  • pwm:
    • pwm0 pinctrl-0: <&pwm0m0-pins> --> <&pwm0m1-pins>
    • pwm7: disabled
    • pwm12 pinctrl-0: <&pwm12m0-pins> --> <&pwm12m1-pins>
    • pwm13 pinctrl-0: <&pwm13m0-pins> --> <&pwm13m1-pins>
    • pwm14 pinctrl-0: <&pwm14m0-pins> --> <&pwm14m1-pins>
    • pwm15 pinctrl-0: <&pwm15m0-pins> --> <&pwm15m1-pins>
  • Ethernet gmac1:
    • snps,reset-gpio: <&gpio3 RK_PC2 1> --> <&gpio0 RK_PC5 1>
    • reset-gpios: <&gpio0 RK_PB6 0> --> <&gpio1 RK_PB2 0>
  • sdmmc1:
    • Added rockchip,default-sample-phase = <0x5a> (90 in decimal)
    • Added sdio-wifi@1
  • sfc: removed flash@0
  • i2c:
    • i2c2 pinctrl-0: <&i2c2m0-xfer> --> <&i2c2m1-xfer>
    • i2c3: Added tft_tp: ns2009@48
  • spi:
    • spi1 pinctrl-0: <&spi1m0-cs0 &spi1m0-cs1 &spi1m0-pins> --> <&spi1m1-cs0 &spi1m1-pins>
    • spi1: added can_mcp2515: can-mcp2515@0
    • spi1: added tft_35: st7789v@1
    • spi3 pinctrl-0: <&spi3m0-cs0 &spi3m0-cs1 &spi3m0-pins> --> <&spi3m1-cs0 &spi3m1-pins>
  • uart:
    • uart1: added dma-names
    • uart1: added bluetooth
    • uart5 pinctrl-0: <&uart5m0-xfer> --> <&uart5m1-xfer>
    • uart7 pinctrl-0: <&uart7m0-xfer> --> <&uart7m2-xfer>
  • usb:
    • usb2phy0_host phy-supply: <&vbus> --> <&vcc5vc0-host-regulator &vcc5v0-otg-regulator>
    • usb2phy1_host phy-supply: <&vcc5v0_usb2t &vcc5v0_usb2b>
  • pinctrl:
    • Added bt:
      • bt_enable: bt-enable-h: <2 RK_PB7 0 &pcfg-pull-down>
      • bt_host_wake: bt-host-wake-l: <2 RK_PC1 0 &pcfg-pull-down>
      • bt_wake: bt-wake-l: <2 RK_PC0 0 &pcfg-pull-none>
    • sdio-pwrseq: added wifi_host_wake: wifi-host-wake-l: <2 RK_PB1 0 &pcfg-pull-down>
    • usb:
      • vcc5v0-host-en: <0 RK_PA6 0 &pcfg-pull-none> --> <0 RK_PB6 0 &pcfg-pull-none>
      • vcc5v0-otg-en: <0 RK_PA5 0 &pcfg-pull-none> --> <0 RK_PB5 0 &pcfg-pull-none>
      • added vcc5v0_usb2t_en: vcc5v0_usb2t-en: <3 RK_PD5 0 &pcfg-pull-none>
      • added vcc5v0_usb2b_en: vcc5v0-usb2b-en: <4 RK_PC4 0 &pcfg-pull-none>
    • work-led:
      • leds-gpio: <0 RK_PC0 0 &pcfg-pull-none> --> <0 RK_PB7 0 &pcfg-pull-none>
      • added blue_led: led-blue: <4 RK_PA1 0 &pcfg-pull-none>
    • pcie/pcie-drv: <0 RK_PB7 0 &pcfg-pull-none> --> <4 RK_PB1 0 &pcfg-pull-none>
    • added mcp2515_int_pin with mcp2515_int_pin: mcp2515_in_pin: <4 RK_PA3 0 &pcfg-pull-up>
  • leds:
    • original node's pinctrl-0 and pinctrl-names moved to led@1
    • added led@0:
      • gpios: <&gpio4 RK_PA1 1>
      • label: "power_led"
      • pinctrl-0: <&blue_led>
      • pinctrl-names: "default"
      • linux,default-trigger: "default-on"
    • led@1:
      • gpios: <&gpio0 RK_PC0 0> --> <&gpio0 RK_PB7 1>
      • pinctrl-0 and pinctrl-names of leds were moved here.
  • removed sprd-mtty
  • removed uwe-bsp
  • regulators:
    • vcc3v3-pcie-regulator gpio: <&gpio0 RK_PB7 0> --> <&gpio4 RK_PB1 0>
    • vcc5v0-host-regulator gpio: <&gpio0 RK_PA6 0> --> <&gpio0 RK_PB6 0>
    • vcc5v0-host-regulator regulator-name: "vcc5v0_host" --> "vcc5v0_host3"
    • vcc5v0-otg-regulator gpio: <&gpio0 RK_PA5 0> --> <&gpio0 RK_PB5 0>
    • vcc5v0-otg-regulator regulator-name: "vcc5v0_otg" --> vcc5v0_otg3"
    • added vcc5v0_usb2t: vcc5v0-usb2t-regulator:
      • pinctrl-0: <&vcc5v0_usb2t_en>
      • gpio: <&gpio3 RK_PD5 0>
      • regulator-name: "vcc5v0_usb2t"
      • otherwise inherit vcc5v0-otg-regulator
    • added vcc5v0_usb2b: vcc5v0-usb2b-regulator
      • pinctrl-0: <&vcc5v0_usb2b_en>
      • gpio: <&gpio4 RK_C4 0>
      • regulator-name: "vcc5v0_usb2b"
      • otherwise inherit vcc5v0-otg-regulator
    • added ext_cam_clk: ext-cam-clk:
      • clock-frequency: <25000000>
      • clock-output-names: ext_cam_clk
      • #clock-cells: <0>
    • added can_mcp2515_osc: can-mcp2515-osc:
      • clock-frequency: <8000000>
      • #clock-cells: <0>

I will now try to make a new device tree, based on orangepi-3b and inserted through the patches system.

@JohnTheCoolingFan
Copy link
Contributor Author

Yeah, I have a fully working device now. dmesg: https://paste.next.armbian.com/ofumurekuy

Will commit my changes and push, then can get to re-organizing and probably remove the tree that is currently in this PR at all.

@JohnTheCoolingFan
Copy link
Contributor Author

JohnTheCoolingFan commented Dec 4, 2024

For some reason the edge (6.12) won't output anything in the same serial port I've used before, maybe my serial/screen setup is messed up again, I don't know. I did change the compatible string for the tsc4525, but I don't even get the u-boot output, weird. I'll focus on current (6.6) for now.

Baked the branch to https://github.com/JohnTheCoolingFan/armbian-build/tree/btt-cb2-old-dts and rebasing this branch, dropping a lot of stuff.

@JohnTheCoolingFan JohnTheCoolingFan removed Work in progress Unfinished / work in progress Help needed We need your involvement labels Dec 4, 2024
@JohnTheCoolingFan
Copy link
Contributor Author

JohnTheCoolingFan commented Dec 4, 2024

Alright, removed the previous dts from history, replaced with new one, squashed a lot of commits during WIP stage, all that was left is these 2 commits instead of 20+. Ready for review.

@JohnTheCoolingFan
Copy link
Contributor Author

JohnTheCoolingFan commented Dec 4, 2024

For some reason the edge (6.12) won't output anything in the same serial port I've used before, maybe my serial/screen setup is messed up again

Nevermind, forgot to put the sd card in. Dmesg just in case: https://paste.next.armbian.com/inuvoyicoq

rpardini
rpardini previously approved these changes Dec 4, 2024
Copy link
Member

@rpardini rpardini left a comment

Choose a reason for hiding this comment

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

Dear John, what a journey. Congratulations. Merge at will.

@JohnTheCoolingFan
Copy link
Contributor Author

Oops, forgot to specify the board maintainer as myself.

@Prokopiev
Copy link

Great work! Can I ask you if hdmi is working? Tried to build your branch and no luck with output

@JohnTheCoolingFan
Copy link
Contributor Author

HDMI works for me on all kernel versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hardware Hardware related like kernel, U-Boot, ... Needs review Seeking for review Patches Patches related to kernel, U-Boot, ... size/large PR with 250 lines or more
Development

Successfully merging this pull request may close these issues.

7 participants