redrathnure / armbian-mkspi

Armbian Linux Build Framework
https://www.armbian.com
GNU General Public License v2.0
90 stars 13 forks source link

Unofficial Armbian build for Makerbase MKS PI and 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.

WIP, 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.

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.

So the idea was to build a normal Armbian image using the available information (provided patches, circuitry and information from the native image).

Goals

Make Armbian build with current and edge kernels.

Please note:

Current status

Supported boards:

MKS IPS50 LCD - works starting from 0.3.1-24.2.0-trunk version.

A build-essential and kernel header packages are preinstalled starting from 0.3.2-24.2.0-trunk version. It should simplify Klipper installation and building custom kernel modules (e.g. WIFI modules like RTL8188GU (RTL8710B) one).

Images should be ready for a daily usage. Everything seem to be workes, however please pay attantion:

  1. Only Ubuntu builds are actively tested (use Debian ones for your own risk)
  2. Some bugs may appear from time to time. Especially it related to edge builds (based on edge 6.x kernel). Please check release page for more details.
  3. Please double check a How to Configure CAN Bus section if you use BTT EBB36 or similar CAN toolhead

ADXL345/SPI Usage

TLTR: Do not forget about klipper_mcu installation.

Full version:

Package Updates via Apt Update

Please double check kernel packages were freezed before running apt update command. E.g. run sudo armbian-config and check System -> Freeze - Disable Armbian kernel updates item.

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:

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
# Unpack DTB file
sudo dtc -I dtb -O dts -o rk3328-roc-cc.dts /boot/dtb/rockchip/rk3328-roc-cc.dtb
#Make a copy to work with
sudo cp rk3328-roc-cc.dts rk3328-roc-cc-rotated.dts

# Find `rotate = <SOME_VALUE>` and change to `rotate = <NEW_VALUE>`, 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

# 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

# Double check
less rk3328-roc-cc-rotated.dts | grep rotate
less rk3328-roc-cc-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

# Update rk3328-roc-cc.dtb with new version
sudo cp rk3328-roc-cc-rotated.dtb /boot/dtb/rockchip/rk3328-roc-cc.dtb

# Reboot
sudo reboot

How to Configure CAN Bus

There are two non obvious points which you should be aware to successfully configure CAN bus:

  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 will not properly work.

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 and flash MCU. Please specify bitrate/speed which will be used for toolhead. USuallu 500 000 or 1 000 000.
  3. Configure can0 interface on MKSPI:

    cat <<-'EOF' | sudo tee -a /etc/network/interfaces.d/can0
    allow-hotplug can0
    iface can0 can static
        bitrate 1000000                                       # Ensure it's the same as selected for MCU firmware.
        # up ifconfig $IFACE txqueuelen 128                   # It will not work because no ifconfig installed by default...
        up ip link set $IFACE txqueuelen 128                  # ... please use this version instead. 
        #up ip link set $IFACE txqueuelen 1024 restart-ms 200 # Bit more aggressive configuration
    
    EOF
  4. Reboot. Yes, it's important!
  5. Hook a toolhead board, find connected devices ~/klippy-env/bin/python ~/klipper/scripts/canbus_query.py can0 and follow Klipper documentation -- USB to CAN bus bridge mode for the rest of configuration.

In case of MCU 'mcu' shutdown: Timer too close, b'Got error -1 in can write: (105)No buffer space available' or similar troubles, please try following steps:

Step 1. Use ip -s link show can0 or/and Moonraker -> Settings -> MCU status to ensure no error/invalid AND no retransmit packages. In case of error/invalid packages please see Step 2. In case of no error but increasing retransmit packages please refer Step 3.

Step 2: double check wiring and terminal resistor. A twisted pair for data signals (CAN_L & CAN_H) is almost required for line longer that 20cm.

Step 3. Ensure sudo systemctl --failed does not show failed units. Otherwice doble check /etc/network/interfaces.d/can0 and ensure that ifconfig command (from the Klipper documentation) is not used. if@can0 unit must start without any issues.

Disable Debug Console UART2 or Freeup UART1 Interface

By default UART2 is used for the kernel debug output (ttyS2, USB Type C connection). Please disable kernel console and double check device file permissions if you need the ttyS2 for any other purposes:

# Or just add console=none to /boot/armbianEnv.txt manually.
echo 'console=none' > sudo tee -a /boot/armbianEnv.txt

# Grant user permissions and prevent getty from taking over the port
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.

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 for more details.

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.

I would advice to read official documentation, however it's short version:

  1. Use Ubunut Jammy 22.04 OS (or VM). Ensure you have 15-40GB of free disk and 4-6GB RAM.
  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
    • 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

Some technical Details:

Origina Image:

# PLEASE DO NOT EDIT THIS FILE
BOARD=mkspi
BOARD_NAME="mkspi"
BOARDFAMILY=rockchip64
BUILD_REPOSITORY_URL=https://github.com/armbian/build.git
BUILD_REPOSITORY_COMMIT=ed589b248-dirty
VERSION=22.05.0-trunk
LINUXFAMILY=rockchip64
ARCH=arm64
IMAGE_TYPE=user-built
BOARD_TYPE=conf
INITRD_ARCH=arm64
KERNEL_IMAGE_TYPE=Image
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)

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:

  1. Changes for /arch/arm64/boot/dts/rockchip/rk3328-roc-cc.dts ( redeclaring a few pins, disabling some features and declaring new ones. mostly for MKSPI-TS35 screen)
  2. HDMI interface change, seems just to declare mode with 5:3 aspect ration
  3. "Patch" for fbtft/fb_ili9341 driver. Basically redefining screen resolution.
  4. patches for SPI support code.
  5. Changes to drm_edid (see /drivers/gpu/drm/drm_edid.c and /drivers/gpu/drm/rockchip/inno_hdmi.c files). However I have no idea what this about and how to apply this patches to new kernel sources.
  6. Kernel v4.4 config. However I am not sure how it's relevant to the current and edge branches.

See Also

Original Armbian README.md

Armbian logo
Armbian Linux Build Framework

GitHub contributors Artifacts generation GitHub last commit (branch)

What does this project do?

Getting started

Requirements for self hosted

For stable branch use --branch=v24.08

apt-get -y install git
git clone --depth=1 --branch=main https://github.com/armbian/build
cd build
./compile.sh

Armbian logo

Build parameter examples

Show work-in-progress areas in interactive mode:

./compile.sh EXPERT="yes"

Build minimal CLI Armbian Jammy for Bananapi M5 with LTS kernel:

./compile.sh \
BOARD=bananapim5 \
BRANCH=current \
RELEASE=jammy \
BUILD_MINIMAL=yes \
BUILD_DESKTOP=no \
KERNEL_CONFIGURE=no

Build with GitHub actions: (advanced version)

name: "Build Armbian"
on:
  workflow_dispatch:
jobs:
  build-armbian:
    runs-on: ubuntu-latest
    steps:
      - uses: armbian/build@main
        with:
          armbian_token:     "${{ secrets.GITHUB_TOKEN }}"  # GitHub token
          armbian_release:   "jammy"                        # userspace
          armbian_target:    "build"                        # build=image, kernel=kernel
          armbian_board:     "bananapim5"                   # build target

Generated image will be uploaded to your repository release. Note: GitHub upload file limit is 2Gb.

More information:

Download prebuilt images releases

Point

Rolling

Compared with industry standards

Expand Check similarities, advantages and disadvantages compared with leading industry standard build software. Function | Armbian | Yocto | Buildroot | |:--|:--|:--|:--| | Target | general purpose | embedded | embedded / IOT | | U-boot and kernel | compiled from sources | compiled from sources | compiled from sources | | Board support maintenance   | complete | outside | outside | | Root file system | Debian or Ubuntu based| custom | custom | | Package manager | APT | any | none | | Configurability | limited | large | large | | Initramfs support | yes | yes | yes | | Getting started | quick | very slow | slow | | Cross compilation | yes | yes | yes |

Project structure

Expand ```text ├── cache Work / cache directory │   ├── aptcache Packages │   ├── ccache C/C++ compiler │   ├── docker Docker last pull │   ├── git-bare Minimal Git │   ├── git-bundles Full Git │   ├── initrd Ram disk │   ├── memoize Git status │   ├── patch Kernel drivers patch │   ├── pip Python │   ├── rootfs Compressed userspaces │   ├── sources Kernel, u-boot and other sources │   ├── tools Additional tools like ORAS │   └── utility ├── config Packages repository configurations │   ├── targets.conf Board build target configuration │   ├── boards Board configurations │   ├── bootenv Initial boot loaders environments per family │   ├── bootscripts Initial Boot loaders scripts per family │   ├── cli CLI packages configurations per distribution │   ├── desktop Desktop packages configurations per distribution │   ├── distributions Distributions settings │   ├── kernel Kernel build configurations per family │   ├── sources Kernel and u-boot sources locations and scripts │   ├── templates User configuration templates which populate userpatches │   └── torrents External compiler and rootfs cache torrents ├── extensions Extend build system with specific functionality ├── lib Main build framework libraries │   ├── functions │   │   ├── artifacts │   │   ├── bsp │   │   ├── cli │   │   ├── compilation │   │   ├── configuration │   │   ├── general │   │   ├── host │   │   ├── image │   │   ├── logging │   │   ├── main │   │   └── rootfs │   └── tools ├── output Build artifact │   └── deb Deb packages │   └── images Bootable images - RAW or compressed │   └── debug Patch and build logs │   └── config Kernel configuration export location │   └── patch Created patches location ├── packages Support scripts, binary blobs, packages │   ├── blobs Wallpapers, various configs, closed source bootloaders │   ├── bsp-cli Automatically added to armbian-bsp-cli package │   ├── bsp-desktop Automatically added to armbian-bsp-desktopo package │   ├── bsp Scripts and configs overlay for rootfs │   └── extras-buildpkgs Optional compilation and packaging engine ├── patch Collection of patches │   ├── atf ARM trusted firmware │   ├── kernel Linux kernel patches | |   └── family-branch Per kernel family and branch │   ├── misc Linux kernel packaging patches │   └── u-boot Universal boot loader patches | ├── u-boot-board For specific board |    └── u-boot-family For entire kernel family ├── tools Tools for dealing with kernel patches and configs └── userpatches User: configuration patching area ├── lib.config User: framework common config/override file ├── config-default.conf User: default user config file ├── customize-image.sh User: script will execute just before closing the image    ├── atf User: ARM trusted firmware    ├── kernel User: Linux kernel per kernel family    ├── misc User: various    └── u-boot User: universal boot loader patches ```

Contribution

Want to help?

We always need those volunteering positions:

Just apply and follow!

Support

For commercial or prioritized assistance:

Free support:

Find free support via general project search engine, documentation, community forums or IRC/Discord. Remember that our awesome community members mainly provide this in a best-effort manner, so there are no guaranteed solutions.

Contact

Contributors

Thank you to all the people who already contributed to Armbian!

Also

Armbian Partners

Armbian's partnership program helps to support Armbian and the Armbian community! Please take a moment to familiarize yourself with our Partners:

Star History

Star History Chart

License

This software is published under the GPL-2.0 License license.