Re: sysupgrade broken on imx nand targets (and maybe others too)

2023-01-23 Thread Lanchon

hi Koen, thanks again.

i copied your log here for ease of reference:
https://gist.github.com/Lanchon/f24ea9c16eda5ffaa5085a7b240238db


first let me say:

- ubinized sysupgrade is not used by any of my devices.

- ubinized sysupgrade happens when when an ubi partition image is fed as 
an upgrade file. the image contains the complete set of ubi volumes that 
are normally stored within the ubi partition on your device: typically 
kernel (raw image), R/O rootfs (sqfs), and R/W overlay (ubifs). during 
said sysupgrade, the current configuration is first copied to RAM, then 
the ubi partition image is written, and finally -if current config is 
kept- the RAM contents are written back to the new overlay volume.


- ubinized sysupgrades were known to be broken by other people at the 
time of my commits, and they wanted to remove the feature altogether 
because it was unused (look it up in the relevant pull request for my 
commits on github). as i remember it, it was broken because some ubi 
volumes within the ubi partition were sometimes mounted or R/O block 
devices were created on top of them (/dev/ubiblock*), locking the ubi 
partition and preventing the upgrade.


- although my devices would normally not use such upgrades, i could 
still take a whole ubi partition backup and then test ubinized 
sysupgrade with it on my devices. in fact, if you restore the ubi 
partition image without conserving the current configuration, then this 
procedure is the best way to do a backup/restore of the complete state 
of the router: kernel, rootfs, and overlay are completely saved and 
restored. btw, i think this should be documented. (and this is mostly 
the reason why i added gzip support on sysupgrade: ubinized images of 
backed-up ubi partitions compress like crazy.)


- my tests of ubinized sysupgrade worked after these changes but not 
before. specifically the fix is in: af34733593 base-files: fix ubinized 
nand sysupgrade



regarding your log:

- nand_do_platform_check succeeds:
https://github.com/openwrt/openwrt/blob/ac21dff5b67698c09f54a4b98d6f9f12af17edd4/package/base-files/files/lib/upgrade/nand.sh#L438-L469
https://gist.github.com/Lanchon/f24ea9c16eda5ffaa5085a7b240238db#file-imx6dl-gw52xx-ubinized-sysupgrade-log-txt-L192

- next comes the actual nand_do_flash_file:
https://github.com/openwrt/openwrt/blob/ac21dff5b67698c09f54a4b98d6f9f12af17edd4/package/base-files/files/lib/upgrade/nand.sh#L379-L405
https://gist.github.com/Lanchon/f24ea9c16eda5ffaa5085a7b240238db#file-imx6dl-gw52xx-ubinized-sysupgrade-log-txt-L2061

- it is determined that passed file is a ubi partition image, so 
nand_upgrade_ubinized is invoked:

https://github.com/openwrt/openwrt/blob/ac21dff5b67698c09f54a4b98d6f9f12af17edd4/package/base-files/files/lib/upgrade/nand.sh#L260-L269
https://gist.github.com/Lanchon/f24ea9c16eda5ffaa5085a7b240238db#file-imx6dl-gw52xx-ubinized-sysupgrade-log-txt-L2088

nand_upgrade_ubinized is basically a one-liner:
${gz}cat "$ubi_file" | ubiformat "/dev/mtd$mtdnum" -y -f - && ubiattach 
-m "$mtdnum"


cat/zcat the image, feeding that to ubiformat -f - which writes it.


and the write does take place, but take a look:

---

+ cat /tmp/nandnew.ubi
+ ubiformat /dev/mtd2 -y -f -
ubiformat: mtd2 (nand), size 250609664 bytes (239.0 MiB), 1912 
eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes


libscan: scanning eraseblock 0 --  0 % complete
libscan: scanning eraseblock 1 --  0 % complete
libscan: scanning eraseblock 2 --  0 % complete
   ...
libscan: scanning eraseblock 1868 -- 97 % complete

libscan: scanning eraseblock
[  207.876200] ci_hdrc ci_hdrc.1: remove, state 1
1869 -- 97 % complete

libscan:
[  207.883339] usb usb2: USB disconnect, device number 1
scanning eraseblock 1870 -- 97 %
[  207.891238] usb 2-1: USB disconnect, device number 2
complete

libscan: scanning eras
[  207.901522] ci_hdrc ci_hdrc.1: USB bus 2 deregistered
eblock 1871 -- 97 % complete

libscan: scanning eraseblock 1872
[  207.910396] ci_hdrc ci_hdrc.0: remove, state 4
 -- 97 % complete

libscan: scan
[  207.917055] usb usb1: USB disconnect, device number 1
ning eraseblock 1873 -- 98 % comp
[  207.925651] ci_hdrc ci_hdrc.0: USB bus 1 deregistered
lete

libscan: scanning eraseblo
[  207.934010] imx2-wdt 20bc000.watchdog: Device shutdown: Expect reboot!
ck 1874 -- 98 % complete

libsca
[  207.942382] reboot: Restarting system

---


while sysupgrade is flashing UBI the partition, the system is rebooted; 
i don't know why.


here are the cleaned-up kernel messages:

[  207.876200] ci_hdrc ci_hdrc.1: remove, state 1
[  207.883339] usb usb2: USB disconnect, device number 1
[  207.891238] usb 2-1: USB disconnect, device number 2
[  207.901522] ci_hdrc ci_hdrc.1: USB bus 2 deregistered
[  207.910396] ci_hdrc ci_hdrc.0: remove, state 4
[  207.917055] usb usb1: USB disconnect, device number 1
[  207.925651] ci_hdrc ci_hdrc.0: USB bus 1 deregistered
[  207.934010] imx2-wdt 20bc000.watchdog: Device 

Re: sysupgrade broken on imx nand targets (and maybe others too)

2023-01-23 Thread Lanchon

hi Koen,

thanks for this detailed report, i'll try to take a look at it tonight.

thank you again.



On 1/23/23 12:37, Koen Vandeputte wrote:

Hi Rodrigo,

After a long absence and now testing the latest master, I noticed that
imx nand flash sysupgrade was broken:

expected behaviour:
- scan the nand
- write image
- format empty space
-reboot

Seen behaviour:
- Scan the nand
- reboots

I traced it back to this batch of commits by you:

9d1e687da3 base-files: verify nand sysupgrade images
9710712120 base-files: accept gzipped nand sysupgrade images
af34733593 base-files: fix ubinized nand sysupgrade
e25e6d8e54 base-files: fix and clean up nand sysupgrade code


It can be easily confirmed by reverting /lib/upgrade/nand.sh with a
version before these commits are applied to it.

I added a "set -x" to nand.sh to get more detailed logs:
https://pastebin.com/raw/yxY0SK1x

Any idea?

Thanks,

Koen



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


[patch] logread : add option to exclude lines matching regex

2023-01-23 Thread Dan Brown
From: Dan Brown 

logread: add option to exclude lines matching regex

This adds another filtering option (-E) to exclude lines that match a
regex, similar to the existing include option (-e):
-einclude messages matching a regexp
-Eexclude messages matching a regexp

The two options -e and -E are independent, and lines must pass both
tests to appear in program output.
* 'logread -E dhcp' will display all lines that do not contain the string "dhcp"
* 'logread -e dhcp -E 192.168' will display all lines that contain
"dhcp" and do not contain "192.168"

signed off by: Dan Brown, danbr...@gmail.com
---
Further update: Sorry for yet another (third) version of this. I
discovered that the regex match checked only the contents of the
message part of the log, but I want to match the entire formatted
logline with program, priority, etc. This new version does that. This
probably deserves some discussion because it changes the behavior of
the existing '-e' option, and may not be what some people want to
match on. Are there use cases that depend on matching only the message
part of the log line?

Update: this newer (second) version fixes a bug where the -e and -E options
would be mutually exclusive instead of independent. Sorry.

The motivation for adding this option to logread is to remove frequent
and uninteresting loglines from being displayed in Luci. One way to
achieve this is to install an alternate logging system (syslog-ng or
rsyslog) and set up rules for filtering there. Instead of that, I
would prefer to use the simpler and standard logd/ubox method with
this small enhancement.

This patch applies to the ubox project
(https://git.openwrt.org/?p=project/ubox.git;a=summary)

--- log/logread.c.orig2023-01-23 13:16:59.502476137 +0100
+++ log/logread.c2023-01-23 20:05:48.478603378 +0100
@@ -60,8 +60,9 @@ static const struct blobmsg_policy log_p

 static struct uloop_timeout retry;
 static struct uloop_fd sender;
-static regex_t regexp_preg;
-static const char *log_file, *log_ip, *log_port, *log_prefix,
*pid_file, *hostname, *regexp_pattern;
+static regex_t regexp_preg_include, regexp_preg_exclude;
+static const char *log_file, *log_ip, *log_port, *log_prefix, *pid_file;
+static const char *hostname, *regexp_pattern_include, *regexp_pattern_exclude;
 static int log_type = LOG_STDOUT;
 static int log_size, log_udp, log_follow, log_trailer_null = 0;
 static int log_timestamp;
@@ -157,9 +158,6 @@ static int log_notify(struct blob_attr *
 return 0;

 m = blobmsg_get_string(tb[LOG_MSG]);
-if (regexp_pattern &&
-regexec(_preg, m, 0, NULL, 0) == REG_NOMATCH)
-return 0;
 t = blobmsg_get_u64(tb[LOG_TIME]) / 1000;
 if (log_timestamp) {
 t_ms = blobmsg_get_u64(tb[LOG_TIME]) % 1000;
@@ -188,6 +186,12 @@ static int log_notify(struct blob_attr *
 if (blobmsg_get_u32(tb[LOG_SOURCE]) == SOURCE_KLOG)
 strncat(buf, "kernel: ", sizeof(buf) - strlen(buf) - 1);
 strncat(buf, m, sizeof(buf) - strlen(buf) - 1);
+if (regexp_pattern_include &&
+regexec(_preg_include, buf, 0, NULL, 0) == REG_NOMATCH)
+return 0;
+if (regexp_pattern_exclude &&
+regexec(_preg_exclude, buf, 0, NULL, 0) != REG_NOMATCH)
+return 0;
 if (log_udp)
 err = write(sender.fd, buf, strlen(buf));
 else {
@@ -211,6 +215,12 @@ static int log_notify(struct blob_attr *
 getcodetext(LOG_FAC(p) << 3, facilitynames),
 getcodetext(LOG_PRI(p), prioritynames),
 (blobmsg_get_u32(tb[LOG_SOURCE])) ? ("") : (" kernel:"), m);
+if (regexp_pattern_include &&
+regexec(_preg_include, buf, 0, NULL, 0) == REG_NOMATCH)
+return 0;
+if (regexp_pattern_exclude &&
+regexec(_preg_exclude, buf, 0, NULL, 0) != REG_NOMATCH)
+return 0;
 ret = write(sender.fd, buf, strlen(buf));
 }

@@ -226,7 +236,8 @@ static int usage(const char *prog)
 "Options:\n"
 "-s Path to ubus socket\n"
 "-lGot only the last 'count' messages\n"
-"-eFilter messages with a regexp\n"
+"-einclude log lines that match a regexp\n"
+"-Eexclude log lines that match a regexp\n"
 "-r Stream message to a server\n"
 "-FLog file\n"
 "-SLog size\n"
@@ -313,7 +324,7 @@ int main(int argc, char **argv)

 signal(SIGPIPE, SIG_IGN);

-while ((ch = getopt(argc, argv, "u0fcs:l:z:Z:r:F:p:S:P:h:e:t")) != -1) {
+while ((ch = getopt(argc, argv, "u0fcs:l:z:Z:r:F:p:S:P:h:e:E:t")) != -1) {
 switch (ch) {
 case 'u':
 log_udp = 1;
@@ -361,8 +372,13 @@ int main(int argc, char **argv)
 hostname = optarg;
 break;
 case 'e':
-if (!regcomp(_preg, optarg, REG_NOSUB)) {
-regexp_pattern = 

Re: mt7621 GPIO mapping mystery

2023-01-23 Thread Peter Naulls

On 1/22/23 13:58, Daniel Santos wrote:




[snip]

Thanks Daniel and all the others (to many to mention).  Yes, I should have read 
the datasheet much earlier, so in the end I really have only myself to blame.


The fix was simply to add back in the "rgmii2" group back into the gpio group. 
I believe I previously removed this in order to try and figure out the handling 
of the ethernet switch in the newer kernel - another poorly documented and very 
confusing change that got made that took me a while to figure out (clue,

swconfig is deprecated and no longer works on mt7621).

As a very long time embedded developer, but only occasional kernel hacker,
this stuff is hard to keep track of. I understand that OpenWrt is highly
volunteer driven with limited resources, and to some extent we're subject
to the vagaries of mainstream kernel hacking, but this clearly could have
been better documented - again, I don't think that's anyone's fault, but
it's still frustrating.

I agree with the sentiment that OpenWrt could be more hacker friendly. I
don't particularly need to dynamic pin grouping, but it might have
been nice to know about in kernel reporting or libgpiod output, etc.

I would kindly suggest that major subsystem changes in the future be updated
in the wiki.  Even if it's just a link to relevant kernel development.



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


sysupgrade broken on imx nand targets (and maybe others too)

2023-01-23 Thread Koen Vandeputte
Hi Rodrigo,

After a long absence and now testing the latest master, I noticed that
imx nand flash sysupgrade was broken:

expected behaviour:
- scan the nand
- write image
- format empty space
-reboot

Seen behaviour:
- Scan the nand
- reboots

I traced it back to this batch of commits by you:

9d1e687da3 base-files: verify nand sysupgrade images
9710712120 base-files: accept gzipped nand sysupgrade images
af34733593 base-files: fix ubinized nand sysupgrade
e25e6d8e54 base-files: fix and clean up nand sysupgrade code


It can be easily confirmed by reverting /lib/upgrade/nand.sh with a
version before these commits are applied to it.

I added a "set -x" to nand.sh to get more detailed logs:
https://pastebin.com/raw/yxY0SK1x

Any idea?

Thanks,

Koen

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


[patch] logread : add option to exclude lines matching regex

2023-01-23 Thread Dan Brown
From: Dan Brown 

logread: add option to exclude lines matching regex

This adds another filtering option (-E) to exclude lines that match a
regex, similar to the existing include option (-e):
-einclude messages matching a regexp
-Eexclude messages matching a regexp

The two options -e and -E are independent, and lines must pass both
tests to appear in program output.
* 'logread -E dhcp' will display all lines that do not contain the string "dhcp"
* 'logread -e dhcp -E 192.168' will display all lines that contain
"dhcp" and do not contain "192.168"

signed off by: Dan Brown, danbr...@gmail.com
---
Update: this newer version fixes a bug where the -e and -E options
would be mutually exclusive instead of independent. Sorry.

The motivation for adding this option to logread is to remove frequent
and uninteresting loglines from being displayed in Luci. One way to
achieve this is to install an alternate logging system (syslog-ng or
rsyslog) and set up rules for filtering there. Instead of that, I
would prefer to use the simpler and standard logd/ubox method with
this small enhancement.

This patch applies to the ubox project
(https://git.openwrt.org/?p=project/ubox.git;a=summary)

--- log/logread.c.orig2023-01-23 13:16:59.502476137 +0100
+++ log/logread.c2023-01-23 14:28:40.199440398 +0100
@@ -60,8 +60,9 @@ static const struct blobmsg_policy log_p

 static struct uloop_timeout retry;
 static struct uloop_fd sender;
-static regex_t regexp_preg;
-static const char *log_file, *log_ip, *log_port, *log_prefix,
*pid_file, *hostname, *regexp_pattern;
+static regex_t regexp_preg_include, regexp_preg_exclude;
+static const char *log_file, *log_ip, *log_port, *log_prefix, *pid_file;
+static const char *hostname, *regexp_pattern_include, *regexp_pattern_exclude;
 static int log_type = LOG_STDOUT;
 static int log_size, log_udp, log_follow, log_trailer_null = 0;
 static int log_timestamp;
@@ -157,8 +158,11 @@ static int log_notify(struct blob_attr *
 return 0;

 m = blobmsg_get_string(tb[LOG_MSG]);
-if (regexp_pattern &&
-regexec(_preg, m, 0, NULL, 0) == REG_NOMATCH)
+if (regexp_pattern_include &&
+regexec(_preg_include, m, 0, NULL, 0) == REG_NOMATCH)
+return 0;
+if (regexp_pattern_exclude &&
+regexec(_preg_exclude, m, 0, NULL, 0) != REG_NOMATCH)
 return 0;
 t = blobmsg_get_u64(tb[LOG_TIME]) / 1000;
 if (log_timestamp) {
@@ -226,7 +230,8 @@ static int usage(const char *prog)
 "Options:\n"
 "-s Path to ubus socket\n"
 "-lGot only the last 'count' messages\n"
-"-eFilter messages with a regexp\n"
+"-einclude messages matching a regexp\n"
+"-Eexclude messages matching a regexp\n"
 "-r Stream message to a server\n"
 "-FLog file\n"
 "-SLog size\n"
@@ -313,7 +318,7 @@ int main(int argc, char **argv)

 signal(SIGPIPE, SIG_IGN);

-while ((ch = getopt(argc, argv, "u0fcs:l:z:Z:r:F:p:S:P:h:e:t")) != -1) {
+while ((ch = getopt(argc, argv, "u0fcs:l:z:Z:r:F:p:S:P:h:e:E:t")) != -1) {
 switch (ch) {
 case 'u':
 log_udp = 1;
@@ -361,8 +366,13 @@ int main(int argc, char **argv)
 hostname = optarg;
 break;
 case 'e':
-if (!regcomp(_preg, optarg, REG_NOSUB)) {
-regexp_pattern = optarg;
+if (!regcomp(_preg_include, optarg, REG_NOSUB)) {
+regexp_pattern_include = optarg;
+}
+break;
+case 'E':
+if (!regcomp(_preg_exclude, optarg, REG_NOSUB)) {
+regexp_pattern_exclude = optarg;
 }
 break;
 case 't':

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


[PATCH] x86: add Barracuda Networks F12 interfaces

2023-01-23 Thread Tomasz Maciej Nowak
From: Tomasz Maciej Nowak 

Match interface numbers with printed numbers on device enclosure and
assign first port as WAN interface.

Notes
Serial console is available through RJ-45 port with Cisco pinout
baud: 19200, parity: none, flow control: none
The device is setup with UEFI. To enter setup hold DEL or ESC key on
boot. Default UEFI Administrator password is: bcndk1
For users using graphics IC it's advisable to disable display with:
i915.disable_display=1
appending to kernel command line inside bootloader, to save about
0.5-0.6W energy on idle.
For users not using graphics IC, disable it in UEFI, this will save about
1.5W energy on idle.
Pins marked CN19 are ATX power On/Off button.

Signed-off-by: Tomasz Maciej Nowak 
---
 target/linux/x86/base-files/etc/board.d/02_network | 8 
 1 file changed, 8 insertions(+)

diff --git a/target/linux/x86/base-files/etc/board.d/02_network 
b/target/linux/x86/base-files/etc/board.d/02_network
index 5befba0a62d0..094a45f91483 100644
--- a/target/linux/x86/base-files/etc/board.d/02_network
+++ b/target/linux/x86/base-files/etc/board.d/02_network
@@ -8,6 +8,14 @@
 board_config_update
 
 case "$(board_name)" in
+barracuda-networks-inc-barracuda-ng-firewall-f12)
+   ucidef_set_network_device_path "eth1" 
"pci:00/:00:14.0/:01:00.0"
+   ucidef_set_network_device_path "eth2" 
"pci:00/:00:14.1/:02:00.0"
+   ucidef_set_network_device_path "eth3" 
"pci:00/:00:13.0/:03:00.0"
+   ucidef_set_network_device_path "eth4" 
"pci:00/:00:13.1/:04:00.0"
+   ucidef_set_network_device_path "eth5" 
"pci:00/:00:13.2/:05:00.0"
+   ucidef_set_interfaces_lan_wan "eth2 eth3 eth4 eth5" "eth1"
+   ;;
 cisco-mx100-hw)
ucidef_set_network_device_path "mgmt" 
"pci:00/:00:01.2/:03:00.3"
ucidef_set_network_device_path "wan" 
"pci:00/:00:01.2/:03:00.2"
-- 
2.39.1


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


[PATCH 1/2] x86: remove bootloader upgrade from preinit

2023-01-23 Thread Tomasz Maciej Nowak
From: Tomasz Maciej Nowak 

This hack was to bring all existing installations to the newest GRUB
version as fast as possible. Since 19.07.x is EoL we can assume this
task is completed. Now sysupgrade will solely be responsible for
bootloader upgrade.

Signed-off-by: Tomasz Maciej Nowak 
---
 .../lib/preinit/81_upgrade_bootloader  | 18 --
 .../x86/base-files/lib/upgrade/platform.sh |  3 +--
 2 files changed, 1 insertion(+), 20 deletions(-)
 delete mode 100644 
target/linux/x86/base-files/lib/preinit/81_upgrade_bootloader

diff --git a/target/linux/x86/base-files/lib/preinit/81_upgrade_bootloader 
b/target/linux/x86/base-files/lib/preinit/81_upgrade_bootloader
deleted file mode 100644
index 42f04d76a7ec..
--- a/target/linux/x86/base-files/lib/preinit/81_upgrade_bootloader
+++ /dev/null
@@ -1,18 +0,0 @@
-upgrade_bootloader() {
-   local diskdev
-
-   . /lib/upgrade/common.sh
-
-   if [ ! -f /boot/grub/upgraded ] && export_bootdevice && 
export_partdevice diskdev 0; then
-   part_magic_efi "/dev/$diskdev" && return 0
-   echo "(hd0) /dev/$diskdev" > /tmp/device.map
-   /usr/sbin/grub-bios-setup \
-   -m "/tmp/device.map" \
-   -d "/boot/grub" \
-   -r "hd0,msdos1" \
-   "/dev/$diskdev" \
-   && touch /boot/grub/upgraded
-   fi
-}
-
-[ "$INITRAMFS" = "1" ] || boot_hook_add preinit_main upgrade_bootloader
diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh 
b/target/linux/x86/base-files/lib/upgrade/platform.sh
index d8f2eba97ecb..5dad7a538a59 100644
--- a/target/linux/x86/base-files/lib/upgrade/platform.sh
+++ b/target/linux/x86/base-files/lib/upgrade/platform.sh
@@ -62,8 +62,7 @@ platform_do_bootloader_upgrade() {
-m "/tmp/device.map" \
-d "/tmp/boot/boot/grub" \
-r "hd0,${parttable}1" \
-   "/dev/$diskdev" \
-   && touch /tmp/boot/boot/grub/upgraded
+   "/dev/$diskdev"
 
umount /tmp/boot
fi
-- 
2.39.1


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


[PATCH 1/2] x86: remove bootloader upgrade from preinit

2023-01-23 Thread Tomasz Maciej Nowak
From: Tomasz Maciej Nowak 

This hack was to bring all existing installations to the newest GRUB
version as fast as possible. Since 19.07.x is EoL we can assume this
task is completed. Now sysupgrade will solely be responsible for
bootloader upgrade.

Signed-off-by: Tomasz Maciej Nowak 
---

Some glitch rejected this email. Re-sending.

 .../lib/preinit/81_upgrade_bootloader  | 18 --
 .../x86/base-files/lib/upgrade/platform.sh |  3 +--
 2 files changed, 1 insertion(+), 20 deletions(-)
 delete mode 100644 
target/linux/x86/base-files/lib/preinit/81_upgrade_bootloader

diff --git a/target/linux/x86/base-files/lib/preinit/81_upgrade_bootloader 
b/target/linux/x86/base-files/lib/preinit/81_upgrade_bootloader
deleted file mode 100644
index 42f04d76a7ec..
--- a/target/linux/x86/base-files/lib/preinit/81_upgrade_bootloader
+++ /dev/null
@@ -1,18 +0,0 @@
-upgrade_bootloader() {
-   local diskdev
-
-   . /lib/upgrade/common.sh
-
-   if [ ! -f /boot/grub/upgraded ] && export_bootdevice && 
export_partdevice diskdev 0; then
-   part_magic_efi "/dev/$diskdev" && return 0
-   echo "(hd0) /dev/$diskdev" > /tmp/device.map
-   /usr/sbin/grub-bios-setup \
-   -m "/tmp/device.map" \
-   -d "/boot/grub" \
-   -r "hd0,msdos1" \
-   "/dev/$diskdev" \
-   && touch /boot/grub/upgraded
-   fi
-}
-
-[ "$INITRAMFS" = "1" ] || boot_hook_add preinit_main upgrade_bootloader
diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh 
b/target/linux/x86/base-files/lib/upgrade/platform.sh
index d8f2eba97ecb..5dad7a538a59 100644
--- a/target/linux/x86/base-files/lib/upgrade/platform.sh
+++ b/target/linux/x86/base-files/lib/upgrade/platform.sh
@@ -62,8 +62,7 @@ platform_do_bootloader_upgrade() {
-m "/tmp/device.map" \
-d "/tmp/boot/boot/grub" \
-r "hd0,${parttable}1" \
-   "/dev/$diskdev" \
-   && touch /tmp/boot/boot/grub/upgraded
+   "/dev/$diskdev"
 
umount /tmp/boot
fi
-- 
2.39.1


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


[PATCH 2/2] grub2: re-add test module

2023-01-23 Thread Tomasz Maciej Nowak
From: Tomasz Maciej Nowak 

It seems more hardware needs early load of firmware when initialised
to work properly (at least Intel hardware). One of previous case is CPU
microcode, which this series[1] tried to change. The second one is Intel
graphics IC, which needs firmware for controlling DMC circuit (switch
conncted display to DC6 power state). As it stands, the i915 module is
built-in and it seems the hardware can't cope with firmware loaded
later from rootfs, it needs to be supplied when the module is loaded.
Unfortunately we need bootloader to handle the load of firmware in this
case, but as previously mentioned series[1], there was an error when
initrd was hardcoded, instead of testing existence for it and then
loading. To remedy this in later the 55b808e0c4be ('x86: image: add test
module to bootloader') was commited. Which was later accidentally
dropped when grub2 image creation was moved to packages. Therefore bring
back test module, so we can test for cases of existing firmware in
grub.cfg.

1. 
https://patchwork.ozlabs.org/project/openwrt/cover/20181120162044.16371-1-tome...@o2.pl

Fixes: 5a5df62d95f5 ("x86/grub2: move grub2 image creation to package")
Signed-off-by: Tomasz Maciej Nowak 
---
 package/boot/grub2/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/package/boot/grub2/Makefile b/package/boot/grub2/Makefile
index c4cc43de2e60..7d6cfd539594 100644
--- a/package/boot/grub2/Makefile
+++ b/package/boot/grub2/Makefile
@@ -122,14 +122,14 @@ define Package/grub2/install
-O i386-pc \
-c $(PKG_BUILD_DIR)/grub-early.cfg \
-o $(STAGING_DIR_IMAGE)/grub2/gpt-core.img \
-   at_keyboard biosdisk boot chain configfile fat linux ls 
part_gpt reboot search serial vga
+   at_keyboard biosdisk boot chain configfile fat linux ls 
part_gpt reboot search serial test vga
$(STAGING_DIR_HOST)/bin/grub-mkimage \
-d $(PKG_BUILD_DIR)/grub-core \
-p /boot/grub \
-O i386-pc \
-c ./files/grub-early.cfg \
-o $(STAGING_DIR_IMAGE)/grub2/generic-core.img \
-   at_keyboard biosdisk boot chain configfile ext2 linux ls 
part_msdos reboot search serial vga
+   at_keyboard biosdisk boot chain configfile ext2 linux ls 
part_msdos reboot search serial test vga
$(STAGING_DIR_HOST)/bin/grub-mkimage \
-d $(PKG_BUILD_DIR)/grub-core \
-p /boot/grub \
@@ -154,7 +154,7 @@ define Package/grub2-efi/install
-O $(CONFIG_ARCH)-efi \
-c $(PKG_BUILD_DIR)/grub-early.cfg \
-o $(STAGING_DIR_IMAGE)/grub2/boot$(if 
$(CONFIG_x86_64),x64,ia32).efi \
-   at_keyboard boot chain configfile fat linux ls part_gpt reboot 
serial efi_gop efi_uga
+   at_keyboard boot chain configfile fat linux ls part_gpt reboot 
serial test efi_gop efi_uga
$(STAGING_DIR_HOST)/bin/grub-mkimage \
-d $(PKG_BUILD_DIR)/grub-core \
-p /boot/grub \
-- 
2.39.1


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


[patch] logread : add option to exclude lines matching regex

2023-01-23 Thread Dan Brown
From: Dan Brown 

logread: add option to exclude lines matching regex

This adds another filtering option (-E) to exclude lines that match a
regex, similar to the existing include option (-e):
-einclude messages matching a regexp
-Eexclude messages matching a regexp

The two options -e and -E are independent, and lines must pass both
tests to appear in program output.
* 'logread -E dhcp' will display all lines that do not contain the string "dhcp"
* 'logread -e dhcp -E 192.168' will display all lines that contain
"dhcp" and do not contain "192.168"

signed off by: Dan Brown, danbr...@gmail.com
---

The motivation for adding this option to logread is to remove frequent
and uninteresting loglines from being displayed in Luci. One way to
achieve this is to install an alternate logging system (syslog-ng or
rsyslog) and set up rules for filtering there. Instead of that, I
would prefer to use the simpler and standard logd/ubox method with
this small enhancement.

This patch applies to the ubox project
(https://git.openwrt.org/?p=project/ubox.git;a=summary)

--- log/logread.c.orig2023-01-23 13:16:59.502476137 +0100
+++ log/logread.c2023-01-23 13:34:27.656416367 +0100
@@ -61,7 +61,8 @@ static const struct blobmsg_policy log_p
 static struct uloop_timeout retry;
 static struct uloop_fd sender;
 static regex_t regexp_preg;
-static const char *log_file, *log_ip, *log_port, *log_prefix,
*pid_file, *hostname, *regexp_pattern;
+static const char *log_file, *log_ip, *log_port, *log_prefix, *pid_file;
+static const char *hostname, *regexp_pattern_include, *regexp_pattern_exclude;
 static int log_type = LOG_STDOUT;
 static int log_size, log_udp, log_follow, log_trailer_null = 0;
 static int log_timestamp;
@@ -157,9 +158,12 @@ static int log_notify(struct blob_attr *
 return 0;

 m = blobmsg_get_string(tb[LOG_MSG]);
-if (regexp_pattern &&
+if (regexp_pattern_include &&
 regexec(_preg, m, 0, NULL, 0) == REG_NOMATCH)
 return 0;
+if (regexp_pattern_exclude &&
+regexec(_preg, m, 0, NULL, 0) != REG_NOMATCH)
+return 0;
 t = blobmsg_get_u64(tb[LOG_TIME]) / 1000;
 if (log_timestamp) {
 t_ms = blobmsg_get_u64(tb[LOG_TIME]) % 1000;
@@ -226,7 +230,8 @@ static int usage(const char *prog)
 "Options:\n"
 "-s Path to ubus socket\n"
 "-lGot only the last 'count' messages\n"
-"-eFilter messages with a regexp\n"
+"-einclude messages matching a regexp\n"
+"-Eexclude messages matching a regexp\n"
 "-r Stream message to a server\n"
 "-FLog file\n"
 "-SLog size\n"
@@ -313,7 +318,7 @@ int main(int argc, char **argv)

 signal(SIGPIPE, SIG_IGN);

-while ((ch = getopt(argc, argv, "u0fcs:l:z:Z:r:F:p:S:P:h:e:t")) != -1) {
+while ((ch = getopt(argc, argv, "u0fcs:l:z:Z:r:F:p:S:P:h:e:E:t")) != -1) {
 switch (ch) {
 case 'u':
 log_udp = 1;
@@ -362,7 +367,12 @@ int main(int argc, char **argv)
 break;
 case 'e':
 if (!regcomp(_preg, optarg, REG_NOSUB)) {
-regexp_pattern = optarg;
+regexp_pattern_include = optarg;
+}
+break;
+case 'E':
+if (!regcomp(_preg, optarg, REG_NOSUB)) {
+regexp_pattern_exclude = optarg;
 }
 break;
 case 't':

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


[PATCH 21.02 only] kernel: expose (unhide) CONFIG_ASN1 as ksmbd requirement

2023-01-23 Thread Rafał Miłecki
From: Rafał Miłecki 

OpenWrt provides kmod-asn1-decoder for CONFIG_ASN1 but selecting it
doesn't really work as expected. Kernel symbol is hidden and can be
actually selected only as a dependency. That works well for in-kernel
stuff but fails for external modules requiring ASN1 like ksmbd.

Modify kernel Kconfig to make CONFIG_ASN1 always selectable. It's
required to satisfy ksmbd dependencies cleanly (without hack like
selecting unrelated modules).

Link: http://lists.openwrt.org/pipermail/openwrt-devel/2023-January/040298.html
Signed-off-by: Rafał Miłecki 
---
 ...e-ASN1-explicitly-selectable-unhide-.patch | 30 +++
 1 file changed, 30 insertions(+)
 create mode 100644 
target/linux/generic/hack-5.4/252-init-Kconfig-make-ASN1-explicitly-selectable-unhide-.patch

diff --git 
a/target/linux/generic/hack-5.4/252-init-Kconfig-make-ASN1-explicitly-selectable-unhide-.patch
 
b/target/linux/generic/hack-5.4/252-init-Kconfig-make-ASN1-explicitly-selectable-unhide-.patch
new file mode 100644
index 00..62bf7f77d5
--- /dev/null
+++ 
b/target/linux/generic/hack-5.4/252-init-Kconfig-make-ASN1-explicitly-selectable-unhide-.patch
@@ -0,0 +1,30 @@
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= 
+Date: Mon, 23 Jan 2023 12:24:12 +0100
+Subject: [PATCH] init/Kconfig: make ASN1 explicitly selectable (unhide it)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Kernel developers assumed ASN1 symbol may be needed only by in-kernel
+code and they made it hidden. It is actually used by ksmbd version being
+developed in GitHub (there is also upstream one since Linux 5.15).
+
+To allow building ksmbd from GitHub cleanly allow selecting its
+dependency (CONFIG_ASN1) explicitly by unhiding it.
+
+Signed-off-by: Rafał Miłecki 
+---
+ init/Kconfig | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/init/Kconfig
 b/init/Kconfig
+@@ -2249,7 +2249,7 @@ config PADATA
+   bool
+ 
+ config ASN1
+-  tristate
++  tristate "ASN.1 grammar compiler"
+   help
+ Build a simple ASN.1 grammar compiler that produces a bytecode output
+ that can be interpreted by the ASN.1 stream decoder and used to
-- 
2.34.1


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


Re: ksmbd (actualy: nf-nathelper-extra = conntrack modules) slows down NAT

2023-01-23 Thread Rafał Miłecki

On 20.01.2023 21:29, Rafał Miłecki wrote:

It's a heads-up and my debugging summary for others that may find it helpful.


A kind of hint is commit c732305ad3f9 ("ksmbd: update to 3.4.1"):
https://git.openwrt.org/?p=feed/packages.git;a=commitdiff;h=c732305ad3f9f282f4601a2418c0f6595a3aa40e
("DEPENDS are hacks")

In OpenWrt's master branch actual dependency is kmod-asn1-decoder which seems
more correct. So we need to fix 21.02 only.

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