From b48ee5dee8e81cedf1638d21c0155f667026a0e2 Mon Sep 17 00:00:00 2001 From: Josua Mayer Date: Sun, 13 May 2018 15:43:25 +0000 Subject: [PATCH 1/3] HACK: Do not try to mount a reserved partition Signed-off-by: Josua Mayer --- lib/board.sh | 2 ++ lib/disk.sh | 3 +++ 2 files changed, 5 insertions(+) diff --git a/lib/board.sh b/lib/board.sh index ec6861c8..c5aa30fe 100644 --- a/lib/board.sh +++ b/lib/board.sh @@ -251,6 +251,8 @@ board_mountpoint ( ) { MOUNTPOINT_PREFIX=${BOARD_BOOT_MOUNTPOINT_PREFIX} elif board_is_freebsd_partition ${ABSINDEX}; then MOUNTPOINT_PREFIX=${BOARD_FREEBSD_MOUNTPOINT_PREFIX} + elif [ $TYPE == "RESERVED" ]; then + MOUNTPOINT_PREFIX=/dev/null else MOUNTPOINT_PREFIX=`eval echo \\$BOARD_${TYPE}_MOUNTPOINT_PREFIX` fi diff --git a/lib/disk.sh b/lib/disk.sh index 6bd9bbd8..ff815f89 100644 --- a/lib/disk.sh +++ b/lib/disk.sh @@ -460,6 +460,9 @@ disk_mount ( ) { UFS) disk_ufs_mount ${MOUNTPOINT} ${RELINDEX} ;; + RESERVED) + # just don't do anything + ;; *) echo "Attempt to mount ${TYPE} partition ${RELINDEX} at ${MOUNTPOINT} failed." echo "Do not know how to mount partitions of type ${TYPE}." From 9348c9fe9493454a4f6dd555e10f509685a9c8fc Mon Sep 17 00:00:00 2001 From: Josua Mayer Date: Sun, 13 May 2018 13:43:30 +0000 Subject: [PATCH 2/3] introduce support for the SolidRun clearfog Initial support for the SolidRun Clearfog laned in FreeBSD with r319914. The board has acceptable support in mainline U-Boot, as well as a vendor fork based on 2018.01. For now an MBR partition table is used, with a fat partition to load DTB and ubldr from, reserved space covering the first 1M of the disk to make sure installing u-boot later doesn't destroy the boot partition. Signed-off-by: Josua Mayer --- board/Clearfog/files/boot.txt | 3 ++ board/Clearfog/overlay/boot/loader.conf | 6 +++ board/Clearfog/overlay/etc/fstab | 3 ++ board/Clearfog/overlay/etc/rc.conf | 12 ++++++ board/Clearfog/overlay/etc/src.conf | 1 + board/Clearfog/setup.sh | 51 +++++++++++++++++++++++++ 6 files changed, 76 insertions(+) create mode 100644 board/Clearfog/files/boot.txt create mode 100644 board/Clearfog/overlay/boot/loader.conf create mode 100644 board/Clearfog/overlay/etc/fstab create mode 100644 board/Clearfog/overlay/etc/rc.conf create mode 100644 board/Clearfog/overlay/etc/src.conf create mode 100644 board/Clearfog/setup.sh diff --git a/board/Clearfog/files/boot.txt b/board/Clearfog/files/boot.txt new file mode 100644 index 00000000..30528524 --- /dev/null +++ b/board/Clearfog/files/boot.txt @@ -0,0 +1,3 @@ +load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${fdtfile} +load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} ubldr.bin +go ${kernel_addr_r} diff --git a/board/Clearfog/overlay/boot/loader.conf b/board/Clearfog/overlay/boot/loader.conf new file mode 100644 index 00000000..53c5c9c0 --- /dev/null +++ b/board/Clearfog/overlay/boot/loader.conf @@ -0,0 +1,6 @@ +# enable level 1 cache prefetch +hw.cpu.quirks.actlr_set = 0x4 +hw.cpu.quirks.actlr_mask = 0x4 + +# don't wait too long +autoboot_delay="3" diff --git a/board/Clearfog/overlay/etc/fstab b/board/Clearfog/overlay/etc/fstab new file mode 100644 index 00000000..cdca775a --- /dev/null +++ b/board/Clearfog/overlay/etc/fstab @@ -0,0 +1,3 @@ +# Device Mountpoint FStype Options Dump Pass# +/dev/ufs/rootfs / ufs rw,noatime 1 1 +/dev/msdosfs/BOOT /boot/msdos msdosfs rw,noatime 0 2 diff --git a/board/Clearfog/overlay/etc/rc.conf b/board/Clearfog/overlay/etc/rc.conf new file mode 100644 index 00000000..875d29ba --- /dev/null +++ b/board/Clearfog/overlay/etc/rc.conf @@ -0,0 +1,12 @@ +clear_tmp_enable="YES" +hostname="clearfog" +ifconfig_DEFAULT="DHCP" +#ntpd_enable="YES" +ntpd_sync_on_start="YES" +sendmail_enable="NONE" +sendmail_msp_queue_enable="NO" +sendmail_outbound_enable="NO" +sendmail_submit_enable="NO" +sshd_enable="YES" +sshd_enable="YES" +syslogd_flags="-ss" diff --git a/board/Clearfog/overlay/etc/src.conf b/board/Clearfog/overlay/etc/src.conf new file mode 100644 index 00000000..336c5681 --- /dev/null +++ b/board/Clearfog/overlay/etc/src.conf @@ -0,0 +1 @@ +KERNCONF=ARMADA38X diff --git a/board/Clearfog/setup.sh b/board/Clearfog/setup.sh new file mode 100644 index 00000000..e1140ce3 --- /dev/null +++ b/board/Clearfog/setup.sh @@ -0,0 +1,51 @@ +KERNCONF=GENERIC +TARGET_ARCH=armv7 +IMAGE_SIZE=$((2 * 1000 * 1000 * 1000)) + +# check for mkimage utility +clearfog_check_uboot-tools ( ) { + if [ -z `which mkimage` ]; then + echo "Clearfog Boot-Script build requires 'mkimage'" + echo "Please install sysutils/u-boot-tools and re-run this script." + exit 1 + fi +} +strategy_add $PHASE_CHECK clearfog_check_uboot-tools + +# build ubldr +strategy_add $PHASE_BUILD_OTHER freebsd_ubldr_build + +# partition disk +# 1: reserved space for u-boot (first 1M into the device) +# 2: boot +# 3: FreeBSD +clearfog_disk_reserved_create_unaligned ( ) { + _DISK_RESERVED_SLICE=`gpart add -s $1 -t '!218' ${DISK_MD} | sed -e 's/ .*//'` + disk_created_new RESERVED ${_DISK_RESERVED_SLICE} +} +clearfog_partition_image ( ) { + disk_partition_mbr + clearfog_disk_reserved_create_unaligned 1985 + disk_fat_create 2m + disk_ufs_create + disk_ufs_label 1 rootfs +} +strategy_add $PHASE_PARTITION_LWW clearfog_partition_image + +# install boot files +clearfog_install_boot-files ( ) { + freebsd_ubldr_copy_ubldr ${BOARD_BOOT_MOUNTPOINT} + mkimage -A arm -O FreeBSD -T script -a 0 -e 0 -d "$BOARDDIR/files/boot.txt" "boot.scr" > ${WORKDIR}/_.mkimage.log + freebsd_install_fdt ../gnu/dts/arm/armada-388-clearfog-base.dts armada-388-clearfog-base.dtb + freebsd_install_fdt ../gnu/dts/arm/armada-388-clearfog-pro.dts armada-388-clearfog-pro.dtb +} +strategy_add $PHASE_BOOT_INSTALL clearfog_install_boot-files + +# install kernel on rootfs +strategy_add $PHASE_FREEBSD_BOARD_INSTALL board_default_installkernel . + +# install ubldr help and configuration to rootfs +strategy_add $PHASE_FREEBSD_BOARD_INSTALL freebsd_ubldr_copy boot + +# create mount-point for boot partition +strategy_add $PHASE_FREEBSD_BOARD_INSTALL mkdir -p boot/msdos From 4d40896f182ad704e23dd55c31290f5859145483 Mon Sep 17 00:00:00 2001 From: Josua Mayer Date: Tue, 15 May 2018 20:49:58 +0000 Subject: [PATCH 3/3] Clearfog: add Helios-4 dtb The Helios-4 uses the same SoM as the Clearfog and can share all of the clearfog specific configuration. The DTB has been copied from the Helios-4 linux fork on github.com: https://github.com/helios-4/linux-marvell/blob/linux-marvell-4.4/arch/arm/boot/dts/armada-388-helios4.dts Signed-off-by: Josua Mayer --- board/Clearfog/files/armada-388-helios4.dts | 340 ++++++++++++++++++++ board/Clearfog/setup.sh | 5 + 2 files changed, 345 insertions(+) create mode 100644 board/Clearfog/files/armada-388-helios4.dts diff --git a/board/Clearfog/files/armada-388-helios4.dts b/board/Clearfog/files/armada-388-helios4.dts new file mode 100644 index 00000000..90c82af2 --- /dev/null +++ b/board/Clearfog/files/armada-388-helios4.dts @@ -0,0 +1,340 @@ +/* + * Device Tree file for Helios-4 + * based on SolidRun Clearfog revision A1 rev 2.0 (88F6828) + * + * Copyright (C) 2017 + * + */ + +/dts-v1/; +#include "armada-388.dtsi" +#include "armada-38x-solidrun-microsom.dtsi" + +/ { + model = "Helios4"; + compatible = "marvell,armada388", + "marvell,armada385", "marvell,armada380"; + + memory { + device_type = "memory"; + reg = <0x00000000 0x40000000>; /* 1 GB */ + }; + + aliases { + /* So that mvebu u-boot can update the MAC addresses */ + ethernet1 = ð0; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + reg_12v: regulator-12v { + compatible = "regulator-fixed"; + regulator-name = "power_brick_12V"; + regulator-min-microvolt = <12000000>; + regulator-max-microvolt = <12000000>; + regulator-always-on; + }; + + reg_3p3v: regulator-3p3v { + compatible = "regulator-fixed"; + regulator-name = "3P3V"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + vin-supply = <®_12v>; + }; + + reg_5p0v_hdd: regulator-5v-hdd { + compatible = "regulator-fixed"; + regulator-name = "5V_HDD"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-always-on; + vin-supply = <®_12v>; + }; + + reg_5p0v_usb: regulator-5v-usb { + compatible = "regulator-fixed"; + regulator-name = "USB-PWR"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + regulator-always-on; + enable-active-high; + gpio = <&expander0 6 GPIO_ACTIVE_HIGH>; + vin-supply = <®_12v>; + }; + + gpio-keys { + compatible = "gpio-keys"; + pinctrl-0 = <&user_button_pins>; + pinctrl-names = "default"; + + button_0 { + label = "User Button"; + gpios = <&gpio0 23 GPIO_ACTIVE_LOW>; + linux,can-disable; + linux,code = ; + }; + }; + + system-leds { + compatible = "gpio-leds"; + status-led { + label = "helios4:green:status"; + gpios = <&gpio0 24 GPIO_ACTIVE_LOW>; + linux,default-trigger = "heartbeat"; + default-state = "on"; + }; + + fault-led { + label = "helios4:red:fault"; + gpios = <&gpio0 25 GPIO_ACTIVE_LOW>; + default-state = "keep"; + }; + }; + + io-leds { + compatible = "gpio-leds"; + sata1-led { + label = "helios4:green:ata1"; + gpios = <&gpio1 17 GPIO_ACTIVE_LOW>; + linux,default-trigger = "ata1"; + default-state = "off"; + }; + sata2-led { + label = "helios4:green:ata2"; + gpios = <&gpio1 18 GPIO_ACTIVE_LOW>; + linux,default-trigger = "ata2"; + default-state = "off"; + }; + sata3-led { + label = "helios4:green:ata3"; + gpios = <&gpio1 20 GPIO_ACTIVE_LOW>; + linux,default-trigger = "ata3"; + default-state = "off"; + }; + sata4-led { + label = "helios4:green:ata4"; + gpios = <&gpio1 21 GPIO_ACTIVE_LOW>; + linux,default-trigger = "ata4"; + default-state = "off"; + }; + usb-led { + label = "helios4:green:usb"; + gpios = <&gpio1 22 GPIO_ACTIVE_LOW>; + linux,default-trigger = "usb-host"; + default-state = "off"; + }; + }; + + fan1: j10-pwm { + compatible = "pwm-fan"; + pwms = <&gpio1 9 3800>; + }; + + fan2: j17-pwm { + compatible = "pwm-fan"; + pwms = <&gpio1 23 3800>; + }; + + usb2_phy: usb2-phy { + compatible = "usb-nop-xceiv"; + vbus-regulator = <®_5p0v_usb>; + }; + + usb3_phy: usb3-phy { + compatible = "usb-nop-xceiv"; + //vbus-regulator = <®_5p0v_usb>; + }; + + soc { + internal-regs { + i2c@11000 { + clock-frequency = <100000>; + pinctrl-0 = <&i2c0_pins>; + pinctrl-names = "default"; + status = "okay"; + + /* + * PCA9655 GPIO expander, up to 1MHz clock. + * 0-Board Revision bit 0 # + * 1-Board Revision bit 1 # + * 5-USB3 overcurrent + * 6-USB3 power + */ + expander0: gpio-expander@20 { + /* + * This is how it should be: + * compatible = "onnn,pca9655", + * "nxp,pca9555"; + * but you can't do this because of + * the way I2C works. + */ + compatible = "nxp,pca9555"; + gpio-controller; + #gpio-cells = <2>; + reg = <0x20>; + pinctrl-names = "default"; + pinctrl-0 = <&pca0_pins>; + interrupt-parent = <&gpio0>; + interrupts = <18 IRQ_TYPE_EDGE_FALLING>; + interrupt-controller; + #interrupt-cells = <2>; + + board_rev_bit_0 { + gpio-hog; + gpios = <0 GPIO_ACTIVE_LOW>; + input; + line-name = "board-rev-0"; + }; + board_rev_bit_1 { + gpio-hog; + gpios = <1 GPIO_ACTIVE_LOW>; + input; + line-name = "board-rev-1"; + }; + usb3_ilimit { + gpio-hog; + gpios = <5 GPIO_ACTIVE_HIGH>; + input; + line-name = "usb-overcurrent-status"; + }; + }; + + temp_sensor: temp@4c { + compatible = "ti,lm75"; + reg = <0x4c>; + vcc-supply = <®_3p3v>; + }; + + /* What device at 0x64 ? */ + }; + + i2c@11100 { + /* + * External I2C Bus for user peripheral + */ + clock-frequency = <400000>; + pinctrl-0 = <&helios_i2c1_pins>; + pinctrl-names = "default"; + status = "okay"; + }; + + sata@a8000 { + status = "okay"; + #address-cells = <1>; + #size-cells = <0>; + + sata0: sata-port@0 { + reg = <0>; + }; + + sata1: sata-port@1 { + reg = <1>; + }; + }; + + sata@e0000 { + status = "okay"; + #address-cells = <1>; + #size-cells = <0>; + + sata2: sata-port@0 { + reg = <0>; + }; + + sata3: sata-port@1 { + reg = <1>; + }; + }; + + spi@10680 { + pinctrl-0 = <&spi1_pins + µsom_spi1_cs_pins>; + pinctrl-names = "default"; + status = "okay"; + + spi-flash@0 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "w25q32", "jedec,spi-nor"; + reg = <0>; /* Chip select 0 */ + spi-max-frequency = <104000000>; + spi-cpha; + status = "okay"; + }; + }; + + sdhci@d8000 { + bus-width = <4>; + cd-gpios = <&gpio0 20 GPIO_ACTIVE_LOW>; + no-1-8-v; + pinctrl-0 = <&helios_sdhci_pins + &helios_sdhci_cd_pins>; + pinctrl-names = "default"; + status = "okay"; + vmmc = <®_3p3v>; + wp-inverted; + }; + + usb@58000 { + //vcc-supply = <®_5p0v_usb>; + usb-phy = <&usb2_phy>; + status = "okay"; + }; + + usb3@f0000 { + status = "okay"; + }; + + usb3@f8000 { + status = "okay"; + }; + + pinctrl@18000 { + pca0_pins: pca0_pins { + marvell,pins = "mpp18"; + marvell,function = "gpio"; + }; + helios_i2c1_pins: i2c1-pins { + marvell,pins = "mpp26", "mpp27"; + marvell,function = "i2c1"; + }; + helios_sdhci_cd_pins: helios-sdhci-cd-pins { + marvell,pins = "mpp20"; + marvell,function = "gpio"; + }; + helios_sdhci_pins: helios-sdhci-pins { + marvell,pins = "mpp21", "mpp28", + "mpp37", "mpp38", + "mpp39", "mpp40"; + marvell,function = "sd0"; + }; + helios_led_pins: helios-led-pins { + marvell,pins = "mpp24", "mpp25", + "mpp49", "mpp50", + "mpp52", "mpp53", + "mpp54"; + marvell,function = "gpio"; + }; + helios_fan_pins: helios-fan-pins { + marvell,pins = "mpp41", "mpp43", + "mpp48", "mpp55"; + marvell,function = "gpio"; + }; + microsom_spi1_cs_pins: spi1-cs-pins { + marvell,pins = "mpp59"; + marvell,function = "spi1"; + }; + user_button_pins: user-button-pins { + marvell,pins = "mpp23"; + marvell,function = "gpio"; + }; + }; + }; + }; +}; + diff --git a/board/Clearfog/setup.sh b/board/Clearfog/setup.sh index e1140ce3..8cb100eb 100644 --- a/board/Clearfog/setup.sh +++ b/board/Clearfog/setup.sh @@ -38,6 +38,11 @@ clearfog_install_boot-files ( ) { mkimage -A arm -O FreeBSD -T script -a 0 -e 0 -d "$BOARDDIR/files/boot.txt" "boot.scr" > ${WORKDIR}/_.mkimage.log freebsd_install_fdt ../gnu/dts/arm/armada-388-clearfog-base.dts armada-388-clearfog-base.dtb freebsd_install_fdt ../gnu/dts/arm/armada-388-clearfog-pro.dts armada-388-clearfog-pro.dtb + + # out of tree DTBs + ln -sv "$BOARDDIR/files/armada-388-helios4.dts" "$FREEBSD_SRC/sys/gnu/dts/arm/armada-388-helios4.dts" + freebsd_install_fdt ../gnu/dts/arm/armada-388-helios4.dts armada-388-helios4.dtb + rm -f "$FREEBSD_SRC/sys/gnu/dts/arm/armada-388-helios4.dts" } strategy_add $PHASE_BOOT_INSTALL clearfog_install_boot-files