Re: [OpenWrt-Devel] [PATCH] utils/spidev_test: Update to current source from upstream Linux

2019-05-10 Thread Jeff Kletsky

On 5/10/19 11:18 PM, Christian Lamparter wrote:


On Friday, May 10, 2019 3:56:37 PM CEST l...@allycomm.com wrote:

From: Jeff Kletsky 

Incorporates multiple changes, including file-based input and output

 From upstream commit:

 commit 35386dfd13b7
 Author: Geert Uytterhoeven 
 Date:   Mon Sep 3 19:33:23 2018 +0200

Signed-off-by: Jeff Kletsky 
---

Hm, this got me thinking. Because we could also just do what the perf
package does and built the spidev_test from the device's linux kernel
source and ship it. This would also entail that we don't need to ship
the spidev_test.c in package/utils/spidev_test/src anymore. What do you
think?

Cheers,
Christian

---
diff --git a/package/utils/spidev_test/Makefile 
b/package/utils/spidev_test/Makefile
index b7c5227f91..29c6a90dc8 100644
--- a/package/utils/spidev_test/Makefile
+++ b/package/utils/spidev_test/Makefile
@@ -10,13 +10,16 @@ include $(INCLUDE_DIR)/kernel.mk
  
  PKG_NAME:=spidev-test

  PKG_RELEASE:=$(LINUX_VERSION)
+PKG_FLAGS:=nonshared
+PKG_BUILD_DIR:=$(LINUX_DIR)/tools/spi-$(TARGET_DIR_NAME)
+PKG_BUILD_PARALLEL:=1
  
  include $(INCLUDE_DIR)/package.mk
  
  define Package/spidev-test

SECTION:=utils
CATEGORY:=Utilities
-  DEPENDS:=+kmod-spi-dev
+  DEPENDS:=+kmod-spi-dev @!IN_SDK
TITLE:=SPI testing utility
VERSION:=$(LINUX_VERSION)-$(PKG_RELEASE)
URL:=http://www.kernel.org
@@ -27,9 +30,26 @@ define Package/spidev-test/description
SPI testing utility.
  endef
  
+define Build/Prepare

+   $(CP) $(LINUX_DIR)/tools/spi/* $(PKG_BUILD_DIR)/
+endef

[...]


Sounds great to me!

It's one of those packages that probably only a couple people a year
need, but when they need it, they really need it. The way you proposed
means that it is as current as the Linux version in hand without further
attention.

I was going to say that it would be a couple days until I was back home
and able to look into it and test as I'm on travel, but it looks like
you've already got things well in order. If you want to go ahead with
your patch, I think it's a much better approach.

Jeff

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


Re: [OpenWrt-Devel] [PATCH] utils/spidev_test: Update to current source from upstream Linux

2019-05-10 Thread Christian Lamparter
On Friday, May 10, 2019 3:56:37 PM CEST l...@allycomm.com wrote:
> From: Jeff Kletsky 
> 
> Incorporates multiple changes, including file-based input and output
> 
> From upstream commit:
> 
> commit 35386dfd13b7
> Author: Geert Uytterhoeven 
> Date:   Mon Sep 3 19:33:23 2018 +0200
> 
> Signed-off-by: Jeff Kletsky 
> ---

Hm, this got me thinking. Because we could also just do what the perf
package does and built the spidev_test from the device's linux kernel
source and ship it. This would also entail that we don't need to ship
the spidev_test.c in package/utils/spidev_test/src anymore. What do you
think?

Cheers,
Christian

---
diff --git a/package/utils/spidev_test/Makefile 
b/package/utils/spidev_test/Makefile
index b7c5227f91..29c6a90dc8 100644
--- a/package/utils/spidev_test/Makefile
+++ b/package/utils/spidev_test/Makefile
@@ -10,13 +10,16 @@ include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=spidev-test
 PKG_RELEASE:=$(LINUX_VERSION)
+PKG_FLAGS:=nonshared
+PKG_BUILD_DIR:=$(LINUX_DIR)/tools/spi-$(TARGET_DIR_NAME)
+PKG_BUILD_PARALLEL:=1
 
 include $(INCLUDE_DIR)/package.mk
 
 define Package/spidev-test
   SECTION:=utils
   CATEGORY:=Utilities
-  DEPENDS:=+kmod-spi-dev
+  DEPENDS:=+kmod-spi-dev @!IN_SDK
   TITLE:=SPI testing utility
   VERSION:=$(LINUX_VERSION)-$(PKG_RELEASE)
   URL:=http://www.kernel.org
@@ -27,9 +30,26 @@ define Package/spidev-test/description
   SPI testing utility.
 endef
 
+define Build/Prepare
+   $(CP) $(LINUX_DIR)/tools/spi/* $(PKG_BUILD_DIR)/
+endef
+
+MAKE_FLAGS = \
+   ARCH="$(LINUX_KARCH)" \
+   CROSS_COMPILE="$(TARGET_CROSS)" \
+   CC="$(TARGET_CC)" \
+   LD="$(TARGET_CROSS)ld" \
+   CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
+   LDFLAGS="$(TARGET_LDFLAGS)" \
+   $(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='') \
+   WERROR=0 \
+   prefix=/usr
+
 define Build/Compile
-   $(TARGET_CC) $(TARGET_CFLAGS) -o $(PKG_BUILD_DIR)/spidev_test \
-   $(PKG_BUILD_DIR)/spidev_test.c
+   +$(MAKE_FLAGS) $(MAKE) $(PKG_JOBS) \
+   -C $(PKG_BUILD_DIR) \
+   -f Makefile \
+   --no-print-directory
 endef
 
 define Package/spidev-test/install
diff --git a/package/utils/spidev_test/src/spidev_test.c 
b/package/utils/spidev_test/src/spidev_test.c
deleted file mode 100644
index 135b3f592b..00
--- a/package/utils/spidev_test/src/spidev_test.c
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * SPI testing utility (using spidev driver)
- *
- * Copyright (c) 2007  MontaVista Software, Inc.
- * Copyright (c) 2007  Anton Vorontsov 
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License.
- *
- * Cross-compile with cross-gcc -I/path/to/cross-kernel/include
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
-
-static void pabort(const char *s)
-{
-   perror(s);
-   abort();
-}
-
-static const char *device = "/dev/spidev1.1";
-static uint32_t mode;
-static uint8_t bits = 8;
-static uint32_t speed = 50;
-static uint16_t delay;
-static int verbose;
-
-uint8_t default_tx[] = {
-   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-   0x40, 0x00, 0x00, 0x00, 0x00, 0x95,
-   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-   0xF0, 0x0D,
-};
-
-uint8_t default_rx[ARRAY_SIZE(default_tx)] = {0, };
-char *input_tx;
-
-static void hex_dump(const void *src, size_t length, size_t line_size, char 
*prefix)
-{
-   int i = 0;
-   const unsigned char *address = src;
-   const unsigned char *line = address;
-   unsigned char c;
-
-   printf("%s | ", prefix);
-   while (length-- > 0) {
-   printf("%02X ", *address++);
-   if (!(++i % line_size) || (length == 0 && i % line_size)) {
-   if (length == 0) {
-   while (i++ % line_size)
-   printf("__ ");
-   }
-   printf(" | ");  /* right close */
-   while (line < address) {
-   c = *line++;
-   printf("%c", (c < 33 || c == 255) ? 0x2E : c);
-   }
-   printf("\n");
-   if (length > 0)
-   printf("%s | ", prefix);
-   }
-   }
-}
-
-/*
- *  Unescape - process hexadecimal escape character
- *  converts shell input "\x23" -> 0x23
- */
-static int unescape(char *_dst, char *_src, size_t len)
-{
-   int ret = 0;
-   char *src = _src;
-   char *dst = _dst;
-   unsigned int ch;
-
-   while (*src) {
-   if (*src == '\\' && *(src+1) == 'x') 

[OpenWrt-Devel] [PATCH v3] ramips: Add support for Head Weblink HDRM200

2019-05-10 Thread Kristian Evensen
Head Weblink HDRM200 is a dual-sim router based on MT7620A. The detailed
specifications are:

- MT7620A (580MHz)
- 64MB RAM
- 16MB of flash (SPI NOR)
- 6x 10/100Mbps Ethernet (MT7620A built-in switch)
- 1x microSD slot
- 1x miniPCIe slot (only USB2.0 bus). Device is shipped with a SIMCOM
SIM7100E LTE modem.
- 2x SIM slots (standard size)
- 1x USB2.0 port
- 1x 2.4GHz wifi (rt2800)
- 1x 5GHz wifi (mt7612)
- 1x reset button
- 1x WPS button
- 3x GPIO-controllable LEDs
- 1x 10 pin terminal block (RS232, RS485, 4 x GPIO)

Tested:
- Ethernet switch
- Wifi
- USB slot
- SD card slot
- miniPCIe-slot
- sysupgrade
- reset button

Installation instructions:

Installing OpenWRT for the first time requires a bit of work, as the
board does not ship with OpenWRT. In addition, the bootloader
automatically reboots when installing an image over tftp.

In order to install OpenWRT, you first need to compile an initramfs
(ramdisk)-image for the device. Once the image is ready, you need to do
the following:

* Copy the initramfs-image to your tftp-root (default filename is
test.bin) and configure networking accordingly (default server IP is
10.10.10.3, client 10.10.10.123). Start your tftp server.
* Open the board and connect to UART. The pins are exposed and clearly
marked.
* Boot the board and press 1.
* Either use the default filename and client/server IP-addresses, or
specify your own.

The image should now be loaded to memory and board boot. If the router
reboots while the image is loading, you need to try again. Once the
board has booted, copy the sysupgrade-image to the router and run
sysupgrade in order to install OpenWRT to the flash.

Notes:

- You control which SIM slot to use by writing 0/1 to
/sys/class/gpio/sim_switch/value. In order for the change to take
effect, you can either use AT-commands (AT+CFUN) or power-cycle the
modem (write 0/1 to /sys/class/gpio/power_mpcie/value).
- RS485 is available on /dev/ttyS0.
- RS232 is available on /dev/ttyS1.
- The name of the ioX-gpios map to the labels on the casing.

Signed-off-by: Kristian Evensen 
---
v2->v3:

* Build initramfs automatically, which means that ramdisk is now enabled
the mt7620-target. Due to this change, an initramfs-image is built for all
deivces, but this seems to be ok when looking at other targets (mt7621)
(thanks Petr Štetiar).
* Use generic board/model detection, updated the match in 01_leds and
02_network (thanks Petr Štetiar).
* Changed the device/target device in the Makefile to match the
compatible-string in the DTS (thanks Petr Štetiar).
* Use the user-space gpio-switch alternative instead of gpio-export in
the DTS (thanks Petr Štetiar).
* Update name of flash node in DTS to the more generic "flash0" (thanks
Petr Štetiar)..
* Fix typo in commit message (mt7621->mt7612) (thanks Tom Psyborg).
* Added the QMI and option drivers, as well as uqmi, so that the modem
is available for use out of the box.

v1->v2:
* Add SPDX line to DTS (thanks Rafał Miłecki).
---
 .../ramips/base-files/etc/board.d/01_leds |   3 +
 .../ramips/base-files/etc/board.d/02_network  |   1 +
 .../base-files/etc/board.d/03_gpio_switches   |   8 +
 target/linux/ramips/dts/HDRM200.dts   | 188 ++
 target/linux/ramips/image/mt7620.mk   |   9 +
 target/linux/ramips/mt7620/target.mk  |   2 +-
 6 files changed, 210 insertions(+), 1 deletion(-)
 create mode 100644 target/linux/ramips/dts/HDRM200.dts

diff --git a/target/linux/ramips/base-files/etc/board.d/01_leds 
b/target/linux/ramips/base-files/etc/board.d/01_leds
index fa20ab0714..0799314f6d 100755
--- a/target/linux/ramips/base-files/etc/board.d/01_leds
+++ b/target/linux/ramips/base-files/etc/board.d/01_leds
@@ -184,6 +184,9 @@ hc5861)
ucidef_set_led_netdev "wifi5g" "wifi5g" "$boardname:blue:wlan5g" "wlan0"
ucidef_set_led_netdev "wifi2g" "wifi2g" "$boardname:blue:wlan2g" "wlan1"
;;
+head-weblink,hdrm200)
+   set_wifi_led "$boardname:green:wifi"
+   ;;
 hg255d)
set_wifi_led "$boardname:green:wlan"
ucidef_set_led_netdev "internet" "internet" "$boardname:green:internet" 
"eth0.2"
diff --git a/target/linux/ramips/base-files/etc/board.d/02_network 
b/target/linux/ramips/base-files/etc/board.d/02_network
index c2646876a2..b0037a0ce2 100755
--- a/target/linux/ramips/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/base-files/etc/board.d/02_network
@@ -314,6 +314,7 @@ ramips_setup_interfaces()
"1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "6@eth0"
;;
hc5661|\
+   head-weblink,hdrm200|\
y1s)
ucidef_add_switch "switch0" \
"1:lan" "2:lan" "3:lan" "4:lan" "5:lan" "0:wan" "6@eth0"
diff --git a/target/linux/ramips/base-files/etc/board.d/03_gpio_switches 
b/target/linux/ramips/base-files/etc/board.d/03_gpio_switches
index 80e3c4c41f..fc376a4d1f 100755
--- a/target/linux/ramips/base-files/etc/board.d/03_gpio_switches
+++ 

[OpenWrt-Devel] [PATCH 1/2] procd: add clang-format kernel style

2019-05-10 Thread Paul Spooren
copied from the official kernel style:

https://github.com/torvalds/linux/blob/master/.clang-format

also modify gitignore to unignore the style file

Signed-off-by: Paul Spooren 
---
 .clang-format | 117 ++
 .gitignore|   1 +
 2 files changed, 118 insertions(+)
 create mode 100644 .clang-format

diff --git a/.clang-format b/.clang-format
new file mode 100644
index 000..9d819d4
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,117 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# clang-format configuration file. Intended for clang-format >= 4.
+#
+# For more information, see:
+#
+#   Documentation/process/clang-format.rst
+#   https://clang.llvm.org/docs/ClangFormat.html
+#   https://clang.llvm.org/docs/ClangFormatStyleOptions.html
+#
+---
+AccessModifierOffset: -4
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+#AlignEscapedNewlines: Left # Unknown to clang-format-4.0
+AlignOperands: true
+AlignTrailingComments: false
+AllowAllParametersOfDeclarationOnNextLine: false
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: None
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: false
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:
+  AfterClass: false
+  AfterControlStatement: false
+  AfterEnum: false
+  AfterFunction: true
+  AfterNamespace: true
+  AfterObjCDeclaration: false
+  AfterStruct: false
+  AfterUnion: false
+  #AfterExternBlock: false # Unknown to clang-format-5.0
+  BeforeCatch: false
+  BeforeElse: false
+  IndentBraces: false
+  #SplitEmptyFunction: true # Unknown to clang-format-4.0
+  #SplitEmptyRecord: true # Unknown to clang-format-4.0
+  #SplitEmptyNamespace: true # Unknown to clang-format-4.0
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Custom
+#BreakBeforeInheritanceComma: false # Unknown to clang-format-4.0
+BreakBeforeTernaryOperators: false
+BreakConstructorInitializersBeforeComma: false
+#BreakConstructorInitializers: BeforeComma # Unknown to clang-format-4.0
+BreakAfterJavaFieldAnnotations: false
+BreakStringLiterals: false
+ColumnLimit: 80
+CommentPragmas: '^ IWYU pragma:'
+#CompactNamespaces: false # Unknown to clang-format-4.0
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 8
+ContinuationIndentWidth: 8
+Cpp11BracedListStyle: false
+DerivePointerAlignment: false
+DisableFormat: false
+ExperimentalAutoDetectBinPacking: false
+#FixNamespaceComments: false # Unknown to clang-format-4.0
+#IncludeBlocks: Preserve # Unknown to clang-format-5.0
+IncludeCategories:
+  - Regex: '.*'
+Priority: 1
+IncludeIsMainRegex: '(Test)?$'
+IndentCaseLabels: false
+#IndentPPDirectives: None # Unknown to clang-format-5.0
+IndentWidth: 8
+IndentWrappedFunctionNames: false
+JavaScriptQuotes: Leave
+JavaScriptWrapImports: true
+KeepEmptyLinesAtTheStartOfBlocks: false
+MacroBlockBegin: ''
+MacroBlockEnd: ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: Inner
+#ObjCBinPackProtocolList: Auto # Unknown to clang-format-5.0
+ObjCBlockIndentWidth: 8
+ObjCSpaceAfterProperty: true
+ObjCSpaceBeforeProtocolList: true
+
+# Taken from git's rules
+#PenaltyBreakAssignment: 10 # Unknown to clang-format-4.0
+PenaltyBreakBeforeFirstCallParameter: 30
+PenaltyBreakComment: 10
+PenaltyBreakFirstLessLess: 0
+PenaltyBreakString: 10
+PenaltyExcessCharacter: 100
+PenaltyReturnTypeOnItsOwnLine: 60
+
+PointerAlignment: Right
+ReflowComments: false
+SortIncludes: false
+#SortUsingDeclarations: false # Unknown to clang-format-4.0
+SpaceAfterCStyleCast: false
+SpaceAfterTemplateKeyword: true
+SpaceBeforeAssignmentOperators: true
+#SpaceBeforeCtorInitializerColon: true # Unknown to clang-format-5.0
+#SpaceBeforeInheritanceColon: true # Unknown to clang-format-5.0
+SpaceBeforeParens: ControlStatements
+#SpaceBeforeRangeBasedForLoopColon: true # Unknown to clang-format-5.0
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: false
+SpacesInContainerLiterals: false
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard: Cpp03
+TabWidth: 8
+UseTab: Always
+...
diff --git a/.gitignore b/.gitignore
index 9d80a74..7896aa0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,4 +10,5 @@ utrace
 ujail
 *.so
 *.cmake
+!.clang-format
 install_manifest.txt
-- 
2.20.1


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


[OpenWrt-Devel] [PATCH 2/2] procd: apply official kernel clang-format style

2019-05-10 Thread Paul Spooren
Currently some files use a mixture of spaces and tabs within a single
file, instead of fixing style manually, a tool could do the job.

Signed-off-by: Paul Spooren 
---
 container.h   |   3 +-
 inittab.c | 109 +++-
 libc-compat.h |   5 +-
 log.h |  12 ++--
 preload.h |  49 ++--
 procd.c   |   6 +-
 rcS.c |  10 ++--
 signal.c  |  22 +++-
 state.c   |  52 -
 system.c  | 151 +-
 sysupgrade.c  |   4 +-
 sysupgrade.h  |   2 -
 ubus.c|  12 ++--
 watchdog.c|  10 ++--
 watchdog.h|   4 +-
 15 files changed, 207 insertions(+), 244 deletions(-)

diff --git a/container.h b/container.h
index d33fa32..4bc0191 100644
--- a/container.h
+++ b/container.h
@@ -17,7 +17,8 @@
 #include 
 #include 
 
-static inline bool is_container() {
+static inline bool is_container()
+{
return !!getenv("container");
 }
 
diff --git a/inittab.c b/inittab.c
index 4b9..c955bc6 100644
--- a/inittab.c
+++ b/inittab.c
@@ -32,22 +32,22 @@
 #include "rcS.h"
 
 #ifndef O_PATH
-#define O_PATH 01000
+#define O_PATH 01000
 #endif
 
-#define TAG_ID 0
-#define TAG_RUNLVL 1
-#define TAG_ACTION 2
-#define TAG_PROCESS3
+#define TAG_ID 0
+#define TAG_RUNLVL 1
+#define TAG_ACTION 2
+#define TAG_PROCESS 3
 
-#define MAX_ARGS   8
+#define MAX_ARGS 8
 
 struct init_action;
 char *console = NULL;
 
 struct init_handler {
const char *name;
-   void (*cb) (struct init_action *a);
+   void (*cb)(struct init_action *a);
int multi;
 };
 
@@ -74,7 +74,7 @@ static int dev_exist(const char *dev)
 {
int dfd, fd;
 
-   dfd = open("/dev", O_PATH|O_DIRECTORY);
+   dfd = open("/dev", O_PATH | O_DIRECTORY);
 
if (dfd < 0)
return 0;
@@ -109,9 +109,8 @@ static void fork_worker(struct init_action *a)
}
 
if (a->proc.pid > 0) {
-   DEBUG(4, "Launched new %s action, pid=%d\n",
-   a->handler->name,
-   (int) a->proc.pid);
+   DEBUG(4, "Launched new %s action, pid=%d\n", a->handler->name,
+ (int)a->proc.pid);
uloop_process_add(>proc);
}
 }
@@ -121,7 +120,7 @@ static void child_exit(struct uloop_process *proc, int ret)
struct init_action *a = container_of(proc, struct init_action, proc);
 
DEBUG(4, "pid:%d\n", proc->pid);
-uloop_timeout_set(>tout, a->respawn);
+   uloop_timeout_set(>tout, a->respawn);
 }
 
 static void respawn(struct uloop_timeout *tout)
@@ -184,8 +183,7 @@ static void askconsole(struct init_action *a)
 
console = strdup(tty);
a->id = strdup(tty);
-   }
-   else {
+   } else {
console = NULL;
a->id = NULL;
}
@@ -209,35 +207,39 @@ static void rcrespawn(struct init_action *a)
fork_worker(a);
 }
 
-static struct init_handler handlers[] = {
-   {
-   .name = "sysinit",
-   .cb = runrc,
-   }, {
-   .name = "shutdown",
-   .cb = runrc,
-   }, {
-   .name = "askfirst",
-   .cb = askfirst,
-   .multi = 1,
-   }, {
-   .name = "askconsole",
-   .cb = askconsole,
-   .multi = 1,
-   }, {
-   .name = "respawn",
-   .cb = rcrespawn,
-   .multi = 1,
-   }, {
-   .name = "askconsolelate",
-   .cb = askconsole,
-   .multi = 1,
-   }, {
-   .name = "respawnlate",
-   .cb = rcrespawn,
-   .multi = 1,
-   }
-};
+static struct init_handler handlers[] = { {
+ .name = "sysinit",
+ .cb = runrc,
+ },
+ {
+ .name = "shutdown",
+ .cb = runrc,
+ },
+ {
+ .name = "askfirst",
+ .cb = askfirst,
+ .multi = 1,
+ },
+ {
+ .name = "askconsole",
+ .cb = askconsole,
+ .multi = 1,
+ },
+ {
+ .name = "respawn",
+ .cb = 

[OpenWrt-Devel] [PATCH] utils/spidev_test: Update to current source from upstream Linux

2019-05-10 Thread lede
From: Jeff Kletsky 

Incorporates multiple changes, including file-based input and output

>From upstream commit:

commit 35386dfd13b7
Author: Geert Uytterhoeven 
Date:   Mon Sep 3 19:33:23 2018 +0200

Signed-off-by: Jeff Kletsky 
---
 package/utils/spidev_test/src/spidev_test.c | 213 
 1 file changed, 189 insertions(+), 24 deletions(-)

diff --git a/package/utils/spidev_test/src/spidev_test.c 
b/package/utils/spidev_test/src/spidev_test.c
index 135b3f592b..4c12e6aea5 100644
--- a/package/utils/spidev_test/src/spidev_test.c
+++ b/package/utils/spidev_test/src/spidev_test.c
@@ -18,7 +18,10 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
+#include 
 #include 
 #include 
 
@@ -33,9 +36,14 @@ static void pabort(const char *s)
 static const char *device = "/dev/spidev1.1";
 static uint32_t mode;
 static uint8_t bits = 8;
+static char *input_file;
+static char *output_file;
 static uint32_t speed = 50;
 static uint16_t delay;
 static int verbose;
+static int transfer_size;
+static int iterations;
+static int interval = 5; /* interval in seconds for showing transfer rate */
 
 uint8_t default_tx[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
@@ -49,7 +57,8 @@ uint8_t default_tx[] = {
 uint8_t default_rx[ARRAY_SIZE(default_tx)] = {0, };
 char *input_tx;
 
-static void hex_dump(const void *src, size_t length, size_t line_size, char 
*prefix)
+static void hex_dump(const void *src, size_t length, size_t line_size,
+char *prefix)
 {
int i = 0;
const unsigned char *address = src;
@@ -64,12 +73,12 @@ static void hex_dump(const void *src, size_t length, size_t 
line_size, char *pre
while (i++ % line_size)
printf("__ ");
}
-   printf(" | ");  /* right close */
+   printf(" |");
while (line < address) {
c = *line++;
-   printf("%c", (c < 33 || c == 255) ? 0x2E : c);
+   printf("%c", (c < 32 || c > 126) ? '.' : c);
}
-   printf("\n");
+   printf("|\n");
if (length > 0)
printf("%s | ", prefix);
}
@@ -83,13 +92,17 @@ static void hex_dump(const void *src, size_t length, size_t 
line_size, char *pre
 static int unescape(char *_dst, char *_src, size_t len)
 {
int ret = 0;
+   int match;
char *src = _src;
char *dst = _dst;
unsigned int ch;
 
while (*src) {
if (*src == '\\' && *(src+1) == 'x') {
-   sscanf(src + 2, "%2x", );
+   match = sscanf(src + 2, "%2x", );
+   if (!match)
+   pabort("malformed input string");
+
src += 4;
*dst++ = (unsigned char)ch;
} else {
@@ -103,7 +116,7 @@ static int unescape(char *_dst, char *_src, size_t len)
 static void transfer(int fd, uint8_t const *tx, uint8_t const *rx, size_t len)
 {
int ret;
-
+   int out_fd;
struct spi_ioc_transfer tr = {
.tx_buf = (unsigned long)tx,
.rx_buf = (unsigned long)rx,
@@ -134,16 +147,32 @@ static void transfer(int fd, uint8_t const *tx, uint8_t 
const *rx, size_t len)
 
if (verbose)
hex_dump(tx, len, 32, "TX");
-   hex_dump(rx, len, 32, "RX");
+
+   if (output_file) {
+   out_fd = open(output_file, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+   if (out_fd < 0)
+   pabort("could not open output file");
+
+   ret = write(out_fd, rx, len);
+   if (ret != len)
+   pabort("not all bytes written to output file");
+
+   close(out_fd);
+   }
+
+   if (verbose)
+   hex_dump(rx, len, 32, "RX");
 }
 
 static void print_usage(const char *prog)
 {
-   printf("Usage: %s [-DsbdlHOLC3]\n", prog);
+   printf("Usage: %s [-DsbdlHOLC3vpNR24SI]\n", prog);
puts("  -D --device   device to use (default /dev/spidev1.1)\n"
 "  -s --speedmax speed (Hz)\n"
 "  -d --delaydelay (usec)\n"
-"  -b --bpw  bits per word \n"
+"  -b --bpw  bits per word\n"
+"  -i --inputinput data from a file (e.g. \"test.bin\")\n"
+"  -o --output   output data to a file (e.g. \"results.bin\")\n"
 "  -l --loop loopback\n"
 "  -H --cpha clock phase\n"
 "  -O --cpol clock polarity\n"
@@ -155,7 +184,9 @@ static void print_usage(const char *prog)
 "  -N --no-csno chip select\n"
 "  -R --readyslave pulls low to pause\n"
 "  -2 --dual dual 

[OpenWrt-Devel] [PATCH] ath79: Remove NAND targets as no available drivers

2019-05-10 Thread lede
From: Jeff Kletsky 

Prior to Linux 4.19 there will be no driver support for SPI NAND

Remove the non-bootable GL.iNet AR300M from nand.mk
so images are not generated.

Based on work with the GL.iNet AR750S, the GL.iNet AR300M, NAND-based
board definition and DTS should be reexamined, as well as the NAND port
completed prior to its reintroduction.

Signed-off-by: Jeff Kletsky 
---
 target/linux/ath79/image/nand.mk | 14 +-
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/target/linux/ath79/image/nand.mk b/target/linux/ath79/image/nand.mk
index eee419194b..30e0c72008 100644
--- a/target/linux/ath79/image/nand.mk
+++ b/target/linux/ath79/image/nand.mk
@@ -1,13 +1 @@
-define Device/glinet_gl-ar300m-nand
-  ATH_SOC := qca9531
-  DEVICE_TITLE := GL-AR300M (NAND)
-  DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-storage 
kmod-usb-ledtrig-usbport
-  KERNEL_SIZE := 2048k
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  VID_HDR_OFFSET := 512
-  IMAGES += factory.ubi
-  IMAGE/sysupgrade.bin := sysupgrade-tar
-  IMAGE/factory.ubi := append-kernel | pad-to (KERNEL_SIZE) | append-ubi
-endef
-TARGET_DEVICES += glinet_gl-ar300m-nand
+# There is no driver support on ath79 for SPI NAND prior to Linux 4.19
-- 
2.11.0


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


[OpenWrt-Devel] [PATCH 1/2] add clang-format kernel style

2019-05-10 Thread Paul Spooren
copied from the official kernel style:

https://github.com/torvalds/linux/blob/master/.clang-format

Signed-off-by: Paul Spooren 
---
 .clang-format | 118 ++
 1 file changed, 118 insertions(+)
 create mode 100644 .clang-format

diff --git a/.clang-format b/.clang-format
new file mode 100644
index 000..3fd09cd
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,118 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# clang-format configuration file. Intended for clang-format >= 4.
+#
+# For more information, see:
+#
+#   Documentation/process/clang-format.rst
+#   https://clang.llvm.org/docs/ClangFormat.html
+#   https://clang.llvm.org/docs/ClangFormatStyleOptions.html
+#
+---
+AccessModifierOffset: -4
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+#AlignEscapedNewlines: Left # Unknown to clang-format-4.0
+AlignOperands: true
+AlignTrailingComments: false
+AllowAllParametersOfDeclarationOnNextLine: false
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: None
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: false
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:
+  AfterClass: false
+  AfterControlStatement: false
+  AfterEnum: false
+  AfterFunction: true
+  AfterNamespace: true
+  AfterObjCDeclaration: false
+  AfterStruct: false
+  AfterUnion: false
+  #AfterExternBlock: false # Unknown to clang-format-5.0
+  BeforeCatch: false
+  BeforeElse: false
+  IndentBraces: false
+  #SplitEmptyFunction: true # Unknown to clang-format-4.0
+  #SplitEmptyRecord: true # Unknown to clang-format-4.0
+  #SplitEmptyNamespace: true # Unknown to clang-format-4.0
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Custom
+#BreakBeforeInheritanceComma: false # Unknown to clang-format-4.0
+BreakBeforeTernaryOperators: false
+BreakConstructorInitializersBeforeComma: false
+#BreakConstructorInitializers: BeforeComma # Unknown to clang-format-4.0
+BreakAfterJavaFieldAnnotations: false
+BreakStringLiterals: false
+ColumnLimit: 80
+CommentPragmas: '^ IWYU pragma:'
+#CompactNamespaces: false # Unknown to clang-format-4.0
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 8
+ContinuationIndentWidth: 8
+Cpp11BracedListStyle: false
+DerivePointerAlignment: false
+DisableFormat: false
+ExperimentalAutoDetectBinPacking: false
+#FixNamespaceComments: false # Unknown to clang-format-4.0
+#IncludeBlocks: Preserve # Unknown to clang-format-5.0
+IncludeCategories:
+  - Regex: '.*'
+Priority: 1
+IncludeIsMainRegex: '(Test)?$'
+IndentCaseLabels: false
+#IndentPPDirectives: None # Unknown to clang-format-5.0
+IndentWidth: 8
+IndentWrappedFunctionNames: false
+JavaScriptQuotes: Leave
+JavaScriptWrapImports: true
+KeepEmptyLinesAtTheStartOfBlocks: false
+MacroBlockBegin: ''
+MacroBlockEnd: ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: Inner
+#ObjCBinPackProtocolList: Auto # Unknown to clang-format-5.0
+ObjCBlockIndentWidth: 8
+ObjCSpaceAfterProperty: true
+ObjCSpaceBeforeProtocolList: true
+
+# Taken from git's rules
+#PenaltyBreakAssignment: 10 # Unknown to clang-format-4.0
+PenaltyBreakBeforeFirstCallParameter: 30
+PenaltyBreakComment: 10
+PenaltyBreakFirstLessLess: 0
+PenaltyBreakString: 10
+PenaltyExcessCharacter: 100
+PenaltyReturnTypeOnItsOwnLine: 60
+
+PointerAlignment: Right
+ReflowComments: false
+SortIncludes: false
+#SortUsingDeclarations: false # Unknown to clang-format-4.0
+SpaceAfterCStyleCast: false
+SpaceAfterTemplateKeyword: true
+SpaceBeforeAssignmentOperators: true
+#SpaceBeforeCtorInitializerColon: true # Unknown to clang-format-5.0
+#SpaceBeforeInheritanceColon: true # Unknown to clang-format-5.0
+SpaceBeforeParens: ControlStatements
+#SpaceBeforeRangeBasedForLoopColon: true # Unknown to clang-format-5.0
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: false
+SpacesInContainerLiterals: false
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard: Cpp03
+TabWidth: 8
+UseTab: Always
+...
+
-- 
2.20.1


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


[OpenWrt-Devel] [PATCH] generic-4.19: Backport spi-nand support for GigaDevice A/E

2019-05-10 Thread lede
From: Jeff Kletsky 

This patch backports verbatim the commits from Linux 5.0 and 5.1
that implemented support for GigaDevice SPI NAND A and E variants.

Supported only in Linux 4.19 and later as based on the upstream
drivers/mtd/nand/spi/ framework.

mtd-spinand-add-support-for-GigaDevice-GD5FxGQ4xA.patch
commit c93c613214ac (5.0)

mtd-spinand-Add-support-for-GigaDevice-GD5F1GQ4UExxG.patch
commit c40c7a990a46 (5.1)

Run-tested-on: GL.iNet AR750S

Signed-off-by: Jeff Kletsky 
---
 ...and-add-support-for-GigaDevice-GD5FxGQ4xA.patch | 196 +
 ...-Add-support-for-GigaDevice-GD5F1GQ4UExxG.patch | 134 ++
 2 files changed, 330 insertions(+)
 create mode 100644 
target/linux/generic/backport-4.19/450-v5.0-mtd-spinand-add-support-for-GigaDevice-GD5FxGQ4xA.patch
 create mode 100644 
target/linux/generic/backport-4.19/451-v5.1-mtd-spinand-Add-support-for-GigaDevice-GD5F1GQ4UExxG.patch

diff --git 
a/target/linux/generic/backport-4.19/450-v5.0-mtd-spinand-add-support-for-GigaDevice-GD5FxGQ4xA.patch
 
b/target/linux/generic/backport-4.19/450-v5.0-mtd-spinand-add-support-for-GigaDevice-GD5FxGQ4xA.patch
new file mode 100644
index 00..15f761ab9d
--- /dev/null
+++ 
b/target/linux/generic/backport-4.19/450-v5.0-mtd-spinand-add-support-for-GigaDevice-GD5FxGQ4xA.patch
@@ -0,0 +1,196 @@
+From c93c613214ac70c87beab5422a60077bf126b855 Mon Sep 17 00:00:00 2001
+From: Chuanhong Guo 
+Date: Wed, 28 Nov 2018 21:07:25 +0800
+Subject: [PATCH] mtd: spinand: add support for GigaDevice GD5FxGQ4xA
+
+Add support for GigaDevice GD5F1G/2G/4GQ4xA SPI NAND.
+
+Signed-off-by: Chuanhong Guo 
+Reviewed-by: Frieder Schrempf 
+Signed-off-by: Miquel Raynal 
+---
+ drivers/mtd/nand/spi/Makefile |   2 +-
+ drivers/mtd/nand/spi/core.c   |   1 +
+ drivers/mtd/nand/spi/gigadevice.c | 148 ++
+ include/linux/mtd/spinand.h   |   1 +
+ 4 files changed, 151 insertions(+), 1 deletion(-)
+ create mode 100644 drivers/mtd/nand/spi/gigadevice.c
+
+--- a/drivers/mtd/nand/spi/Makefile
 b/drivers/mtd/nand/spi/Makefile
+@@ -1,3 +1,3 @@
+ # SPDX-License-Identifier: GPL-2.0
+-spinand-objs := core.o macronix.o micron.o winbond.o
++spinand-objs := core.o gigadevice.o macronix.o micron.o winbond.o
+ obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
+--- a/drivers/mtd/nand/spi/core.c
 b/drivers/mtd/nand/spi/core.c
+@@ -762,6 +762,7 @@ static const struct nand_ops spinand_ops
+ };
+ 
+ static const struct spinand_manufacturer *spinand_manufacturers[] = {
++  _spinand_manufacturer,
+   _spinand_manufacturer,
+   _spinand_manufacturer,
+   _spinand_manufacturer,
+--- /dev/null
 b/drivers/mtd/nand/spi/gigadevice.c
+@@ -0,0 +1,148 @@
++// SPDX-License-Identifier: GPL-2.0
++/*
++ * Author:
++ *Chuanhong Guo 
++ */
++
++#include 
++#include 
++#include 
++
++#define SPINAND_MFR_GIGADEVICE0xC8
++#define GD5FXGQ4XA_STATUS_ECC_1_7_BITFLIPS(1 << 4)
++#define GD5FXGQ4XA_STATUS_ECC_8_BITFLIPS  (3 << 4)
++
++static SPINAND_OP_VARIANTS(read_cache_variants,
++  SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 2, NULL, 0),
++  SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
++  SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0),
++  SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
++  SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
++  SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
++
++static SPINAND_OP_VARIANTS(write_cache_variants,
++  SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
++  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));
++
++static int gd5fxgq4xa_ooblayout_ecc(struct mtd_info *mtd, int section,
++struct mtd_oob_region *region)
++{
++  if (section > 3)
++  return -ERANGE;
++
++  region->offset = (16 * section) + 8;
++  region->length = 8;
++
++  return 0;
++}
++
++static int gd5fxgq4xa_ooblayout_free(struct mtd_info *mtd, int section,
++ struct mtd_oob_region *region)
++{
++  if (section > 3)
++  return -ERANGE;
++
++  if (section) {
++  region->offset = 16 * section;
++  region->length = 8;
++  } else {
++  /* section 0 has one byte reserved for bad block mark */
++  region->offset = 1;
++  region->length = 7;
++  }
++  return 0;
++}
++
++static int gd5fxgq4xa_ecc_get_status(struct spinand_device *spinand,
++   u8 status)
++{
++  switch (status & STATUS_ECC_MASK) {
++  case STATUS_ECC_NO_BITFLIPS:
++  return 0;
++
++  case GD5FXGQ4XA_STATUS_ECC_1_7_BITFLIPS:
++  /* 1-7 bits are flipped. return the maximum. */
++  

[OpenWrt-Devel] [PATCH] generic-4.19: Backport spi-nand support for GigaDevice A/E

2019-05-10 Thread lede
This backport patch serves as groundwork for supporting SPI NAND
devices on the ath79 platform. Other manufacturers' devices are also
available upstream. The GigaDevice was backported as it is used in the
GL.iNet AR750S.

Patches to support the newer GigaDevice chip in use in the AR750S
have been submitted upstream.

mtd: spinand: Add support for GigaDevice GD5F1GQ4UFxxG
https://patchwork.ozlabs.org/patch/1098024/

Based on the combination of this patch and local application of above
I have been able to sucessfully bring up the AR750S on the ath79-nand
subtarget with Linux 4.19, including sysupgrade.

Jeff


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


Re: [OpenWrt-Devel] [PATCH] ath79: Add missing read-only properties

2019-05-10 Thread David Bauer
Hello Adrian,

On 09.05.19 13:50, Adrian Schmutzler wrote:
> The read-only properties for non-firmware partitions seem to have
> been assigned rather randomly.
> I went through the DTS files in ath79 and assigned the read-only
> to all partitions that seem to require protection.
> diff --git a/target/linux/ath79/dts/ar9344_ocedo_raccoon.dts 
> b/target/linux/ath79/dts/ar9344_ocedo_raccoon.dts
> index 0875c319b9..c5b4775167 100644
> --- a/target/linux/ath79/dts/ar9344_ocedo_raccoon.dts
> +++ b/target/linux/ath79/dts/ar9344_ocedo_raccoon.dts
> @@ -100,6 +100,7 @@
>   partition@4 {
>   label = "u-boot-env";
>   reg = <0x04 0x01>;
> + read-only;
>   };
>  
>   partition@5 {
> diff --git a/target/linux/ath79/dts/qca9558_ocedo_koala.dts 
> b/target/linux/ath79/dts/qca9558_ocedo_koala.dts
> index 23835492a3..2b861ec8c0 100644
> --- a/target/linux/ath79/dts/qca9558_ocedo_koala.dts
> +++ b/target/linux/ath79/dts/qca9558_ocedo_koala.dts
> @@ -95,6 +95,7 @@
>   partition@4 {
>   label = "u-boot-env";
>   reg = <0x04 0x01>;
> + read-only;
>   };
>  
>   partition@5 {
> diff --git a/target/linux/ath79/dts/qca9558_ocedo_ursus.dts 
> b/target/linux/ath79/dts/qca9558_ocedo_ursus.dts
> index 1a92da3946..926cc70e4d 100644
> --- a/target/linux/ath79/dts/qca9558_ocedo_ursus.dts
> +++ b/target/linux/ath79/dts/qca9558_ocedo_ursus.dts
> @@ -68,6 +68,7 @@
>   partition@4 {
>   label = "u-boot-env";
>   reg = <0x04 0x01>;
> + read-only;
>   };
>  
>   partition@5 {


This would break the current flashing instructions, which require to set
the correct partition to boot from the initramfs. [0]

I would prefer not to add read-only flags on uboot-environment without a
real reason. However, I'm fine with adding read-only on ART partitions.

[0]
https://git.openwrt.org/?p=openwrt/openwrt.git;a=commit;h=c4931713df8ffb3c4e5c1be7d0b6d4aa96a7dd4c

Best wishes
David

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


Re: [OpenWrt-Devel] [PATCH] ath79: Add missing read-only properties

2019-05-10 Thread Sven Eckelmann
On Thursday, 9 May 2019 13:50:39 CEST Adrian Schmutzler wrote:
> diff --git a/target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v2.dts b/
target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v2.dts
> index 1e3cf40f71..fa74cf2344 100644
> --- a/target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v2.dts
> +++ b/target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v2.dts
> @@ -114,6 +114,7 @@
> partition@1 {
> label = "u-boot-env";
> reg = <0x04 0x01>;
> +   read-only;
> };
>  
> partition@2 {

I think this device is in a weird state for ath79 but following info would be 
relevant when it would support flash installations and sysupgrade like under 
ar71xx:

This device needs to write access to the u-boot-env to switch the firmware 
partition and adjust the kernel + (static part of) rootfs checksums during 
syspgrade.

Kind regards,
Sven

signature.asc
Description: This is a digitally signed message part.
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel