diff --git a/Documentation/boards/orangepi.md b/Documentation/boards/orangepi.md new file mode 100644 index 000000000..a5f2e82f0 --- /dev/null +++ b/Documentation/boards/orangepi.md @@ -0,0 +1,20 @@ +# Raspberry PI + +Supported Hardware: + +| Device | Board | +|--------|-----------| +| Orange Pi Prime | opi-prime | + +## Serial console + +The serial port on the Orange Pi Prime is a 3 pin header located between the +power and reset buttons. The pins are labelled away from the board edge. Flow +control must be disabled in order to send data. The serial specs are 3.3V TTL, +115200,8,n,1 + +## I2C + +Add `dtparam=i2c0=on` to `cmdline.txt` + +[config]: ../configuration.md#automatic diff --git a/Documentation/kernel.md b/Documentation/kernel.md index c1a814fae..d262bc0f4 100644 --- a/Documentation/kernel.md +++ b/Documentation/kernel.md @@ -7,4 +7,5 @@ | Raspberry Pi | 4.14.81 | | Tinker Board | 4.14.82 | | Odroid-C2 | 4.18.20 | +| Orangepi-Prime | 4.18.20 | | Intel NUC | 4.14.82 | diff --git a/buildroot-external/board/orangepi/hassos-hook.sh b/buildroot-external/board/orangepi/hassos-hook.sh new file mode 100755 index 000000000..983837053 --- /dev/null +++ b/buildroot-external/board/orangepi/hassos-hook.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2155 + +function hassos_pre_image() { + local BOOT_DATA="$(path_boot_dir)" + local SPL="${BINARIES_DIR}/sunxi-spl.bin" + local UBOOT="${BINARIES_DIR}/u-boot.itb" + local spl_img="$(path_spl_img)" + + cp "${BINARIES_DIR}/boot.scr" "${BOOT_DATA}/boot.scr" + cp "${BINARIES_DIR}/sun50i-h5-orangepi-prime.dtb" "${BOOT_DATA}/sun50i-h5-orangepi-prime.dtb" + touch "${BOOT_DATA}/cmdline.txt" + touch "${BOOT_DATA}/config.txt" + + # SPL + create_spl_image + + dd if="${SPL}" of="${spl_img}" conv=notrunc bs=512 seek=16 + dd if="${UBOOT}" of="${spl_img}" conv=notrunc bs=512 seek=80 +} + + +function hassos_post_image() { + convert_disk_image_gz +} diff --git a/buildroot-external/board/orangepi/patches/README.md b/buildroot-external/board/orangepi/patches/README.md new file mode 100644 index 000000000..7b1911b5f --- /dev/null +++ b/buildroot-external/board/orangepi/patches/README.md @@ -0,0 +1,5 @@ +## Kernel +https://github.com/armbian/build/tree/master/patch/kernel/sunxi-next + +## u-boot +https://github.com/armbian/build/tree/master/patch/u-boot/u-boot-sunxi diff --git a/buildroot-external/board/orangepi/patches/uboot/0020-sunxi-call-fdt_fixup_ethernet-again-to-set-macaddr-f.patch b/buildroot-external/board/orangepi/patches/uboot/0020-sunxi-call-fdt_fixup_ethernet-again-to-set-macaddr-f.patch new file mode 100644 index 000000000..45dc3ae32 --- /dev/null +++ b/buildroot-external/board/orangepi/patches/uboot/0020-sunxi-call-fdt_fixup_ethernet-again-to-set-macaddr-f.patch @@ -0,0 +1,41 @@ +From 55d3cc28b37000d1a3d7224c0ba4a808274e0b33 Mon Sep 17 00:00:00 2001 +From: Icenowy Zheng +Date: Fri, 27 Oct 2017 17:25:00 +0800 +Subject: [PATCH 20/20] sunxi: call fdt_fixup_ethernet again to set macaddr for + more aliases + +Sometimes some ethernet aliases do not exist in U-Boot FDT but they +exist in the FDT used to boot the system. In this situation +setup_environment is called again in ft_board_setup to generate macaddr +environment variable for them. However now the call to +fdt_fixup_ethernet is moved before the call of ft_board_setup. + +Call fdt_fixup_ethernet again to add MAC addresses for the extra +ethernet aliases. + +Signed-off-by: Icenowy Zheng +--- + board/sunxi/board.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/board/sunxi/board.c b/board/sunxi/board.c +index 192cf8ca45..0fe70f47cb 100644 +--- a/board/sunxi/board.c ++++ b/board/sunxi/board.c +@@ -751,10 +751,12 @@ int ft_board_setup(void *blob, bd_t *bd) + int __maybe_unused r; + + /* +- * Call setup_environment again in case the boot fdt has +- * ethernet aliases the u-boot copy does not have. ++ * Call setup_environment and fdt_fixup_ethernet again ++ * in case the boot fdt has ethernet aliases the u-boot ++ * copy does not have. + */ + setup_environment(blob); ++ fdt_fixup_ethernet(blob); + + #ifdef CONFIG_VIDEO_DT_SIMPLEFB + r = sunxi_simplefb_setup(blob); +-- +2.13.6 diff --git a/buildroot-external/board/orangepi/patches/uboot/4kfix-limit-screen-to-full-hd.patch b/buildroot-external/board/orangepi/patches/uboot/4kfix-limit-screen-to-full-hd.patch new file mode 100644 index 000000000..7abe749fc --- /dev/null +++ b/buildroot-external/board/orangepi/patches/uboot/4kfix-limit-screen-to-full-hd.patch @@ -0,0 +1,19 @@ +diff --git a/drivers/video/sunxi/sunxi_display.c b/drivers/video/sunxi/sunxi_display.c +index 92c9d06054..cd16d69e30 100644 +--- a/drivers/video/sunxi/sunxi_display.c ++++ b/drivers/video/sunxi/sunxi_display.c +@@ -1274,8 +1274,12 @@ void *video_hw_init(void) + ret = sunxi_hdmi_hpd_detect(hpd_delay); + if (ret) { + printf("HDMI connected: "); +- if (edid && sunxi_hdmi_edid_get_mode(&custom) == 0) +- mode = &custom; ++ if (edid && sunxi_hdmi_edid_get_mode(&custom) == 0) { ++ if ((custom.xres <= 1920) && (custom.yres <= 1080)) ++ mode = &custom; ++ else ++ mode = &res_mode_init[RES_MODE_1920x1080]; ++ } + } else if (hpd) { + sunxi_hdmi_shutdown(); + sunxi_display.monitor = sunxi_get_default_mon(false); diff --git a/buildroot-external/board/orangepi/patches/uboot/adjust-default-dram-clockspeeds.patch b/buildroot-external/board/orangepi/patches/uboot/adjust-default-dram-clockspeeds.patch new file mode 100644 index 000000000..5156fd2d6 --- /dev/null +++ b/buildroot-external/board/orangepi/patches/uboot/adjust-default-dram-clockspeeds.patch @@ -0,0 +1,13 @@ +diff --git a/configs/orangepi_prime_defconfig b/configs/orangepi_prime_defconfig +index 103936d772..990cf2a8c0 100644 +--- a/configs/orangepi_prime_defconfig ++++ b/configs/orangepi_prime_defconfig +@@ -1,7 +1,7 @@ + CONFIG_ARM=y + CONFIG_ARCH_SUNXI=y + CONFIG_MACH_SUN50I_H5=y +-CONFIG_DRAM_CLK=672 ++CONFIG_DRAM_CLK=624 + CONFIG_DRAM_ZQ=3881977 + CONFIG_DEFAULT_DEVICE_TREE="sun50i-h5-orangepi-prime" + # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set diff --git a/buildroot-external/board/orangepi/patches/uboot/do-not-relocate-initrd.patch b/buildroot-external/board/orangepi/patches/uboot/do-not-relocate-initrd.patch new file mode 100644 index 000000000..f5020ded0 --- /dev/null +++ b/buildroot-external/board/orangepi/patches/uboot/do-not-relocate-initrd.patch @@ -0,0 +1,27 @@ +diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h +index 64a190059a..bbec551cac 100644 +--- a/include/configs/sunxi-common.h ++++ b/include/configs/sunxi-common.h +@@ -503,6 +503,12 @@ extern int soft_i2c_gpio_scl; + #define FDTFILE CONFIG_DEFAULT_DEVICE_TREE ".dtb" + #endif + ++#ifdef CONFIG_MACH_SUN8I_H3 ++#define INITRD_HIGH_ENV "initrd_high=0xFFFFFFFF\0" ++#else ++#define INITRD_HIGH_ENV ++#endif ++ + #define CONFIG_EXTRA_ENV_SETTINGS \ + CONSOLE_ENV_SETTINGS \ + MEM_LAYOUT_ENV_SETTINGS \ +@@ -512,7 +518,8 @@ extern int soft_i2c_gpio_scl; + SUNXI_MTDIDS_DEFAULT \ + SUNXI_MTDPARTS_DEFAULT \ + BOOTCMD_SUNXI_COMPAT \ +- BOOTENV ++ BOOTENV \ ++ INITRD_HIGH_ENV + + #else /* ifndef CONFIG_SPL_BUILD */ + #define CONFIG_EXTRA_ENV_SETTINGS diff --git a/buildroot-external/board/orangepi/patches/uboot/enable-DT-overlays-support.patch b/buildroot-external/board/orangepi/patches/uboot/enable-DT-overlays-support.patch new file mode 100644 index 000000000..fd5ed2039 --- /dev/null +++ b/buildroot-external/board/orangepi/patches/uboot/enable-DT-overlays-support.patch @@ -0,0 +1,13 @@ +diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig +index 0ed36cded..822ebb812 100644 +--- a/arch/arm/Kconfig ++++ b/arch/arm/Kconfig +@@ -578,6 +578,8 @@ config ARCH_SUNXI + select CMD_GPIO + select CMD_MMC if MMC + select CMD_USB if DISTRO_DEFAULTS ++ select OF_LIBFDT ++ select OF_LIBFDT_OVERLAY + select DM + select DM_ETH + select DM_GPIO diff --git a/buildroot-external/board/orangepi/patches/uboot/enable-r_pio-gpio-access-h3-h5.patch b/buildroot-external/board/orangepi/patches/uboot/enable-r_pio-gpio-access-h3-h5.patch new file mode 100644 index 000000000..1ff273de7 --- /dev/null +++ b/buildroot-external/board/orangepi/patches/uboot/enable-r_pio-gpio-access-h3-h5.patch @@ -0,0 +1,24 @@ +diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c +index 7ac8360..0484e7a 100644 +--- a/arch/arm/mach-sunxi/board.c ++++ b/arch/arm/mach-sunxi/board.c +@@ -23,6 +23,7 @@ + #include + #include + #include ++#include + + #include + +@@ -65,6 +66,11 @@ struct mm_region *mem_map = sunxi_mem_map; + + static int gpio_init(void) + { ++#if defined(CONFIG_MACH_SUNXI_H3_H5) ++ /* enable R_PIO GPIO access */ ++ prcm_apb0_enable(PRCM_APB0_GATE_PIO); ++#endif ++ + #if CONFIG_CONS_INDEX == 1 && defined(CONFIG_UART0_PORT_F) + #if defined(CONFIG_MACH_SUN4I) || \ + defined(CONFIG_MACH_SUN7I) || \ diff --git a/buildroot-external/board/orangepi/patches/uboot/fdt-setprop-fix-unaligned-access.patch b/buildroot-external/board/orangepi/patches/uboot/fdt-setprop-fix-unaligned-access.patch new file mode 100644 index 000000000..882ceaa08 --- /dev/null +++ b/buildroot-external/board/orangepi/patches/uboot/fdt-setprop-fix-unaligned-access.patch @@ -0,0 +1,23 @@ +diff --git a/cmd/fdt.c b/cmd/fdt.c +index d7654b2c4f..a71b7713a8 100644 +--- a/cmd/fdt.c ++++ b/cmd/fdt.c +@@ -17,6 +17,7 @@ + #include + #include + #include ++#include + + #define MAX_LEVEL 32 /* how deeply nested we will go */ + #define SCRATCHPAD 1024 /* bytes of scratchpad memory */ +@@ -781,7 +782,10 @@ static int fdt_parse_prop(char * const *newval, int count, char *data, int *len) + cp = newp; + tmp = simple_strtoul(cp, &newp, 0); + if (*cp != '?') +- *(fdt32_t *)data = cpu_to_fdt32(tmp); ++ { ++ tmp = cpu_to_fdt32(tmp); ++ put_unaligned(tmp, (fdt32_t *)data); ++ } + else + newp++; diff --git a/buildroot-external/board/orangepi/patches/uboot/h3-Fix-PLL1-setup-to-never-use-dividers.patch b/buildroot-external/board/orangepi/patches/uboot/h3-Fix-PLL1-setup-to-never-use-dividers.patch new file mode 100644 index 000000000..f8163ffd3 --- /dev/null +++ b/buildroot-external/board/orangepi/patches/uboot/h3-Fix-PLL1-setup-to-never-use-dividers.patch @@ -0,0 +1,32 @@ +From 7f5071f906f79bdc99d6b4b0ccf0cb280abe740b Mon Sep 17 00:00:00 2001 +From: Ondrej Jirman +Date: Tue, 20 Dec 2016 11:25:12 +0100 +Subject: [PATCH] sunxi: h3: Fix PLL1 setup to never use dividers + +Kernel would lower the divider on first CLK change and cause the +lock up. +--- + arch/arm/mach-sunxi/clock_sun6i.c | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +diff --git a/arch/arm/mach-sunxi/clock_sun6i.c b/arch/arm/mach-sunxi/clock_sun6i.c +index 50fb302a19..91aa2a0478 100644 +--- a/arch/arm/mach-sunxi/clock_sun6i.c ++++ b/arch/arm/mach-sunxi/clock_sun6i.c +@@ -94,11 +94,10 @@ void clock_set_pll1(unsigned int clk) + int k = 1; + int m = 1; + +- if (clk > 1152000000) { +- k = 2; +- } else if (clk > 768000000) { ++ if (clk >= 1368000000) { + k = 3; +- m = 2; ++ } else if (clk >= 768000000) { ++ k = 2; + } + + /* Switch to 24MHz clock while changing PLL1 */ +-- +2.11.0 diff --git a/buildroot-external/board/orangepi/patches/uboot/h3-enable-power-led.patch b/buildroot-external/board/orangepi/patches/uboot/h3-enable-power-led.patch new file mode 100644 index 000000000..1082db0ba --- /dev/null +++ b/buildroot-external/board/orangepi/patches/uboot/h3-enable-power-led.patch @@ -0,0 +1,16 @@ +diff --git a/board/sunxi/board.c b/board/sunxi/board.c +index 3cf3614..89cf7f5 100644 +--- a/board/sunxi/board.c ++++ b/board/sunxi/board.c +@@ -478,6 +478,11 @@ void sunxi_board_init(void) + int power_failed = 0; + unsigned long ramsize; + ++#ifdef CONFIG_MACH_SUN8I_H3 ++ /* turn on power LED (PL10) on H3 boards */ ++ gpio_direction_output(SUNXI_GPL(10), 1); ++#endif ++ + #ifdef CONFIG_SY8106A_POWER + power_failed = sy8106a_set_vout1(CONFIG_SY8106A_VOUT1_VOLT); + #endif diff --git a/buildroot-external/board/orangepi/patches/uboot/h3-set-safe-axi_apb-clock-dividers.patch b/buildroot-external/board/orangepi/patches/uboot/h3-set-safe-axi_apb-clock-dividers.patch new file mode 100644 index 000000000..a59c4b178 --- /dev/null +++ b/buildroot-external/board/orangepi/patches/uboot/h3-set-safe-axi_apb-clock-dividers.patch @@ -0,0 +1,42 @@ +diff --git a/arch/arm/mach-sunxi/clock_sun6i.c b/arch/arm/mach-sunxi/clock_sun6i.c +index 15272c9..cedddc2 100644 +--- a/arch/arm/mach-sunxi/clock_sun6i.c ++++ b/arch/arm/mach-sunxi/clock_sun6i.c +@@ -117,8 +117,8 @@ void clock_set_pll1(unsigned int clk) + sdelay(200); + + /* Switch CPU to PLL1 */ +- writel(AXI_DIV_3 << AXI_DIV_SHIFT | +- ATB_DIV_2 << ATB_DIV_SHIFT | ++ writel(AXI_DIV_4 << AXI_DIV_SHIFT | ++ ATB_DIV_4 << ATB_DIV_SHIFT | + CPU_CLK_SRC_PLL1 << CPU_CLK_SRC_SHIFT, + &ccm->cpu_axi_cfg); + } +diff --git a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h +index f2990db..b3a8575 100644 +--- a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h ++++ b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h +@@ -180,6 +180,7 @@ struct sunxi_ccm_reg { + #define CCM_PLL1_CTRL_N(n) ((((n) - 1) & 0x1f) << 8) + #define CCM_PLL1_CTRL_P(n) (((n) & 0x3) << 16) + #define CCM_PLL1_CTRL_EN (0x1 << 31) ++#define CCM_PLL1_CTRL_LOCK (0x1 << 28) + + #define CCM_PLL3_CTRL_M_SHIFT 0 + #define CCM_PLL3_CTRL_M_MASK (0xf << CCM_PLL3_CTRL_M_SHIFT) +diff --git a/arch/arm/mach-sunxi/clock_sun6i.c b/arch/arm/mach-sunxi/clock_sun6i.c +index cedddc2..3fe9305 100644 +--- a/arch/arm/mach-sunxi/clock_sun6i.c ++++ b/arch/arm/mach-sunxi/clock_sun6i.c +@@ -114,7 +114,9 @@ void clock_set_pll1(unsigned int clk) + writel(CCM_PLL1_CTRL_EN | CCM_PLL1_CTRL_P(p) | + CCM_PLL1_CTRL_N(clk / (24000000 * k / m)) | + CCM_PLL1_CTRL_K(k) | CCM_PLL1_CTRL_M(m), &ccm->pll1_cfg); +- sdelay(200); ++ ++ while (!(readl(&ccm->pll1_cfg) & CCM_PLL1_CTRL_LOCK)) ++ ; + + /* Switch CPU to PLL1 */ + writel(AXI_DIV_4 << AXI_DIV_SHIFT | diff --git a/buildroot-external/board/orangepi/patches/uboot/lower-default-DRAM-freq-A64-H5.patch.disabled b/buildroot-external/board/orangepi/patches/uboot/lower-default-DRAM-freq-A64-H5.patch.disabled new file mode 100644 index 000000000..d94120f20 --- /dev/null +++ b/buildroot-external/board/orangepi/patches/uboot/lower-default-DRAM-freq-A64-H5.patch.disabled @@ -0,0 +1,13 @@ +diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig +index 2309f59999..716e9c5e26 100644 +--- a/arch/arm/mach-sunxi/Kconfig ++++ b/arch/arm/mach-sunxi/Kconfig +@@ -278,7 +278,7 @@ config DRAM_CLK + default 312 if MACH_SUN6I || MACH_SUN8I + default 360 if MACH_SUN4I || MACH_SUN5I || MACH_SUN7I || \ + MACH_SUN8I_V3S +- default 672 if MACH_SUN50I ++ default 648 if MACH_SUN50I || MACH_SUN50I_H5 + ---help--- + Set the dram clock speed, valid range 240 - 480 (prior to sun9i), + must be a multiple of 24. For the sun9i (A80), the tested values diff --git a/buildroot-external/board/orangepi/patches/uboot/sun8i-set-machid.patch b/buildroot-external/board/orangepi/patches/uboot/sun8i-set-machid.patch new file mode 100644 index 000000000..e11f4f600 --- /dev/null +++ b/buildroot-external/board/orangepi/patches/uboot/sun8i-set-machid.patch @@ -0,0 +1,11 @@ +diff --git a/include/configs/sun8i.h b/include/configs/sun8i.h +index a4c3fb69e..47ce2e9e6 100644 +--- a/include/configs/sun8i.h ++++ b/include/configs/sun8i.h +@@ -30,4 +30,6 @@ + */ + #include + ++#define CONFIG_MACH_TYPE (0x1029) ++ + #endif /* __CONFIG_H */ diff --git a/buildroot-external/board/orangepi/patches/uboot/sunxi-boot-splash.patch b/buildroot-external/board/orangepi/patches/uboot/sunxi-boot-splash.patch new file mode 100644 index 000000000..8577d1912 --- /dev/null +++ b/buildroot-external/board/orangepi/patches/uboot/sunxi-boot-splash.patch @@ -0,0 +1,62 @@ +diff --git a/cmd/Kconfig b/cmd/Kconfig +index d6d130edfa..92795119ea 100644 +--- a/cmd/Kconfig ++++ b/cmd/Kconfig +@@ -1029,6 +1029,7 @@ menu "Misc commands" + config CMD_BMP + bool "Enable 'bmp' command" + depends on LCD || DM_VIDEO || VIDEO ++ default y + help + This provides a way to obtain information about a BMP-format iamge + and to display it. BMP (which presumably stands for BitMaP) is a +diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h +index 9ed6b9892c..75d5176edf 100644 +--- a/include/config_distro_bootcmd.h ++++ b/include/config_distro_bootcmd.h +@@ -323,6 +323,15 @@ + BOOTENV_SHARED_UBIFS \ + BOOTENV_SHARED_EFI \ + "boot_prefixes=/ /boot/\0" \ ++ "splashpos=m,m\0" \ ++ "splashimage=66000000\0" \ ++ "loadsplash= " \ ++ "for prefix in ${boot_prefixes}; do " \ ++ "if test -e mmc 0 ${prefix}boot.bmp; then " \ ++ "load mmc 0 ${splashimage} ${prefix}boot.bmp; " \ ++ "bmp d ${splashimage}; " \ ++ "fi; " \ ++ "done\0" \ + "boot_scripts=boot.scr.uimg boot.scr\0" \ + "boot_script_dhcp=boot.scr.uimg\0" \ + BOOTENV_BOOT_TARGETS \ +diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h +index 02d7be0849..cbdea20d08 100644 +--- a/include/configs/sunxi-common.h ++++ b/include/configs/sunxi-common.h +@@ -284,6 +284,16 @@ extern int soft_i2c_gpio_scl; + + #endif /* CONFIG_VIDEO */ + ++#if defined CONFIG_VIDEO || defined CONFIG_DM_VIDEO ++#define CONFIG_VIDEO_LOGO ++#define CONFIG_SPLASH_SCREEN ++#define CONFIG_SPLASH_SCREEN_ALIGN ++#define CONFIG_BMP_16BPP ++#define CONFIG_BMP_24BPP ++#define CONFIG_BMP_32BPP ++#define CONFIG_VIDEO_BMP_RLE8 ++#endif ++ + /* Ethernet support */ + #ifdef CONFIG_SUNXI_EMAC + #define CONFIG_PHY_ADDR 1 +@@ -444,7 +454,7 @@ extern int soft_i2c_gpio_scl; + + #ifdef CONFIG_USB_KEYBOARD + #define CONSOLE_STDIN_SETTINGS \ +- "preboot=usb start\0" \ ++ "preboot=run loadsplash; usb start\0" \ + "stdin=serial,usbkbd\0" + #else + #define CONSOLE_STDIN_SETTINGS \ diff --git a/buildroot-external/board/orangepi/prime/meta b/buildroot-external/board/orangepi/prime/meta new file mode 100644 index 000000000..14ad302e9 --- /dev/null +++ b/buildroot-external/board/orangepi/prime/meta @@ -0,0 +1,7 @@ +BOARD_ID=opi-prime +BOARD_NAME="Orange Pi Prime" +CHASSIS=embedded +BOOTLOADER=uboot +KERNEL_FILE=Image +BOOT_SYS=spl +BOOT_ENV_SIZE=0x8000 diff --git a/buildroot-external/board/orangepi/prime/uboot-boot.ush b/buildroot-external/board/orangepi/prime/uboot-boot.ush new file mode 100644 index 000000000..e5a8353bf --- /dev/null +++ b/buildroot-external/board/orangepi/prime/uboot-boot.ush @@ -0,0 +1,75 @@ + +part start mmc ${devnum} 6 mmc_env +mmc dev ${devnum} +setenv loadbootstate " \ + echo 'loading env...'; \ + mmc read ${ramdisk_addr_r} ${mmc_env} 0x40; \ + env import -c ${ramdisk_addr_r} 0x8000;" + +setenv storebootstate " \ + echo 'storing env...'; \ + env export -c -s 0x8000 ${ramdisk_addr_r} BOOT_ORDER BOOT_A_LEFT BOOT_B_LEFT; \ + mmc write ${ramdisk_addr_r} ${mmc_env} 0x40;" + +if load mmc ${devnum}:1 ${ramdisk_addr_r} config.txt; then + env import -t ${ramdisk_addr_r} ${filesize}; +fi + +run loadbootstate +test -n "${BOOT_ORDER}" || setenv BOOT_ORDER "A B" +test -n "${BOOT_A_LEFT}" || setenv BOOT_A_LEFT 3 +test -n "${BOOT_B_LEFT}" || setenv BOOT_B_LEFT 3 + +# HassOS bootargs +setenv bootargs_hassos "zram.enabled=1 zram.num_devices=3 apparmor=1 security=apparmor cgroup_enable=memory rootwait" + +# HassOS system A/B +setenv bootargs_a "root=PARTUUID=8d3d53e3-6d49-4c38-8349-aff6859e82fd rootfstype=squashfs ro" +setenv bootargs_b "root=PARTUUID=a3ec664e-32ce-4665-95ea-7ae90ce9aa20 rootfstype=squashfs ro" + +# Load extraargs +fileenv mmc ${devnum}:1 ${ramdisk_addr_r} cmdline.txt cmdline + +# Load device tree +fatload mmc ${devnum}:1 ${fdt_addr_r} sun50i-h5-orangepi-prime.dtb + +setenv bootargs +for BOOT_SLOT in "${BOOT_ORDER}"; do + if test "x${bootargs}" != "x"; then + # skip remaining slots + elif test "x${BOOT_SLOT}" = "xA"; then + if test ${BOOT_A_LEFT} -gt 0; then + setexpr BOOT_A_LEFT ${BOOT_A_LEFT} - 1 + echo "Found valid slot A, ${BOOT_A_LEFT} attempts remaining" + setenv load_kernel "ext4load mmc ${devnum}:2 ${kernel_addr_r} Image" + setenv bootargs "${bootargs_hassos} ${bootargs_a} rauc.slot=A ${cmdline}" + fi + elif test "x${BOOT_SLOT}" = "xB"; then + if test ${BOOT_B_LEFT} -gt 0; then + setexpr BOOT_B_LEFT ${BOOT_B_LEFT} - 1 + echo "Found valid slot B, ${BOOT_B_LEFT} attempts remaining" + setenv load_kernel "ext4load mmc ${devnum}:4 ${kernel_addr_r} Image" + setenv bootargs "${bootargs_hassos} ${bootargs_b} rauc.slot=B ${cmdline}" + fi + fi +done + +if test -n "${bootargs}"; then + run storebootstate +else + echo "No valid slot found, resetting tries to 3" + setenv BOOT_A_LEFT 3 + setenv BOOT_B_LEFT 3 + run storebootstate + reset +fi + +echo "Loading kernel" +run load_kernel +echo " Starting kernel" +printenv load_kernel +printenv bootargs +booti ${kernel_addr_r} - ${fdt_addr_r} + +echo "Fails on boot" +reset diff --git a/buildroot-external/board/orangepi/prime/uboot.config b/buildroot-external/board/orangepi/prime/uboot.config new file mode 100644 index 000000000..8afa0b76a --- /dev/null +++ b/buildroot-external/board/orangepi/prime/uboot.config @@ -0,0 +1,8 @@ +# CONFIG_USB_STORAGE is not set +# CONFIG_DOS_PARTITIONcs not set +CONFIG_EFI_PARTITION is not set +CONFIG_USB=y +CONFIG_CMD_USB=y +CONFIG_DM_USB=y +CONFIG_CMD_FILEENV=y +CONFIG_ENV_IS_NOWHERE=Y diff --git a/buildroot-external/configs/opi_prime_defconfig b/buildroot-external/configs/opi_prime_defconfig new file mode 100644 index 000000000..28361e812 --- /dev/null +++ b/buildroot-external/configs/opi_prime_defconfig @@ -0,0 +1,112 @@ +BR2_aarch64=y +BR2_cortex_a53=y +BR2_ARM_FPU_VFPV4=y +BR2_DL_DIR="/cache/dl" +BR2_CCACHE=y +BR2_CCACHE_DIR="/cache/cc" +BR2_GLOBAL_PATCH_DIR="$(BR2_EXTERNAL_HASSOS_PATH)/patches $(BR2_EXTERNAL_HASSOS_PATH)/board/orangepi/patches" +BR2_TOOLCHAIN_BUILDROOT_GLIBC=y +BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_18=y +BR2_GCC_VERSION_7_X=y +BR2_TOOLCHAIN_BUILDROOT_CXX=y +BR2_BINUTILS_ENABLE_LTO=y +BR2_GCC_ENABLE_LTO=y +BR2_TARGET_GENERIC_HOSTNAME="hassio" +BR2_TARGET_GENERIC_ISSUE="Welcome to HassOS" +BR2_INIT_SYSTEMD=y +BR2_TARGET_GENERIC_GETTY_PORT="tty0" +# BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is not set +BR2_TARGET_ARM_TRUSTED_FIRMWARE=y +BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_GIT=y +BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_REPO_URL="https://github.com/apritzel/arm-trusted-firmware.git" +BR2_TARGET_ARM_TRUSTED_FIRMWARE_PLATFORM="sun50iw1p1" +BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_REPO_VERSION="aa75c8da415158a94b82a430b2b40000778e851f" +BR2_TARGET_ARM_TRUSTED_FIRMWARE_BL31=y +BR2_TARGET_UBOOT=y +BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y +BR2_TARGET_UBOOT_CUSTOM_VERSION=y +BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2018.11" +BR2_TARGET_UBOOT_BOARD_DEFCONFIG="orangepi_prime" +BR2_TARGET_UBOOT_NEEDS_DTC=y +BR2_TARGET_UBOOT_NEEDS_ATF_BL31=y +BR2_TARGET_UBOOT_FORMAT_CUSTOM=y +BR2_TARGET_UBOOT_FORMAT_CUSTOM_NAME="u-boot.itb" +BR2_TARGET_UBOOT_SPL=y +BR2_TARGET_UBOOT_SPL_NAME="spl/sunxi-spl.bin" +BR2_TARGET_UBOOT_BOOT_SCRIPT=y +BR2_TARGET_UBOOT_BOOT_SCRIPT_SOURCE="$(BR2_EXTERNAL_HASSOS_PATH)/board/orangepi/prime/uboot-boot.ush" +BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_HASSOS_PATH)/bootloader/uboot.config $(BR2_EXTERNAL_HASSOS_PATH)/board/orangepi/prime/uboot.config" +BR2_LINUX_KERNEL=y +BR2_LINUX_KERNEL_CUSTOM_VERSION=y +BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.18.20" +BR2_LINUX_KERNEL_DTS_SUPPORT=y +BR2_LINUX_KERNEL_INTREE_DTS_NAME="allwinner/sun50i-h5-orangepi-prime" +BR2_LINUX_KERNEL_LZ4=y +BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y +BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF=y +BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y +BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_HASSOS_PATH)/kernel/hassos.config $(BR2_EXTERNAL_HASSOS_PATH)/kernel/docker.config $(BR2_EXTERNAL_HASSOS_PATH)/kernel/device-support.config $(BR2_EXTERNAL_HASSOS_PATH)/board/orangepi/prime/kernel.config" +BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL_HASSOS_PATH)/rootfs-overlay" +BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL_HASSOS_PATH)/scripts/post-build.sh" +BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL_HASSOS_PATH)/scripts/post-image.sh" +BR2_ROOTFS_POST_SCRIPT_ARGS="$(BR2_EXTERNAL_HASSOS_PATH)/board/orangepi/prime $(BR2_EXTERNAL_HASSOS_PATH)/board/orangepi/hassos-hook.sh" +BR2_PACKAGE_BUSYBOX_CONFIG="$(BR2_EXTERNAL_HASSOS_PATH)/busybox.config" +BR2_PACKAGE_BUSYBOX_INDIVIDUAL_BINARIES=y +BR2_PACKAGE_JQ=y +BR2_PACKAGE_E2FSPROGS=y +BR2_PACKAGE_E2FSPROGS_RESIZE2FS=y +BR2_PACKAGE_SQUASHFS=y +BR2_PACKAGE_LINUX_FIRMWARE=y +BR2_PACKAGE_LINUX_FIRMWARE_RTL_87XX=y +BR2_PACKAGE_GPTFDISK=y +BR2_PACKAGE_GPTFDISK_SGDISK=y +BR2_PACKAGE_UBOOT_TOOLS=y +BR2_PACKAGE_CA_CERTIFICATES=y +BR2_PACKAGE_LIBDNET=y +BR2_PACKAGE_LIBCGROUP=y +BR2_PACKAGE_LIBCGROUP_TOOLS=y +BR2_PACKAGE_AVAHI=y +# BR2_PACKAGE_AVAHI_AUTOIPD is not set +BR2_PACKAGE_AVAHI_DAEMON=y +BR2_PACKAGE_AVAHI_LIBDNSSD_COMPATIBILITY=y +BR2_PACKAGE_BLUEZ5_UTILS=y +BR2_PACKAGE_BLUEZ5_UTILS_CLIENT=y +BR2_PACKAGE_DHCP=y +BR2_PACKAGE_DHCP_CLIENT=y +BR2_PACKAGE_DROPBEAR=y +# BR2_PACKAGE_DROPBEAR_CLIENT is not set +# BR2_PACKAGE_IFUPDOWN_SCRIPTS is not set +BR2_PACKAGE_NETWORK_MANAGER=y +BR2_PACKAGE_NETWORK_MANAGER_MODEM_MANAGER=y +BR2_PACKAGE_TINI=y +BR2_PACKAGE_DOCKER_ENGINE=y +BR2_PACKAGE_DOCKER_CLI=y +BR2_PACKAGE_RAUC=y +BR2_PACKAGE_RAUC_NETWORK=y +# BR2_PACKAGE_SYSTEMD_HWDB is not set +# BR2_PACKAGE_SYSTEMD_NETWORKD is not set +BR2_PACKAGE_SYSTEMD_RANDOMSEED=y +# BR2_PACKAGE_SYSTEMD_RESOLVED is not set +BR2_PACKAGE_UTIL_LINUX_PARTX=y +BR2_PACKAGE_UTIL_LINUX_ZRAMCTL=y +BR2_TARGET_ROOTFS_SQUASHFS=y +BR2_TARGET_ROOTFS_SQUASHFS4_LZ4=y +# BR2_TARGET_ROOTFS_TAR is not set +BR2_PACKAGE_HOST_DOSFSTOOLS=y +BR2_PACKAGE_HOST_E2FSPROGS=y +BR2_PACKAGE_HOST_GPTFDISK=y +BR2_PACKAGE_HOST_MTOOLS=y +BR2_PACKAGE_HOST_RAUC=y +BR2_PACKAGE_HOST_SWIG=y +BR2_PACKAGE_HASSOS=y +BR2_PACKAGE_HASSOS_SUPERVISOR="homeassistant/aarch64-hassio-supervisor" +BR2_PACKAGE_HASSOS_SUPERVISOR_VERSION="141" +BR2_PACKAGE_HASSOS_SUPERVISOR_ARGS="-e HOMEASSISTANT_REPOSITORY=homeassistant/orangepi-prime-homeassistant" +BR2_PACKAGE_HASSOS_SUPERVISOR_PROFILE="hassio-supervisor" +BR2_PACKAGE_HASSOS_SUPERVISOR_PROFILE_URL="http://s3.amazonaws.com/hassio-version/apparmor.txt" +BR2_PACKAGE_HASSOS_CLI="homeassistant/aarch64-hassio-cli" +BR2_PACKAGE_HASSOS_CLI_VERSION="7" +BR2_PACKAGE_HASSOS_CLI_ARGS="--network=hassio --add-host hassio:172.30.32.2" +BR2_PACKAGE_HASSOS_CLI_PROFILE="docker-default" +BR2_PACKAGE_HASSOS_APPARMOR_DIR="supervisor/apparmor" +BR2_PACKAGE_APPARMOR=y diff --git a/scripts/build-all.sh b/scripts/build-all.sh index 50d15ab04..7d74f628c 100755 --- a/scripts/build-all.sh +++ b/scripts/build-all.sh @@ -3,7 +3,7 @@ set -e mkdir -p /build/release -all_platforms=(ova rpi rpi0_w rpi2 rpi3 rpi3_64 tinker odroid_c2 intel_nuc) +all_platforms=(ova rpi rpi0_w rpi2 rpi3 rpi3_64 tinker odroid_c2 intel_nuc opi_prime) for platform in "${all_platforms[@]}"; do make -C /build/buildroot BR2_EXTERNAL=/build/buildroot-external \ "${platform}_defconfig"