diff --git a/README.md b/README.md index 935946f6eeb4..88fd2357b779 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,35 @@ -# Unofficial Armbian build for Makerbase [MKS PI](https://github.com/makerbase-mks/MKS-PI) and [MKS SKIPR](https://github.com/makerbase-mks/MKS-SKIPR) and few more boards +# Unofficial Armbian for Makerbase [MKS PI](https://github.com/makerbase-mks/MKS-PI), [MKS SKIPR](https://github.com/makerbase-mks/MKS-SKIPR) and few more boards -TLTR: Unofficial support of Makerbase MKS PI and MKS SKIPR and other boards. Contains `mkspi` board declaration and related kernel and u-boot patches. -Please note, result Armbian image is not full replacement for mks distributed image. You have to do yourself all OS configuration and and Klipper components installation. +TLTR: Unofficial Armbian images of Makerbase MKS PI, MKS SKIPR and several derivatives boards. Contains `mkspi` board configuration, related kernel and u-boot patches. +Unlike MKS images, these does not have pre-installed Klipper. You have to configure OS, Klipper and all related software from the scratch. However you would get up-to-dated OS, EU/US based package repositories and only official Armbian components. -**WIP, absolutely no guarantees, you do everything at your own risk.** +⚠️ WARNING **absolutely no guarantees, you do everything at your own risk.** ## Bit of Liric -The MKS-PI ads look good, especially considering the price and the display (e.g. the size fits the Ghost Flying Bear printer). However, the software and support from the manufacturer is terrible. +The MKS-PI and SKIPR specs look pretty good for the price and should be enought for most of 3D printing machines. Size of MKSPI-TS35 the same as some Ghost Flying Bear printers, so it may be considered as easy Klipper upgrade. However, the software and service support from the manufacturer is terrible. -There is no source code (yeah, GPL license, of course), no answer to questions, etc. They provide preconfigured Armbian+Klipper, but the image contains random/outdated components and I have problems with WIFI adapters. And who knows what else is hidden in there. +There is no source code (yeah, GPL license, of course), no answer for questions/GitHub issues. Official images are based of EOL distro and have problems with some WIFI dongles. And who knows what else is hidden in there. -So the idea was to build a normal Armbian image using the available information (provided patches, circuitry and information from the native image). - - -## Goals - -Prepare an Armbian build with `current` and `edge` kernels that is ready to install Klipper from scratch. +The idea was to build a normal Armbian image based on up-to-dated distro and kernel with posibility to install fresh instance of Klipper, KlipperScreen, Katapult you name it. Please note: -* Klipper, Fluid and other related components are outside the scope of this repo. Please see [Klipper Installation And Update Helper (KIAUH)](https://github.com/dw-0/kiauh) if you are interested in these topics. +* Klipper, Fluid and other related components are **not** in the scope of this repo. Please see [Klipper Installation And Update Helper (KIAUH)](https://github.com/dw-0/kiauh) if you are interested in these topics. * The original patches were taken from the [Makerbase `armbian-build` repository](https://github.com/makerbase-mks/armbian-build), this means you have to be mentally ready to see ~~this mess~~ "fast and dirty" approach. I do not have enough knowledge and time to organize this mess in the right way. * I do not have access to full MKS PI set and cannot test all features. Main goal is to have worked on the following component: * booting from microSD * MKSPI-TS35 TFT display (ideally with working touch screen :) ) - * worked HDMI output + * worked HDMI output (video only) * USB ports, including USB 3 port * ADXL345 (SPI bus) * CAN bus for SKIPR board * Feel free to get involved in development, testing or hardware support if you are interested in additional features. -* ~~At the moment I only focus on Ubuntu LTS builds (`current` and `edge` kernels). Feel free to open PRs if you need non-LTS Ubuntu or Debian images.~~ Ubuntu LTS (tested) and Debian Bullseye (untested) builds are supported. +* [Release page](https://github.com/redrathnure/armbian-mkspi/releases) has Ubuntu LTS and Debian LTS images. However only Ubuntu ones are tested. -Feel free to discuss or just open PRs if you know the right way to orgonize these patches and the right places in the Armbian sources. +Please check a few chapters bellow to get a few hints about typical configuration tasks (screen rotation, ADXL345 and CANbus configuration). A `Technical Details` section contains information which would be useful for adaptation of similar board or other DTS/kernel customizations. ## Current status @@ -56,11 +51,9 @@ When the board boots from EMMC card and ADXL345 sensor is connected (SPI bus), [ * connect ADXL345 board only when it's needed * use HDMI-connected display -The images should be ready for use on a daily basis. However, please note the following: +The images should be ready for daily uages. Please check [release page](https://github.com/redrathnure/armbian-mkspi/releases) for more details and feel free [to report an issue](https://github.com/redrathnure/armbian-mkspi/issues). -1. Only latest LTS Ubuntu images are actively tested. Please use the Debian ones at your own risk. -2. Bugs may appear from time to time. Especially it related to edge images. Please check [release page](https://github.com/redrathnure/armbian-mkspi/releases) for more details and feel free [to report an issue](https://github.com/redrathnure/armbian-mkspi/issues). -3. Please double check a [How to Configure CAN Bus](#how-to-configure-can-bus) section if you are using the [BTT EBB36](https://github.com/bigtreetech/EBB) or similar CAN toolhead +Please double check a [How to Configure CAN Bus](#how-to-configure-can-bus) section if you are using the [BTT EBB36](https://github.com/bigtreetech/EBB) or similar CAN toolhead. ### ADXL345/SPI Usage @@ -110,7 +103,9 @@ Please double check kernel packages are freezed before running `apt update` comm ### How to Rotate Screen -Sometimes you need to rotate the image on the screen, for example, when upgrading Flying Bear Ghost 5 printer. To do this you need to change value for `rotate` parameter under `spi_for_lcd@0` section (configuration for the display) and use `touchscreen-inverted-x = <0x01>` and/or `touchscreen-inverted-y = <0x01>` parameters for `spi_for_touch@1` section (configuration for touchscreen) in `/boot/dtb/rockchip/rk3328-roc-cc.dtb` file. Please note, value for `touchscreen-inverted-x = <0x01>` or `touchscreen-inverted-y = <0x01>` does *not* affect anything. To disable e.g. y-inversion, whole parameter should be commented out (`# touchscreen-inverted-y = <0x01>;`). There are few examples: +⚠️ WARNING starting from v1.0.0 DTS was renamed from `rk3328-roc-cc` to `rk3328-mkspi`. This means all files like `/boot/dtb/rockchip/rk3328-roc-cc.dtb` now renamed to `/boot/dtb/rockchip/rk3328-mkspi.dtb`. + +Sometimes you need to rotate the image on the screen, for example, when upgrading Flying Bear Ghost 5 printer. To do this you need to change value for `rotate` parameter under `spi_for_lcd@0` section (configuration for the display) and use `touchscreen-inverted-x = <0x01>` and/or `touchscreen-inverted-y = <0x01>` parameters for `spi_for_touch@1` section (configuration for touchscreen) in `/boot/dtb/rockchip/rk3328-mkspi.dtb` file. Please note, value for `touchscreen-inverted-x = <0x01>` or `touchscreen-inverted-y = <0x01>` does *not* affect anything. To disable e.g. y-inversion, whole parameter should be commented out (`# touchscreen-inverted-y = <0x01>;`). There are few examples: * 270° (default mode) - `rotate = <270>;` (or `rotate = <0x10e>;` and `touchscreen-inverted-y = <0x01>` * 90° (flipped horizontally) - `rotate = <90>;` and `touchscreen-inverted-x = <0x01>` @@ -118,28 +113,28 @@ Sometimes you need to rotate the image on the screen, for example, when upgradin Following commands may be used to perform this configuration: ``` # Backup -sudo cp /boot/dtb/rockchip/rk3328-roc-cc.dtb /boot/dtb/rockchip/rk3328-roc-cc.dtb.$(date +"%Y%m%d_%H%M%S").bak +sudo cp /boot/dtb/rockchip/rk3328-mkspi.dtb /boot/dtb/rockchip/rk3328-mkspi.dtb.$(date +"%Y%m%d_%H%M%S").bak # Unpack DTB file -sudo dtc -I dtb -O dts -o rk3328-roc-cc.dts /boot/dtb/rockchip/rk3328-roc-cc.dtb +sudo dtc -I dtb -O dts -o rk3328-mkspi.dts /boot/dtb/rockchip/rk3328-mkspi.dtb #Make a copy to work with -sudo cp rk3328-roc-cc.dts rk3328-roc-cc-rotated.dts +sudo cp rk3328-mkspi.dts rk3328-mkspi-rotated.dts # Find `rotate = ` and change to `rotate = `, where NEW_VALUE is a rotation angle, e.g. `rotate = <90>` or `rotate = <270>` # Then find `touchscreen-inverted-y` attribute and add or replace `touchscreen-inverted-x` one -nano rk3328-roc-cc-rotated.dts +sudo nano rk3328-mkspi-rotated.dts -# Or sed -i -e "s/<0x10e>/<90>/g" rk3328-roc-cc-rotated.dts -# and sed -i -e "s/touchscreen-inverted-y/touchscreen-inverted-x/g" rk3328-roc-cc-rotated.dts +# Or sudo sed -i -e "s/<0x10e>/<90>/g" rk3328-mkspi-rotated.dts +# and sudo sed -i -e "s/touchscreen-inverted-y/touchscreen-inverted-x/g" rk3328-mkspi-rotated.dts # Double check -less rk3328-roc-cc-rotated.dts | grep rotate -less rk3328-roc-cc-rotated.dts | grep touchscreen-inverted +less rk3328-mkspi-rotated.dts | grep rotate +less rk3328-mkspi-rotated.dts | grep touchscreen-inverted # Pack DTS to DTB -dtc -I dts -O dtb -o rk3328-roc-cc-rotated.dtb rk3328-roc-cc-rotated.dts +dtc -I dts -O dtb -o rk3328-mkspi-rotated.dtb rk3328-mkspi-rotated.dts -# Update rk3328-roc-cc.dtb with new version -sudo cp rk3328-roc-cc-rotated.dtb /boot/dtb/rockchip/rk3328-roc-cc.dtb +# Update rk3328-mkspi.dtb with new version +sudo cp rk3328-mkspi-rotated.dtb /boot/dtb/rockchip/rk3328-mkspi.dtb # Reboot sudo reboot @@ -153,13 +148,14 @@ There are few non-obvious points that you should be aware of to successfully con 1. MKS SKIPR board must be connected via USB (UART connection does not work for CAN bridge mode) 2. By default latest images/Ubuntu distros do not have `ifconfig` command out of the box, so [Klipper documentation -- USB to CAN bus bridge mode](https://www.klipper3d.org/CANBUS.html#usb-to-can-bus-bridge-mode) will not properly work. 3. Starting from `0.4.0-24.11.0-trunk` image, Ubuntu and Debian distro use NetworkManager by default, which means `/etc/network/interfaces.d/*` files have no effect anymore. So CANbus must be consfigured via Systemd-Networkd (see text bellow). It's OK to use NetworkManager for KlipperScreen to manage WIFI and Ethernet interfaces, and Systemd-Networkd for the CANbus interface at the same time. +4. ⚠️ WARNING modern Ubuntu and Debian distros supports NetworkManager only configuration. Means starting from `0.4.0-24.11.0-trunk` and later `/etc/network/interfaces.d/can0` file does **not** work anymore. You have to configure can interface via Systemd-Networkd. E.g. see [klipper_canbus](https://maz0r.github.io/klipper_canbus/extras/systemd-networkd.html) as example. Steps to configure CAN bus: -1. (For SKIPR board) hook MCU via USB cable ("USB to CAN bus bridge" is not supported for UART connection type). -2. (For SKIPR board) [compile Klipper firmware](https://klipper.discourse.group/t/mks-skipr-can-bus/5377/16) and flash MCU. Please specify bitrate/speed which will be used for toolhead. USuallu 500 000 or 1 000 000. +1. (For SKIPR board) hook MCU via USB cable (from USB Type A on "MKSPI part" to USB Type C on MCU part, build in UART connection is not supported yet). +2. (For SKIPR board) [compile Klipper firmware](https://klipper.discourse.group/t/mks-skipr-can-bus/5377/16) and flash MCU. Please specify bitrate/speed which will be used for toolhead. Usually 500 000 or 1 000 000. 3. Configure `can0` interface on MKSPI -3.1. Debian Interfaces file. Only for old distros, pre `0.4.0-24.11.0-trunk` images: +3.1. Debian Interfaces file. ⚠️ Only for old distros, pre `0.4.0-24.11.0-trunk` images: ``` cat <<-'EOF' | sudo tee -a /etc/network/interfaces.d/can0 allow-hotplug can0 @@ -181,12 +177,15 @@ Steps to configure CAN bus: BitRate=1M RestartSec=200ms # see also https://www.freedesktop.org/software/systemd/man/latest/systemd.network.html#[CAN]%20Section%20Options - + EOF + + cat <<-'EOF' | sudo tee /etc/systemd/network/80-can.link + [Match] + Type=can [Link] TransmitQueueLength=1024 # see also https://www.freedesktop.org/software/systemd/man/latest/systemd.network.html#%5BLink%5D%20Section%20Options - EOF sudo systemctl enable systemd-networkd @@ -219,12 +218,33 @@ echo 'KERNEL=="ttyS2",MODE="0660"' > /etc/udev/rules.d/99-ttyS2.rules systemctl mask serial-getty@ttyS2.service ``` -A `mkspi-uart1` overlay may be used to disable LCD and Touchscreen intefraces and freeup UART1/ttyS1 for custom purposes. e.g. by adding `overlays=mkspi-uart1` string to `/boot/armbianEnv.txt` file. +A `mkspi-uart1` (pre v1.0.0 images) or `mkspi-disable-lcd-spi` (starting vrom v1.0.0 images) overlay may be used to disable LCD and Touchscreen intefraces and freeup UART1/ttyS1 for custom purposes. e.g. by adding `overlays=mkspi-disable-lcd-spi` or `overlays=mkspi-uart1` string to `/boot/armbianEnv.txt` file. This solution was tested on QIDI X-7 (Q1 Pro mainboard) and X-6 printers. Please see [Disable kernel console debug messages for ttyS2 #31](https://github.com/redrathnure/armbian-mkspi/issues/31) for more details. -## How to Build + +## Technical Details + +MKSPI board is very similar to [Renegade ROC-RK3328-CC - libre.computer](https://libre.computer/products/roc-rk3328-cc/) as well as provided documentation. It's a Rockchip RK3328 chip with RK805 power controller and a few additional components. + +MKS SKIPR board (from schematic point of view) is the MKSPI + MKS Robin Nano 3.2, which is connected via UART interface. So Armbian part is the same as for MKSPI, klipper MCU and configuration similar to MKS Robin Nano 3.2 one. + +The biggest part of Kernel and U-Boot configuration is done in DTS/DTB files. Original MKS images and my releases prior v1.0.0 use `/boot/dtb/rockchip/rk3328-roc-cc.dtb` file. Images v1.0.0 and later use `/boot/dtb/rockchip/rk3328-mkspi.dtb` one. + +If you belive you board is similar to MKSPI one, you may perform follwing steps: + +* Verify original DTS descriptor. For example a `/boot/dtb/rockchip/rk3328-roc-cc.dtb` file may be extracted from an original worked image. Better to have a readable unpacked dts file, just for the reference. This file may be renamed to `rk3328-mkspi.dtb` and place to `/boot/dtb/rockchip` location of the Amrbian image (renaming is not requered for images prior v1.0.0). + +* (match better option!) Try to compare unpacked DTS file form original working image with cofiguration from this repo (e.g. [patch/kernel/archive/rockchip64-6.6/dt/rk3328-mkspi.dts](https://github.com/redrathnure/armbian-mkspi/blob/custom/mkspi_25.2.0-trunk_new/patch/kernel/archive/rockchip64-6.6/dt/rk3328-mkspi.dts)). This should give you an idea about configuration of supported devices. + +* (hard but may give the best result) use schematic or/and customer support to build your ouwn DTS file e.g. based on [patch/kernel/archive/rockchip64-6.6/dt/rk3328-mkspi.dts](https://github.com/redrathnure/armbian-mkspi/blob/custom/mkspi_25.2.0-trunk_new/patch/kernel/archive/rockchip64-6.6/dt/rk3328-mkspi.dts) file. + + +Please note you also need to patch u-boot DTS, which is very similar to the related kernel file (e.g. see [mkspi patches](https://github.com/redrathnure/armbian-mkspi/tree/custom/mkspi_25.2.0-trunk_new/patch/u-boot/u-boot-rockchip64/board_mkspi)). + + +### How to Build The new `mkspi` board was declared. Now has support only for `current` and `edge` kernels and Ubuntu Jammy (22.04) and Noble (24.04) OS (CLI and desktop editions). Build process is pretty usual for Armbain build. @@ -235,21 +255,18 @@ I would advice to read official documentation, however it's short version: 2. Clone repo 3. `cd armbian-mkspi` 4. `./compile.sh` and follow instructions... Please do not forget about `BSPFREEZE=yes` build arg (or freezing kernel updates via `sudo armbian-config` right after the first login). A few ready to use commands: - * Ubuntu Jammy with current kernel: `./compile.sh BOARD=mkspi BRANCH=current RELEASE=jammy BSPFREEZE=yes BUILD_DESKTOP=no BUILD_MINIMAL=no KERNEL_CONFIGURE=no COMPRESS_OUTPUTIMAGE=sha,gpg,img INSTALL_HEADERS=yes BUILD_KSRC=yes INSTALL_KSRC=yes` - * Ubuntu Jammy with edge kernel: `./compile.sh BOARD=mkspi BRANCH=edge RELEASE=jammy BSPFREEZE=yes BUILD_DESKTOP=no BUILD_MINIMAL=no KERNEL_CONFIGURE=no COMPRESS_OUTPUTIMAGE=sha,gpg,img INSTALL_HEADERS=yes BUILD_KSRC=yes INSTALL_KSRC=yes` * Ubuntu Noble with current kernel: `./compile.sh BOARD=mkspi BRANCH=current RELEASE=noble BSPFREEZE=yes BUILD_DESKTOP=no BUILD_MINIMAL=no KERNEL_CONFIGURE=no COMPRESS_OUTPUTIMAGE=sha,gpg,img INSTALL_HEADERS=yes BUILD_KSRC=yes INSTALL_KSRC=yes` * Ubuntu Noble with edge kernel: `./compile.sh BOARD=mkspi BRANCH=edge RELEASE=noble BSPFREEZE=yes BUILD_DESKTOP=no BUILD_MINIMAL=no KERNEL_CONFIGURE=no COMPRESS_OUTPUTIMAGE=sha,gpg,img INSTALL_HEADERS=yes BUILD_KSRC=yes INSTALL_KSRC=yes` - * Debian bullseye with current kernel: `./compile.sh BOARD=mkspi BRANCH=current RELEASE=bullseye BSPFREEZE=yes BUILD_DESKTOP=no BUILD_MINIMAL=no KERNEL_CONFIGURE=no COMPRESS_OUTPUTIMAGE=sha,gpg,img INSTALL_HEADERS=yes BUILD_KSRC=yes INSTALL_KSRC=yes` - * Debian bullseye with edge kernel: `./compile.sh BOARD=mkspi BRANCH=edge RELEASE=bullseye BSPFREEZE=yes BUILD_DESKTOP=no BUILD_MINIMAL=no KERNEL_CONFIGURE=no COMPRESS_OUTPUTIMAGE=sha,gpg,img INSTALL_HEADERS=yes BUILD_KSRC=yes INSTALL_KSRC=yes` - * Debian bookworm with current kernel: `./compile.sh BOARD=mkspi BRANCH=current RELEASE=bookworm BSPFREEZE=yes BUILD_DESKTOP=no BUILD_MINIMAL=no KERNEL_CONFIGURE=no COMPRESS_OUTPUTIMAGE=sha,gpg,img INSTALL_HEADERS=yes BUILD_KSRC=yes INSTALL_KSRC=yes` - * Debian bookworm with edge kernel: `./compile.sh BOARD=mkspi BRANCH=edge RELEASE=bookworm BSPFREEZE=yes BUILD_DESKTOP=no BUILD_MINIMAL=no KERNEL_CONFIGURE=no COMPRESS_OUTPUTIMAGE=sha,gpg,img INSTALL_HEADERS=yes BUILD_KSRC=yes INSTALL_KSRC=yes` + * Debian Bookworm with current kernel: `./compile.sh BOARD=mkspi BRANCH=current RELEASE=bookworm BSPFREEZE=yes BUILD_DESKTOP=no BUILD_MINIMAL=no KERNEL_CONFIGURE=no COMPRESS_OUTPUTIMAGE=sha,gpg,img INSTALL_HEADERS=yes BUILD_KSRC=yes INSTALL_KSRC=yes` + * Debian Bookworm with edge kernel: `./compile.sh BOARD=mkspi BRANCH=edge RELEASE=bookworm BSPFREEZE=yes BUILD_DESKTOP=no BUILD_MINIMAL=no KERNEL_CONFIGURE=no COMPRESS_OUTPUTIMAGE=sha,gpg,img INSTALL_HEADERS=yes BUILD_KSRC=yes INSTALL_KSRC=yes` * append `INSTALL_HEADERS=yes BUILD_KSRC=yes INSTALL_KSRC=yes` and `BSFREEZE=yes` flags if you will need kernel headers, e.g. to compile custom WiFi drivers - * if you need to modify the kernel sources: `./compile.sh BOARD=mkspi BRANCH=current RELEASE=jammy BSPFREEZE=yes BUILD_DESKTOP=no BUILD_MINIMAL=no KERNEL_CONFIGURE=no COMPRESS_OUTPUTIMAGE=sha,gpg,img kernel-patch` 5. Wait a 20-180 minutes (depends of your hardware, mostly disk system) and check `output\images\` directory +Following comand may be used to modify the kernel sources and prepare a new patch: `./compile.sh BOARD=mkspi BRANCH=current RELEASE=noble BSPFREEZE=yes BUILD_DESKTOP=no BUILD_MINIMAL=no KERNEL_CONFIGURE=no COMPRESS_OUTPUTIMAGE=sha,gpg,img kernel-patch`. See also [Armbian - Build commands](https://docs.armbian.com/Developer-Guide_Build-Commands/) documentation for more details. -## Some technical Details: +### Some Technical Details About MKS Images + Origina Image: ``` # PLEASE DO NOT EDIT THIS FILE @@ -269,7 +286,7 @@ BRANCH=edge /etc/armbian-release (END) ``` -https://github.com/makerbase-mks/armbian-build repo contains random crap (half worked patches for legacy 4.4 Kernel and non full armbian integration) +https://github.com/makerbase-mks/armbian-build repo contains random crap (half worked patches for legacy 4.4 Kernel and non fully armbian integration) In generally it's not clear what was changed, however looks like MKS guys were not too creative and almost copy rockchip64/Renegade board. Patches include: @@ -281,7 +298,8 @@ In generally it's not clear what was changed, however looks like MKS guys were n 6. Kernel v4.4 config. However I am not sure how it's relevant to the current and edge branches. -## See Also +See also: + - https://github.com/makerbase-mks/MKS-PI - MKS delivered image, official instructions and schematic. - https://github.com/makerbase-mks/armbian-build - kind of sources (state of Dec.23 - random unworked crap)