diff options
| author | Sébastien Dailly <sebastien@dailly.me> | 2026-05-30 09:58:45 +0200 |
|---|---|---|
| committer | Sébastien Dailly <sebastien@dailly.me> | 2026-05-30 09:58:45 +0200 |
| commit | 8b2420f74367e4973be0dd9556c021588abfe591 (patch) | |
| tree | b95fbf8d5aefc51f619b2506d8ae75ee9f29b75b /board | |
Initial commit
Diffstat (limited to 'board')
18 files changed, 474 insertions, 0 deletions
diff --git a/board/common/common.sh b/board/common/common.sh new file mode 100644 index 0000000..ee1af1f --- /dev/null +++ b/board/common/common.sh @@ -0,0 +1,28 @@ +create_missing_dir() { + echo "creating directory ${TARGET_DIR}/$1" + test -d "${TARGET_DIR}/$1" || mkdir -p "${TARGET_DIR}/$1" +} + +remove_text() { + echo sed --in-place "s/$2//" $1 + sed --in-place "s/$2//" $1 +} + +add_tmpfs() { + create_missing_dir "$1" + if ! grep -q "$1" "${TARGET_DIR}/etc/fstab"; then + cat << __EOF__ >> "${TARGET_DIR}/etc/fstab" +tmpfs $1 tmpfs rw 0 0 +__EOF__ + fi +} + +# Enable a systemd service +enable_service() { + if [ -e "$BR2_EXTERNAL_BASTION_PATH/local/services/$1" ]; then + cp "$BR2_EXTERNAL_BASTION_PATH/local/services/$1" "${TARGET_DIR}/etc/systemd/system/$1" + else + echo "WARN: local/services/$1 does not exists" + fi + ln -sf /etc/systemd/system/$1 "${TARGET_DIR}/usr/lib/systemd/system/multi-user.target.wants/$1" +} diff --git a/board/common/network.sh b/board/common/network.sh new file mode 100644 index 0000000..d28997e --- /dev/null +++ b/board/common/network.sh @@ -0,0 +1,36 @@ +########################### +# # +# Network configuration # +# # +########################### + +# Add default wpa_supplicant.conf if it exists +if [ -f "$BR2_EXTERNAL_BASTION_PATH/wpa_supplicant.conf" ]; then + create_missing_dir "/etc/wpa_supplicant/" + cat "$BR2_EXTERNAL_BASTION_PATH/wpa_supplicant.conf" > "${TARGET_DIR}/etc/wpa_supplicant/wpa_supplicant-wlan0.conf" + + +# cat << __EOF__ > "${TARGET_DIR}/etc/systemd/network/wireless.network" +#[Match] +#Name=wlan0 +# +#[Network] +#DHCP=yes +#__EOF__ + + # Create the link to interface wlan0 directly in the system configuration + ln -sf /usr/lib/systemd/system/wpa_supplicant@.service "${TARGET_DIR}/usr/lib/systemd/system/multi-user.target.wants/wpa_supplicant@wlan0.service" + +fi + + +cat << __EOF__ > "${TARGET_DIR}/etc/systemd/network/dhcp.network" +[Match] +Name=* + +[Network] +DHCP=yes + +[DHCP] +UseDNS=true +__EOF__ diff --git a/board/common/post-build.sh b/board/common/post-build.sh new file mode 100755 index 0000000..d96b74b --- /dev/null +++ b/board/common/post-build.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +set -u +set -e + +# Copie des fichiers de clef ssh +cp -v $BR2_EXTERNAL_BASTION_PATH/local/ssh/* ${TARGET_DIR}/etc/ssh +chmod go-r ${TARGET_DIR}/etc/ssh/ssh_host_ecdsa_key +chmod go-r ${TARGET_DIR}/etc/ssh/ssh_host_ed25519_key +chmod go-r ${TARGET_DIR}/etc/ssh/ssh_host_rsa_key +if ! grep -qF 'Include /etc/ssh/sshd_config.d/*.conf' "${TARGET_DIR}/etc/ssh/sshd_config"; then + cat << __EOF__ >> "${TARGET_DIR}/etc/ssh/sshd_config" +Include /etc/ssh/sshd_config.d/*.conf +__EOF__ +fi + + +#touch ${TARGET_DIR}/home/sebastien/test + +. "${BR2_EXTERNAL_BASTION_PATH}/board/common/common.sh" +. "${BR2_EXTERNAL_BASTION_PATH}/board/common/network.sh" +add_tmpfs '/tmp' +# +## Add a console on tty1 +#if [ -e ${TARGET_DIR}/etc/inittab ]; then +# grep -qE '^tty1::' ${TARGET_DIR}/etc/inittab || \ +# sed -i '/GENERIC_SERIAL/a\ +#tty1::respawn:/sbin/getty -L tty1 0 vt100 # HDMI console' ${TARGET_DIR}/etc/inittab +#fi + +# Put the whole system in readonly +#sed -ie '/^\/dev\/root/ s/rw 0 1/ro 0 0/' "${TARGET_DIR}/etc/fstab" + +mkdir -p "${TARGET_DIR}"/etc/systemd/system/getty.target.wants +# Add a console on ttyAMA0 and enable auto login +ln -sf /usr/lib/systemd/system/serial-getty@.service "${TARGET_DIR}"/etc/systemd/system/getty.target.wants/serial-getty@ttyGS0.service +sed '/^ExecStart=/ s/-o .-p -- ..u./--skip-login --noclear --noissue --login-options "-f root"/' -i "${TARGET_DIR}"/usr/lib/systemd/system/serial-getty@.service diff --git a/board/common/rootfs_overlay/etc/ssh/sshd_config.d/locale.conf b/board/common/rootfs_overlay/etc/ssh/sshd_config.d/locale.conf new file mode 100644 index 0000000..cce7f73 --- /dev/null +++ b/board/common/rootfs_overlay/etc/ssh/sshd_config.d/locale.conf @@ -0,0 +1 @@ +AcceptEnv LANG LC_* COLORTERM NO_COLOR diff --git a/board/common/rootfs_overlay/etc/ssh/sshd_config.d/no_password.conf b/board/common/rootfs_overlay/etc/ssh/sshd_config.d/no_password.conf new file mode 100644 index 0000000..1efa6ab --- /dev/null +++ b/board/common/rootfs_overlay/etc/ssh/sshd_config.d/no_password.conf @@ -0,0 +1,2 @@ +PasswordAuthentication no +PubkeyAuthentication yes diff --git a/board/common/rootfs_overlay/etc/systemd/resolved.conf.d/listen_all.conf b/board/common/rootfs_overlay/etc/systemd/resolved.conf.d/listen_all.conf new file mode 100644 index 0000000..9e68b7a --- /dev/null +++ b/board/common/rootfs_overlay/etc/systemd/resolved.conf.d/listen_all.conf @@ -0,0 +1,3 @@ +[Resolve] +DNSStubListenerExtra=0.0.0.0 +DNSStubListenerExtra=:: diff --git a/board/orangepi/common/extlinux.conf b/board/orangepi/common/extlinux.conf new file mode 100644 index 0000000..12f496b --- /dev/null +++ b/board/orangepi/common/extlinux.conf @@ -0,0 +1,4 @@ +LABEL default + kernel /boot/%LINUXIMAGE% + devicetreedir /boot + append root=PARTUUID=%PARTUUID% rootwait console=${console} rootfstype=ext4 quiet panic=10 diff --git a/board/orangepi/common/genimage.cfg b/board/orangepi/common/genimage.cfg new file mode 100644 index 0000000..c748108 --- /dev/null +++ b/board/orangepi/common/genimage.cfg @@ -0,0 +1,20 @@ +image sdcard.img { + partition u-boot { + in-partition-table = false + image = "u-boot-sunxi-with-spl.bin" + offset = 8K + size = 1000K # 1MB - 8KB(offset) - 16KB(GPT) + } + + hdimage { + partition-table-type = "gpt" + gpt-location = 1008K # 1MB - 16KB(GPT) + gpt-no-backup = true + } + + partition rootfs { + offset = 1M + image = "rootfs.ext4" + partition-uuid = %PARTUUID% + } +} diff --git a/board/orangepi/common/post-build.sh b/board/orangepi/common/post-build.sh new file mode 100755 index 0000000..bc5d630 --- /dev/null +++ b/board/orangepi/common/post-build.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +. ${BR2_EXTERNAL_BASTION_PATH}/board/common/post-build.sh + +linux_image() +{ + if grep -Eq "^BR2_LINUX_KERNEL_UIMAGE=y$" ${BR2_CONFIG}; then + echo "uImage" + elif grep -Eq "^BR2_LINUX_KERNEL_IMAGE=y$" ${BR2_CONFIG}; then + echo "Image" + elif grep -Eq "^BR2_LINUX_KERNEL_IMAGEGZ=y$" ${BR2_CONFIG}; then + echo "Image.gz" + else + echo "zImage" + fi +} + +generic_getty() +{ + if grep -Eq "^BR2_TARGET_GENERIC_GETTY=y$" ${BR2_CONFIG}; then + echo "" + else + echo "s/\s*console=\S*//" + fi +} + +PARTUUID="$($HOST_DIR/bin/uuidgen)" + +install -d "$TARGET_DIR/boot/extlinux/" + +sed -e "$(generic_getty)" \ + -e "s/%LINUXIMAGE%/$(linux_image)/g" \ + -e "s/%PARTUUID%/$PARTUUID/g" \ + "board/orangepi/common/extlinux.conf" > "$TARGET_DIR/boot/extlinux/extlinux.conf" + +sed "s/%PARTUUID%/$PARTUUID/g" "board/orangepi/common/genimage.cfg" > "$BINARIES_DIR/genimage.cfg" diff --git a/board/orangepi/orangepi-zero/linux-extras.fragment b/board/orangepi/orangepi-zero/linux-extras.fragment new file mode 100644 index 0000000..2db241d --- /dev/null +++ b/board/orangepi/orangepi-zero/linux-extras.fragment @@ -0,0 +1,20 @@ +# spidev +CONFIG_SPI_SPIDEV=y + +# spi nor +CONFIG_MTD=y +CONFIG_MTD_OF_PARTS=y +CONFIG_MTD_SPI_NOR=y +CONFIG_MTD_M25P80=y + +# wireless core +CONFIG_WIRELESS=y +CONFIG_CFG80211=y +CONFIG_MAC80211=y +CONFIG_CFG80211_WEXT=y + +# wireless drivers +CONFIG_WLAN=y + +# ondemand cpufreq governor +CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y diff --git a/board/orangepi/orangepi-zero/patches/linux/0001-ARM-dts-orange-pi-zero-interrupt-triggering-xr819.patch b/board/orangepi/orangepi-zero/patches/linux/0001-ARM-dts-orange-pi-zero-interrupt-triggering-xr819.patch new file mode 100644 index 0000000..16207af --- /dev/null +++ b/board/orangepi/orangepi-zero/patches/linux/0001-ARM-dts-orange-pi-zero-interrupt-triggering-xr819.patch @@ -0,0 +1,35 @@ +From 321faaf4b78d46a0c77782c1798856746f0619e9 Mon Sep 17 00:00:00 2001 +From: Sergey Matyukevich <geomatsi@gmail.com> +Date: Fri, 19 May 2017 23:39:48 +0300 +Subject: [PATCH] ARM: dts: orange-pi-zero: specify XR819 WiFi chip + interrupts + +The orange-pi-zero board has Allwinner XR819 SDIO wifi chip. The board +dts file provides a node enabling mmc1 controller. Together with an +out-of-tree driver https://github.com/fifteenhex/xradio this node +enables using the wifi chip. + +This commit specifies XR819 interrupt configuration for the driver. + +Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com> +--- + arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts b/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts +index b7ca916d871d..4e1a9050c6b4 100644 +--- a/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts ++++ b/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts +@@ -125,6 +125,9 @@ + */ + xr819: sdio_wifi@1 { + reg = <1>; ++ compatible = "xradio,xr819"; ++ interrupt-parent = <&pio>; ++ interrupts = <6 10 IRQ_TYPE_EDGE_RISING>; + }; + }; + +-- +2.11.0 + diff --git a/board/orangepi/orangepi-zero/patches/linux/0002-ARM-dts-orange-pi-zero-enable-spi-nor.patch b/board/orangepi/orangepi-zero/patches/linux/0002-ARM-dts-orange-pi-zero-enable-spi-nor.patch new file mode 100644 index 0000000..e4c52ab --- /dev/null +++ b/board/orangepi/orangepi-zero/patches/linux/0002-ARM-dts-orange-pi-zero-enable-spi-nor.patch @@ -0,0 +1,42 @@ +From 068c3baff3048a3db4ef2518ff917ce749cd8169 Mon Sep 17 00:00:00 2001 +From: Sergey Matyukevich <geomatsi@gmail.com> +Date: Sat, 20 May 2017 11:24:26 +0300 +Subject: [PATCH] ARM: dts: orange-pi-zero: enable SPI NOR + +Enable SPI NOR on orange-pi-zero board. + +For more information see: +- http://linux-sunxi.org/Orange_Pi_Zero#SPI_NOR_flash + +Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com> +--- + arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + +diff --git a/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts b/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts +index 4e1a9050c6b4..cdf19821b1f3 100644 +--- a/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts ++++ b/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts +@@ -161,3 +161,19 @@ + /* USB VBUS is always on */ + status = "okay"; + }; ++ ++&spi0 { ++ status = "okay"; ++ ++ flash@0 { ++ #address-cells = <1>; ++ #size-cells = <1>; ++ compatible = "mxicy,mx25l1606e", "winbond,w25q128"; ++ reg = <0>; ++ spi-max-frequency = <40000000>; ++ ++ partition@00000000 { ++ reg = <0x00000000 0x200000>; /* 2Mb */ ++ }; ++ }; ++}; +-- +2.11.0 + diff --git a/board/orangepi/orangepi-zero/patches/linux/0003-ARM-dts-orange-pi-zero-enable-spidev.patch b/board/orangepi/orangepi-zero/patches/linux/0003-ARM-dts-orange-pi-zero-enable-spidev.patch new file mode 100644 index 0000000..ae0ed9b --- /dev/null +++ b/board/orangepi/orangepi-zero/patches/linux/0003-ARM-dts-orange-pi-zero-enable-spidev.patch @@ -0,0 +1,42 @@ +From 8dd1b2a696bb7e9914abd11cc6f5c0f54c33d626 Mon Sep 17 00:00:00 2001 +From: Sergey Matyukevich <geomatsi@gmail.com> +Date: Sat, 20 May 2017 15:36:51 +0300 +Subject: [PATCH] ARM: dts: orange-pi-zero: enable spidev + +On orange-pi-zero board SPI1 pins are accessible via GPIO expansion port. +This patch enables spidev driver for SPI1. + +Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com> +--- + arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts b/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts +index cdf19821b1f3..7242aaecb14f 100644 +--- a/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts ++++ b/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts +@@ -59,6 +59,7 @@ + serial0 = &uart0; + /* ethernet0 is the H3 emac, defined in sun8i-h3.dtsi */ + ethernet1 = &xr819; ++ spi1 = &spi1; + }; + + chosen { +@@ -177,3 +178,13 @@ + }; + }; + }; ++ ++&spi1 { ++ status = "okay"; ++ ++ spidev@0 { ++ compatible = "rohm,dh2228fv"; ++ reg = <0>; ++ spi-max-frequency = <10000000>; ++ }; ++}; +-- +2.11.0 + diff --git a/board/orangepi/orangepi-zero/patches/linux/0004-ARM-dts-orange-pi-zero-enable-uart.patch b/board/orangepi/orangepi-zero/patches/linux/0004-ARM-dts-orange-pi-zero-enable-uart.patch new file mode 100644 index 0000000..839bc16 --- /dev/null +++ b/board/orangepi/orangepi-zero/patches/linux/0004-ARM-dts-orange-pi-zero-enable-uart.patch @@ -0,0 +1,35 @@ +From e8768cc1f0f1231cbd4864417de629330e21222d Mon Sep 17 00:00:00 2001 +From: Sergey Kuzminov <kuzminov.sergey81@gmail.com> +Date: Sun, 21 Nov 2021 00:58:32 +0300 +Subject: [PATCH] ARM: dts: orange-pi-zero: enable uart + +Enable uart1 and uart2 on orange-pi-zero board. + +Signed-off-by: Sergey Kuzminov <kuzminov.sergey81@gmail.com> +--- + arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts b/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts +index f19ed981da9d..03acf166ab70 100644 +--- a/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts ++++ b/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts +@@ -184,13 +184,13 @@ &uart0 { + &uart1 { + pinctrl-names = "default"; + pinctrl-0 = <&uart1_pins>; +- status = "disabled"; ++ status = "okay"; + }; + + &uart2 { + pinctrl-names = "default"; + pinctrl-0 = <&uart2_pins>; +- status = "disabled"; ++ status = "okay"; + }; + + &usb_otg { +-- +2.32.0 + diff --git a/board/orangepi/orangepi-zero/readme.txt b/board/orangepi/orangepi-zero/readme.txt new file mode 100644 index 0000000..1afdbb7 --- /dev/null +++ b/board/orangepi/orangepi-zero/readme.txt @@ -0,0 +1,29 @@ +OrangePi Zero + +Intro +===== + +This default configuration will allow you to start experimenting with the +buildroot environment for the OrangePi Zero. With the current configuration +it will bring-up the board, and allow access through the serial console. + +How to build it +=============== + +Configure Buildroot: + + $ make orangepi_zero_defconfig + +Compile everything and build the SD card image: + + $ make + +How to write the SD card +======================== + +Once the build process is finished you will have an image called "sdcard.img" +in the output/images/ directory. + +Copy the bootable "sdcard.img" onto an SD card with "dd": + + $ sudo dd if=output/images/sdcard.img of=/dev/sdX diff --git a/board/post-image.sh b/board/post-image.sh new file mode 100755 index 0000000..806eb6b --- /dev/null +++ b/board/post-image.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +set -e + +. "${BR2_EXTERNAL_BASTION_PATH}/board/common/common.sh" + +BOARD_DIR="$(dirname $0)" +GENIMAGE_CFG="${BOARD_DIR}/genimage-${BOARDNAME}.cfg" +GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp" + +for arg in "$@" +do + case "${arg}" in + --add-miniuart-bt-overlay) + if ! grep -qE '^dtoverlay=' "${BINARIES_DIR}/rpi-firmware/config.txt"; then + echo "Adding 'dtoverlay=miniuart-bt' to config.txt (fixes ttyAMA0 serial console)." + cat << __EOF__ >> "${BINARIES_DIR}/rpi-firmware/config.txt" + +# fixes rpi (3B, 3B+, 3A+, 4B and Zero W) ttyAMA0 serial console +dtoverlay=miniuart-bt +__EOF__ + fi + ;; + --aarch64) + # Run a 64bits kernel (armv8) + sed -e '/^kernel=/s,=.*,=Image,' -i "${BINARIES_DIR}/rpi-firmware/config.txt" + if ! grep -qE '^arm_64bit=1' "${BINARIES_DIR}/rpi-firmware/config.txt"; then + cat << __EOF__ >> "${BINARIES_DIR}/rpi-firmware/config.txt" + +# enable 64bits support +arm_64bit=1 +__EOF__ + fi + ;; + --gpu_mem_256=*|--gpu_mem_512=*|--gpu_mem_1024=*) + # Set GPU memory + gpu_mem="${arg:2}" + sed -e "/^${gpu_mem%=*}=/s,=.*,=${gpu_mem##*=}," -i "${BINARIES_DIR}/rpi-firmware/config.txt" + ;; + + --configure-piaudio) + # Configure piaudio + + # Inform the kernel about the filesystem and ro state + if ! grep -qE 'fastboot noswap ro' "${BINARIES_DIR}/rpi-firmware/cmdline.txt"; then + sed '/^root=/ s/$/ fastboot noswap ro/' -i "${BINARIES_DIR}/rpi-firmware/cmdline.txt" + fi + + ;; + esac + +done + +# Pass an empty rootpath. genimage makes a full copy of the given rootpath to +# ${GENIMAGE_TMP}/root so passing TARGET_DIR would be a waste of time and disk +# space. We don't rely on genimage to build the rootfs image, just to insert a +# pre-built one in the disk image. + +trap 'rm -rf "${ROOTPATH_TMP}"' EXIT +ROOTPATH_TMP="$(mktemp -d)" + +rm -rf "${GENIMAGE_TMP}" + +genimage \ + --rootpath "${ROOTPATH_TMP}" \ + --tmppath "${GENIMAGE_TMP}" \ + --inputpath "${BINARIES_DIR}" \ + --outputpath "${BINARIES_DIR}" \ + --config "${GENIMAGE_CFG}" + +exit $? diff --git a/board/raspberrypi/cmdline.txt b/board/raspberrypi/cmdline.txt new file mode 100644 index 0000000..a318558 --- /dev/null +++ b/board/raspberrypi/cmdline.txt @@ -0,0 +1 @@ +root=/dev/mmcblk0p2 rootwait modules-load=dwc2,g_serial console=tty1 console=ttyAMA0,115200 diff --git a/board/raspberrypi/config_0w.txt b/board/raspberrypi/config_0w.txt new file mode 100644 index 0000000..6b862ef --- /dev/null +++ b/board/raspberrypi/config_0w.txt @@ -0,0 +1,32 @@ +# Please note that this is only a sample, we recommend you to change it to fit +# your needs. +# You should override this file using a post-build script. +# See http://buildroot.org/manual.html#rootfs-custom +# and http://elinux.org/RPiconfig for a description of config.txt syntax + +# We always use the same names, the real used variant is selected by +# BR2_PACKAGE_RPI_FIRMWARE_{DEFAULT,X,CD} choice +start_file=start.elf +fixup_file=fixup.dat + +kernel=zImage + +# To use an external initramfs file +#initramfs rootfs.cpio.gz + +# Disable overscan assuming the display supports displaying the full resolution +# If the text shown on the screen disappears off the edge, comment this out +disable_overscan=1 + +# How much memory in MB to assign to the GPU on Pi models having +# 256, 512 or 1024 MB total memory +gpu_mem_256=100 +gpu_mem_512=100 +gpu_mem_1024=100 +boot_delay=0 +initial_turbo=10 +dtoverlay=dwc2 + +# https://github.com/raspberrypi/firmware/tree/master/boot/overlays +# dtparam=krnbt=on +dtparam=i2c=on |
