From de24c4c3c0bbc7509f571fd6f68671e5eb4f9618 Mon Sep 17 00:00:00 2001 From: Yilin Sun Date: Sun, 21 Jan 2024 16:23:28 +0800 Subject: [PATCH] Initial commit. Signed-off-by: Yilin Sun --- .gitignore | 2 + .gitmodules | 3 + LICENSE | 8 + README.md | 18 + buildroot | 1 + buildroot_make.sh | 3 + external_tree/Config.in | 0 external_tree/board/.gitkeep | 0 .../tronlong/t113i-minievm/linux.fragment | 9 + .../sun8i-t113i-tronlong-tlt113-minievm.dts | 322 ++++++++++++++++++ .../configs/tlt113_minievm_defconfig | 41 +++ .../customizations/overlay/etc/sudoers | 97 ++++++ .../overlay/etc/systemd/journald.conf | 2 + .../customizations/users.table.example | 1 + external_tree/external.desc | 3 + external_tree/external.mk | 0 external_tree/package/.gitkeep | 0 external_tree/patches/kernel/foresee.patch | 15 + 18 files changed, 525 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 LICENSE create mode 100644 README.md create mode 160000 buildroot create mode 100755 buildroot_make.sh create mode 100644 external_tree/Config.in create mode 100644 external_tree/board/.gitkeep create mode 100644 external_tree/board/tronlong/t113i-minievm/linux.fragment create mode 100644 external_tree/board/tronlong/t113i-minievm/sun8i-t113i-tronlong-tlt113-minievm.dts create mode 100644 external_tree/configs/tlt113_minievm_defconfig create mode 100644 external_tree/customizations/overlay/etc/sudoers create mode 100644 external_tree/customizations/overlay/etc/systemd/journald.conf create mode 100644 external_tree/customizations/users.table.example create mode 100644 external_tree/external.desc create mode 100644 external_tree/external.mk create mode 100644 external_tree/package/.gitkeep create mode 100644 external_tree/patches/kernel/foresee.patch diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7f1f834 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/output +/external_tree/customizations/users.table diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e1d58ff --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "buildroot"] + path = buildroot + url = https://github.com/buildroot/buildroot.git diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6487540 --- /dev/null +++ b/LICENSE @@ -0,0 +1,8 @@ +MIT licence +Copyright (c) 2021 imi415 + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..883ea58 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +# SystemAgent - Base system port + +This is the project for SystemAgent compatible SBCs. + +## How to build the same image + +* Clone buildroot repository. +* Run `buildroot_make.sh xxxx_defconfig` (see `external_tree/configs`). +* Run `buildroot_make.sh nconfig` to make your changes. +* Run `buildroot_make.sh` to start your runs. + +## Necessary modifications +### Add new users +Edit users.table in `external_tree/customizations` directory. + +### Copy whatever you want into the filesystem +Add them to the `external_tree/customizations/overlay` directory, if the directory does not exist, create it. + diff --git a/buildroot b/buildroot new file mode 160000 index 0000000..954aeb7 --- /dev/null +++ b/buildroot @@ -0,0 +1 @@ +Subproject commit 954aeb7c721bf7edd56832650e8ebfb3b5c6fbd3 diff --git a/buildroot_make.sh b/buildroot_make.sh new file mode 100755 index 0000000..921a6af --- /dev/null +++ b/buildroot_make.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +make O=${PWD}/output BR2_EXTERNAL=${PWD}/external_tree -C buildroot "$@" diff --git a/external_tree/Config.in b/external_tree/Config.in new file mode 100644 index 0000000..e69de29 diff --git a/external_tree/board/.gitkeep b/external_tree/board/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/external_tree/board/tronlong/t113i-minievm/linux.fragment b/external_tree/board/tronlong/t113i-minievm/linux.fragment new file mode 100644 index 0000000..5dd2e4e --- /dev/null +++ b/external_tree/board/tronlong/t113i-minievm/linux.fragment @@ -0,0 +1,9 @@ +CONFIG_LEDS_TRIGGER_MTD=y +CONFIG_MTD=y +CONFIG_MTD_UBI=y +CONFIG_MTD_SPI_NAND=y +CONFIG_UBIFS_FS=y +CONFIG_MOTORCOMM_PHY=y +CONFIG_TYPEC=y +CONFIG_TYPEC_WUSB3801=y +CONFIG_DRM_LONTIUM_LT8912B=y diff --git a/external_tree/board/tronlong/t113i-minievm/sun8i-t113i-tronlong-tlt113-minievm.dts b/external_tree/board/tronlong/t113i-minievm/sun8i-t113i-tronlong-tlt113-minievm.dts new file mode 100644 index 0000000..fed40a1 --- /dev/null +++ b/external_tree/board/tronlong/t113i-minievm/sun8i-t113i-tronlong-tlt113-minievm.dts @@ -0,0 +1,322 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +// Copyright (C) 2022 Arm Ltd. +/* + * Common peripherals and configurations for MangoPi MQ-R boards. + */ + +#include +#include + +/dts-v1/; + +#include + +/ { + model = "Tronlong TLT113-MiniEVM"; + compatible = "tronlong,tlt113-minievm", "allwinner,sun8i-t113i"; + + aliases { + serial2 = &uart2; + }; + + chosen { + stdout-path = "serial2:115200n8"; + }; + + leds { + compatible = "gpio-leds"; + + led-0 { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&pio 2 0 GPIO_ACTIVE_HIGH>; /* PC0 */ + linux,default-trigger = "heartbeat"; + }; + + led-1 { + color = ; + function = LED_FUNCTION_DISK; + gpios = <&pio 2 1 GPIO_ACTIVE_HIGH>; /* PC1 */ + linux,default-trigger = "mtd"; + }; + + led-2 { + color = ; + function = LED_FUNCTION_HEARTBEAT; + gpios = <&pio 6 11 GPIO_ACTIVE_HIGH>; /* PG11 */ + linux,default-trigger = "default-on"; + }; + + }; + + hdmi-connector { + compatible = "hdmi-connector"; + ddc-i2c-bus = <&i2c0>; + label = "hdmi"; + type = "a"; + + port { + hdmi_connector_in: endpoint { + remote-endpoint = <&bridge_hdmi_out>; + }; + }; + }; + + /* EC2232E DC/DC regulator on SoM */ + reg_vcc5v: regulator-5v { + compatible = "regulator-fixed"; + regulator-name = "vcc-5v"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-always-on; + }; + + /* EC2232E DC/DC regulator on SoM */ + reg_3v3: regulator-3v3 { + compatible = "regulator-fixed"; + regulator-name = "vcc-3v3"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + vin-supply = <®_vcc5v>; + }; + + /* EC2232E DC/DC regulator on SoM, also supplying VDD-SYS */ + reg_vcc_core: regulator-core { + compatible = "regulator-fixed"; + regulator-name = "vcc-core"; + regulator-min-microvolt = <880000>; + regulator-max-microvolt = <880000>; + vin-supply = <®_vcc5v>; + }; + + reg_vbus_supply: regulator-vbus-otg { + compatible = "regulator-fixed"; + regulator-name = "vbus-otg"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + gpio = <&pio 1 12 GPIO_ACTIVE_HIGH>; + vin-supply = <®_vcc5v>; + }; +}; + +&cpu0 { + cpu-supply = <®_vcc_core>; +}; + +&cpu1 { + cpu-supply = <®_vcc_core>; +}; + +&wdt { + status = "okay"; +}; + +&dcxo { + clock-frequency = <24000000>; +}; + +&ehci1 { + status = "okay"; +}; + +&ohci1 { + status = "okay"; +}; + +&pio { + vcc-pb-supply = <®_3v3>; + vcc-pd-supply = <®_3v3>; + vcc-pe-supply = <®_3v3>; + vcc-pf-supply = <®_3v3>; + vcc-pg-supply = <®_3v3>; + + uart2_pg_pins: uart2-pg-pins { + pins = "PG17", "PG18"; + function = "uart2"; + }; + + rgmii_pg_pins: rgmii-pg-pins { + pins = "PG0", "PG1", "PG2", "PG3", "PG4", + "PG5", "PG6", "PG7", "PG8", "PG9", + "PG10", "PG12", "PG14", "PG15"; + function = "emac"; + }; + + i2c0_pins: i2c0-pins { + pins = "PB10", "PB11"; + function = "i2c0"; + }; + + i2c2_pins: i2c2-pins { + pins = "PE12", "PE13"; + function = "i2c2"; + }; + + spi0_misc_pins: spi0-misc-pins { + pins = "PC6", "PC7"; + function = "spi0"; + }; +}; + +&uart2 { + pinctrl-names = "default"; + pinctrl-0 = <&uart2_pg_pins>; + status = "okay"; +}; + +&mmc0 { + pinctrl-0 = <&mmc0_pins>; + pinctrl-names = "default"; + vmmc-supply = <®_3v3>; + cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; + disable-wp; + bus-width = <4>; + status = "okay"; +}; + +&emac { + pinctrl-0 = <&rgmii_pg_pins>; + pinctrl-names = "default"; + status = "okay"; + phy-handle = <&ephy>; + phy-mode = "rgmii-id"; + allwinner,tx-delay-ps = <200>; + allwinner,rx-delay-ps = <0>; + phy-supply = <®_3v3>; +}; + +&mdio { + ephy: ethernet-phy@0 { + reg = <0>; + reset-gpios = <&pio 6 13 GPIO_ACTIVE_LOW>; /* PG13 */ + rx-internal-delay-ps = <600>; + tx-internal-delay-ps = <450>; + reset-assert-us = <10000>; + reset-deassert-us = <1000000>; + }; +}; + +&i2c0 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c0_pins>; + status = "okay"; +}; + +&i2c2 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c2_pins>; + status = "okay"; + + hdmi_lontium_lt8912: hdmi@48 { + compatible = "lontium,lt8912b"; + reg = <0x48>; + reset-gpios = <&pio 4 11 GPIO_ACTIVE_LOW>; /* PE11 */ + status = "okay"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + bridge_dsi_in: endpoint { + data-lanes = <0 1 2 3>; + remote-endpoint = <&host_dsi_out>; + }; + }; + + port@1 { + reg = <1>; + bridge_hdmi_out: endpoint { + remote-endpoint = <&hdmi_connector_in>; + }; + }; + }; + }; + tcpc@60 { + compatible = "willsemi,wusb3801"; + reg = <0x60>; + interrupt-parent = <&pio>; + interrupts = <4 3 IRQ_TYPE_LEVEL_LOW>; /* PE3 */ + + connector { + compatible = "usb-c-connector"; + label = "USB-C"; + vbus-supply = <®_vbus_supply>; + power-role = "source"; + data-role = "dual"; + typec-power-opmode = "default"; + pd-disable; + }; + }; +}; + +&spi0 { + pinctrl-names = "default"; + pinctrl-0 = <&spi0_pins &spi0_misc_pins>; + status = "okay"; + + spi_nand@0 { + compatible = "spi-nand"; + reg = <0>; + spi-max-frequency = <80000000>; + spi-tx-bus-width = <4>; + spi-rx-bus-width = <4>; + partitions { + #address-cells = <1>; + #size-cells = <1>; + + compatible = "fixed-partitions"; + partition@0 { + label = "u-boot"; + reg = <0x0 0x100000>; /* 1MB */ + }; + + partition@100000 { + label = "env"; + reg = <0x100000 0x400000>; /* 4MB */ + }; + + partition@500000 { + label = "rootfs"; + reg = <0x500000 0xfb00000>; /* 251MB */ + }; + }; + }; +}; + +&dsi { + status = "okay"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port { + host_dsi_out: endpoint { + remote-endpoint = <&bridge_dsi_in>; + }; + }; + }; +}; + +&dphy { + status = "okay"; +}; + +&tcon_top { + status = "okay"; +}; + +&tcon_lcd0 { + status = "okay"; +}; + +&usb_otg { + dr_mode = "peripheral"; + status = "okay"; +}; + +&usbphy { + usb1_vbus-supply = <®_vcc5v>; + status = "okay"; +}; diff --git a/external_tree/configs/tlt113_minievm_defconfig b/external_tree/configs/tlt113_minievm_defconfig new file mode 100644 index 0000000..ae8d18b --- /dev/null +++ b/external_tree/configs/tlt113_minievm_defconfig @@ -0,0 +1,41 @@ +BR2_arm=y +BR2_cortex_a7=y +BR2_BINUTILS_VERSION_2_41_X=y +BR2_GCC_VERSION_13_X=y +BR2_TOOLCHAIN_BUILDROOT_CXX=y +BR2_PACKAGE_HOST_GDB=y +BR2_PACKAGE_HOST_GDB_TUI=y +BR2_GDB_VERSION_13=y +BR2_TARGET_GENERIC_HOSTNAME="imi415-t113i-1" +BR2_TARGET_GENERIC_ISSUE="What industrial?" +BR2_INIT_SYSTEMD=y +# BR2_TARGET_ENABLE_ROOT_LOGIN is not set +BR2_SYSTEM_BIN_SH_BASH=y +BR2_SYSTEM_DHCP="eth0" +BR2_GENERATE_LOCALE="en_US.UTF-8" +BR2_TARGET_LOCALTIME="Asia/Shanghai" +BR2_ROOTFS_USERS_TABLES="$(BR2_EXTERNAL_t113_mini_PATH)/customizations/users.table" +BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL_t113_mini_PATH)/customizations/overlay" +BR2_LINUX_KERNEL=y +BR2_LINUX_KERNEL_CUSTOM_GIT=y +BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/torvalds/linux.git" +BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="de927f6c0b07d9e698416c5b287c521b07694cac" +BR2_LINUX_KERNEL_PATCH="$(BR2_EXTERNAL_t113_mini_PATH)/patches/kernel" +BR2_LINUX_KERNEL_DEFCONFIG="sunxi" +BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_t113_mini_PATH)/board/tronlong/t113i-minievm/linux.fragment" +BR2_LINUX_KERNEL_DTS_SUPPORT=y +BR2_LINUX_KERNEL_CUSTOM_DTS_PATH="$(BR2_EXTERNAL_t113_mini_PATH)/board/tronlong/t113i-minievm/sun8i-t113i-tronlong-tlt113-minievm.dts" +BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT=y +BR2_LINUX_KERNEL_INSTALL_TARGET=y +BR2_PACKAGE_MTD=y +BR2_PACKAGE_I2C_TOOLS=y +BR2_PACKAGE_MDIO_TOOLS=y +BR2_PACKAGE_SYSSTAT=y +BR2_PACKAGE_IPERF3=y +BR2_PACKAGE_OPENSSH=y +BR2_PACKAGE_SUDO=y +BR2_PACKAGE_HTOP=y +BR2_TARGET_ROOTFS_UBI=y +BR2_TARGET_ROOTFS_UBI_SUBSIZE=0 +BR2_TARGET_ROOTFS_UBIFS_LEBSIZE=0x1F000 +BR2_TARGET_ROOTFS_UBIFS_OPTS="-F" diff --git a/external_tree/customizations/overlay/etc/sudoers b/external_tree/customizations/overlay/etc/sudoers new file mode 100644 index 0000000..f4a262a --- /dev/null +++ b/external_tree/customizations/overlay/etc/sudoers @@ -0,0 +1,97 @@ +## sudoers file. +## +## This file MUST be edited with the 'visudo' command as root. +## Failure to use 'visudo' may result in syntax or file permission errors +## that prevent sudo from running. +## +## See the sudoers man page for the details on how to write a sudoers file. +## + +## +## Host alias specification +## +## Groups of machines. These may include host names (optionally with wildcards), +## IP addresses, network numbers or netgroups. +# Host_Alias WEBSERVERS = www1, www2, www3 + +## +## User alias specification +## +## Groups of users. These may consist of user names, uids, Unix groups, +## or netgroups. +# User_Alias ADMINS = millert, dowdy, mikef + +## +## Cmnd alias specification +## +## Groups of commands. Often used to group related commands together. +# Cmnd_Alias PROCESSES = /usr/bin/nice, /bin/kill, /usr/bin/renice, \ +# /usr/bin/pkill, /usr/bin/top +# Cmnd_Alias REBOOT = /sbin/halt, /sbin/reboot, /sbin/poweroff + +## +## Defaults specification +## +## You may wish to keep some of the following environment variables +## when running commands via sudo. +## +## Locale settings +# Defaults env_keep += "LANG LANGUAGE LINGUAS LC_* _XKB_CHARSET" +## +## Run X applications through sudo; HOME is used to find the +## .Xauthority file. Note that other programs use HOME to find +## configuration files and this may lead to privilege escalation! +# Defaults env_keep += "HOME" +## +## X11 resource path settings +# Defaults env_keep += "XAPPLRESDIR XFILESEARCHPATH XUSERFILESEARCHPATH" +## +## Desktop path settings +# Defaults env_keep += "QTDIR KDEDIR" +## +## Allow sudo-run commands to inherit the callers' ConsoleKit session +# Defaults env_keep += "XDG_SESSION_COOKIE" +## +## Uncomment to enable special input methods. Care should be taken as +## this may allow users to subvert the command being run via sudo. +# Defaults env_keep += "XMODIFIERS GTK_IM_MODULE QT_IM_MODULE QT_IM_SWITCHER" +## +## Uncomment to use a hard-coded PATH instead of the user's to find commands +# Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" +## +## Uncomment to send mail if the user does not enter the correct password. +# Defaults mail_badpass +## +## Uncomment to enable logging of a command's output, except for +## sudoreplay and reboot. Use sudoreplay to play back logged sessions. +# Defaults log_output +# Defaults!/usr/bin/sudoreplay !log_output +# Defaults!/usr/local/bin/sudoreplay !log_output +# Defaults!REBOOT !log_output + +## +## Runas alias specification +## + +## +## User privilege specification +## +root ALL=(ALL) ALL + +## Uncomment to allow members of group wheel to execute any command +# %wheel ALL=(ALL) ALL + +## Same thing without a password +%wheel ALL=(ALL) NOPASSWD: ALL + +## Uncomment to allow members of group sudo to execute any command +# %sudo ALL=(ALL) ALL + +## Uncomment to allow any user to run sudo if they know the password +## of the user they are running the command as (root by default). +# Defaults targetpw # Ask for the password of the target user +# ALL ALL=(ALL) ALL # WARNING: only use this together with 'Defaults targetpw' + +## Read drop-in files from /etc/sudoers.d +## (the '#' here does not indicate a comment) +#includedir /etc/sudoers.d diff --git a/external_tree/customizations/overlay/etc/systemd/journald.conf b/external_tree/customizations/overlay/etc/systemd/journald.conf new file mode 100644 index 0000000..b69850d --- /dev/null +++ b/external_tree/customizations/overlay/etc/systemd/journald.conf @@ -0,0 +1,2 @@ +[Journal] +Storage=volatile diff --git a/external_tree/customizations/users.table.example b/external_tree/customizations/users.table.example new file mode 100644 index 0000000..d2edb46 --- /dev/null +++ b/external_tree/customizations/users.table.example @@ -0,0 +1 @@ +# See https://buildroot.org/downloads/manual/manual.html#makeuser-syntax for documentation. diff --git a/external_tree/external.desc b/external_tree/external.desc new file mode 100644 index 0000000..e8fbb6a --- /dev/null +++ b/external_tree/external.desc @@ -0,0 +1,3 @@ +name: t113_mini +desc: Tronlong T113-i MiniEVM base system + diff --git a/external_tree/external.mk b/external_tree/external.mk new file mode 100644 index 0000000..e69de29 diff --git a/external_tree/package/.gitkeep b/external_tree/package/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/external_tree/patches/kernel/foresee.patch b/external_tree/patches/kernel/foresee.patch new file mode 100644 index 0000000..bd72009 --- /dev/null +++ b/external_tree/patches/kernel/foresee.patch @@ -0,0 +1,15 @@ +diff --git a/drivers/mtd/nand/spi/foresee.c b/drivers/mtd/nand/spi/foresee.c +index e0d2d9257045..05b27341b9bd 100644 +--- a/drivers/mtd/nand/spi/foresee.c ++++ b/drivers/mtd/nand/spi/foresee.c +@@ -22,8 +22,8 @@ static SPINAND_OP_VARIANTS(write_cache_variants, + SPINAND_PROG_LOAD(true, 0, NULL, 0)); + + static SPINAND_OP_VARIANTS(update_cache_variants, +- SPINAND_PROG_LOAD_X4(false, 0, NULL, 0), +- SPINAND_PROG_LOAD(false, 0, NULL, 0)); ++ SPINAND_PROG_LOAD_X4(true, 0, NULL, 0), ++ SPINAND_PROG_LOAD(true, 0, NULL, 0)); + + static int f35sqa002g_ooblayout_ecc(struct mtd_info *mtd, int section, + struct mtd_oob_region *region)