[OpenWrt-Devel] Understanding Ethernet Architecture (I/O --> MDIO --> MII vs I/O --> MAC) for mt7620 (OpenWRT)

2019-06-14 Thread Daniel Santos
Hello,

I'm still fairly new to Ethernet drivers and there are a lot of
interesting pieces.  What I need help with is understanding MDIO -->
(R)MII vs direct I/O to the MAC (e.g., via ioread32, iowrite32).  Why is
there not always a struct mii_bus to talk to this hardware?  Is it
because the PHY and/or MAC hardware sometimes attached via an MDIO
device and sometimes directly to the I/O bus?  Or does some type of
"indirect access" need to be enabled for that to work?

I might be trying to do something that's unnecessary however, I'm not
sure yet.  I need to add functionality to change a port's
auto-negotiate, duplex, etc.  I'm adding it to the swconfig first and
then will look at adding it for DSA afterwards.  When I run "swconfig
dev switch0 port 0 show", the current mt7530 / mt7620 driver is querying
the MAC status register (at base + 0x3008 + 0x100 * port, described on
pages 323-324 of the MT7620 Programming Guide), so I implemented the
"set" functionality by modifying the MAC's control register (offset
0x3000 on page 321), but it doesn't seem to change anything.  So I
figured maybe I need to modify the MII interface's control register for
the port (page 350), but upon debugging I can see that the struct
mii_bus *bus member is NULL.

So should I be able to change it via the MAC's control register and
something else is wrong?  Why is there no struct mii_bus?  Can I talk to
the MII hardware in some other way?

Thanks,
Daniel

https://download.villagetelco.org/hardware/MT7620/MT7620_ProgrammingGuide.pdf

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


Re: [OpenWrt-Devel] [PATCH 1/3] gemini: Make a per-board case for ethernet MAC

2019-06-14 Thread Linus Walleij
On Fri, Jun 14, 2019 at 7:24 PM Christian Lamparter  wrote:

> I put together a patchset in my staging tree starting from
>
> https://git.openwrt.org/?p=openwrt/staging/chunkeey.git;a=commit;h=620462e09afc40602110b82caeb2858903709567
> https://git.openwrt.org/?p=openwrt/staging/chunkeey.git;a=commit;h=bbde89504fb6124da5a3f0014025753db4d6ec67
> https://git.openwrt.org/?p=openwrt/staging/chunkeey.git;a=commit;h=6096e5208373822d123b8fe4f848b8612f3d04c8
> https://git.openwrt.org/?p=openwrt/staging/chunkeey.git;a=commit;h=1d8ddcfc7a00701ab73d7dd06cf5fa420c1a5882
> https://git.openwrt.org/?p=openwrt/staging/chunkeey.git;a=commit;h=b106a522001e970378c38279fe598acbc867d0f4
>
> Let me know if this works now with the ip tool.

Yes! I applied this series and all comes up nicely, right MAC address
and writeable root filesystem. Feel free to push this and thanks so
much for the help!

Yours,
Linus Walleij

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


Re: [OpenWrt-Devel] [PATCH] gpio-button-hotplug: gpio-keys: read initial state

2019-06-14 Thread Christian Lamparter
On Thursday, June 13, 2019 11:00:36 PM CEST David Bauer wrote:
> This commit reads the initial state for interrupt triggered gpio-keys.
> Without this commit, the switch to the initial stable input-state
> triggers a button-event. Button events are now only triggered when the
> button state differs fromt the initial state.
> 
> Effectively, this reverts commit 6c5bfaac84b0 ("gpio-button-hotplug:
> gpio-keys: fix always missing first event"), but in addition, we read
> the initial button state on driver probe. This commit caused some devices
> to enter failsafe mode every time when booting.
> 
> Run-tested on devolo WiFi pro 1200e & 1200i.
> 
> Signed-off-by: David Bauer 

Oh boy, I think the problem is in the failsafe button handler instead.

|
|#!/bin/sh
|
|[ "${TYPE}" = "switch" ] || echo ${BUTTON} > /tmp/failsafe_button
|
|return 0
|

It's not checking the button state, so even a single "released" message
can do something. If this turns out to be even more troublesome I think
we should enlist Linus Walleij... he might be interested too, since he's
the upstream linux-gpio maintainer and gemini target contributor.

Maybe he can point to a specifc reason why the interrupt gets triggered
when the module is loaded and how to handle it. Because this behavior
seems to be common between different platforms now and the upstream
gpio-keys (which does work differently!) seems to handle it just fine.

@Linus: Do you have any inside knowledge about the issue? That when
gpio-keys is loaded (in OpenWrt it's a module due to kernel size
constraint on various routers) the associated interrupt fires and
this results in a ghost key event. I have to add that OpenWrt's
gpio-button-hotplug.c (which registers the gpio-keys and
gpio-keys-polled) is a special, out-of-tree module that sends broadcast
events (netlink) rather than using the input-subsystem (again due
to space issues). 

the OpenWrt's gpio-button-hotplug.c source is right here:
https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c

Regards,
Christian

> ---
>  .../src/gpio-button-hotplug.c  | 18 +-
>  1 file changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c 
> b/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c
> index daa4b2a4f7..5bc783e015 100644
> --- a/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c
> +++ b/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c
> @@ -341,8 +341,16 @@ static void gpio_keys_irq_work_func(struct work_struct 
> *work)
>   struct gpio_keys_button_data *bdata = container_of(work,
>   struct gpio_keys_button_data, work.work);
>  
> - button_hotplug_event(bdata, bdata->b->type ?: EV_KEY,
> -  gpio_button_get_value(bdata));
> + int state = gpio_button_get_value(bdata);
> +
> + if (state != bdata->last_state) {
> + unsigned int type = bdata->b->type ?: EV_KEY;
> +
> + if (bdata->last_state != -1 || type == EV_SW)
> + button_hotplug_event(bdata, type, state);
> +
> + bdata->last_state = state;
> + }
>  }
>  
>  static irqreturn_t button_handle_irq(int irq, void *_bdata)
> @@ -607,6 +615,9 @@ static int gpio_keys_probe(struct platform_device *pdev)
>  
>   INIT_DELAYED_WORK(>work, gpio_keys_irq_work_func);
>  
> + schedule_delayed_work(>work,
> +   msecs_to_jiffies(bdata->software_debounce));
> +
>   ret = devm_request_threaded_irq(>dev,
>   bdata->irq, NULL, button_handle_irq,
>   irqflags, dev_name(>dev), bdata);
> @@ -620,9 +631,6 @@ static int gpio_keys_probe(struct platform_device *pdev)
>   dev_dbg(>dev, "gpio:%d has irq:%d\n",
>   button->gpio, bdata->irq);
>   }
> -
> - if (bdata->b->type == EV_SW)
> - button_hotplug_event(bdata, EV_SW, 
> gpio_button_get_value(bdata));
>   }
>  
>   return 0;
> 





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


[OpenWrt-Devel] [PATCH 3/6] tools: Fix unintended lib link in $(STAGING_DIR_HOST)/lib

2019-06-14 Thread Jeffery To
Currently, if the $(STAGING_DIR_HOST)/lib64 link already exists, ln (in
tools/prepare) will interpret $(STAGING_DIR_HOST)/lib64 as a directory
rather than a link name.

The result is a symbolic link named "lib" inside
$(STAGING_DIR_HOST)/lib, pointing to itself.

This adds the -n option to ln so that $(STAGING_DIR_HOST)/lib64 is
treated as a link name.

Signed-off-by: Jeffery To 
---
 tools/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/Makefile b/tools/Makefile
index d7207ba89d..f3d8debe23 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -138,7 +138,7 @@ $(STAGING_DIR_HOST)/.prepared: $(TMP_DIR)/.build
mkdir -p $(BUILD_DIR_HOST)/stamp $(STAGING_DIR_HOST)/include/sys
$(INSTALL_DATA) $(TOPDIR)/tools/include/*.h $(STAGING_DIR_HOST)/include/
$(INSTALL_DATA) $(TOPDIR)/tools/include/sys/*.h 
$(STAGING_DIR_HOST)/include/sys/
-   ln -sf lib $(STAGING_DIR_HOST)/lib64
+   ln -snf lib $(STAGING_DIR_HOST)/lib64
touch $@
 
 endif
-- 
2.20.1


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


[OpenWrt-Devel] [PATCH 6/6] packages: Install files into staging directory in Host/Install

2019-06-14 Thread Jeffery To
This updates Host/Install for packages to install files into the given
staging directory, instead of into $(STAGING_DIR_HOSTPKG) (or
$(STAGING_DIR_HOST)) directly, so that files can be automatically
tracked and uninstalled.

Signed-off-by: Jeffery To 
---
 package/libs/gettext/Makefile   |  8 
 package/libs/libiconv/Makefile  | 12 ++--
 package/system/fwtool/Makefile  |  1 +
 package/system/iucode-tool/Makefile |  5 -
 package/system/opkg/Makefile|  4 +++-
 package/utils/bsdiff/Makefile   |  8 ++--
 package/utils/bzip2/Makefile|  8 +++-
 package/utils/lua/Makefile  |  9 +++--
 8 files changed, 26 insertions(+), 29 deletions(-)

diff --git a/package/libs/gettext/Makefile b/package/libs/gettext/Makefile
index f37c4e4e74..2eff4410db 100644
--- a/package/libs/gettext/Makefile
+++ b/package/libs/gettext/Makefile
@@ -47,11 +47,11 @@ define Host/Compile
 endef
 
 define Host/Install
-   $(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/include
-   $(INSTALL_DATA) ./src/include/libintl.h $(STAGING_DIR_HOSTPKG)/include/
+   $(INSTALL_DIR) $(1)/include
+   $(INSTALL_DATA) ./src/include/libintl.h $(1)/include/
 
-   $(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/share/aclocal
-   $(INSTALL_DATA) ./src/m4/* $(STAGING_DIR_HOSTPKG)/share/aclocal/
+   $(INSTALL_DIR) $(1)/share/aclocal
+   $(INSTALL_DATA) ./src/m4/* $(1)/share/aclocal/
 endef
 
 define Package/libintl/install
diff --git a/package/libs/libiconv/Makefile b/package/libs/libiconv/Makefile
index 4d7dcd3498..7e9baa4129 100644
--- a/package/libs/libiconv/Makefile
+++ b/package/libs/libiconv/Makefile
@@ -65,14 +65,14 @@ define Host/Compile
 endef
 
 define Host/Install
-   $(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/lib
-   $(INSTALL_DATA) $(HOST_BUILD_DIR)/libiconv.a $(STAGING_DIR_HOSTPKG)/lib/
+   $(INSTALL_DIR) $(1)/lib
+   $(INSTALL_DATA) $(HOST_BUILD_DIR)/libiconv.a $(1)/lib/
 
-   $(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/include
-   $(INSTALL_DATA) ./src/include/iconv.h $(STAGING_DIR_HOSTPKG)/include/
+   $(INSTALL_DIR) $(1)/include
+   $(INSTALL_DATA) ./src/include/iconv.h $(1)/include/
 
-   $(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/share/aclocal
-   $(INSTALL_DATA) ./src/m4/* $(STAGING_DIR_HOSTPKG)/share/aclocal/
+   $(INSTALL_DIR) $(1)/share/aclocal
+   $(INSTALL_DATA) ./src/m4/* $(1)/share/aclocal/
 endef
 
 $(eval $(call HostBuild))
diff --git a/package/system/fwtool/Makefile b/package/system/fwtool/Makefile
index 901081c1f4..86ec807281 100644
--- a/package/system/fwtool/Makefile
+++ b/package/system/fwtool/Makefile
@@ -31,6 +31,7 @@ define Host/Compile
 endef
 
 define Host/Install
+   $(INSTALL_DIR) $(1)/bin
$(INSTALL_BIN) $(HOST_BUILD_DIR)/fwtool $(1)/bin/
 endef
 
diff --git a/package/system/iucode-tool/Makefile 
b/package/system/iucode-tool/Makefile
index 5f4cfb6238..afa75f61c6 100644
--- a/package/system/iucode-tool/Makefile
+++ b/package/system/iucode-tool/Makefile
@@ -22,6 +22,8 @@ PKG_LICENSE:=GPL-2.0
 
 PKG_INSTALL:=1
 
+HOST_BUILD_PREFIX:=$(STAGING_DIR_HOST)
+
 include $(INCLUDE_DIR)/package.mk
 include $(INCLUDE_DIR)/host-build.mk
 
@@ -40,7 +42,8 @@ define Package/iucode-tool/install
 endef
 
 define Host/Install
-   $(INSTALL_BIN) $(HOST_BUILD_DIR)/iucode_tool 
$(STAGING_DIR_HOST)/bin/iucode_tool
+   $(INSTALL_DIR) $(1)/bin
+   $(INSTALL_BIN) $(HOST_BUILD_DIR)/iucode_tool $(1)/bin/iucode_tool
 endef
 
 $(eval $(call HostBuild))
diff --git a/package/system/opkg/Makefile b/package/system/opkg/Makefile
index 313a058933..2f6735895a 100644
--- a/package/system/opkg/Makefile
+++ b/package/system/opkg/Makefile
@@ -33,6 +33,7 @@ HOST_BUILD_PARALLEL:=1
 PKG_INSTALL:=1
 
 HOST_BUILD_DEPENDS:=libubox/host
+HOST_BUILD_PREFIX:=$(STAGING_DIR_HOST)
 
 include $(INCLUDE_DIR)/package.mk
 include $(INCLUDE_DIR)/host-build.mk
@@ -96,7 +97,8 @@ define Package/opkg/install
 endef
 
 define Host/Install
-   $(INSTALL_BIN) $(HOST_BUILD_DIR)/src/opkg-cl 
$(STAGING_DIR_HOST)/bin/opkg
+   $(INSTALL_DIR) $(1)/bin
+   $(INSTALL_BIN) $(HOST_BUILD_DIR)/src/opkg-cl $(1)/bin/opkg
 endef
 
 $(eval $(call BuildPackage,opkg))
diff --git a/package/utils/bsdiff/Makefile b/package/utils/bsdiff/Makefile
index db1f320872..b9e662b3ed 100644
--- a/package/utils/bsdiff/Makefile
+++ b/package/utils/bsdiff/Makefile
@@ -58,11 +58,6 @@ define Package/bspatch/install
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bspatch $(1)/usr/bin/bspatch
 endef
 
-define Host/Install
-   $(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/bin/
-   $(MAKE) -C $(HOST_BUILD_DIR) PREFIX=$(STAGING_DIR_HOSTPKG)/ install
-endef
-
 define Host/Compile
$(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS) \
-o $(HOST_BUILD_DIR)/bsdiff \
@@ -70,7 +65,8 @@ define Host/Compile
 endef
 
 define Host/Install
-   $(INSTALL_BIN) $(HOST_BUILD_DIR)/bsdiff $(STAGING_DIR_HOSTPKG)/bin/
+   $(INSTALL_DIR) $(1)/bin
+   $(INSTALL_BIN) $(HOST_BUILD_DIR)/bsdiff 

[OpenWrt-Devel] [PATCH 5/6] tools: Install files into staging directory

2019-06-14 Thread Jeffery To
This updates Host/Install for many tools to install files into the given
staging directory, instead of into $(STAGING_DIR_HOST) directly, so that
files can be automatically tracked and uninstalled.

This also removes Host/Clean (now necessary) for many tools.

Signed-off-by: Jeffery To 
---
 tools/automake/Makefile   | 21 -
 tools/b43-tools/Makefile  | 17 +
 tools/bison/Makefile  |  9 ++---
 tools/cbootimage-configs/Makefile |  8 ++--
 tools/cbootimage/Makefile |  5 -
 tools/ccache/Makefile | 12 
 tools/e2fsprogs/Makefile  | 18 +++---
 tools/elftosb/Makefile|  3 ++-
 tools/expat/Makefile  |  4 
 tools/firmware-utils/Makefile |  3 ++-
 tools/flex/Makefile   |  9 ++---
 tools/flock/Makefile  |  3 ++-
 tools/genext2fs/Makefile  |  7 ++-
 tools/gengetopt/Makefile  |  7 ++-
 tools/kernel2minor/Makefile   |  7 ++-
 tools/libelf/Makefile | 12 +++-
 tools/libtool/Makefile| 13 -
 tools/lzma-old/Makefile   |  7 ++-
 tools/lzma/Makefile   |  7 ++-
 tools/m4/Makefile |  5 -
 tools/make-ext4fs/Makefile|  7 ++-
 tools/missing-macros/Makefile |  8 
 tools/mkimage/Makefile| 10 +++---
 tools/mklibs/Makefile | 15 ++-
 tools/mm-macros/Makefile  |  9 ++---
 tools/mtd-utils/Makefile  |  7 ++-
 tools/mtools/Makefile | 10 +++---
 tools/padjffs2/Makefile   |  7 ++-
 tools/patch-image/Makefile| 10 +++---
 tools/patchelf/Makefile   |  4 ++--
 tools/pkg-config/Makefile | 11 +++
 tools/qemu/Makefile   |  4 ++--
 tools/scons/Makefile  |  7 ---
 tools/sdimage/Makefile|  7 ++-
 tools/sed/Makefile|  7 ++-
 tools/sparse/Makefile |  3 ++-
 tools/squashfs/Makefile   | 10 +++---
 tools/squashfskit4/Makefile   | 10 +++---
 tools/sstrip/Makefile |  7 ++-
 tools/wrt350nv2-builder/Makefile  | 13 -
 tools/xz/Makefile |  2 +-
 tools/zip/Makefile|  4 ++--
 tools/zlib/Makefile   | 18 +++---
 43 files changed, 119 insertions(+), 248 deletions(-)

diff --git a/tools/automake/Makefile b/tools/automake/Makefile
index c016f1d76a..e63871f6ba 100644
--- a/tools/automake/Makefile
+++ b/tools/automake/Makefile
@@ -33,19 +33,14 @@ define Host/Install
# remove old automake resources to avoid version conflicts
rm -rf $(STAGING_DIR_HOST)/share/aclocal-[0-9]*
rm -rf $(STAGING_DIR_HOST)/share/automake-[0-9]*
-   $(MAKE) -C $(HOST_BUILD_DIR) install
-   mv $(STAGING_DIR_HOST)/bin/aclocal $(STAGING_DIR_HOST)/bin/aclocal.real
-   $(INSTALL_BIN) ./files/aclocal $(STAGING_DIR_HOST)/bin
-   ln -sf aclocal $(STAGING_DIR_HOST)/bin/aclocal-1.9
-   ln -sf aclocal $(STAGING_DIR_HOST)/bin/aclocal-1.10
-   ln -sf aclocal $(STAGING_DIR_HOST)/bin/aclocal-1.11
-   ln -sf aclocal $(STAGING_DIR_HOST)/bin/aclocal-1.11.6
-   ln -sf aclocal $(STAGING_DIR_HOST)/bin/aclocal-1.15
-endef
-
-define Host/Clean
-   -$(MAKE) -C $(HOST_BUILD_DIR) uninstall
-   $(call Host/Clean/Default)
+   $(call Host/Install/Default,$(1),)
+   mv $(1)/bin/aclocal $(1)/bin/aclocal.real
+   $(INSTALL_BIN) ./files/aclocal $(1)/bin/
+   ln -sf aclocal $(1)/bin/aclocal-1.9
+   ln -sf aclocal $(1)/bin/aclocal-1.10
+   ln -sf aclocal $(1)/bin/aclocal-1.11
+   ln -sf aclocal $(1)/bin/aclocal-1.11.6
+   ln -sf aclocal $(1)/bin/aclocal-1.15
 endef
 
 $(eval $(call HostBuild))
diff --git a/tools/b43-tools/Makefile b/tools/b43-tools/Makefile
index a99b0c9e53..1ef7d8ce58 100644
--- a/tools/b43-tools/Makefile
+++ b/tools/b43-tools/Makefile
@@ -33,18 +33,11 @@ define Host/Compile
 endef
 
 define Host/Install
-   $(INSTALL_DIR) $(STAGING_DIR_HOST)/bin
-   $(INSTALL_BIN) $(HOST_BUILD_DIR)/fwcutter/b43-fwcutter 
$(STAGING_DIR_HOST)/bin/
-   $(INSTALL_BIN) $(HOST_BUILD_DIR)/assembler/b43-asm 
$(STAGING_DIR_HOST)/bin/
-   $(INSTALL_BIN) $(HOST_BUILD_DIR)/assembler/b43-asm.bin 
$(STAGING_DIR_HOST)/bin/
-   $(INSTALL_BIN) ./files/b43-fwsquash.py $(STAGING_DIR_HOST)/bin/
-endef
-
-define Host/Clean
-   rm -f $(STAGING_DIR_HOST)/bin/b43-fwcutter
-   rm -f $(STAGING_DIR_HOST)/bin/b43-asm
-   rm -f $(STAGING_DIR_HOST)/bin/b43-asm.bin
-   rm -f $(STAGING_DIR_HOST)/bin/b43-fwsquash.py
+   $(INSTALL_DIR) $(1)/bin
+   $(INSTALL_BIN) $(HOST_BUILD_DIR)/fwcutter/b43-fwcutter $(1)/bin/
+   $(INSTALL_BIN) $(HOST_BUILD_DIR)/assembler/b43-asm $(1)/bin/
+   $(INSTALL_BIN) $(HOST_BUILD_DIR)/assembler/b43-asm.bin $(1)/bin/
+   $(INSTALL_BIN) ./files/b43-fwsquash.py 

[OpenWrt-Devel] [PATCH 4/6] tools/autoconf, tools/quilt: Use default Host/Compile and Host/Install

2019-06-14 Thread Jeffery To
Since bash is used for all submake processes, it isn't necessary to
override Host/Compile and Host/Install to explicitly set SHELL=bash.

Using the default Host/Install also allows their files to be
automatically tracked and uninstalled.

Signed-off-by: Jeffery To 
---
 tools/autoconf/Makefile | 13 -
 tools/quilt/Makefile| 13 ++---
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/tools/autoconf/Makefile b/tools/autoconf/Makefile
index 6eb64d77d5..671564337f 100644
--- a/tools/autoconf/Makefile
+++ b/tools/autoconf/Makefile
@@ -21,17 +21,4 @@ HOST_CONFIGURE_ARGS += \
 HOST_CONFIGURE_VARS += \
PERL="/usr/bin/env perl"
 
-define Host/Compile
-   export SHELL="$(BASH)"; $(MAKE) -C $(HOST_BUILD_DIR)
-endef
-
-define Host/Install
-   export SHELL="$(BASH)"; $(MAKE) -C $(HOST_BUILD_DIR) install
-endef
-
-define Host/Clean
-   -export SHELL="$(BASH)"; $(MAKE) -C $(HOST_BUILD_DIR) uninstall
-   $(call Host/Clean/Default)
-endef
-
 $(eval $(call HostBuild))
diff --git a/tools/quilt/Makefile b/tools/quilt/Makefile
index d0532b5984..e8f1a7a05f 100644
--- a/tools/quilt/Makefile
+++ b/tools/quilt/Makefile
@@ -21,16 +21,7 @@ define Host/Configure
[ -f $(HOST_BUILD_DIR)/Makefile ]
 endef
 
-define Host/Compile
-   $(MAKE) -C $(HOST_BUILD_DIR) SHELL="$(BASH)" all
-endef
-
-define Host/Install
-   $(MAKE) -C $(HOST_BUILD_DIR) SHELL="$(BASH)" install
-endef
-
-define Host/Clean
-   rm -f $(STAGING_DIR_HOST)/bin/quilt
-endef
+HOST_MAKE_INSTALL_FLAGS += \
+   BUILD_ROOT="$(HOST_INSTALL_DIR)"
 
 $(eval $(call HostBuild))
-- 
2.20.1


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


[OpenWrt-Devel] [PATCH 1/6] build: Add auto file tracking / uninstall for Host/Install

2019-06-14 Thread Jeffery To
This adds automatic file tracking and uninstallation (similar to that
for Build/InstallDev) for files installed by Host/Install.

A path to a staging directory will be passed to Host/Install. If files
are placed in that staging directory, they will be tracked and installed
into $(HOST_BUILD_PREFIX) (either $(STAGING_DIR_HOST) or
$(STAGING_DIR_HOSTPKG), depend on the package/tool).

If Host/Install doesn't use the staging directory and install to
$(STAGING_DIR_HOST) / $(STAGING_DIR_HOSTPKG) directly, no error is
raised.

This also updates Host/Install/Default to handle the staging directory,
combined with setting DESTDIR in a new HOST_MAKE_INSTALL_FLAGS variable.

Host/Install/Default now also handles a second parameter, allowing a
different install target to be specified (similar to
Build/Install/Default).

Signed-off-by: Jeffery To 
---
 include/host-build.mk | 52 ++-
 1 file changed, 47 insertions(+), 5 deletions(-)

diff --git a/include/host-build.mk b/include/host-build.mk
index 827ea6bbfb..ce2fcc26eb 100644
--- a/include/host-build.mk
+++ b/include/host-build.mk
@@ -30,6 +30,20 @@ HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.built
 HOST_BUILD_PREFIX?=$(if 
$(IS_PACKAGE_BUILD),$(STAGING_DIR_HOSTPKG),$(STAGING_DIR_HOST))
 HOST_STAMP_INSTALLED:=$(HOST_BUILD_PREFIX)/stamp/.$(PKG_NAME)_installed
 
+HOST_STAGING_FILES_LIST:=$(PKG_NAME).list
+HOST_STAGING_DIR:=$(TMP_DIR)/$(if 
$(IS_PACKAGE_BUILD),hostpkg,host)-stage-$(PKG_NAME)
+
+define HostCleanStaging
+   rm -f $(HOST_STAMP_INSTALLED)
+   @-(\
+   if [ -f 
$(HOST_BUILD_PREFIX)/packages/$(HOST_STAGING_FILES_LIST) ]; then \
+   $(SCRIPT_DIR)/clean-package.sh \
+   
"$(HOST_BUILD_PREFIX)/packages/$(HOST_STAGING_FILES_LIST)" \
+   "$(HOST_BUILD_PREFIX)"; \
+   fi; \
+   )
+endef
+
 override MAKEFLAGS=
 
 include $(INCLUDE_DIR)/autotools.mk
@@ -77,6 +91,10 @@ HOST_MAKE_VARS = \
 
 HOST_MAKE_FLAGS =
 
+HOST_MAKE_INSTALL_FLAGS = \
+   $(HOST_MAKE_FLAGS) \
+   DESTDIR="$(HOST_INSTALL_DIR)"
+
 HOST_CONFIGURE_CMD = $(BASH) ./configure
 
 ifeq ($(HOST_OS),Darwin)
@@ -112,11 +130,17 @@ define Host/Compile
 endef
 
 define Host/Install/Default
-   $(call Host/Compile/Default,install)
+   +$(HOST_MAKE_VARS) \
+   $(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
+   $(HOST_MAKE_INSTALL_FLAGS) \
+   $(if $(2),$(2),install)
+   $(if $(1),
+   $(CP) $(HOST_INSTALL_DIR)/$(HOST_BUILD_PREFIX)/* $(1)/
+   )
 endef
 
 define Host/Install
-  $(call Host/Install/Default,$(HOST_BUILD_PREFIX))
+  $(call Host/Install/Default,$(1),)
 endef
 
 
@@ -169,8 +193,25 @@ ifndef DUMP
 
   $(call Host/Exports,$(HOST_STAMP_INSTALLED))
   $(HOST_STAMP_INSTALLED): $(HOST_STAMP_BUILT) $(if 
$(FORCE_HOST_INSTALL),FORCE)
-   $(call Host/Install,$(HOST_BUILD_PREFIX))
-   $(foreach hook,$(Hooks/HostInstall/Post),$(call $(hook))$(sep))
+   rm -rf $(HOST_STAGING_DIR)
+   mkdir -p $(HOST_STAGING_DIR) $(HOST_BUILD_PREFIX)/packages
+   $(call Host/Install,$(HOST_STAGING_DIR))
+   $(foreach hook,$(Hooks/HostInstall/Post),\
+   $(call $(hook),$(HOST_STAGING_DIR))$(sep)\
+   )
+   if [ -f 
$(HOST_BUILD_PREFIX)/packages/$(HOST_STAGING_FILES_LIST) ]; then \
+   $(SCRIPT_DIR)/clean-package.sh \
+   
"$(HOST_BUILD_PREFIX)/packages/$(HOST_STAGING_FILES_LIST)" \
+   "$(HOST_BUILD_PREFIX)"; \
+   fi
+   if [ -z "(find $(HOST_STAGING_DIR) -maxdepth 0 -type d 
-empty)" ]; then \
+   (cd $(HOST_STAGING_DIR); find ./ > 
$(HOST_STAGING_DIR).files); \
+   $(call locked, \
+   mv $(HOST_STAGING_DIR).files 
$(HOST_BUILD_PREFIX)/packages/$(HOST_STAGING_FILES_LIST) && \
+   $(CP) $(HOST_STAGING_DIR)/* 
$(HOST_BUILD_PREFIX)/ \
+   ,host-staging-dir); \
+   fi
+   rm -rf $(HOST_STAGING_DIR)
mkdir -p $$(shell dirname $$@)
touch $(HOST_STAMP_BUILT)
touch $$@
@@ -193,9 +234,10 @@ ifndef DUMP
rm -rf $(HOST_BUILD_DIR) $(HOST_STAMP_BUILT)
 
   host-clean: host-clean-build
+   $(HostCleanStaging)
$(call Host/Clean)
$(call Host/Uninstall)
-   rm -rf $(HOST_STAMP_INSTALLED)
+   rm -f $(HOST_BUILD_PREFIX)/packages/$(HOST_STAGING_FILES_LIST)
 
 ifneq ($(CONFIG_AUTOREMOVE),)
   host-compile:
-- 
2.20.1


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


[OpenWrt-Devel] [PATCH 2/6] build: Remove directory symbolic links when cleaning STAGING_DIR

2019-06-14 Thread Jeffery To
Currently, a symbolic link whose target is a directory will not be
removed by scripts/clean-package.sh. (In the first pass, the -f test is
false because the link target is a directory. In the second pass, the
link is not removed by rmdir.)

This updates clean-package.sh to remove all non-directories in the first
pass.

Signed-off-by: Jeffery To 
---
 scripts/clean-package.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/clean-package.sh b/scripts/clean-package.sh
index 6dd9bf7306..035725625d 100755
--- a/scripts/clean-package.sh
+++ b/scripts/clean-package.sh
@@ -12,7 +12,7 @@ cat "$1" | (
cd "$2"
while read entry; do
[ -n "$entry" ] || break
-   [ -f "$entry" ] && rm -f $entry
+   [ ! -d "$entry" ] || [ -L "$entry" ] && rm -f "$entry"
done
 )
 sort -r "$1" | (
-- 
2.20.1


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


Re: [OpenWrt-Devel] [PATCH 1/3] gemini: Make a per-board case for ethernet MAC

2019-06-14 Thread Christian Lamparter
Hello Linus,

On Tuesday, June 11, 2019 4:40:12 PM CEST Linus Walleij wrote:
> Hi Christian,
> 
> I worked in all the changes you requested until I got to this:
> 
> On Thu, May 30, 2019 at 12:46 AM Christian Lamparter  
> wrote:
> 
> > > + ifconfig eth0 hw ether $MAC1 2>/dev/null
> >
> > I guess while we are at it, why not change it to
> > "ip link set dev eth0 address $MAC1"
> 
> Testing this:
> 
> ip link set eth0 address 00:50:c2:11:11:11
> ip: socket(AF_PACKET,2,0): Address family not supported by protocol
> 
> Any hints? According to the help it should work ...
Yeah, now that I'm home (I'm away pretty much "away" during the workdays
of the week) I did take a quick look.

target/linux/gemini/config-4.14 and target/linux/gemini/config-4.19
both have
# CONFIG_PACKET is not set

I think these should be removed (so CONFIG_PACKET is enabled because
target/linux/generic/config-4.1X sets it to =y)? Because otherwise
other helpful tools like tcpdump won't work either.

I put together a patchset in my staging tree starting from 

https://git.openwrt.org/?p=openwrt/staging/chunkeey.git;a=commit;h=620462e09afc40602110b82caeb2858903709567
https://git.openwrt.org/?p=openwrt/staging/chunkeey.git;a=commit;h=bbde89504fb6124da5a3f0014025753db4d6ec67
https://git.openwrt.org/?p=openwrt/staging/chunkeey.git;a=commit;h=6096e5208373822d123b8fe4f848b8612f3d04c8
https://git.openwrt.org/?p=openwrt/staging/chunkeey.git;a=commit;h=1d8ddcfc7a00701ab73d7dd06cf5fa420c1a5882
https://git.openwrt.org/?p=openwrt/staging/chunkeey.git;a=commit;h=b106a522001e970378c38279fe598acbc867d0f4

Let me know if this works now with the ip tool.

Regards,
Christian



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


[OpenWrt-Devel] [PATCH] ubus: Support static builds

2019-06-14 Thread Alban Bedel
Extend the cmake config to build and install static libraries
when -DBUILD_STATIC=ON is used.

Signed-off-by: Alban Bedel 
---
 CMakeLists.txt | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 471b38e..f8ef4aa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,8 +14,8 @@ ADD_DEFINITIONS( -DUBUS_UNIX_SOCKET="${UBUS_UNIX_SOCKET}")
 ADD_DEFINITIONS( -DUBUS_MAX_MSGLEN=${UBUS_MAX_MSGLEN})
 
 IF(BUILD_STATIC)
-  FIND_LIBRARY(ubox_library NAMES ubox.a)
-  FIND_LIBRARY(blob_library NAMES blobmsg_json.a)
+  FIND_LIBRARY(ubox_library NAMES libubox.a)
+  FIND_LIBRARY(blob_library NAMES libblobmsg_json.a)
 ELSE(BUILD_STATIC)
   FIND_LIBRARY(ubox_library NAMES ubox)
   FIND_LIBRARY(blob_library NAMES blobmsg_json)
@@ -24,7 +24,13 @@ ENDIF(BUILD_STATIC)
 FIND_PATH(ubox_include_dir libubox/usock.h)
 INCLUDE_DIRECTORIES(${ubox_include_dir})
 
-ADD_LIBRARY(ubus SHARED libubus.c libubus-io.c libubus-obj.c libubus-sub.c 
libubus-req.c libubus-acl.c)
+SET(LIB_SOURCES libubus.c libubus-io.c libubus-obj.c libubus-sub.c 
libubus-req.c libubus-acl.c)
+
+IF(BUILD_STATIC)
+  ADD_LIBRARY(ubus STATIC ${LIB_SOURCES})
+ELSE(BUILD_STATIC)
+  ADD_LIBRARY(ubus SHARED ${LIB_SOURCES})
+ENDIF(BUILD_STATIC)
 TARGET_LINK_LIBRARIES(ubus ${ubox_library})
 
 find_library(json NAMES json-c json)
@@ -40,6 +46,7 @@ ADD_SUBDIRECTORY(lua)
 ADD_SUBDIRECTORY(examples)
 
 INSTALL(TARGETS ubus cli
+   ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
 )
-- 
2.20.1


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


[OpenWrt-Devel] [PATCH 2/3] network/config/xfrm: add host-dependency for xfrm interface parent

2019-06-14 Thread André Valentin
Add proto_add_host_dependency to add a dependency to the tunlink interface

Signed-off-by: André Valentin 
---
 package/network/config/xfrm/files/xfrm.sh | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/package/network/config/xfrm/files/xfrm.sh 
b/package/network/config/xfrm/files/xfrm.sh
index df28d38613..4711bf2f55 100755
--- a/package/network/config/xfrm/files/xfrm.sh
+++ b/package/network/config/xfrm/files/xfrm.sh
@@ -14,24 +14,27 @@ proto_xfrm_setup() {
local tunlink ifid mtu zone
json_get_vars tunlink ifid mtu zone
 
-   proto_init_update "$cfg" 1
-
-   proto_add_tunnel
-   json_add_string mode "$mode"
-   json_add_int mtu "${mtu:-1280}"
-
[ -z "$tunlink" ] && {
proto_notify_error "$cfg" NO_TUNLINK
proto_block_restart "$cfg"
exit
}
-   json_add_string link "$tunlink"
-
[ -z "$ifid" ] && {
proto_notify_error "$cfg" NO_IFID
proto_block_restart "$cfg"
exit
}
+
+   ( proto_add_host_dependency "$cfg" '' "$tunlink" )
+
+   proto_init_update "$cfg" 1
+
+   proto_add_tunnel
+   json_add_string mode "$mode"
+   json_add_int mtu "${mtu:-1280}"
+
+   json_add_string link "$tunlink"
+
json_add_object 'data'
[ -n "$ifid" ] && json_add_int ifid "$ifid"
json_close_object
-- 
2.11.0


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


[OpenWrt-Devel] [PATCH 2/3] netsupport: improve xfrm module support

2019-06-14 Thread André Valentin
-switch to module autoprobe
-exclude 4.9 kernel

Signed-off-by: André Valentin 
---
 package/kernel/linux/modules/netsupport.mk | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/package/kernel/linux/modules/netsupport.mk 
b/package/kernel/linux/modules/netsupport.mk
index 20616d9af6..9732ee0d73 100644
--- a/package/kernel/linux/modules/netsupport.mk
+++ b/package/kernel/linux/modules/netsupport.mk
@@ -386,10 +386,10 @@ $(eval $(call KernelPackage,ip6-vti))
 define KernelPackage/xfrm-interface
   SUBMENU:=$(NETWORK_SUPPORT_MENU)
   TITLE:=IPsec XFRM Interface
-  DEPENDS:=+kmod-ipsec4 +kmod-ipsec6 @!LINUX_4_14
+  DEPENDS:=+kmod-ipsec4 +kmod-ipsec6 @!LINUX_4_14 @!LINUX_4_9
   KCONFIG:=CONFIG_XFRM_INTERFACE
   FILES:=$(LINUX_DIR)/net/xfrm/xfrm_interface.ko
-  AUTOLOAD:=$(call AutoLoad,33,xfrm_interface)
+  AUTOLOAD:=$(call AutoProbe,xfrm_interface)
 endef
 
 define KernelPackage/xfrm-interface/description
-- 
2.11.0


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


[OpenWrt-Devel] [PATCH 1/3] netifd: fix xfrm interface deletion and standardize netlink call

2019-06-14 Thread André Valentin
-xfrm interfaces were deleted before
-use standard parameters for xfrm interface created

Signed-off-by: André Valentin 
---
 system-linux.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/system-linux.c b/system-linux.c
index 6e5ca28..f63aeb2 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -2883,7 +2883,7 @@ static int system_add_xfrm_tunnel(const char *name, const 
char *kind,
struct blob_attr *cur;
int ret = 0;
 
-   nlm = nlmsg_alloc_simple(RTM_NEWLINK, NLM_F_REQUEST | NLM_F_ACK | 
NLM_F_CREATE | NLM_F_EXCL);
+   nlm = nlmsg_alloc_simple(RTM_NEWLINK, NLM_F_REQUEST | NLM_F_REPLACE | 
NLM_F_CREATE);
if (!nlm)
return -1;
 
@@ -3216,7 +3216,8 @@ static int __system_del_ip_tunnel(const char *name, 
struct blob_attr **tb)
if (!strcmp(str, "greip") || !strcmp(str, "gretapip") ||
!strcmp(str, "greip6") || !strcmp(str, "gretapip6") ||
!strcmp(str, "vtiip") || !strcmp(str, "vtiip6") ||
-   !strcmp(str, "vxlan") || !strcmp(str, "vxlan6"))
+   !strcmp(str, "vxlan") || !strcmp(str, "vxlan6") ||
+   !strcmp(str, "xfrm"))
return system_link_del(name);
else
return tunnel_ioctl(name, SIOCDELTUNNEL, NULL);
-- 
2.11.0


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


[OpenWrt-Devel] [PATCH 0/3] xfrm: fix xfrm interface deletion and improve module loading

2019-06-14 Thread André Valentin
This fixes the following problems:
-xfrm interfaces could not be deleted before
-add proto_host_dependency
-add Kernel 4.9 exclude
-enable module autoprobing

Thanks to Hans and Hauke for helping me.

André Valentin (1):
  netifd: fix xfrm interface deletion and standardize netlink call

 system-linux.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

-- 
2.11.0


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