[OpenWrt-Devel] [PATCH 4/4] gemini: Add SL93512R Support

2019-01-19 Thread Linus Walleij
This generates images for the StorLink SL93512R reference
design which is supported in kernel v4.19.

Signed-off-by: Linus Walleij 
---
 target/linux/gemini/image/Makefile | 21 +
 1 file changed, 21 insertions(+)

diff --git a/target/linux/gemini/image/Makefile 
b/target/linux/gemini/image/Makefile
index 59041a72a785..722df1c82b00 100644
--- a/target/linux/gemini/image/Makefile
+++ b/target/linux/gemini/image/Makefile
@@ -39,6 +39,19 @@ define Build/dns313-images
if [ -d $(BIN_DIR)/.boot ] ; then rm -rf $(BIN_DIR)/.boot ; fi
 endef
 
+# Create the special SL93512R image format with the squashfs
+# split across two "partitions" named rd.gz and hddapp.tgz but
+# essentially just being used by OpenWRT as one big squashfs
+# partition
+define Build/sl93512r-images
+   dd if=$(IMAGE_ROOTFS) of=$(BIN_DIR)/rd.gz bs=6144k conv=sync
+   dd if=$(IMAGE_ROOTFS) of=$(BIN_DIR)/hddapp.bz2 bs=6144k count=1 seek=1
+   cp $(IMAGE_KERNEL) $(BIN_DIR)/zImage
+   mv $(BIN_DIR)/rd.gz $(BIN_DIR)/$(IMG_PREFIX)-sl93512r-rd.gz
+   mv $(BIN_DIR)/hddapp.bz2 $(BIN_DIR)/$(IMG_PREFIX)-sl93512r-hddapp.bz2
+   mv $(BIN_DIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-sl93512r-zImage
+endef
+
 # Create the special NAS4220B image format with the squashfs
 # and overlay inside the "rd.gz" file. We pad it out to 6144K
 # which is the size of the initramfs partition.
@@ -122,6 +135,14 @@ define Device/dlink-dns-313
 endef
 TARGET_DEVICES += dlink-dns-313
 
+define Device/sl93512r
+   DEVICE_TITLE := StorLink SL93512R Reference Design
+   IMAGES += sl93512r-image
+   IMAGE/sl93512r-image := sl93512r-images
+   DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES)
+endef
+TARGET_DEVICES += sl93512r
+
 define Device/nas4220b
DEVICE_TITLE := Raidsonic NAS IB-4220-B
IMAGES += nas4220b-image
-- 
2.19.2


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 2/4] gemini: Switch to kernel v4.19

2019-01-19 Thread Linus Walleij
This adds a config and augments the gemini makefile to
use kernel v4.19.

These devices work so much better with v4.19 so let's
immediately make it the default.

Signed-off-by: Linus Walleij 
---
 target/linux/gemini/Makefile|   2 +-
 target/linux/gemini/config-4.19 | 453 
 2 files changed, 454 insertions(+), 1 deletion(-)
 create mode 100644 target/linux/gemini/config-4.19

diff --git a/target/linux/gemini/Makefile b/target/linux/gemini/Makefile
index 3204b3f5d81e..03f0fdbb1d6c 100644
--- a/target/linux/gemini/Makefile
+++ b/target/linux/gemini/Makefile
@@ -13,7 +13,7 @@ FEATURES:=squashfs pci rtc usb dt gpio display
 CPU_TYPE:=fa526
 MAINTAINER:=Roman Yeryomin 
 
-KERNEL_PATCHVER:=4.14
+KERNEL_PATCHVER:=4.19
 
 define Target/Description
Build firmware images for the StorLink/Cortina Gemini CS351x ARM FA526 
CPU
diff --git a/target/linux/gemini/config-4.19 b/target/linux/gemini/config-4.19
new file mode 100644
index ..d071bfa49064
--- /dev/null
+++ b/target/linux/gemini/config-4.19
@@ -0,0 +1,453 @@
+CONFIG_ALIGNMENT_TRAP=y
+CONFIG_AMBA_PL08X=y
+CONFIG_ARCH_CLOCKSOURCE_DATA=y
+CONFIG_ARCH_GEMINI=y
+CONFIG_ARCH_HAS_DEBUG_VIRTUAL=y
+CONFIG_ARCH_HAS_ELF_RANDOMIZE=y
+CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y
+CONFIG_ARCH_HAS_RESET_CONTROLLER=y
+CONFIG_ARCH_HAS_SET_MEMORY=y
+CONFIG_ARCH_HAS_SG_CHAIN=y
+CONFIG_ARCH_HAS_STRICT_KERNEL_RWX=y
+CONFIG_ARCH_HAS_STRICT_MODULE_RWX=y
+CONFIG_ARCH_HAVE_CUSTOM_GPIO_H=y
+CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y
+# CONFIG_ARCH_MOXART is not set
+CONFIG_ARCH_MULTIPLATFORM=y
+# CONFIG_ARCH_MULTI_CPU_AUTO is not set
+CONFIG_ARCH_MULTI_V4=y
+# CONFIG_ARCH_MULTI_V4T is not set
+CONFIG_ARCH_MULTI_V4_V5=y
+# CONFIG_ARCH_MULTI_V5 is not set
+CONFIG_ARCH_NR_GPIO=0
+CONFIG_ARCH_OPTIONAL_KERNEL_RWX=y
+# CONFIG_ARCH_OPTIONAL_KERNEL_RWX_DEFAULT is not set
+# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set
+# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set
+CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y
+CONFIG_ARCH_SUPPORTS_UPROBES=y
+CONFIG_ARCH_USE_BUILTIN_BSWAP=y
+CONFIG_ARCH_USE_CMPXCHG_LOCKREF=y
+CONFIG_ARCH_WANT_GENERAL_HUGETLB=y
+CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
+CONFIG_ARM=y
+CONFIG_ARM_AMBA=y
+CONFIG_ARM_APPENDED_DTB=y
+# CONFIG_ARM_ATAG_DTB_COMPAT is not set
+CONFIG_ARM_HAS_SG_CHAIN=y
+CONFIG_ARM_L1_CACHE_SHIFT=5
+CONFIG_ARM_PATCH_PHYS_VIRT=y
+# CONFIG_ARM_SMMU is not set
+# CONFIG_ARM_SP805_WATCHDOG is not set
+CONFIG_ARM_UNWIND=y
+CONFIG_ATA=y
+CONFIG_ATAGS=y
+CONFIG_ATA_VERBOSE_ERROR=y
+CONFIG_AUTO_ZRELADDR=y
+CONFIG_BINFMT_MISC=y
+CONFIG_BLK_DEV_SD=y
+CONFIG_BLK_MQ_PCI=y
+CONFIG_BLK_SCSI_REQUEST=y
+CONFIG_BOUNCE=y
+# CONFIG_BPF_SYSCALL is not set
+# CONFIG_CACHE_L2X0 is not set
+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_CLKDEV_LOOKUP=y
+CONFIG_CLKSRC_MMIO=y
+CONFIG_CLONE_BACKWARDS=y
+CONFIG_CMA=y
+CONFIG_CMDLINE="console=ttyS0,19200n8"
+CONFIG_CMDLINE_FROM_BOOTLOADER=y
+CONFIG_COMMON_CLK=y
+CONFIG_COMMON_CLK_GEMINI=y
+CONFIG_CONSOLE_TRANSLATIONS=y
+CONFIG_COREDUMP=y
+CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y
+CONFIG_CPU_32v4=y
+CONFIG_CPU_ABRT_EV4=y
+# CONFIG_CPU_BPREDICT_DISABLE is not set
+CONFIG_CPU_CACHE_FA=y
+CONFIG_CPU_CACHE_VIVT=y
+CONFIG_CPU_COPY_FA=y
+CONFIG_CPU_CP15=y
+CONFIG_CPU_CP15_MMU=y
+# CONFIG_CPU_DCACHE_WRITETHROUGH is not set
+CONFIG_CPU_FA526=y
+# CONFIG_CPU_ICACHE_DISABLE is not set
+CONFIG_CPU_NO_EFFICIENT_FFS=y
+CONFIG_CPU_PABRT_LEGACY=y
+CONFIG_CPU_TLB_FA=y
+CONFIG_CPU_USE_DOMAINS=y
+CONFIG_CRASH_CORE=y
+CONFIG_CRC16=y
+# CONFIG_CRC32_SARWATE is not set
+CONFIG_CRC32_SLICEBY8=y
+CONFIG_CRC_CCITT=y
+CONFIG_CRC_ITU_T=y
+CONFIG_CROSS_MEMORY_ATTACH=y
+CONFIG_CRYPTO_AEAD=y
+CONFIG_CRYPTO_AEAD2=y
+CONFIG_CRYPTO_CCM=y
+CONFIG_CRYPTO_CMAC=y
+CONFIG_CRYPTO_CRC32C=y
+CONFIG_CRYPTO_CTR=y
+CONFIG_CRYPTO_DES=y
+CONFIG_CRYPTO_DRBG=y
+CONFIG_CRYPTO_DRBG_HMAC=y
+CONFIG_CRYPTO_DRBG_MENU=y
+CONFIG_CRYPTO_ECB=y
+CONFIG_CRYPTO_ECHAINIV=y
+CONFIG_CRYPTO_GCM=y
+CONFIG_CRYPTO_GF128MUL=y
+CONFIG_CRYPTO_GHASH=y
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_HASH2=y
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_HW=y
+CONFIG_CRYPTO_JITTERENTROPY=y
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_MANAGER2=y
+CONFIG_CRYPTO_MD4=y
+CONFIG_CRYPTO_MD5=y
+CONFIG_CRYPTO_NULL=y
+CONFIG_CRYPTO_NULL2=y
+CONFIG_CRYPTO_RNG=y
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_RNG_DEFAULT=y
+CONFIG_CRYPTO_SEQIV=y
+CONFIG_CRYPTO_SHA256=y
+CONFIG_CRYPTO_WORKQUEUE=y
+CONFIG_DEBUG_BUGVERBOSE=y
+CONFIG_DEBUG_LL_INCLUDE="mach/debug-macro.S"
+CONFIG_DEBUG_MEMORY_INIT=y
+# CONFIG_DEBUG_UART_8250 is not set
+# CONFIG_DEBUG_USER is not set
+CONFIG_DECOMPRESS_BZIP2=y
+CONFIG_DECOMPRESS_GZIP=y
+CONFIG_DECOMPRESS_LZ4=y
+CONFIG_DECOMPRESS_LZMA=y
+CONFIG_DECOMPRESS_LZO=y
+CONFIG_DECOMPRESS_XZ=y
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
+CONFIG_DMADEVICES=y
+CONFIG_DMATEST=y
+CONFIG_DMA_ENGINE=y
+CONFIG_DMA_ENGINE_RAID=y
+CONFIG_DMA_OF=y
+CONFIG_DMA_SHARED_BUFFER=y
+CONFIG_DMA_VIRTUAL_CHANNELS=y
+CONFIG_DRM=y
+CONFIG_DRM_PANEL_ILITEK_IL

[OpenWrt-Devel] [PATCH 0/4] Update Gemini to kernel v4.19

2019-01-19 Thread Linus Walleij
This updates the Gemini platform to use kernel v4.19.

Since many of the in-flight patches are upstream in v4.19
we cut down a bit on the patch burden with this, and we
also invented and patched some new stuff.

As the Gemini platforms use DSA switches as of v4.19 we
don't need the switch kmod or swconfig anymore.

A new reference design named SL93512R is available so
support it.

If the first patch is too big, the patches are also
available here:
https://dflund.se/~triad/krad/gemini/openwrt/

Linus Walleij (4):
  gemini: Add v4.19 kernel patches
  gemini: Switch to kernel v4.19
  gemini: Drop switch kmod and swconfig
  gemini: Add SL93512R Support

 target/linux/gemini/Makefile  |   2 +-
 target/linux/gemini/config-4.19   | 453 ++
 target/linux/gemini/image/Makefile|  22 +-
 ...pinctrl-gemini-Mask-and-set-properly.patch |  36 ++
 ...inctrl-gemini-Fix-up-TVC-clock-group.patch | 146 ++
 ...nctrl-gemini-Drop-noisy-debug-prints.patch |  87 
 .../0004-boot-sq201-from-sda1.patch   |  25 +
 ...hysmap_of-Move-custom-initialization.patch |  52 ++
 ...physmap_of_gemini-Handle-pin-control.patch | 194 
 ...he-D-Link-DIR-685-MTD-partition-info.patch |  71 +++
 ...8-ARM-dts-Enable-Gemini-flash-access.patch | 169 +++
 ...rtitions-Add-RedBoot-FIS-DT-bindings.patch |  51 ++
 ...ns-Add-second-compatible-for-redboot.patch |  77 +++
 ...11-ARM-dts-Fix-up-SQ201-flash-access.patch |  73 +++
 ...ARM-dts-Blank-D-Link-DIR-685-console.patch |  30 ++
 ...ost-fotg2-add-silicon-clock-handling.patch | 123 +
 ...st-add-DT-bindings-for-faraday-fotg2.patch |  69 +++
 ...b-host-fotg2-add-device-tree-probing.patch |  48 ++
 ...t-fotg2-add-Gemini-specific-handling.patch | 138 ++
 ...t-fotg2-restart-hcd-after-port-reset.patch |  32 ++
 ...he-FOTG210-USB-host-to-Gemini-boards.patch | 210 
 21 files changed, 2106 insertions(+), 2 deletions(-)
 create mode 100644 target/linux/gemini/config-4.19
 create mode 100644 
target/linux/gemini/patches-4.19/0001-pinctrl-gemini-Mask-and-set-properly.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0002-pinctrl-gemini-Fix-up-TVC-clock-group.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0003-pinctrl-gemini-Drop-noisy-debug-prints.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0004-boot-sq201-from-sda1.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0005-mtd-physmap_of-Move-custom-initialization.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0006-mtd-physmap_of_gemini-Handle-pin-control.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0007-ARM-dts-Fix-up-the-D-Link-DIR-685-MTD-partition-info.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0008-ARM-dts-Enable-Gemini-flash-access.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0009-mtd-partitions-Add-RedBoot-FIS-DT-bindings.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0010-mtd-partitions-Add-second-compatible-for-redboot.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0011-ARM-dts-Fix-up-SQ201-flash-access.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0012-ARM-dts-Blank-D-Link-DIR-685-console.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0013-usb-host-fotg2-add-silicon-clock-handling.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0014-usb-host-add-DT-bindings-for-faraday-fotg2.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0015-usb-host-fotg2-add-device-tree-probing.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0016-usb-host-fotg2-add-Gemini-specific-handling.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0017-usb-host-fotg2-restart-hcd-after-port-reset.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0018-ARM-dts-Add-the-FOTG210-USB-host-to-Gemini-boards.patch

-- 
2.19.2


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 3/4] gemini: Drop switch kmod and swconfig

2019-01-19 Thread Linus Walleij
The DIR-685 needs this module compiled in for safety
(it is facing the LAN ports) and it is now using the DSA
switch architecture so swconfig is not needed.

Signed-off-by: Linus Walleij 
---
 target/linux/gemini/image/Makefile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/target/linux/gemini/image/Makefile 
b/target/linux/gemini/image/Makefile
index c1d7792bf8ff..59041a72a785 100644
--- a/target/linux/gemini/image/Makefile
+++ b/target/linux/gemini/image/Makefile
@@ -108,7 +108,6 @@ GEMINI_NAS_PACKAGES:=kmod-md-mod kmod-md-linear 
kmod-md-multipath \
 define Device/dlink-dir-685
DEVICE_TITLE := D-Link DIR-685 Xtreme N Storage Router
DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES) \
-   kmod-switch-rtl8366rb swconfig \
rt2800-pci
IMAGES += dir685-image
IMAGE/dir685-image := dir685-images
-- 
2.19.2


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 1/4] gemini: Add v4.19 kernel patches

2019-01-19 Thread Linus Walleij
This is the remainder of kernel patches for the v4.19
kernel. A whole slew of the previous patch stack is now
upstream, so this mainly contains the stuff that was
added upstream between v4.19 and v5.0-rc1, and then
the USB FOTG201 patches from Hans.

Signed-off-by: Linus Walleij 
---
 ...pinctrl-gemini-Mask-and-set-properly.patch |  36 +++
 ...inctrl-gemini-Fix-up-TVC-clock-group.patch | 146 
 ...nctrl-gemini-Drop-noisy-debug-prints.patch |  87 
 .../0004-boot-sq201-from-sda1.patch   |  25 +++
 ...hysmap_of-Move-custom-initialization.patch |  52 +
 ...physmap_of_gemini-Handle-pin-control.patch | 194 
 ...he-D-Link-DIR-685-MTD-partition-info.patch |  71 ++
 ...8-ARM-dts-Enable-Gemini-flash-access.patch | 169 ++
 ...rtitions-Add-RedBoot-FIS-DT-bindings.patch |  51 +
 ...ns-Add-second-compatible-for-redboot.patch |  77 +++
 ...11-ARM-dts-Fix-up-SQ201-flash-access.patch |  73 ++
 ...ARM-dts-Blank-D-Link-DIR-685-console.patch |  30 +++
 ...ost-fotg2-add-silicon-clock-handling.patch | 123 ++
 ...st-add-DT-bindings-for-faraday-fotg2.patch |  69 ++
 ...b-host-fotg2-add-device-tree-probing.patch |  48 
 ...t-fotg2-add-Gemini-specific-handling.patch | 138 
 ...t-fotg2-restart-hcd-after-port-reset.patch |  32 +++
 ...he-FOTG210-USB-host-to-Gemini-boards.patch | 210 ++
 18 files changed, 1631 insertions(+)
 create mode 100644 
target/linux/gemini/patches-4.19/0001-pinctrl-gemini-Mask-and-set-properly.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0002-pinctrl-gemini-Fix-up-TVC-clock-group.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0003-pinctrl-gemini-Drop-noisy-debug-prints.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0004-boot-sq201-from-sda1.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0005-mtd-physmap_of-Move-custom-initialization.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0006-mtd-physmap_of_gemini-Handle-pin-control.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0007-ARM-dts-Fix-up-the-D-Link-DIR-685-MTD-partition-info.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0008-ARM-dts-Enable-Gemini-flash-access.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0009-mtd-partitions-Add-RedBoot-FIS-DT-bindings.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0010-mtd-partitions-Add-second-compatible-for-redboot.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0011-ARM-dts-Fix-up-SQ201-flash-access.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0012-ARM-dts-Blank-D-Link-DIR-685-console.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0013-usb-host-fotg2-add-silicon-clock-handling.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0014-usb-host-add-DT-bindings-for-faraday-fotg2.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0015-usb-host-fotg2-add-device-tree-probing.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0016-usb-host-fotg2-add-Gemini-specific-handling.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0017-usb-host-fotg2-restart-hcd-after-port-reset.patch
 create mode 100644 
target/linux/gemini/patches-4.19/0018-ARM-dts-Add-the-FOTG210-USB-host-to-Gemini-boards.patch

diff --git 
a/target/linux/gemini/patches-4.19/0001-pinctrl-gemini-Mask-and-set-properly.patch
 
b/target/linux/gemini/patches-4.19/0001-pinctrl-gemini-Mask-and-set-properly.patch
new file mode 100644
index ..3cc7bad8b84c
--- /dev/null
+++ 
b/target/linux/gemini/patches-4.19/0001-pinctrl-gemini-Mask-and-set-properly.patch
@@ -0,0 +1,36 @@
+From f8ac3d3472a8dc99c8647a637611d146d88be8cb Mon Sep 17 00:00:00 2001
+From: Linus Walleij 
+Date: Tue, 9 Oct 2018 10:09:14 +0200
+Subject: [PATCH 01/18] pinctrl: gemini: Mask and set properly
+
+The code was written under the assumption that the
+regmap_update_bits() would mask the bits in the mask and
+set the bits in the value.
+
+It missed the points that it will not set bits in the value
+unless these are also masked in the mask. Set value bits
+that are not in the mask will simply be ignored.
+
+Fixes: 06351d133dea ("pinctrl: add a Gemini SoC pin controller")
+Signed-off-by: Linus Walleij 
+---
+ drivers/pinctrl/pinctrl-gemini.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/pinctrl/pinctrl-gemini.c 
b/drivers/pinctrl/pinctrl-gemini.c
+index fa7d998e1d5a..1e484a36ff07 100644
+--- a/drivers/pinctrl/pinctrl-gemini.c
 b/drivers/pinctrl/pinctrl-gemini.c
+@@ -2184,7 +2184,8 @@ static int gemini_pmx_set_mux(struct pinctrl_dev 
*pctldev,
+func->name, grp->name);
+ 
+   regmap_read(pmx->map, GLOBAL_MISC_CTRL, &before);
+-  regmap_update_bits(pmx->map, GLOBAL_MISC_CTRL, grp->mask,
++  regmap_update_bits(pmx->map, GLOBAL_MISC_CTRL,
++ grp->mask | grp->value,
+  grp->value);
+  

[OpenWrt-Devel] [PATCH] bcm53xx: add support for Phicomm K3

2019-01-19 Thread Hao Dong
Hardware specifications:

- CPU: Broadcom BCM4709C0 @1.4GHz (Dual-Core ARM)
- RAM: 512 MB (DDR3)
- Flash: 128 MB (NAND)
- LAN ports: 3, LAN speed: 10/100/1000
- WAN ports: 1, WAN speed: 10/100/1000
- 2.4G: BCM4366 4x4 MIMO 1000Mbps -- Skyworks SE2623L 2.4GHz Power Amplifier 
(x4)
- 5G: BCM4366 4x4 MIMO 2167Mbps -- RFMD RFPA5542 5GHz Power Amplifier Module 
(x4)
- USB: 1x USB 3.0 port
- 1x LED, 1x reset button, 1x power switch
- 1x system status touch screen

Flash:

- Enter CFE
- Upload the trx file
- Reboot

Signed-off-by: Hao Dong 
---
 .../bcm53xx/base-files/etc/board.d/02_network |   6 +
 target/linux/bcm53xx/image/Makefile   |   7 +
 ...BCM5301X-Add-basic-DT-for-Phicomm-K3.patch | 122 ++
 ...BCM5301X-Add-basic-DT-for-Phicomm-K3.patch | 122 ++
 4 files changed, 257 insertions(+)
 create mode 100644 
target/linux/bcm53xx/patches-4.14/322-ARM-dts-BCM5301X-Add-basic-DT-for-Phicomm-K3.patch
 create mode 100644 
target/linux/bcm53xx/patches-4.19/322-ARM-dts-BCM5301X-Add-basic-DT-for-Phicomm-K3.patch

diff --git a/target/linux/bcm53xx/base-files/etc/board.d/02_network 
b/target/linux/bcm53xx/base-files/etc/board.d/02_network
index dc17af4891..8c9e8b3f3f 100755
--- a/target/linux/bcm53xx/base-files/etc/board.d/02_network
+++ b/target/linux/bcm53xx/base-files/etc/board.d/02_network
@@ -24,6 +24,12 @@ buffalo,wzr-1750dhp)
board_config_flush
exit 0
;;
+phicomm,k3)
+   ucidef_add_switch "switch0" \
+   "0:lan" "1:lan" "2:lan" "3:wan" "5@eth0"
+   board_config_flush
+   exit 0
+;;
 esac
 
 wan_macaddr="$(nvram get wan_hwaddr)"
diff --git a/target/linux/bcm53xx/image/Makefile 
b/target/linux/bcm53xx/image/Makefile
index 55db479701..fc18a96232 100644
--- a/target/linux/bcm53xx/image/Makefile
+++ b/target/linux/bcm53xx/image/Makefile
@@ -313,6 +313,13 @@ define Device/smartrg-sr400ac
 endef
 TARGET_DEVICES += smartrg-sr400ac
 
+define Device/phicomm-k3
+  DEVICE_TITLE := PHICOMM K3
+  DEVICE_PACKAGES := $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
+  IMAGES := trx
+endef
+TARGET_DEVICES += phicomm-k3
+
 define Device/tenda-ac9
   DEVICE_TITLE := Tenda AC9
   DEVICE_PACKAGES := $(B43) $(USB2_PACKAGES)
diff --git 
a/target/linux/bcm53xx/patches-4.14/322-ARM-dts-BCM5301X-Add-basic-DT-for-Phicomm-K3.patch
 
b/target/linux/bcm53xx/patches-4.14/322-ARM-dts-BCM5301X-Add-basic-DT-for-Phicomm-K3.patch
new file mode 100644
index 00..cd8ddd15c0
--- /dev/null
+++ 
b/target/linux/bcm53xx/patches-4.14/322-ARM-dts-BCM5301X-Add-basic-DT-for-Phicomm-K3.patch
@@ -0,0 +1,122 @@
+From 8ab0ea8e9275c03f253f84dc83ee86cdbeb1fcf4 Mon Sep 17 00:00:00 2001
+From: Hao Dong 
+Date: Sat, 19 Jan 2019 17:25:29 +
+Subject: [PATCH] ARM: dts: BCM5301X: Add basic DT for Phicomm K3
+
+This router has BCM4709C0, 128MB NAND flash (MX30LF1G18AC-TI),
+and 512MB memory, with 3 x LAN and 1 x WAN. WL chips are
+BCM4366C0 x 2. The router has a small LCD and 3 capactive keys
+driven by a PIC microcontroller, which is in turn wired to
+UART1 of main board.
+
+Everything except the LCD works. Hamster has activated LCD through
+UART1, but further programming, i.e., a independent package, is
+required to make sure its working properly.
+
+Since the firmware of Broadcom 4366c0 has been provided by
+openwrt.org, now its wireless is functional but limited. The
+"official" firmware cannot work properly in some 5G Hz channel.
+
+Signed-off-by: Hao Dong 
+---
+ arch/arm/boot/dts/Makefile|  1 +
+ arch/arm/boot/dts/bcm47094-phicomm-k3.dts | 75 +++
+ 2 files changed, 76 insertions(+)
+ create mode 100644 arch/arm/boot/dts/bcm47094-phicomm-k3.dts
+
+diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
+index 6e0534f..9209fbb 100644
+--- a/arch/arm/boot/dts/Makefile
 b/arch/arm/boot/dts/Makefile
+@@ -115,6 +115,7 @@ dtb-$(CONFIG_ARCH_BCM_5301X) += \
+   bcm47094-luxul-xwr-3100.dtb \
+   bcm47094-luxul-xwr-3150-v1.dtb \
+   bcm47094-netgear-r8500.dtb \
++  bcm47094-phicomm-k3.dtb \
+   bcm94708.dtb \
+   bcm94709.dtb \
+   bcm953012er.dtb \
+diff --git a/arch/arm/boot/dts/bcm47094-phicomm-k3.dts 
b/arch/arm/boot/dts/bcm47094-phicomm-k3.dts
+new file mode 100644
+index 000..b6e020b
+--- /dev/null
 b/arch/arm/boot/dts/bcm47094-phicomm-k3.dts
+@@ -0,0 +1,75 @@
++// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
++/*
++* Copyright (C) 2017 Hamster Tian 
++* Copyright (C) 2019 Hao Dong 
++*/
++
++/dts-v1/;
++
++#include "bcm47094.dtsi"
++#include "bcm5301x-nand-cs0-bch4.dtsi"
++
++/ {
++  compatible = "phicomm,k3", "brcm,bcm47094", "brcm,bcm4708";
++  model = "Phicomm K3";
++
++  chosen {
++  bootargs = "console=ttyS0,115200";
++  };
++
++  memory {
++  reg = <0x 0x0800
++   0x8800 0x1800>;
++  };
++
++  gpio-keys {
++  compatible = "gpio-keys";
++  #address-cells = <1>;
++  #siz

Re: [OpenWrt-Devel] MIPS stack security and other problems

2019-01-19 Thread Dave Taht
Hauke Mehrtens  writes:

> On 12/18/18 12:46 PM, Hauke Mehrtens wrote:
>> On 12/17/18 1:54 AM, Dave Taht wrote:
>>>
>>> A pretty deep look at home MIPS and arm routers, and a surprising bug in 
>>> Linux/MIPS - by mudge and co:
>>>
>>> https://cyber-itl.org/2018/12/07/a-look-at-home-routers-and-linux-mips.html
>>>
>>> I have no idea if current openwrt, or what prior releases... are subject to
>>> the problems they outline.
>>
>> In the second paper "Build Safety of Software in 28 Popular Home Router"
>> [0] they checked the "security" of multiple popular devices, by checking
>> if they activate ASLR, Non stack Exec, Relro and stack guards. The best
>> device was the Linksys wrt32x and this is based on OpenWrt with not so
>> many modifications. ;-) Just something like Samba downgrade to 3.0.37.
>> The paper also wonders why the other Linksys devices like the wrt1900ac
>> are much worse, but they probably do not use OpenWrt or a much older
>> version. The GPL source code tar.gz of the Linksys wrt32x, begins with
>> cloning from https://github.com/openwrt/openwrt.git
>>
>>
>> It is also interesting how different this approve to security checking
>> is to what the German BSI published in the "BSI TR-03148: Secure
>> Broadband Router:" [1].
>> You can build a device which scores 100% in the one and 0% in the other,
>> there is no overlap. ;-)
>>
>> Hauke
>>
>>
>> [0]:
>> https://cyber-itl.org/assets/papers/2018/build_safety_of_software_in_28_popular_home_routers.pdf
>> [1]:
>> https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR03148/TR03148.pdf?__blob=publicationFile&v=2
>
> It looks like they ran checksec from
> http://github.com/slimm609/checksec.sh on the root file system of the
> devices and came up with these results. The numbers for the Linksys
> wrt32x look very similar to current OpenWrt master, even for MIPS
> CPUs.
>
> I attached two outputs of checksec to this mail from the lantiq target
> with a MIP24Kc CPU. One with master and the current default
> configuration and one with master + activated ASLR configuration
> option.
>
> You can generate these yourself like this:
> ../checksec.sh/checksec -d build_dir/target-mips_24kc_musl/root-lantiq/

This might be a useful tool to make more obvious security issues to
future builders of openwrt.

>
> ASLR increases the image size by about 2.8%:
> Without ASLR: 5.386.965 bytes
> With ASLR:5.540.565 bytes

To me this seems worth it on the larger flash sizes.

> This is caused by increased user space binary size, see for example
> busybox binary which is 7% bigger:
> Without ASLR: 425.532 bytes
> With ASLR:457.336 bytes
>
> The fortified function count does not work with fortify-headers, but
> only with glibc. With glibc some function calls are getting replaced
> with calls to *_chk functions which are taking extra arguments, this
> is done by some glibc header magic. For musl libc OpenWrt uses
> fortify-headers which overwrites the original functions and inlined
> some extra security checks into the calling application. The result
> should be similar, so I assume that we have at least in most places
> similar security for the glibc fortified functions.
> I checked this by compiling an test application and checked the
> assembler code, it contained some extra size checks.
>
> It looks like the detection does not work correctly for kernel modules.
>
> Currently RELRO is not activated for the following libraries:
>   root-lantiq/usr/lib/libbz2.so.1.0
>   root-lantiq/usr/lib/libbz2.so.1.0.6
>   root-lantiq/lib/libgcc_s.so.1
> this looks like a bug.
>
> For libgcc_s.so.1 also NX is disabled, which is not good.

Hmm. Does gcc still actually contain executable code in this segment?

> Some binaries do not use a stack canary, I assume that these binaries
> just do not have an array on the stack which could be exploited. The
> compiler adds stack canaries only to functions which the compiler
> thinks need it.
>
> ASLR is deactivated for root-lantiq/sbin/vdsl_cpe_control, because
> this application does not link any more when ASLR is activated, this
> is a bug in the package build system.
>
> Hauke
>
>
> ___
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel