[OpenWrt-Devel] Bug on procps-ng-skill OpenWrt 19.07.2

2020-04-19 Thread Marcelo Pacheco
In module procps-ng-3.3.15, source skill.c, function check_proc
char buf[128];

This buffer is too small to read /proc//stat
The code requires the whole file to be read:
 len = read(fd, buf, sizeof(buf));
if (len <= 0 || (size_t)len >= sizeof(buf))
goto closure;

Fix I used is to increase to 256 bytes.
Worked for me.
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Can build x86_64 because of ntf_reject_ipv4.ko missing

2020-04-19 Thread Philip Prindeville
Sigh.

*Can’t* build.



> On Apr 19, 2020, at 9:47 PM, Philip Prindeville 
>  wrote:
> 
> Hi all,
> 
> I just rebased to openwrt master today, and tried to rebuild from scratch but 
> I’m getting:
> 
> make[3]: Entering directory '/home/philipp/lede/package/kernel/linux'
> mkdir -p /home/philipp/lede/staging_dir/target-x86_64_musl/root-x86/stamp
> 
> SHELL= flock /home/philipp/lede/tmp/.root-copy.flock -c 'cp -fpR 
> /home/philipp/lede/build_dir/target-x86_64_musl/linux-x86_64/packages/.pkgdir/kernel/.
>  /home/philipp/lede/staging_dir/target-x86_64_musl/root-x86/'
> touch 
> /home/philipp/lede/staging_dir/target-x86_64_musl/root-x86/stamp/.kernel_installed
> ERROR: module 
> '/home/philipp/lede/build_dir/target-x86_64_musl/linux-x86_64/linux-5.4.33/net/ipv4/netfilter/nft_reject_ipv4.ko'
>  is missing.
> modules/netfilter.mk:1068: recipe for target 
> '/home/philipp/lede/bin/targets/x86/64/packages/kmod-nft-core_5.4.33-1_x86_64.ipk'
>  failed
> make[3]: *** 
> [/home/philipp/lede/bin/targets/x86/64/packages/kmod-nft-core_5.4.33-1_x86_64.ipk]
>  Error 1
> make[3]: Leaving directory '/home/philipp/lede/package/kernel/linux'
> time: package/kernel/linux/compile#4.29#0.18#4.76
> package/Makefile:111: recipe for target 'package/kernel/linux/compile' failed
> make[2]: *** [package/kernel/linux/compile] Error 2
> make[2]: Leaving directory '/home/philipp/lede'
> package/Makefile:107: recipe for target 
> '/home/philipp/lede/staging_dir/target-x86_64_musl/stamp/.package_compile' 
> failed
> make[1]: *** 
> [/home/philipp/lede/staging_dir/target-x86_64_musl/stamp/.package_compile] 
> Error 2
> make[1]: Leaving directory '/home/philipp/lede'
> /home/philipp/lede/include/toplevel.mk:218: recipe for target 'world’ failed
> 
> 
> which frankly I don’t understand.  Shouldn’t all of the dependencies for the 
> kmod-* take care of itself?
> 
> I have:
> 
> philipp@ubuntu16:~/lede$ grep -i reject .config
> CONFIG_PACKAGE_kmod-nf-reject=y
> CONFIG_PACKAGE_kmod-nf-reject6=y
> philipp@ubuntu16:~/lede$ 
> 
> but I don’t know if something else is needed for kmod-nft-reject or what.
> 
> Looking in package/kernel/linux/modules/netfilter.mk I don’t see anything 
> obvious.  Of course, I’m not sure I understand the difference between 
> nf-reject* and nft-reject* after staring at this for so long.
> 
> I’m excited about being able to build 5.4 (eventually), but need to get past 
> this blocker.
> 
> My production router is also where I test upstream my proposed contributions 
> for Tacacs+, xtables-addons, etc.
> 
> Any assistance appreciated.
> 
> Thanks,
> 
> -Philip

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


[OpenWrt-Devel] Can build x86_64 because of ntf_reject_ipv4.ko missing

2020-04-19 Thread Philip Prindeville
Hi all,

I just rebased to openwrt master today, and tried to rebuild from scratch but 
I’m getting:

make[3]: Entering directory '/home/philipp/lede/package/kernel/linux'
mkdir -p /home/philipp/lede/staging_dir/target-x86_64_musl/root-x86/stamp

SHELL= flock /home/philipp/lede/tmp/.root-copy.flock -c 'cp -fpR 
/home/philipp/lede/build_dir/target-x86_64_musl/linux-x86_64/packages/.pkgdir/kernel/.
 /home/philipp/lede/staging_dir/target-x86_64_musl/root-x86/'
touch 
/home/philipp/lede/staging_dir/target-x86_64_musl/root-x86/stamp/.kernel_installed
ERROR: module 
'/home/philipp/lede/build_dir/target-x86_64_musl/linux-x86_64/linux-5.4.33/net/ipv4/netfilter/nft_reject_ipv4.ko'
 is missing.
modules/netfilter.mk:1068: recipe for target 
'/home/philipp/lede/bin/targets/x86/64/packages/kmod-nft-core_5.4.33-1_x86_64.ipk'
 failed
make[3]: *** 
[/home/philipp/lede/bin/targets/x86/64/packages/kmod-nft-core_5.4.33-1_x86_64.ipk]
 Error 1
make[3]: Leaving directory '/home/philipp/lede/package/kernel/linux'
time: package/kernel/linux/compile#4.29#0.18#4.76
package/Makefile:111: recipe for target 'package/kernel/linux/compile' failed
make[2]: *** [package/kernel/linux/compile] Error 2
make[2]: Leaving directory '/home/philipp/lede'
package/Makefile:107: recipe for target 
'/home/philipp/lede/staging_dir/target-x86_64_musl/stamp/.package_compile' 
failed
make[1]: *** 
[/home/philipp/lede/staging_dir/target-x86_64_musl/stamp/.package_compile] 
Error 2
make[1]: Leaving directory '/home/philipp/lede'
/home/philipp/lede/include/toplevel.mk:218: recipe for target 'world’ failed


which frankly I don’t understand.  Shouldn’t all of the dependencies for the 
kmod-* take care of itself?

I have:

philipp@ubuntu16:~/lede$ grep -i reject .config
CONFIG_PACKAGE_kmod-nf-reject=y
CONFIG_PACKAGE_kmod-nf-reject6=y
philipp@ubuntu16:~/lede$ 

but I don’t know if something else is needed for kmod-nft-reject or what.

Looking in package/kernel/linux/modules/netfilter.mk I don’t see anything 
obvious.  Of course, I’m not sure I understand the difference between 
nf-reject* and nft-reject* after staring at this for so long.

I’m excited about being able to build 5.4 (eventually), but need to get past 
this blocker.

My production router is also where I test upstream my proposed contributions 
for Tacacs+, xtables-addons, etc.

Any assistance appreciated.

Thanks,

-Philip


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


[OpenWrt-Devel] ubus acls for params or hotplugd ?

2020-04-19 Thread Etienne Champetier
Hi all,

Most OpenWrt daemon are still running as root today.
If we take the case of ntpd, to do its job it just need CAP_SYS_TIME
and to be able to deliver a hotplug event.
Right now hotplug-call is a simple shell loop executing all the
scripts in /etc/hotplug.d/$1/, so ntpd need to run as root.

I would like to have this hotplug call go over ubus, and I see 2 ways:
1) either extend ubus acl to validate params, then have a generic exec
functionality to basically have a sudo via ubus (really flexible but
not super clean)
2) or have a small hotplugd that publish one path per type (ie have
'hotplug.ntp' with an 'event' method)

Similarly to ntpd, udhcpc and odhcp6c don't require much capabilities
(at most CAP_NET_RAW, CAP_NET_BIND_SERVICE) if we send the dhcp events
as hotplug events over ubus.

As some of you might already have ideas on this topic, I'm sending
this email to get feedback how you would see this implemented (1, 2 or
...)

Thanks
Etienne

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


[OpenWrt-Devel] [PATCH v3 3/3] build: have config-clean deal with old temp files

2020-04-19 Thread Eneas U de Queiroz
This is a temporary commit to have 'make config-clean' remove
temporary files from the previous scripts/config version.

The .gitignore file is updated to deal with the old files as well.

Cc: Kevin Darbyshire-Bryant 
Signed-off-by: Eneas U de Queiroz 

diff --git a/scripts/config/.gitignore b/scripts/config/.gitignore
index b5bf92f66d..737c5b7953 100644
--- a/scripts/config/.gitignore
+++ b/scripts/config/.gitignore
@@ -12,3 +12,10 @@ mconf
 nconf
 qconf
 gconf
+
+#
+# temporary files from older version.  Should be removed
+#
+zconf.???.c
+zconf.hash.c
+.tmp_qtcheck
diff --git a/scripts/config/Makefile b/scripts/config/Makefile
index eb55b759a8..d98f15c393 100644
--- a/scripts/config/Makefile
+++ b/scripts/config/Makefile
@@ -7,7 +7,10 @@ all: conf mconf
 clean:
rm -f *.o lxdialog/*.o *.moc $(clean-files) conf mconf qconf
 
-clean-files:=
+# This clean-files definition is here to ensure that temporary files from the
+# previous version are removed by make config-clean.
+# It should be removed or emptied when this Makefile get updated again.
+clean-files:= zconf.tab.c zconf.lex.c zconf.hash.c .tmp_qtcheck
 
 # ===
 # Variables needed by the upstream Makefile

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


[OpenWrt-Devel] [PATCH v3 2/3] build: add option to treat recursive deps as error

2020-04-19 Thread Eneas U de Queiroz
Running make with RECURSIVE_DEP_IS_ERROR=1 will cause a hard failure
when a recursive dependency is detected.  This is useful to apply
stricter Ci tests, for example.

Signed-off-by: Eneas U de Queiroz 

diff --git a/include/toplevel.mk b/include/toplevel.mk
index ad8e5b8f20..5cf93ce7ef 100644
--- a/include/toplevel.mk
+++ b/include/toplevel.mk
@@ -99,6 +99,9 @@ prepare-tmpinfo: FORCE
$(_SINGLE)$(NO_TRACE_MAKE) menuconfig $(PREP_MK); \
fi
 
+ifeq ($(RECURSIVE_DEP_IS_ERROR),1)
+  KCONF_FLAGS=--fatalrecursive
+endif
 ifneq ($(DISTRO_PKG_CONFIG),)
 scripts/config/%onf: export PATH:=$(dir $(DISTRO_PKG_CONFIG)):$(PATH)
 endif
@@ -111,7 +114,7 @@ $(eval $(call rdep,scripts/config,scripts/config/mconf))
 
 config: scripts/config/conf prepare-tmpinfo FORCE
[ -L .config ] && export KCONFIG_OVERWRITECONFIG=1; \
-   $< Config.in
+   $< $(KCONF_FLAGS) Config.in
 
 config-clean: FORCE
$(_SINGLE)$(NO_TRACE_MAKE) -C scripts/config clean
@@ -120,7 +123,7 @@ defconfig: scripts/config/conf prepare-tmpinfo FORCE
touch .config
@if [ ! -s .config -a -e $(HOME)/.openwrt/defconfig ]; then cp 
$(HOME)/.openwrt/defconfig .config; fi
[ -L .config ] && export KCONFIG_OVERWRITECONFIG=1; \
-   $< --defconfig=.config Config.in
+   $< $(KCONF_FLAGS) --defconfig=.config Config.in
 
 confdefault-y=allyes
 confdefault-m=allmod
@@ -129,7 +132,7 @@ confdefault:=$(confdefault-$(CONFDEFAULT))
 
 oldconfig: scripts/config/conf prepare-tmpinfo FORCE
[ -L .config ] && export KCONFIG_OVERWRITECONFIG=1; \
-   $< --$(if $(confdefault),$(confdefault),old)config Config.in
+   $< $(KCONF_FLAGS) --$(if 
$(confdefault),$(confdefault),old)config Config.in
 
 menuconfig: scripts/config/mconf prepare-tmpinfo FORCE
if [ \! -e .config -a -e $(HOME)/.openwrt/defconfig ]; then \
@@ -210,7 +213,7 @@ ifeq ($(SDK),1)
 
 %::
@+$(PREP_MK) $(NO_TRACE_MAKE) -r -s prereq
-   @./scripts/config/conf --defconfig=.config Config.in
+   @./scripts/config/conf $(KCONF_FLAGS) --defconfig=.config Config.in
@+$(ULIMIT_FIX) $(SUBMAKE) -r $@
 
 else
@@ -219,7 +222,7 @@ else
@+$(PREP_MK) $(NO_TRACE_MAKE) -r -s prereq
@( \
cp .config tmp/.config; \
-   ./scripts/config/conf --defconfig=tmp/.config -w tmp/.config 
Config.in > /dev/null 2>&1; \
+   ./scripts/config/conf $(KCONF_FLAGS) --defconfig=tmp/.config -w 
tmp/.config Config.in > /dev/null 2>&1; \
if ./scripts/kconfig.pl '>' .config tmp/.config | grep -q 
CONFIG; then \
printf "$(_R)WARNING: your configuration is out of 
sync. Please run make menuconfig, oldconfig or defconfig!$(_N)\n" >&2; \
fi \

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


[OpenWrt-Devel] [PATCH v3 0/3] build: update scripts/config to kconfig-v5.6

2020-04-19 Thread Eneas U de Queiroz
After breaking the build bots for a couple of days, this is another
attempt to update scripts/config to linux kconfig-v5.6.  This time I've
spent some time testing it with the SDK, which is heavily dependent on
recursive dependencies.

While testing it, I found some minor bugs, which I've sent separate
patches to fix.  I've kept them out of this series, as they are
independent anyway.

I've changed the default behavior to treat them as warnings, not errors.
Instead of a compile-time choice, I've added a command-line option to
scripts/config/conf, --fatalrecursive, to error out when detecing a
recursive dependency.  The option is activated in openwrt by running
make with RECURSIVE_DEP_IS_ERROR=1.

Another change from v2 was that the commit handling the selection of a
module from a bool, 9bfa6971ae ("scripts/config: properly handle select
on symbols with unmet direct dependencies"), which was not done right in
v2, was properly fixed here.

The commits to get from upstream kconfig-v5.6 to the openwrt version
here can be seen at
https://github.com/cotequeiroz/linux/commits/openwrt/scripts/kconfig

The last commit of this series is optional.  Previously, ldir had
included leftover temporary files from previous version to .gitignore,
so git would not complain about untracked files.  I took that one step
further and added them to make config-clean.  I do intend this to be
temporary, to be reverted before the next branch, and  added comments
to the affected lines as a reminder.

I don't have the resources to do a full buildbot setup, but I've used
jow's suggested simpler way of testing it with the SDK.  I've compared
the output of the failed run with the v2 of this patch applied, from the
bots and with the SDK, and the errors do appear to be the same.

I've tested this with a self-compiled SKD for ath79, and compared the
resulting .config files against master at 508462a399.  I've also used
several config.buildinfo from snapshots of different targets on full 
build root.  I used this to compare the generated .config files:
  diff -I '^\(# end of.*\)\?$' openwrt.{old,new}/.config
The new version adds '# end of ' comments, which are being
ignored.

While working with the SDK, I've applied a previously submitted patch
("sdk: add OpenWrt branding to menuconfig & .config")
https://patchwork.ozlabs.org/project/openwrt/patch/20200418214931.24983-1-cotequei...@gmail.com/
so that the titles of the .config files would match.

I also tested the behavior of menuconfig when selecting multiple
targets, to ensure the selection of a module from a bool was working as
intended.

Eneas U de Queiroz (3):
  build: scripts/config - update to kconfig-v5.6
  build: add option to treat recursive deps as error
  build: have config-clean deal with old temp files

 include/toplevel.mk   |   13 +-
 scripts/config/.gitignore |   34 +-
 scripts/config/Makefile   |  177 +-
 scripts/config/README |   29 +-
 scripts/config/conf.c |  255 +-
 scripts/config/confdata.c |  533 +-
 scripts/config/expr.c |  216 +-
 scripts/config/expr.h |  110 +-
 scripts/config/images.c   |   34 +-
 scripts/config/images.h   |   33 +
 scripts/config/{zconf.l => lexer.l}   |  340 +-
 scripts/config/lexer.lex.c| 4499 +
 scripts/config/list.h |1 +
 scripts/config/lkc.h  |   59 +-
 scripts/config/lkc_proto.h|   21 +-
 scripts/config/lxdialog/.gitignore|2 -
 scripts/config/lxdialog/check-lxdialog.sh |   91 -
 scripts/config/lxdialog/checklist.c   |   19 +-
 scripts/config/lxdialog/dialog.h  |   23 +-
 scripts/config/lxdialog/inputbox.c|   22 +-
 scripts/config/lxdialog/menubox.c |   25 +-
 scripts/config/lxdialog/textbox.c |   17 +-
 scripts/config/lxdialog/util.c|   15 +-
 scripts/config/lxdialog/yesno.c   |   19 +-
 scripts/config/mconf-cfg.sh   |   50 +
 scripts/config/mconf.c|  179 +-
 scripts/config/menu.c |  451 +-
 .../{zconf.tab.c_shipped => parser.tab.c} |  939 ++--
 scripts/config/parser.tab.h   |  129 +
 scripts/config/{zconf.y => parser.y}  |  429 +-
 scripts/config/preprocess.c   |  575 +++
 scripts/config/qconf-cfg.sh   |   32 +
 scripts/config/qconf.cc   |  174 +-
 scripts/config/qconf.h|3 +-
 scripts/config/symbol.c   |  272 +-
 scripts/config/util.c |   86 +-
 scripts/config/zconf.gperf|   49 -
 scripts/config/zconf.hash.c_shipped   |  250 -
 scripts/config/zconf.lex.c_shipped   

[OpenWrt-Devel] [PATCH] uboot-mxs: bump to v2020.04

2020-04-19 Thread Michael Heimpold
Also update the U-Boot BSP patch for I2SE Duckbill devices.

Signed-off-by: Michael Heimpold 
---
 package/boot/uboot-mxs/Makefile   |  4 +-
 .../patches/001-add-i2se-duckbill.patch   | 66 ++-
 2 files changed, 36 insertions(+), 34 deletions(-)

diff --git a/package/boot/uboot-mxs/Makefile b/package/boot/uboot-mxs/Makefile
index 3112d673d4..2a202dca8f 100644
--- a/package/boot/uboot-mxs/Makefile
+++ b/package/boot/uboot-mxs/Makefile
@@ -8,10 +8,10 @@
 include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/kernel.mk
 
-PKG_VERSION:=2020.01
+PKG_VERSION:=2020.04
 PKG_RELEASE:=1
 
-PKG_HASH:=aa453c603208b1b27bd03525775a7f79b443adec577fdc6e8f06974025a135f1
+PKG_HASH:=fe732aaf037d9cc3c0909bad8362af366ae964bbdac6913a34081ff4ad565372
 
 include $(INCLUDE_DIR)/u-boot.mk
 include $(INCLUDE_DIR)/package.mk
diff --git a/package/boot/uboot-mxs/patches/001-add-i2se-duckbill.patch 
b/package/boot/uboot-mxs/patches/001-add-i2se-duckbill.patch
index 033c843202..50702cb3cb 100644
--- a/package/boot/uboot-mxs/patches/001-add-i2se-duckbill.patch
+++ b/package/boot/uboot-mxs/patches/001-add-i2se-duckbill.patch
@@ -1,6 +1,6 @@
-From b66c70cd15fa02297b94d928970932ef62c2ff02 Mon Sep 17 00:00:00 2001
+From 83ee930c18b068c9a16b66c01aaa5d6e06570152 Mon Sep 17 00:00:00 2001
 From: Michael Heimpold 
-Date: Sun, 3 Nov 2019 00:50:21 +0100
+Date: Sun, 19 Apr 2020 02:46:46 +0200
 Subject: [PATCH] arm: mxs: add support for I2SE's Duckbill boards
 
 The Duckbill devices are small, pen-drive sized boards based on
@@ -28,13 +28,13 @@ Signed-off-by: Stefan Wahren 
 ---
  arch/arm/mach-imx/mxs/Kconfig   |   5 +
  board/i2se/duckbill/Kconfig |  15 +++
- board/i2se/duckbill/MAINTAINERS |   6 ++
+ board/i2se/duckbill/MAINTAINERS |   6 +
  board/i2se/duckbill/Makefile|  10 ++
- board/i2se/duckbill/duckbill.c  | 186 
- board/i2se/duckbill/iomux.c | 156 +++
- configs/duckbill_defconfig  |  41 +++
- include/configs/duckbill.h  | 176 ++
- 8 files changed, 595 insertions(+)
+ board/i2se/duckbill/duckbill.c  | 189 
+ board/i2se/duckbill/iomux.c | 157 ++
+ configs/duckbill_defconfig  |  43 
+ include/configs/duckbill.h  | 172 +
+ 8 files changed, 597 insertions(+)
  create mode 100644 board/i2se/duckbill/Kconfig
  create mode 100644 board/i2se/duckbill/MAINTAINERS
  create mode 100644 board/i2se/duckbill/Makefile
@@ -44,7 +44,7 @@ Signed-off-by: Stefan Wahren 
  create mode 100644 include/configs/duckbill.h
 
 diff --git a/arch/arm/mach-imx/mxs/Kconfig b/arch/arm/mach-imx/mxs/Kconfig
-index 68072d5a1f..82aaa3ef76 100644
+index b90d7b6e41..e7d8bc6792 100644
 --- a/arch/arm/mach-imx/mxs/Kconfig
 +++ b/arch/arm/mach-imx/mxs/Kconfig
 @@ -50,6 +50,10 @@ config TARGET_APX4DEVKIT
@@ -58,14 +58,14 @@ index 68072d5a1f..82aaa3ef76 100644
  config TARGET_MX28EVK
bool "Support mx28evk"
select BOARD_EARLY_INIT_F
-@@ -67,6 +71,7 @@ config SYS_SOC
+@@ -70,6 +74,7 @@ config SYS_SOC
  
  source "board/bluegiga/apx4devkit/Kconfig"
  source "board/freescale/mx28evk/Kconfig"
 +source "board/i2se/duckbill/Kconfig"
+ source "board/liebherr/xea/Kconfig"
  source "board/ppcag/bg0900/Kconfig"
  source "board/schulercontrol/sc_sps_1/Kconfig"
- source "board/technologic/ts4600/Kconfig"
 diff --git a/board/i2se/duckbill/Kconfig b/board/i2se/duckbill/Kconfig
 new file mode 100644
 index 00..98c1e4689f
@@ -101,13 +101,13 @@ index 00..5496baa330
 +F:configs/duckbill_defconfig
 diff --git a/board/i2se/duckbill/Makefile b/board/i2se/duckbill/Makefile
 new file mode 100644
-index 00..0079eb413c
+index 00..11bac98e4c
 --- /dev/null
 +++ b/board/i2se/duckbill/Makefile
 @@ -0,0 +1,10 @@
 +# SPDX-License-Identifier: GPL-2.0+
 +#
-+# (C) Copyright 2014-2019
++# (C) Copyright 2014-2020
 +# Michael Heimpold, m...@heimpold.de.
 +
 +ifndefCONFIG_SPL_BUILD
@@ -117,15 +117,15 @@ index 00..0079eb413c
 +endif
 diff --git a/board/i2se/duckbill/duckbill.c b/board/i2se/duckbill/duckbill.c
 new file mode 100644
-index 00..f93c372611
+index 00..93defc6c28
 --- /dev/null
 +++ b/board/i2se/duckbill/duckbill.c
-@@ -0,0 +1,186 @@
+@@ -0,0 +1,189 @@
 +// SPDX-License-Identifier: GPL-2.0+
 +/*
 + * I2SE Duckbill board
 + *
-+ * (C) Copyright 2014-2019 Michael Heimpold 
++ * Copyright (C) 2014-2020 Michael Heimpold 
 + */
 +
 +#include 
@@ -177,14 +177,14 @@ index 00..f93c372611
 +  return 0;
 +}
 +
-+#ifdefCONFIG_CMD_MMC
++#ifdef CONFIG_CMD_MMC
 +int board_mmc_init(bd_t *bis)
 +{
 +  return mxsmmc_initialize(bis, 0, NULL, NULL);
 +}
 +#endif
 +
-+#ifdefCONFIG_CMD_NET
++#ifdef CONFIG_CMD_NET
 +int board_eth_init(bd_t *bis)
 +{
 +  unsigned int reset_gpio;
@@ -198,6 +198,7 @@ index 00..f93c372611
 +  reset_gpio = 

[OpenWrt-Devel] [sdwalker/sdwalker.github.io] 3edb67: This week's update

2020-04-19 Thread Stephen Walker
  Branch: refs/heads/master
  Home:   https://github.com/sdwalker/sdwalker.github.io
  Commit: 3edb673752adbb80a61fe89ace18be87be99c4b4
  
https://github.com/sdwalker/sdwalker.github.io/commit/3edb673752adbb80a61fe89ace18be87be99c4b4
  Author: Stephen Walker 
  Date:   2020-04-19 (Sun, 19 Apr 2020)

  Changed paths:
M uscan/index-18.06.html
M uscan/index-19.07.html
M uscan/index.html

  Log Message:
  ---
  This week's update



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


[OpenWrt-Devel] [PATCH] ramips: mt7621: use lzma-loader for D-Link DIR-860L B1

2020-04-19 Thread Szabolcs Hubai
This device has trouble extracting big kernel from flash,
and supports LZMA compressed kernels only.

Using OpenWrt kernel loader saves us 64 KB compared to the dictionary
size limiting workaround.

Factory image sizes (commit: 5f126c541a74) with "CONFIG_ALL_KMODS=y":
- original ("-d23", default): 4784188 bytes, LZMA ERROR 1
- with "-d19": 4915260, LZMA ERROR 1
- with "-d18": 4915260, diff to original: +128 KB
- with "-d17": 4980796, diff to original: +192 KB
- with this patch: 4849724, diff to original: +64 KB

To save some CPU cycle, use minimal compression ("-a0") for the LZMA
compressed uImage.

The most robust solution would use a different loader,
which reads the compressed kernel directly from the flash.
See the thread at [0] for more details!

[0] http://lists.infradead.org/pipermail/openwrt-devel/2020-April/022926.html

Signed-off-by: Szabolcs Hubai 
---
 target/linux/ramips/image/mt7621.mk | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/target/linux/ramips/image/mt7621.mk 
b/target/linux/ramips/image/mt7621.mk
index aa6836d50a..e954f730da 100644
--- a/target/linux/ramips/image/mt7621.mk
+++ b/target/linux/ramips/image/mt7621.mk
@@ -218,7 +218,9 @@ define Device/dlink_dir-860l-b1
   $(Device/seama)
   BLOCKSIZE := 64k
   SEAMA_SIGNATURE := wrgac13_dlink.2013gui_dir860lb
-  KERNEL := kernel-bin | append-dtb | relocate-kernel | lzma | uImage lzma
+  LOADER_TYPE := bin
+  KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | \
+  relocate-kernel | lzma -a0 | uImage lzma
   IMAGE_SIZE := 16064k
   DEVICE_VENDOR := D-Link
   DEVICE_MODEL := DIR-860L
-- 
2.17.1


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


[OpenWrt-Devel] [PATCH v3] ramips: mt7621: use lzma-loader for D-Link DIR-860L B1

2020-04-19 Thread Szabolcs Hubai



Hello,

This is my third attempt to revive the snapshot images for D-Link DIR-860L B1.

In this version, only the dlink_dir-860l-b1 recipe is modified.


--
Regards,
Szabolcs


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


Re: [OpenWrt-Devel] [PATCH 2/2] ramips: mt7621: use lzma-loader for D-Link DIR-860L

2020-04-19 Thread Szabolcs Hubai
Hello!

Chuanhong Guo  ezt írta (időpont: 2020. ápr. 19.,
V, 17:42):
>
> Hi!
>
> On Sun, Apr 19, 2020 at 8:38 AM Szabolcs Hubai  wrote:
> >
> > This device has trouble extracting big kernel from flash,
> > and supports LZMA compressed kernels only.
> >
> > Using OpenWrt kernel loader saves us 64 KB compared to the dictionary
> > size limiting workaround.
> >
> > Factory image sizes (commit: 5f126c541a74) with "CONFIG_ALL_KMODS=y":
> > - original ("-d23", default): 4784188 bytes, LZMA ERROR 1
> > - with "-d19": 4915260, LZMA ERROR 1
> > - with "-d18": 4915260, diff to original: +128 KB
> > - with "-d17": 4980796, diff to original: +192 KB
> > - with this patch: 4849724, diff to original: +64 KB
> >
> > To save some CPU cycle, use minimal compression ("-a0") for the LZMA
> > compressed uImage.
>
> My original thought on this device is to use a different loader. The first
> 4MB of SPI-NOR flash on mt7621 is mapped to 0x1fc0 and lzma
> loader can read compressed kernel directly from flash. If the kernel
> can be put at a fixed offset in flash, we could compress lzma loader
> separately and let u-boot decompress only the loader.
> You could take a look at the tp-link-nolzma recipe in:
> target/linux/ath79/image/common-tp-link.mk
> and see if you could implement a similar solution for mt7621.
> Note: You need to fix AR71XX_FLASH_START defined in:
> target/linux/ramips/image/lzma-loader/src/loader.c
> to 0x1fc0 for this method to work.
>

Yes, that new loader would be best solution.
I'm a DevOps guy and my C-fu is just Googling and copy-pasting. :D

I'm interested in the implementation, so I would play with the source code
as a homework, but those patches wouldn't be ready for the 20.xx release. ;)

> If you can't implement it, I'm fine with your current solution too.
> but I prefer to drop patch 1/2 and write the complete kernel
> recipe for dir-860l only. It's a bit confusing to use "KERNEL +="
>

I'm going to go this way. Thank you both for the comments.


--
BR,
Szabolcs



> --
> Regards,
> Chuanhong Guo

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


Re: [OpenWrt-Devel] [PATCH 2/2] ramips: mt7621: use lzma-loader for D-Link DIR-860L

2020-04-19 Thread Chuanhong Guo
Hi!

On Sun, Apr 19, 2020 at 8:38 AM Szabolcs Hubai  wrote:
>
> This device has trouble extracting big kernel from flash,
> and supports LZMA compressed kernels only.
>
> Using OpenWrt kernel loader saves us 64 KB compared to the dictionary
> size limiting workaround.
>
> Factory image sizes (commit: 5f126c541a74) with "CONFIG_ALL_KMODS=y":
> - original ("-d23", default): 4784188 bytes, LZMA ERROR 1
> - with "-d19": 4915260, LZMA ERROR 1
> - with "-d18": 4915260, diff to original: +128 KB
> - with "-d17": 4980796, diff to original: +192 KB
> - with this patch: 4849724, diff to original: +64 KB
>
> To save some CPU cycle, use minimal compression ("-a0") for the LZMA
> compressed uImage.

My original thought on this device is to use a different loader. The first
4MB of SPI-NOR flash on mt7621 is mapped to 0x1fc0 and lzma
loader can read compressed kernel directly from flash. If the kernel
can be put at a fixed offset in flash, we could compress lzma loader
separately and let u-boot decompress only the loader.
You could take a look at the tp-link-nolzma recipe in:
target/linux/ath79/image/common-tp-link.mk
and see if you could implement a similar solution for mt7621.
Note: You need to fix AR71XX_FLASH_START defined in:
target/linux/ramips/image/lzma-loader/src/loader.c
to 0x1fc0 for this method to work.

If you can't implement it, I'm fine with your current solution too.
but I prefer to drop patch 1/2 and write the complete kernel
recipe for dir-860l only. It's a bit confusing to use "KERNEL +="

-- 
Regards,
Chuanhong Guo

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


Re: [OpenWrt-Devel] [PATCH 2/2] ramips: mt7621: use lzma-loader for D-Link DIR-860L

2020-04-19 Thread Szabolcs Hubai
 ezt írta (időpont: 2020. ápr. 19., V, 14:40):
>
> Hi,
>
> > -Original Message-
> > From: openwrt-devel [mailto:openwrt-devel-boun...@lists.openwrt.org]
> > On Behalf Of Szabolcs Hubai
> > Sent: Sonntag, 19. April 2020 02:37
> > To: openwrt-devel@lists.openwrt.org
> > Cc: Szabolcs Hubai 
> > Subject: [OpenWrt-Devel] [PATCH 2/2] ramips: mt7621: use lzma-loader for
> > D-Link DIR-860L
> >
> > This device has trouble extracting big kernel from flash, and supports LZMA
> > compressed kernels only.
> >
> > Using OpenWrt kernel loader saves us 64 KB compared to the dictionary size
> > limiting workaround.
> >
> > Factory image sizes (commit: 5f126c541a74) with "CONFIG_ALL_KMODS=y":
> > - original ("-d23", default): 4784188 bytes, LZMA ERROR 1
> > - with "-d19": 4915260, LZMA ERROR 1
> > - with "-d18": 4915260, diff to original: +128 KB
> > - with "-d17": 4980796, diff to original: +192 KB
> > - with this patch: 4849724, diff to original: +64 KB
> >
> > To save some CPU cycle, use minimal compression ("-a0") for the LZMA
> > compressed uImage.
> >
> > Signed-off-by: Szabolcs Hubai 
> > ---
> >  target/linux/ramips/image/mt7621.mk | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/target/linux/ramips/image/mt7621.mk
> > b/target/linux/ramips/image/mt7621.mk
> > index aa6836d50a..28d2637bd3 100644
> > --- a/target/linux/ramips/image/mt7621.mk
> > +++ b/target/linux/ramips/image/mt7621.mk
> > @@ -216,9 +216,10 @@ TARGET_DEVICES += buffalo_wsr-600dhp
> >
> >  define Device/dlink_dir-860l-b1
> >$(Device/seama)
> > +  $(Device/lzma-loader)
>
> I do not really see the benefit of having this definition if you have to 
> modify it below anyway.
> Having seen this, I'd prefer to drop patch 1/2 entirely and just add the 
> necessary adjustments directly to this particular device:
>
> LOADER_TYPE := bin
> KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | relocate-kernel | 
> lzma -a0 | uImage lzma
> (properly wrapped of course)
>
> If we have five devices like this at some point, I'll be happy to discuss how 
> we can create a shared recipe.
>
> Best
>
> Adrian
>

As a newcomer it took me days to leave the "KERNEL_DTB += -d21" line
alone while debugging this LZMA ERROR on this device.
With the new recipe I wanted to emphasize that D-Link DIR-860L also
uses the kernel loader method, but it needs more magic to complete the
workaround.

Sure, that one properly wrapped line should also fix the snapshot images,
but I think creating and reusing that new recipe has the added value.


I like the new recipe better, but I'm OK with the one-liner, if you
think that the new recipe is overkill for this fix.

--
Szabolcs



> >BLOCKSIZE := 64k
> >SEAMA_SIGNATURE := wrgac13_dlink.2013gui_dir860lb
> > -  KERNEL := kernel-bin | append-dtb | relocate-kernel | lzma | uImage lzma
> > +  KERNEL += | relocate-kernel | lzma -a0 | uImage lzma
> >IMAGE_SIZE := 16064k
> >DEVICE_VENDOR := D-Link
> >DEVICE_MODEL := DIR-860L
> > --
> > 2.17.1
> >
> >
> > ___
> > 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


[OpenWrt-Devel] [PATCH 8/9] mtd: rawnand: bcm47xx: Merge all source files

2020-04-19 Thread Boris Brezillon
Given the number of lines it doesn't make them to split the code. Let's
merge everything in main.c and rename the file into bcm47xxnflash.c.

Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/bcm47xxnflash/Makefile   |  3 -
 .../{ops_bcm4706.c => bcm47xxnflash.c}| 81 ++-
 .../nand/raw/bcm47xxnflash/bcm47xxnflash.h| 21 -
 drivers/mtd/nand/raw/bcm47xxnflash/main.c | 77 --
 4 files changed, 78 insertions(+), 104 deletions(-)
 rename drivers/mtd/nand/raw/bcm47xxnflash/{ops_bcm4706.c => bcm47xxnflash.c} 
(82%)
 delete mode 100644 drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.h
 delete mode 100644 drivers/mtd/nand/raw/bcm47xxnflash/main.c

diff --git a/drivers/mtd/nand/raw/bcm47xxnflash/Makefile 
b/drivers/mtd/nand/raw/bcm47xxnflash/Makefile
index b531a630c9cf..71a953078799 100644
--- a/drivers/mtd/nand/raw/bcm47xxnflash/Makefile
+++ b/drivers/mtd/nand/raw/bcm47xxnflash/Makefile
@@ -1,5 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0-only
-bcm47xxnflash-y+= main.o
-bcm47xxnflash-y+= ops_bcm4706.o
-
 obj-$(CONFIG_MTD_NAND_BCM47XXNFLASH)   += bcm47xxnflash.o
diff --git a/drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c 
b/drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.c
similarity index 82%
rename from drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c
rename to drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.c
index ab989de54cfc..ae0391c1ee28 100644
--- a/drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c
+++ b/drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.c
@@ -5,13 +5,14 @@
  * Copyright (C) 2012 Rafał Miłecki 
  */
 
-#include "bcm47xxnflash.h"
-
+#include 
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
+#include 
+#include 
 
 /* Broadcom uses 1'000'000 but it seems to be too many. Tests on WNDR4500 has
  * shown ~1000 retries as maxiumum. */
@@ -48,6 +49,17 @@
 #define CONF_COL_BYTES(x)  (((x) - 1) << 4)
 #define CONF_ROW_BYTES(x)  (((x) - 1) << 6)
 
+#ifndef pr_fmt
+#define pr_fmt(fmt)KBUILD_MODNAME ": " fmt
+#endif
+
+struct bcm47xxnflash {
+   struct nand_controller base;
+   struct bcma_drv_cc *cc;
+
+   struct nand_chip nand_chip;
+};
+
 /**
  * Various helpers
  **/
@@ -276,3 +288,66 @@ int bcm47xxnflash_ops_bcm4706_init(struct bcm47xxnflash 
*b47n)
 
return err;
 }
+
+static const char *probes[] = { "bcm47xxpart", NULL };
+
+static int bcm47xxnflash_probe(struct platform_device *pdev)
+{
+   struct bcma_nflash *nflash = dev_get_platdata(>dev);
+   struct bcm47xxnflash *b47n;
+   struct mtd_info *mtd;
+   int err = 0;
+
+   b47n = devm_kzalloc(>dev, sizeof(*b47n), GFP_KERNEL);
+   if (!b47n)
+   return -ENOMEM;
+
+   nand_set_controller_data(>nand_chip, b47n);
+   mtd = nand_to_mtd(>nand_chip);
+   mtd->dev.parent = >dev;
+   b47n->cc = container_of(nflash, struct bcma_drv_cc, nflash);
+
+   if (b47n->cc->core->bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) {
+   err = bcm47xxnflash_ops_bcm4706_init(b47n);
+   } else {
+   pr_err("Device not supported\n");
+   err = -ENOTSUPP;
+   }
+   if (err) {
+   pr_err("Initialization failed: %d\n", err);
+   return err;
+   }
+
+   platform_set_drvdata(pdev, b47n);
+
+   err = mtd_device_parse_register(mtd, probes, NULL, NULL, 0);
+   if (err) {
+   pr_err("Failed to register MTD device: %d\n", err);
+   return err;
+   }
+
+   return 0;
+}
+
+static int bcm47xxnflash_remove(struct platform_device *pdev)
+{
+   struct bcm47xxnflash *nflash = platform_get_drvdata(pdev);
+
+   nand_release(>nand_chip);
+
+   return 0;
+}
+
+static struct platform_driver bcm47xxnflash_driver = {
+   .probe  = bcm47xxnflash_probe,
+   .remove = bcm47xxnflash_remove,
+   .driver = {
+   .name = "bcma_nflash",
+   },
+};
+module_platform_driver(bcm47xxnflash_driver);
+
+MODULE_DESCRIPTION("NAND flash driver for BCMA bus");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Rafał Miłecki");
+
diff --git a/drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.h 
b/drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.h
deleted file mode 100644
index 8de0e7e0a3a4..
--- a/drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __BCM47XXNFLASH_H
-#define __BCM47XXNFLASH_H
-
-#ifndef pr_fmt
-#define pr_fmt(fmt)KBUILD_MODNAME ": " fmt
-#endif
-
-#include 
-#include 
-
-struct bcm47xxnflash {
-   struct nand_controller base;
-   struct bcma_drv_cc *cc;
-
-   struct nand_chip nand_chip;
-};
-
-int bcm47xxnflash_ops_bcm4706_init(struct bcm47xxnflash *b47n);
-
-#endif /* BCM47XXNFLASH */
diff --git 

[OpenWrt-Devel] [PATCH 7/9] mtd: rawnand: bcm47xx: Simplify the init() function

2020-04-19 Thread Boris Brezillon
The row and column sizes are now set as part of the exec_op() procedure
and adjusted to match the requested number of address cycles. No need
to set them in the init() function since those values will be
overwritten anyway. As for the other sanity check that was done on the
chip size, I don't think it's really needed.

Signed-off-by: Boris Brezillon 
---
 .../mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c  | 31 ++-
 1 file changed, 2 insertions(+), 29 deletions(-)

diff --git a/drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c 
b/drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c
index 4e38b685d207..ab989de54cfc 100644
--- a/drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c
+++ b/drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c
@@ -237,10 +237,6 @@ int bcm47xxnflash_ops_bcm4706_init(struct bcm47xxnflash 
*b47n)
u16 clock;
u8 w0, w1, w2, w3, w4;
 
-   unsigned long chipsize; /* MiB */
-   u8 tbits, col_bits, col_size, row_bits, row_bsize;
-   u32 val;
-
nand_controller_init(>base);
b47n->base.ops = _ops;
b47n->nand_chip.controller = >base;
@@ -274,32 +270,9 @@ int bcm47xxnflash_ops_bcm4706_init(struct bcm47xxnflash 
*b47n)
err = nand_scan(>nand_chip, 1);
if (err) {
pr_err("Could not scan NAND flash: %d\n", err);
-   goto exit;
-   }
-
-   /* Configure FLASH */
-   chipsize = nanddev_target_size(>nand_chip.base) >> 20;
-   tbits = ffs(chipsize); /* find first bit set */
-   if (!tbits || tbits != fls(chipsize)) {
-   pr_err("Invalid flash size: 0x%lX\n", chipsize);
-   err = -ENOTSUPP;
-   goto exit;
-   }
-   tbits += 19; /* Broadcom increases *index* by 20, we increase *pos* */
-
-   col_bits = b47n->nand_chip.page_shift + 1;
-   col_size = (col_bits + 7) / 8;
-
-   row_bits = tbits - col_bits + 1;
-   row_bsize = (row_bits + 7) / 8;
-
-   val = CONF_ROW_BYTES(row_bsize) | CONF_COL_BYTES(col_size) |
- CONF_MAGIC_BIT;
-   bcma_cc_write32(b47n->cc, BCMA_CC_NFLASH_CONF, val);
-
-exit:
-   if (err)
bcma_cc_mask32(b47n->cc, BCMA_CC_4706_FLASHSCFG,
   ~BCMA_CC_4706_FLASHSCFG_NF1);
+   }
+
return err;
 }
-- 
2.25.2


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


[OpenWrt-Devel] [PATCH 6/9] mtd: rawnand: bcm47xx: Get rid of the legacy implementation

2020-04-19 Thread Boris Brezillon
Now that exec_op() is implemented we don't need to implement all those
legacy hooks, which simplifies the code quite a bit.

Signed-off-by: Boris Brezillon 
---
 .../nand/raw/bcm47xxnflash/bcm47xxnflash.h|   6 -
 .../mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c  | 315 --
 2 files changed, 321 deletions(-)

diff --git a/drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.h 
b/drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.h
index 00d0974b73cb..8de0e7e0a3a4 100644
--- a/drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.h
+++ b/drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.h
@@ -14,12 +14,6 @@ struct bcm47xxnflash {
struct bcma_drv_cc *cc;
 
struct nand_chip nand_chip;
-
-   unsigned curr_command;
-   int curr_page_addr;
-   int curr_column;
-
-   u8 id_data[8];
 };
 
 int bcm47xxnflash_ops_bcm4706_init(struct bcm47xxnflash *b47n);
diff --git a/drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c 
b/drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c
index 184f78b3d45a..4e38b685d207 100644
--- a/drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c
+++ b/drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c
@@ -75,313 +75,10 @@ static int bcm47xxnflash_ops_bcm4706_ctl_cmd(struct 
bcma_drv_cc *cc, u32 code)
return 0;
 }
 
-static int bcm47xxnflash_ops_bcm4706_poll(struct bcma_drv_cc *cc)
-{
-   int i;
-
-   for (i = 0; i < NFLASH_READY_RETRIES; i++) {
-   if (bcma_cc_read32(cc, BCMA_CC_NFLASH_CTL) & NCTL_READY) {
-   if (bcma_cc_read32(cc, BCMA_CC_NFLASH_CTL) &
-   BCMA_CC_NFLASH_CTL_ERR) {
-   pr_err("Error on polling\n");
-   return -EBUSY;
-   } else {
-   return 0;
-   }
-   }
-   }
-
-   pr_err("Polling timeout!\n");
-   return -EBUSY;
-}
-
-/**
- * R/W
- **/
-
-static void bcm47xxnflash_ops_bcm4706_read(struct mtd_info *mtd, uint8_t *buf,
-  int len)
-{
-   struct nand_chip *nand_chip = mtd_to_nand(mtd);
-   struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip);
-
-   u32 ctlcode;
-   u32 *dest = (u32 *)buf;
-   int i;
-   int toread;
-
-   BUG_ON(b47n->curr_page_addr & ~nand_chip->pagemask);
-   /* Don't validate column using nand_chip->page_shift, it may be bigger
-* when accessing OOB */
-
-   while (len) {
-   /* We can read maximum of 0x200 bytes at once */
-   toread = min(len, 0x200);
-
-   /* Set page and column */
-   bcma_cc_write32(b47n->cc, BCMA_CC_NFLASH_COL_ADDR,
-   b47n->curr_column);
-   bcma_cc_write32(b47n->cc, BCMA_CC_NFLASH_ROW_ADDR,
-   b47n->curr_page_addr);
-
-   /* Prepare to read */
-   ctlcode = NCTL_CSA | NCTL_CMD1W | NCTL_ROW | NCTL_COL |
- NCTL_CMD0;
-   ctlcode |= NAND_CMD_READSTART << 8;
-   if (bcm47xxnflash_ops_bcm4706_ctl_cmd(b47n->cc, ctlcode))
-   return;
-   if (bcm47xxnflash_ops_bcm4706_poll(b47n->cc))
-   return;
-
-   /* Eventually read some data :) */
-   for (i = 0; i < toread; i += 4, dest++) {
-   ctlcode = NCTL_CSA | NCTL_DATA_CYCLES(4) | NCTL_READ;
-   if (i == toread - 4) /* Last read goes without that */
-   ctlcode &= ~NCTL_CSA;
-   if (bcm47xxnflash_ops_bcm4706_ctl_cmd(b47n->cc,
- ctlcode))
-   return;
-   *dest = bcma_cc_read32(b47n->cc, BCMA_CC_NFLASH_DATA);
-   }
-
-   b47n->curr_column += toread;
-   len -= toread;
-   }
-}
-
-static void bcm47xxnflash_ops_bcm4706_write(struct mtd_info *mtd,
-   const uint8_t *buf, int len)
-{
-   struct nand_chip *nand_chip = mtd_to_nand(mtd);
-   struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip);
-   struct bcma_drv_cc *cc = b47n->cc;
-
-   u32 ctlcode;
-   const u32 *data = (u32 *)buf;
-   int i;
-
-   BUG_ON(b47n->curr_page_addr & ~nand_chip->pagemask);
-   /* Don't validate column using nand_chip->page_shift, it may be bigger
-* when accessing OOB */
-
-   for (i = 0; i < len; i += 4, data++) {
-   bcma_cc_write32(cc, BCMA_CC_NFLASH_DATA, *data);
-
-   ctlcode = NCTL_CSA | NCTL_DATA_CYCLES(4) | NCTL_WRITE;
-   if (i == len - 4) /* Last read goes without that */
-   ctlcode &= ~NCTL_CSA;
-   if 

[OpenWrt-Devel] [PATCH 9/9] mtd: rawnand: bcm47xx: Move the driver to drivers/mtd/nand/raw/

2020-04-19 Thread Boris Brezillon
Now that we have a single we can move it to the directory where all
single source file drivers live.

Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/Makefile| 1 +
 drivers/mtd/nand/raw/{bcm47xxnflash => }/bcm47xxnflash.c | 0
 drivers/mtd/nand/raw/bcm47xxnflash/Makefile  | 2 --
 3 files changed, 1 insertion(+), 2 deletions(-)
 rename drivers/mtd/nand/raw/{bcm47xxnflash => }/bcm47xxnflash.c (100%)
 delete mode 100644 drivers/mtd/nand/raw/bcm47xxnflash/Makefile

diff --git a/drivers/mtd/nand/raw/Makefile b/drivers/mtd/nand/raw/Makefile
index 2d136b158fb7..703d696c2d61 100644
--- a/drivers/mtd/nand/raw/Makefile
+++ b/drivers/mtd/nand/raw/Makefile
@@ -58,6 +58,7 @@ obj-$(CONFIG_MTD_NAND_TEGRA)  += tegra_nand.o
 obj-$(CONFIG_MTD_NAND_STM32_FMC2)  += stm32_fmc2_nand.o
 obj-$(CONFIG_MTD_NAND_MESON)   += meson_nand.o
 obj-$(CONFIG_MTD_NAND_CADENCE) += cadence-nand-controller.o
+obj-$(CONFIG_MTD_NAND_BCM47XXNFLASH)   += bcm47xxnflash.o
 
 nand-objs := nand_base.o nand_legacy.o nand_bbt.o nand_timings.o nand_ids.o
 nand-objs += nand_onfi.o
diff --git a/drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.c 
b/drivers/mtd/nand/raw/bcm47xxnflash.c
similarity index 100%
rename from drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.c
rename to drivers/mtd/nand/raw/bcm47xxnflash.c
diff --git a/drivers/mtd/nand/raw/bcm47xxnflash/Makefile 
b/drivers/mtd/nand/raw/bcm47xxnflash/Makefile
deleted file mode 100644
index 71a953078799..
--- a/drivers/mtd/nand/raw/bcm47xxnflash/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-obj-$(CONFIG_MTD_NAND_BCM47XXNFLASH)   += bcm47xxnflash.o
-- 
2.25.2


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


[OpenWrt-Devel] [PATCH 5/9] mtd: rawnand: bcm47xx: Implement the exec_op() interface

2020-04-19 Thread Boris Brezillon
Implement the exec_op() interface so we can get rid of the convoluted
cmdfunc() implementation.

Signed-off-by: Boris Brezillon 
---
This is based on my understanding of how this controller works, and I
think it covers all the use cases covered by the custom cmdfunc()
implementation. I might be wrong of course, so it'd be great to have
someone test on real HW.
---
 .../nand/raw/bcm47xxnflash/bcm47xxnflash.h|   1 +
 .../mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c  | 150 ++
 2 files changed, 151 insertions(+)

diff --git a/drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.h 
b/drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.h
index 201b9baa52a0..00d0974b73cb 100644
--- a/drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.h
+++ b/drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.h
@@ -10,6 +10,7 @@
 #include 
 
 struct bcm47xxnflash {
+   struct nand_controller base;
struct bcma_drv_cc *cc;
 
struct nand_chip nand_chip;
diff --git a/drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c 
b/drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c
index fbb7acebc8f7..184f78b3d45a 100644
--- a/drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c
+++ b/drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c
@@ -382,6 +382,153 @@ static void bcm47xxnflash_ops_bcm4706_write_buf(struct 
nand_chip *nand_chip,
pr_err("Invalid command for buf write: 0x%X\n", b47n->curr_command);
 }
 
+static int
+bcm47xxnflash_ops_bcm4706_exec_cmd_addr(struct nand_chip *chip,
+   const struct nand_subop *subop)
+{
+   struct bcm47xxnflash *b47n = nand_get_controller_data(chip);
+   u32 nctl = 0, col = 0, row = 0, ncols = 0, nrows = 0;
+   unsigned int i, j;
+
+   for (i = 0; i < subop->ninstrs; i++) {
+   const struct nand_op_instr *instr = >instrs[i];
+
+   switch (instr->type) {
+   case NAND_OP_CMD_INSTR:
+   if (WARN_ON_ONCE((nctl & NCTL_CMD0) &&
+(nctl & NCTL_CMD1W)))
+   return -EINVAL;
+   else if (nctl & NCTL_CMD0)
+   nctl |= NCTL_CMD1W |
+   ((u32)instr->ctx.cmd.opcode << 8);
+   else
+   nctl |= NCTL_CMD0 | instr->ctx.cmd.opcode;
+   break;
+   case NAND_OP_ADDR_INSTR:
+   for (j = 0; j < instr->ctx.addr.naddrs; j++) {
+   u32 addr = instr->ctx.addr.addrs[j];
+
+   if (i < 2) {
+   col |= addr << i * 8;
+   nctl |= NCTL_COL;
+   ncols++;
+   } else {
+   row |= addr << (i - 2) * 8;
+   nctl |= NCTL_ROW;
+   nrows++;
+   }
+   }
+   break;
+   default:
+   WARN_ON_ONCE(1);
+   return -EINVAL;
+   }
+   }
+
+   /* Keep the CS line asserted if there's something else to execute. */
+   if (!subop->is_last)
+   nctl |= NCTL_CSA;
+
+   bcma_cc_write32(b47n->cc, BCMA_CC_NFLASH_CONF,
+   CONF_MAGIC_BIT |
+   CONF_COL_BYTES(ncols) |
+   CONF_ROW_BYTES(nrows));
+   return bcm47xxnflash_ops_bcm4706_ctl_cmd(b47n->cc, nctl);
+}
+
+static int
+bcm47xxnflash_ops_bcm4706_exec_waitrdy(struct nand_chip *chip,
+  const struct nand_subop *subop)
+{
+   struct bcm47xxnflash *b47n = nand_get_controller_data(chip);
+   const struct nand_op_instr *instr = >instrs[0];
+   unsigned long timeout_jiffies = jiffies;
+
+   if (WARN_ON(subop->ninstrs != 1 ||
+   instr->type != NAND_OP_DATA_IN_INSTR))
+   return -EINVAL;
+
+   timeout_jiffies += msecs_to_jiffies(instr->ctx.waitrdy.timeout_ms) + 1;
+   do {
+   if (bcma_cc_read32(b47n->cc, BCMA_CC_NFLASH_CTL) & NCTL_READY)
+   return 0;
+
+   usleep_range(10, 100);
+   } while (time_before(jiffies, timeout_jiffies));
+
+   return -ETIMEDOUT;
+}
+
+static int
+bcm47xxnflash_ops_bcm4706_exec_rw(struct nand_chip *chip,
+ const struct nand_subop *subop)
+{
+   struct bcm47xxnflash *b47n = nand_get_controller_data(chip);
+   const struct nand_op_instr *instr = >instrs[0];
+   unsigned int i;
+   int ret;
+
+   if (WARN_ON(subop->ninstrs != 1 ||
+   (instr->type != NAND_OP_DATA_IN_INSTR &&
+instr->type != NAND_OP_DATA_OUT_INSTR)))
+   return -EINVAL;
+
+   for (i = 0; i < 

[OpenWrt-Devel] [PATCH 4/9] mtd: rawnand: bcm47xx: Demistify a few more things

2020-04-19 Thread Boris Brezillon
There were a few places were raw hex values were used instead of the
macro def.

We also add macros to help forming the conf value (note that we still
have one magic bit whose meaning I couldn't extract from the code), and
add an extra macro to specify the number of DATA cycles to issue when
the READ or WRITE flag is set.

Signed-off-by: Boris Brezillon 
---
 .../mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c  | 34 +++
 1 file changed, 27 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c 
b/drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c
index 591775173034..fbb7acebc8f7 100644
--- a/drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c
+++ b/drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c
@@ -25,12 +25,29 @@
 #define NCTL_CMD1W 0x0008
 #define NCTL_READ  0x0010
 #define NCTL_WRITE 0x0020
+/* When the SPECADDR is set CMD1 is interpreted as a single ADDR cycle */
 #define NCTL_SPECADDR  0x0100
 #define NCTL_READY 0x0400
 #define NCTL_ERR   0x0800
+/*
+ * Number of DATA cycles to issue when NCTL_{READ,WRITE} is set. The minimum
+ * value is 1 and the maximum value is 4. Those bytes are then stored in the
+ * BCMA_CC_NFLASH_DATA register.
+ */
+#define NCTL_DATA_CYCLES(x)x) - 1) & 0x3) << 28)
+/*
+ * The CS pin seems to be asserted even if NCTL_CSA is not set. All this bit
+ * seems to encode is whether the CS line should stay asserted after the
+ * operation has been executed. In other words, you should only set it if if
+ * you intend to do more operations on the NAND bus.
+ */
 #define NCTL_CSA   0x4000
 #define NCTL_START 0x8000
 
+#define CONF_MAGIC_BIT 0x0002
+#define CONF_COL_BYTES(x)  (((x) - 1) << 4)
+#define CONF_ROW_BYTES(x)  (((x) - 1) << 6)
+
 /**
  * Various helpers
  **/
@@ -118,7 +135,7 @@ static void bcm47xxnflash_ops_bcm4706_read(struct mtd_info 
*mtd, uint8_t *buf,
 
/* Eventually read some data :) */
for (i = 0; i < toread; i += 4, dest++) {
-   ctlcode = NCTL_CSA | 0x3000 | NCTL_READ;
+   ctlcode = NCTL_CSA | NCTL_DATA_CYCLES(4) | NCTL_READ;
if (i == toread - 4) /* Last read goes without that */
ctlcode &= ~NCTL_CSA;
if (bcm47xxnflash_ops_bcm4706_ctl_cmd(b47n->cc,
@@ -150,7 +167,7 @@ static void bcm47xxnflash_ops_bcm4706_write(struct mtd_info 
*mtd,
for (i = 0; i < len; i += 4, data++) {
bcma_cc_write32(cc, BCMA_CC_NFLASH_DATA, *data);
 
-   ctlcode = NCTL_CSA | 0x3000 | NCTL_WRITE;
+   ctlcode = NCTL_CSA | NCTL_DATA_CYCLES(4) | NCTL_WRITE;
if (i == len - 4) /* Last read goes without that */
ctlcode &= ~NCTL_CSA;
if (bcm47xxnflash_ops_bcm4706_ctl_cmd(cc, ctlcode)) {
@@ -229,7 +246,7 @@ static void bcm47xxnflash_ops_bcm4706_cmdfunc(struct 
nand_chip *nand_chip,
nand_wait_ready(nand_chip);
break;
case NAND_CMD_READID:
-   ctlcode = NCTL_CSA | 0x0100 | NCTL_CMD1W | NCTL_CMD0;
+   ctlcode = NCTL_CSA | NCTL_SPECADDR | NCTL_CMD1W | NCTL_CMD0;
ctlcode |= NAND_CMD_READID;
if (bcm47xxnflash_ops_bcm4706_ctl_cmd(b47n->cc, ctlcode)) {
pr_err("READID error\n");
@@ -242,7 +259,7 @@ static void bcm47xxnflash_ops_bcm4706_cmdfunc(struct 
nand_chip *nand_chip,
 * to perform, so cache everything.
 */
for (i = 0; i < ARRAY_SIZE(b47n->id_data); i++) {
-   ctlcode = NCTL_CSA | NCTL_READ;
+   ctlcode = NCTL_CSA | NCTL_READ | NCTL_DATA_CYCLES(1);
if (i == ARRAY_SIZE(b47n->id_data) - 1)
ctlcode &= ~NCTL_CSA;
if (bcm47xxnflash_ops_bcm4706_ctl_cmd(b47n->cc,
@@ -285,7 +302,7 @@ static void bcm47xxnflash_ops_bcm4706_cmdfunc(struct 
nand_chip *nand_chip,
b47n->curr_page_addr);
 
/* Prepare to write */
-   ctlcode = 0x4000 | NCTL_ROW | NCTL_COL | NCTL_CMD0;
+   ctlcode = NCTL_CSA | NCTL_ROW | NCTL_COL | NCTL_CMD0;
ctlcode |= NAND_CMD_SEQIN;
if (bcm47xxnflash_ops_bcm4706_ctl_cmd(cc, ctlcode))
pr_err("SEQIN failed\n");
@@ -320,7 +337,9 @@ static u8 bcm47xxnflash_ops_bcm4706_read_byte(struct 
nand_chip *nand_chip)
}
return b47n->id_data[b47n->curr_column++];
case NAND_CMD_STATUS:
-   if 

[OpenWrt-Devel] [PATCH 3/9] mtd: rawnand: bcm47xx: Allow compiling the driver when COMPILE_TEST=y

2020-04-19 Thread Boris Brezillon
Makes it easier to spot compile-time issues.

Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index 60c4eb9d382f..1f8aa353f764 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -242,7 +242,7 @@ config MTD_NAND_BRCMNAND
 
 config MTD_NAND_BCM47XXNFLASH
tristate "BCM4706 BCMA NAND controller"
-   depends on BCMA_NFLASH
+   depends on BCMA_NFLASH || COMPILE_TEST
help
  BCMA bus can have various flash memories attached, they are
  registered by bcma as platform devices. This enables driver for
-- 
2.25.2


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


[OpenWrt-Devel] [PATCH 2/9] mtd: rawnand: bcm47xx: Drop dependency on BCMA

2020-04-19 Thread Boris Brezillon
BCMA_NFLASH can only be selected if BCMA is enabled and we already
depend on BCMA_NFLASH, making the dependency on BCMA useless.

Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/Kconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index a80a46bb5b8b..60c4eb9d382f 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -243,7 +243,6 @@ config MTD_NAND_BRCMNAND
 config MTD_NAND_BCM47XXNFLASH
tristate "BCM4706 BCMA NAND controller"
depends on BCMA_NFLASH
-   depends on BCMA
help
  BCMA bus can have various flash memories attached, they are
  registered by bcma as platform devices. This enables driver for
-- 
2.25.2


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


[OpenWrt-Devel] [PATCH 0/9] mtd: rawnand: bcm47xx: Convert the driver exec_op()

2020-04-19 Thread Boris Brezillon
Hello,

Recently I've been CC-ed on a few new driver submissions that were
implementing the legacy interface, which made me realize the only way
to prevent that from happening was to:

1/ convert all existing drivers to exec_op()
2/ document the new way of doing things

#2 is definitely needed, but I don't think it's be enough, as people
tend to re-shuffle what they had in their downstream kernel when
they submit something upstream, and those downstream drivers were most
likely based on the legacy cmd_ctrl/cmdfunc() interface.

So here I am, trying to convert existing drivers one by one. I'd be
grateful if someone from the OpenWRT community (Rafal?) could test/help
me debug that one as I don't have the HW myself.

Regards,

Boris

Boris Brezillon (9):
  mtd: rawnand: Add an is_last flag to nand_subop
  mtd: rawnand: bcm47xx: Drop dependency on BCMA
  mtd: rawnand: bcm47xx: Allow compiling the driver when COMPILE_TEST=y
  mtd: rawnand: bcm47xx: Demistify a few more things
  mtd: rawnand: bcm47xx: Implement the exec_op() interface
  mtd: rawnand: bcm47xx: Get rid of the legacy implementation
  mtd: rawnand: bcm47xx: Simplify the init() function
  mtd: rawnand: bcm47xx: Merge all source files
  mtd: rawnand: bcm47xx: Move the driver to drivers/mtd/nand/raw/

 drivers/mtd/nand/raw/Kconfig  |   3 +-
 drivers/mtd/nand/raw/Makefile |   1 +
 drivers/mtd/nand/raw/bcm47xxnflash.c  | 353 ++
 drivers/mtd/nand/raw/bcm47xxnflash/Makefile   |   5 -
 .../nand/raw/bcm47xxnflash/bcm47xxnflash.h|  26 -
 drivers/mtd/nand/raw/bcm47xxnflash/main.c |  77 ---
 .../mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c  | 450 --
 drivers/mtd/nand/raw/nand_base.c  |   2 +
 include/linux/mtd/rawnand.h   |   2 +
 9 files changed, 359 insertions(+), 560 deletions(-)
 create mode 100644 drivers/mtd/nand/raw/bcm47xxnflash.c
 delete mode 100644 drivers/mtd/nand/raw/bcm47xxnflash/Makefile
 delete mode 100644 drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.h
 delete mode 100644 drivers/mtd/nand/raw/bcm47xxnflash/main.c
 delete mode 100644 drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c

-- 
2.25.2


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


[OpenWrt-Devel] [PATCH 1/9] mtd: rawnand: Add an is_last flag to nand_subop

2020-04-19 Thread Boris Brezillon
Some controllers need to know when they're passed the last subop so
they can de-assert the CE pin.

Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/nand_base.c | 2 ++
 include/linux/mtd/rawnand.h  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index fa9ac18e97a1..f81b54634061 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -2101,6 +2101,8 @@ nand_op_parser_match_pat(const struct 
nand_op_parser_pattern *pat,
 */
ctx->subop.ninstrs = ninstrs;
ctx->subop.last_instr_end_off = instr_offset;
+   if (ctx->subop.instrs + ninstrs == end && !instr_offset)
+   ctx->subop.is_last = true;
 
return true;
 }
diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
index 8e8d1a61e2fb..99f4ac47c8d3 100644
--- a/include/linux/mtd/rawnand.h
+++ b/include/linux/mtd/rawnand.h
@@ -701,6 +701,7 @@ struct nand_op_instr {
  *of the sub-operation
  * @last_instr_end_off: offset to end at (excluded) for the last instruction
  * of the sub-operation
+ * @is_last: this sub-operation is the last one
  *
  * Both @first_instr_start_off and @last_instr_end_off only apply to data or
  * address instructions.
@@ -715,6 +716,7 @@ struct nand_subop {
unsigned int ninstrs;
unsigned int first_instr_start_off;
unsigned int last_instr_end_off;
+   bool is_last;
 };
 
 unsigned int nand_subop_get_addr_start_off(const struct nand_subop *subop,
-- 
2.25.2


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


Re: [OpenWrt-Devel] [PATCH 2/2] ramips: mt7621: use lzma-loader for D-Link DIR-860L

2020-04-19 Thread mail
Hi,

> -Original Message-
> From: openwrt-devel [mailto:openwrt-devel-boun...@lists.openwrt.org]
> On Behalf Of Szabolcs Hubai
> Sent: Sonntag, 19. April 2020 02:37
> To: openwrt-devel@lists.openwrt.org
> Cc: Szabolcs Hubai 
> Subject: [OpenWrt-Devel] [PATCH 2/2] ramips: mt7621: use lzma-loader for
> D-Link DIR-860L
> 
> This device has trouble extracting big kernel from flash, and supports LZMA
> compressed kernels only.
> 
> Using OpenWrt kernel loader saves us 64 KB compared to the dictionary size
> limiting workaround.
> 
> Factory image sizes (commit: 5f126c541a74) with "CONFIG_ALL_KMODS=y":
> - original ("-d23", default): 4784188 bytes, LZMA ERROR 1
> - with "-d19": 4915260, LZMA ERROR 1
> - with "-d18": 4915260, diff to original: +128 KB
> - with "-d17": 4980796, diff to original: +192 KB
> - with this patch: 4849724, diff to original: +64 KB
> 
> To save some CPU cycle, use minimal compression ("-a0") for the LZMA
> compressed uImage.
> 
> Signed-off-by: Szabolcs Hubai 
> ---
>  target/linux/ramips/image/mt7621.mk | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/target/linux/ramips/image/mt7621.mk
> b/target/linux/ramips/image/mt7621.mk
> index aa6836d50a..28d2637bd3 100644
> --- a/target/linux/ramips/image/mt7621.mk
> +++ b/target/linux/ramips/image/mt7621.mk
> @@ -216,9 +216,10 @@ TARGET_DEVICES += buffalo_wsr-600dhp
> 
>  define Device/dlink_dir-860l-b1
>$(Device/seama)
> +  $(Device/lzma-loader)

I do not really see the benefit of having this definition if you have to modify 
it below anyway.
Having seen this, I'd prefer to drop patch 1/2 entirely and just add the 
necessary adjustments directly to this particular device:

LOADER_TYPE := bin
KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | relocate-kernel | 
lzma -a0 | uImage lzma
(properly wrapped of course)

If we have five devices like this at some point, I'll be happy to discuss how 
we can create a shared recipe.

Best

Adrian

>BLOCKSIZE := 64k
>SEAMA_SIGNATURE := wrgac13_dlink.2013gui_dir860lb
> -  KERNEL := kernel-bin | append-dtb | relocate-kernel | lzma | uImage lzma
> +  KERNEL += | relocate-kernel | lzma -a0 | uImage lzma
>IMAGE_SIZE := 16064k
>DEVICE_VENDOR := D-Link
>DEVICE_MODEL := DIR-860L
> --
> 2.17.1
> 
> 
> ___
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel


openpgp-digital-signature.asc
Description: PGP signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 1/2] ramips: define image recipe for plain lzma-loader for advanced cases

2020-04-19 Thread mail
Hi,

> -Original Message-
> From: openwrt-devel [mailto:openwrt-devel-boun...@lists.openwrt.org]
> On Behalf Of Szabolcs Hubai
> Sent: Sonntag, 19. April 2020 02:37
> To: openwrt-devel@lists.openwrt.org
> Cc: Szabolcs Hubai 
> Subject: [OpenWrt-Devel] [PATCH 1/2] ramips: define image recipe for plain
> lzma-loader for advanced cases
> 
> This change allows to make other transformations to kernel before uImage
> 
> Signed-off-by: Szabolcs Hubai 
> ---
>  target/linux/ramips/image/Makefile | 9 +++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/target/linux/ramips/image/Makefile
> b/target/linux/ramips/image/Makefile
> index f93ea8ab2a..707bc85f9a 100644
> --- a/target/linux/ramips/image/Makefile
> +++ b/target/linux/ramips/image/Makefile
> @@ -37,9 +37,14 @@ define Device/Default
>IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs |
> append-metadata | check-size  endef
> 
> -define Device/uimage-lzma-loader
> +define Device/lzma-loader
>LOADER_TYPE := bin
> -  KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | uImage none
> +  KERNEL := kernel-bin | append-dtb | lzma | loader-kernel endef
> +
> +define Device/uimage-lzma-loader
> +  $(Device/lzma-loader)
> +  KERNEL += | uImage none

IMO, this is more complicated to read than just keeping the full command.
Since it's only two lines of which one is different, I'd prefer to just add the 
lzma-loader without referencing:

define Device/lzma-loader
  LOADER_TYPE := bin
  KERNEL := kernel-bin | append-dtb | lzma | loader-kernel
endef

(with no change to uimage-lzma-loader)

This should also be consistent with the rest, I don't think we use KERNEL += | 
... anywhere.

Best

Adrian 


openpgp-digital-signature.asc
Description: PGP signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] linux5.4: build-dependency to rsync

2020-04-19 Thread Bjørn Mork
Sven Roederer  writes:

> I was just building a master-branch for x86-generic and got following error:
>
> make[5]: Entering directory '/mnt/local/btrfs/build/freifunk/ffberlin/
> firmware/openwrt/build_dir/toolchain-i386_pentium4_gcc-8.4.0_musl/
> linux-5.4.28'
>   INSTALL /mnt/local/btrfs/build/freifunk/ffberlin/firmware/openwrt/build_dir/
> toolchain-i386_pentium4_gcc-8.4.0_musl/linux-dev//include
> /bin/sh: 1: rsync: not found
> make[5]: *** [Makefile:1186: headers_install] Error 127
> make[5]: Leaving directory '/mnt/local/btrfs/build/freifunk/ffberlin/firmware/
> openwrt/build_dir/toolchain-i386_pentium4_gcc-8.4.0_musl/linux-5.4.28'
> make[4]: *** [Makefile:108: /mnt/local/btrfs/build/freifunk/ffberlin/firmware/
> openwrt/build_dir/toolchain-i386_pentium4_gcc-8.4.0_musl/
> linux-5.4.28/.configured] Error 2
> make[4]: Leaving directory '/mnt/local/btrfs/build/freifunk/ffberlin/firmware/
> openwrt/toolchain/kernel-headers'
> time: toolchain/kernel-headers/compile#1.46#0.83#2.26
>
>
> In https://github.com/torvalds/linux/commit/59b2bd05f5f4d the call to rsync 
> was added. I think we have the 2 options:
> * use host-command (changing the build-requirements)
> * compile it ourself (like we do with zip: ad8c2d6099a7da51)

This new dependency looks like it might have been unintentional.  rsync
is not documented in Documentation/process/changes.rst . And there must
be many other recursive file copying rules in the kernel build system,
which do *not* depend on rsync.

Maybe check with the kernel community first, verifying that this new
build dependency was in fact intended?  At the very least, that should
result in a patch to Documentation/process/changes.rst making this
explicit. 



Bjørn

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