basic configuration for Pinecube: kernel, bootloader, wireless driver

This commit is contained in:
Grzegorz Kowalski 2023-10-19 13:32:32 +02:00
parent 787cb17f7d
commit a79388fd88
18 changed files with 407 additions and 0 deletions

18
conf/layer.conf Normal file
View File

@ -0,0 +1,18 @@
# We have a conf and classes directory, add to BBPATH
BBPATH .= ":${LAYERDIR}"
# We have recipes-* directories, add to BBFILES
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
${LAYERDIR}/recipes-*/*/*.bbappend"
BBFILE_COLLECTIONS += "pinecube-bsp"
BBFILE_PATTERN_pinecube-bsp = "^${LAYERDIR}/"
BBFILE_PRIORITY_pinecube-bsp = "6"
# This should only be incremented on significant changes that will
# cause compatibility issues with other layers
LAYERVERSION_pinecube-bsp = "2"
LAYERDEPENDS_pinecube-bsp = "core sunxi-bsp"
LAYERSERIES_COMPAT_pinecube-bsp = "langdale mickledore"

View File

@ -0,0 +1,41 @@
# Pinecube
#
# Sochip S3 SoC
# ARMv7 Processor rev 5 (v7l)
# Allwinner sun8i Family
# half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
#
# There apparently is some support for the device in mainline kernel,
# let's see how far can we take it.
# Architecture tuning
require conf/machine/include/sun8i.inc
require conf/machine/include/arm/feature-arm-dsp.inc
require conf/machine/include/arm/feature-arm-idiv.inc
# Available machine features
MACHINE_FEATURES = "ext2 rtc serial usbhost vfat wifi"
# Kernel and device tree
PREFERRED_PROVIDER_virtual/kernel = "linux-yocto"
PREFERRED_VERSION_virtual/kernel = "6.1%"
KERNEL_DEVICETREE = "sun8i-s3-pinecube.dtb"
MACHINE_EXTRA_RRECOMMENDS = "kernel-modules kernel-devicetree"
# Serial console
SERIAL_CONSOLES ?= "115200;ttyS0"
SERIAL_CONSOLES_CHECK = "${SERIAL_CONSOLES}"
# Bootloader
EXTRA_IMAGEDEPENDS += "virtual/bootloader"
PREFERRED_PROVIDER_virtual/bootloader ?= "u-boot"
SPL_BINARY = "u-boot-sunxi-with-spl.bin"
UBOOT_MACHINE = "pinecube_defconfig"
# wic SD card image
IMAGE_FSTYPES += " wic"
WKS_FILE = "pinecube.wks"
do_image_wic[depends] += "mtools-native:do_populate_sysroot dosfstools-native:do_populate_sysroot virtual/bootloader:do_deploy"
IMAGE_BOOT_FILES ?= "${SPL_BINARY} boot.scr ${KERNEL_IMAGETYPE} ${KERNEL_DEVICETREE}"
MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "kernel-image kernel-devicetree"

View File

@ -0,0 +1,65 @@
# Pinecube u-boot script
# Adapted from Armbian
echo "[+] Helium u-boot script for Pinecube"
echo "[+] Congratulations! Boot ROM has found and started the bootloader."
# Setup
setenv load_addr "0x45000000"
setenv overlay_error "false"
# Default options
setenv verbosity "7"
setenv console "on"
setenv disp_mem_reserves "off"
setenv docker_optimizations "on"
setenv earlycon "on"
# Deault rootfs
setenv devnum "0"
setenv rootdev "/dev/mmcblk${devnum}p1"
setenv rootfstype "ext4"
# Print boot source
itest.b *0x28 == 0x00 && setenv boot_source "Primary SD card"
itest.b *0x28 == 0x02 && setenv boot_source "eMMC/Secondary SD card"
itest.b *0x28 == 0x03 && setenv boot_source "SPI ROM"
echo "[+] Boot source: ${boot_source}"
# Set up boot device info
if test "${devtype}" = "mmc"; then
part uuid mmc ${devnum}:1 partuuid;
setenv devnum ${mmc_bootdev}
setenv rootdev "/dev/mmcblk${mmc_bootdev}p1"
fi
echo "[+] Boot script loaded from ${devtype}:${devnum}"
# Load boot configuration
if test -e ${devtype} ${devnum} ${prefix}boot.cfg; then
load ${devtype} ${devnum} ${load_addr} ${prefix}boot.cfg
env import -t ${load_addr} ${filesize}
echo "[+] Loaded boot configuration: ${devtype}:${devnum}:${prefix}boot.cfg"
else
echo "[-] No boot configuration found, running defaults"
fi
# Apply boot configuration
if test "${console}" = "on"; then setenv consoleargs "console=ttyS0,115200 console=tty1"; fi
if test "${earlyconsole}" = "on"; then setenv consoleargs "earlycon ${consoleargs}"; fi
setenv bootargs "root=${rootdev} rootwait rootfstype=${rootfstype} ${consoleargs} consoleblank=0 loglevel=${verbosity} ubootpart=${partuuid} ubootsource=${devtype} usb-storage.quirks=${usbstoragequirks} ${extraargs} ${extraboardargs}"
if test "${disp_mem_reserves}" = "off"; then setenv bootargs "${bootargs} sunxi_ve_mem_reserve=0 sunxi_g2d_mem_reserve=0 sunxi_fb_mem_reserve=16"; fi
if test "${docker_optimizations}" = "on"; then setenv bootargs "${bootargs} cgroup_enable=memory swapaccount=1"; fi
# Load boot files
echo "[+] Loading kernel image ${devtype}:${devnum}:${prefix}zImage @ ${kernel_addr_r}"
load ${devtype} ${devnum} ${kernel_addr_r} ${prefix}zImage
echo "[+] Loading device tree ${devtype}:${devnum}:${prefix}${fdtfile} @ ${fdt_addr_r}"
load ${devtype} ${devnum} ${fdt_addr_r} ${prefix}${fdtfile}
fdt addr ${fdt_addr_r}
fdt resize 65536
echo "[+] Setup finished, booting..."
# We're booting without initramfs
bootz ${kernel_addr_r} - ${fdt_addr_r}

View File

@ -0,0 +1,37 @@
SUMMARY = "Boot script for u-boot"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
COMPATIBLE_MACHINE = "pinecube"
PACKAGE_ARCH = "${MACHINE_ARCH}"
DEPENDS = "u-boot-mkimage-native"
inherit deploy
SRC_URI += "file://boot.cmd"
FILES:${PN} += "/boot"
do_mkimage () {
uboot-mkimage -A arm -O linux -T script -C none -a 0 -e 0 \
-n "${DISTRO}-${MACHINE} u-boot script" \
-d ${THISDIR}/${PN}/boot.cmd ${B}/boot.scr
}
addtask mkimage after do_compile before do_install
do_compile[noexec] = "1"
do_install () {
install -D -m 644 ${B}/boot.scr ${D}/boot/boot.scr
}
do_deploy () {
install -D -m 644 ${D}/boot/boot.scr ${DEPLOYDIR}/boot.scr-${MACHINE}-${PV}-${PR}
cd ${DEPLOYDIR}
rm -f boot.scr
ln -sf boot.scr-${MACHINE}-${PV}-${PR} boot.scr
}
addtask deploy after do_install before do_build

View File

@ -0,0 +1,12 @@
SUMMARY = "Base image for Pinecube"
LICENSE = "MIT"
#MACHINE := "pinecube"
COMPATIBLE_MACHINE = "pinecube"
IMAGE_INSTALL += " \
u-boot-script \
kernel-module-8189es \
"
IMAGE_FEATURES += "hwcodecs"

View File

@ -0,0 +1,21 @@
SUMMARY = "Realtek RTL8189ES wireless driver module"
# TODO: The repo doesn't specify a license, however source files suggest GPLv2
LICENSE = "CLOSED"
SRC_URI = "git://github.com/jwrdegoede/rtl8189ES_linux.git;protocol=https;branch=master"
SRCREV = "05996691a5f3a61968a83f8b368454fd2c6885ca"
S = "${WORKDIR}/git"
PV = "git${SRCREV}"
DEPENDS = "virtual/kernel"
inherit module
EXTRA_OEMAKE = "ARCH=${ARCH}"
EXTRA_OEMAKE += "KSRC=${STAGING_KERNEL_BUILDDIR}"
do_install() {
install -d ${D}/lib/modules/${KERNEL_VERSION}
install -m 0755 ${B}/8189es.ko ${D}/lib/modules/${KERNEL_VERSION}/8192eu.ko
}

View File

@ -0,0 +1,18 @@
diff -purN a/arch/arm/boot/dts/sun8i-s3-pinecube.dts b/arch/arm/boot/dts/sun8i-s3-pinecube.dts
--- a/arch/arm/boot/dts/sun8i-s3-pinecube.dts
+++ b/arch/arm/boot/dts/sun8i-s3-pinecube.dts
@@ -25,12 +25,12 @@ leds {
led1 {
label = "pine64:ir:led1";
- gpios = <&pio 1 10 GPIO_ACTIVE_LOW>; /* PB10 */
+ gpios = <&pio 1 10 GPIO_ACTIVE_HIGH>; /* PB10 */
};
led2 {
label = "pine64:ir:led2";
- gpios = <&pio 1 12 GPIO_ACTIVE_LOW>; /* PB12 */
+ gpios = <&pio 1 12 GPIO_ACTIVE_HIGH>; /* PB12 */
};
};

View File

@ -0,0 +1,14 @@
diff -purN a/arch/arm/boot/dts/sun8i-s3-pinecube.dts b/arch/arm/boot/dts/sun8i-s3-pinecube.dts
--- a/arch/arm/boot/dts/sun8i-s3-pinecube.dts
+++ b/arch/arm/boot/dts/sun8i-s3-pinecube.dts
@@ -162,6 +162,10 @@ &ac_power_supply {
status = "okay";
};
+&battery_power_supply {
+ status = "okay";
+};
+
&reg_dcdc2 {
regulator-always-on;
regulator-min-microvolt = <1250000>;

View File

@ -0,0 +1,12 @@
diff -purN a/arch/arm/boot/dts/sun8i-s3-pinecube.dts b/arch/arm/boot/dts/sun8i-s3-pinecube.dts
--- a/arch/arm/boot/dts/sun8i-s3-pinecube.dts
+++ b/arch/arm/boot/dts/sun8i-s3-pinecube.dts
@@ -207,7 +207,7 @@ &spi0 {
flash@0 {
#address-cells = <1>;
#size-cells = <1>;
- compatible = "winbond,w25q128", "jedec,spi-nor";
+ compatible = "xtx,xt25f128b", "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <40000000>;
};

View File

@ -0,0 +1,34 @@
diff -purN a/arch/arm/boot/dts/sun8i-s3-pinecube.dts b/arch/arm/boot/dts/sun8i-s3-pinecube.dts
--- a/arch/arm/boot/dts/sun8i-s3-pinecube.dts
+++ b/arch/arm/boot/dts/sun8i-s3-pinecube.dts
@@ -75,6 +75,18 @@ csi1_ep: endpoint {
};
};
+&ehci0 {
+ phys = <&usbphy 0>;
+ phy-names = "usb";
+ status = "okay";
+};
+
+&ohci0 {
+ phys = <&usbphy 0>;
+ phy-names = "usb";
+ status = "okay";
+};
+
&emac {
phy-handle = <&int_mii_phy>;
phy-mode = "mii";
@@ -217,11 +229,6 @@ &uart2 {
status = "okay";
};
-&usb_otg {
- dr_mode = "host";
- status = "okay";
-};
-
&usbphy {
usb0_vbus-supply = <&reg_vcc5v0>;
status = "okay";

View File

@ -0,0 +1,12 @@
diff -purN a/arch/arm/boot/dts/sun8i-s3-pinecube.dts b/arch/arm/boot/dts/sun8i-s3-pinecube.dts
--- a/arch/arm/boot/dts/sun8i-s3-pinecube.dts
+++ b/arch/arm/boot/dts/sun8i-s3-pinecube.dts
@@ -64,6 +64,8 @@ &csi1 {
status = "okay";
port {
+ #address-cells = <1>;
+ #size-cells = <0>;
csi1_ep: endpoint {
remote-endpoint = <&ov5640_ep>;
bus-width = <8>;

View File

@ -0,0 +1,21 @@
diff -purN a/arch/arm/boot/dts/sun8i-s3-pinecube.dts b/arch/arm/boot/dts/sun8i-s3-pinecube.dts
--- a/arch/arm/boot/dts/sun8i-s3-pinecube.dts
+++ b/arch/arm/boot/dts/sun8i-s3-pinecube.dts
@@ -226,3 +226,16 @@ &usbphy {
usb0_vbus-supply = <&reg_vcc5v0>;
status = "okay";
};
+
+&i2s0 {
+ status = "okay";
+};
+
+&codec {
+ allwinner,pa-gpio = <&pio 6 6 GPIO_ACTIVE_HIGH>; /*PG6*/
+ allwinner,audio-routing =
+ "Speaker", "LINEOUT",
+ "MIC1", "Mic",
+ "Mic", "MBIAS";
+ status = "okay";
+};
+

View File

@ -0,0 +1,19 @@
diff -purN a/arch/arm/boot/dts/sun8i-s3-pinecube.dts b/arch/arm/boot/dts/sun8i-s3-pinecube.dts
--- a/arch/arm/boot/dts/sun8i-s3-pinecube.dts
+++ b/arch/arm/boot/dts/sun8i-s3-pinecube.dts
@@ -99,9 +99,13 @@ &i2c0 {
status = "okay";
axp209: pmic@34 {
+ compatible = "x-powers,axp203",
+ "x-powers,axp209";
reg = <0x34>;
- interrupt-parent = <&nmi_intc>;
- interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
+ interrupt-parent = <&gic>;
+ interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-controller;
+ #interrupt-cells = <1>;
};
};

View File

@ -0,0 +1,23 @@
# Pinecube-specific configuration
# AXP209 PMIC
CONFIG_INPUT_AXP20X_PEK=y
CONFIG_PINCTRL_AXP209=y
CONFIG_CHARGER_AXP20X=y
CONFIG_BATTERY_AXP20X=y
CONFIG_AXP20X_POWER=y
CONFIG_MFD_AXP20X=y
CONFIG_MFD_AXP20X_I2C=y
CONFIG_MFD_AXP20X_RSB=y
CONFIG_REGULATOR_AXP20X=y
CONFIG_AXP20X_ADC=y
# OV5640 over CSI
CONFIG_MEDIA_CAMERA_SUPPORT=y
CONFIG_VIDEO_SUN6I_CSI=y
CONFIG_VIDEO_OV5640=y
# Wireless - needed for RTL8189ES driver
CONFIG_WIRELESS=y
CONFIG_RFKILL=y
CONFIG_CFG80211=y

View File

@ -0,0 +1,27 @@
define KMACHINE pinecube
define KTYPE standard
define KARCH arm
# TODO: find a way to actually include this here instead of in bbappend
#include sun8i.scc
kconf hardware sunxi-cedrus.cfg
kconf hardware sochip-s3.cfg
kconf hardware pinecube.cfg
# Pinecube relevant parts of original patchset from Icenowy Zheng,
# microcai and Daniel Fullmer that didn't make it into mainline.
# Adapted for linux-yocto 6.1.25
patch 0001-pinecube-dts-fix-ir-leds.patch
patch 0002-pinecube-dts-battery.patch
patch 0003-pinecube-dts-flash-xtx.patch
patch 0004-pinecube-dts-usb.patch
patch 0005-pinecube-dts-csi.patch
# applying axp209 patch freezes kernel on boot
# it seems we can either have power control
# or working kernel, but not both
#patch 0006-pinecube-dts-axp209.patch
# in case axp209 ever works, this should be 0007
patch 0006-pinecube-dts-audio.patch

View File

@ -0,0 +1,9 @@
# Configuration for Sochip S3 SoC
# Disable SMP, we have only one CPU
CONFIG_SMP=n
CONFIG_NR_CPUS=n
# sun8i V3S specific
CONFIG_SUN8I_V3S_CCU=y
CONFIG_PINCTRL_SUN8I_V3S=y

View File

@ -0,0 +1,10 @@
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
COMPATIBLE_MACHINE:pinecube = "pinecube"
# TODO: sun8i.scc should be included by pinecube.scc
# but apparently yocto has a problem with including
# scc files from other layers.
SRC_URI += "file://sun8i.scc;type=kmeta;destsuffix=sun8i"
SRC_URI += "file://pinecube.scc;type=kmeta;destsuffix=pinecube"
LINUX_VERSION_EXTENSION = "-${DISTRO}-${MACHINE}-1"

14
wic/pinecube.wks Normal file
View File

@ -0,0 +1,14 @@
# short-description: Helium SD card image for Pinecube
# base: meta-sunxi-bsp/wic/sunxi.wks
# Allwinner sunxi boot ROM expects to find a bootloader at 8KB offset
# on the boot device. The bootloader should be the eGON SPL boot image,
# eg. u-boot-sunxi. For u-boot the built image is usually named
# u-boot-sunxi-with-spl.bin. It should be added to machine's
# IMAGE_BOOT_FILES for wic to find it.
part u-boot --source rawcopy --sourceparams="file=u-boot-sunxi-with-spl.bin" --ondisk mmcblk0 --offset 8 --no-table
# add your partitions and options below:
part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --label helium-root --active --align 4
bootloader --append="console=ttyS0,115200"