Re: [PATCH] rtl838x: clean up build instructions

2020-09-29 Thread Sander Vanheule
Hi Adrian,

On Tue, 2020-09-29 at 19:44 +0200, Adrian Schmutzler wrote:
> > -define Build/custom-uimage
> > -   mkimage -A $(LINUX_KARCH) \
> > -   -O linux -T kernel \
> > -   -C gzip -a $(KERNEL_LOADADDR) $(if $(UIMAGE_MAGIC),-M
> > $(UIMAGE_MAGIC),) \
> > -   -e $(if
> > $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
> > -   -n '$(1)' -d $@ $@.new
> > -   mv $@.new $@
> > -endef
> > +DEVICE_VARS += UIMAGE_MAGIC
> > 
> > +define Build/realtek-uImage
> > +   $(call Build/uImage,$(1) $(if $(UIMAGE_MAGIC),-M
> > $(UIMAGE_MAGIC),))
> > +endef
> 
> I like the idea, but don't like this hack with the argument.
> Either we can move the if here into image-commands.mk (which won't
> work if we need UIMAGE_MAGIC only for certain recipes ...), or I'd
> keep the old one.

I got this from target/linux/ath79/image/common-netgear.mk, but with
the optional UIMAGE_MAGIC from the original recipe. I do agree it's a
hack.

To check if the above works for both cases, I've tested this with
UIMAGE_MAGIC left undefined. Then I got the standard header magic, as
expected. So I'm not sure what you mean with "won't work if we only
need UIMAGE_MAGIC for certain recipes".

If you have no objections, I can try to turn this change into a
treewide patch so all platforms have access to (optional) custom uImage
magic bytes.

> >  define Device/Default
> >PROFILES = Default
> > -  KERNEL := kernel-bin | append-dtb | gzip | uImage gzip
> > -  KERNEL_INITRAMFS := kernel-bin | append-dtb | gzip | uImage gzip
> > +  KERNEL := kernel-bin | append-dtb | gzip | realtek-uImage gzip
> 
> So, can we assume that we always need the magic for this target?

As far as I can tell, the Realtek SDK seems to push OEMs to use a
custom magic. I've checked a few of the vendor firmware files for the
devices listed at https://biot.com/switches/hardware:
* Cisco SF220-24, SG220-28: 0x838
* D-Link DGS-1210 (Rev F): 0x12345000
* Netgear: per-device magic (like they do on other platforms)
* Zyxel GS1900-10HP, GS1900-24E: 0x8380

The default here appears to be 0x838, which could go into
Device/Default then.

For devices using an older SDK (with kernel 2.6), gzip compression is
used. On the GS110TPP, with a newer SDK (and 3.18 kernel), lzma
compression is used.

> > + KERNEL_INITRAMFS := $$(KERNEL)
> >DEVICE_DTS_DIR := ../dts
> >DEVICE_DTS = $$(SOC)_$(1)
> >SUPPORTED_DEVICES := $(subst _,$(comma),$(1))
> >IMAGES := sysupgrade.bin
> > -  IMAGE/sysupgrade.bin := append-kernel | pad-to 64k | append-
> > rootfs |
> > pad-rootfs | \
> > -   append-metadata | check-size
> > +  IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \
> > +  append-metadata | check-size
> 
> I'm not sure whether this is correct, but it should be a separate
> change anyway.

Okay, I'll take it out of this patch and (wait to) introduce it with
another patch.

I've also had a short discussion with Birger about this. The firmware
files provided by the vendors are uImages with an initramfs, so there
doesn't really appear to be any reference for the sysupgrade images
anyway. Persistence is achieved by using a separate config partition¹.

[1] https://biot.com/switches/gs110tpp#firmware

> >  endef
> > 
> >  define Device/allnet_all-sg8208m
> > +  $(Device/Default)
> 
> Device/Default is added to all devices by default (if it's defined)
> automatically!
> 
> https://github.com/openwrt/openwrt/blob/master/include/image.mk#L696
> 
> So, this would actually add it a second time.

That's my lack of experience the OpenWrt code shining through again,
I'll take it out.

Best,
Sander


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


Re: [PATCH 4/5] initd: Don't search the environment list if the watchdog, fd is initialized

2020-09-29 Thread John Crispin



On 29.09.20 21:00, Michael Jones wrote:

On Tue, Sep 29, 2020 at 1:59 PM John Crispin  wrote:


On 29.09.20 20:55, Michael Jones wrote:

On Tue, Sep 29, 2020 at 1:47 PM John Crispin  wrote:

On 29.09.20 18:22, Michael Jones wrote:

Signed-off-by: Michael Jones 
---
watchdog.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/watchdog.c b/watchdog.c
index 20830c3..ac5b656 100644
--- a/watchdog.c
+++ b/watchdog.c
@@ -49,11 +49,11 @@ static void watchdog_timeout_cb(struct uloop_timeout *t)

static int watchdog_open(bool cloexec)
{
-char *env = getenv("WDTFD");
-
if (wdt_fd >= 0)
return wdt_fd;

+char *env = getenv("WDTFD");
+
if (env) {
DEBUG(2, "Watchdog handover: fd=%s\n", env);
wdt_fd = atoi(env);

this breaks c99 compliance

   John


Do you mean C89 compliance? This should compile just fine in C99.

C99 was released 20 years ago, and C89 30 years ago. I'm personally
not interested in supporting either.

The patch can be modified, or used as inspiration, by someone who is
concerned about C89/C99 compliance and would like to see the
watchdog_open() function improved in this way.


variable declarations should always be at the start of the function.

  John


Sorry, I disagree, and there was no documentation that I could see
anywhere related to this on either the OpenWRT wiki, or the procd
repository.

Take the patches or leave them. I'm not going to make updates.


ok !

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


Re: [PATCH 4/5] initd: Don't search the environment list if the watchdog, fd is initialized

2020-09-29 Thread Michael Jones
On Tue, Sep 29, 2020 at 1:59 PM John Crispin  wrote:
>
>
> On 29.09.20 20:55, Michael Jones wrote:
> > On Tue, Sep 29, 2020 at 1:47 PM John Crispin  wrote:
> >>
> >> On 29.09.20 18:22, Michael Jones wrote:
> >>> Signed-off-by: Michael Jones 
> >>> ---
> >>>watchdog.c | 4 ++--
> >>>1 file changed, 2 insertions(+), 2 deletions(-)
> >>>
> >>> diff --git a/watchdog.c b/watchdog.c
> >>> index 20830c3..ac5b656 100644
> >>> --- a/watchdog.c
> >>> +++ b/watchdog.c
> >>> @@ -49,11 +49,11 @@ static void watchdog_timeout_cb(struct uloop_timeout 
> >>> *t)
> >>>
> >>>static int watchdog_open(bool cloexec)
> >>>{
> >>> -char *env = getenv("WDTFD");
> >>> -
> >>>if (wdt_fd >= 0)
> >>>return wdt_fd;
> >>>
> >>> +char *env = getenv("WDTFD");
> >>> +
> >>>if (env) {
> >>>DEBUG(2, "Watchdog handover: fd=%s\n", env);
> >>>wdt_fd = atoi(env);
> >> this breaks c99 compliance
> >>
> >>   John
> >>
> > Do you mean C89 compliance? This should compile just fine in C99.
> >
> > C99 was released 20 years ago, and C89 30 years ago. I'm personally
> > not interested in supporting either.
> >
> > The patch can be modified, or used as inspiration, by someone who is
> > concerned about C89/C99 compliance and would like to see the
> > watchdog_open() function improved in this way.
>
>
> variable declarations should always be at the start of the function.
>
>  John
>

Sorry, I disagree, and there was no documentation that I could see
anywhere related to this on either the OpenWRT wiki, or the procd
repository.

Take the patches or leave them. I'm not going to make updates.

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


Re: [PATCH 4/5] initd: Don't search the environment list if the watchdog, fd is initialized

2020-09-29 Thread John Crispin


On 29.09.20 20:55, Michael Jones wrote:

On Tue, Sep 29, 2020 at 1:47 PM John Crispin  wrote:


On 29.09.20 18:22, Michael Jones wrote:

Signed-off-by: Michael Jones 
---
   watchdog.c | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/watchdog.c b/watchdog.c
index 20830c3..ac5b656 100644
--- a/watchdog.c
+++ b/watchdog.c
@@ -49,11 +49,11 @@ static void watchdog_timeout_cb(struct uloop_timeout *t)

   static int watchdog_open(bool cloexec)
   {
-char *env = getenv("WDTFD");
-
   if (wdt_fd >= 0)
   return wdt_fd;

+char *env = getenv("WDTFD");
+
   if (env) {
   DEBUG(2, "Watchdog handover: fd=%s\n", env);
   wdt_fd = atoi(env);

this breaks c99 compliance

  John


Do you mean C89 compliance? This should compile just fine in C99.

C99 was released 20 years ago, and C89 30 years ago. I'm personally
not interested in supporting either.

The patch can be modified, or used as inspiration, by someone who is
concerned about C89/C99 compliance and would like to see the
watchdog_open() function improved in this way.



variable declarations should always be at the start of the function.

    John


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


Re: [PATCH 4/5] initd: Don't search the environment list if the watchdog, fd is initialized

2020-09-29 Thread Michael Jones
On Tue, Sep 29, 2020 at 1:47 PM John Crispin  wrote:
>
>
> On 29.09.20 18:22, Michael Jones wrote:
> > Signed-off-by: Michael Jones 
> > ---
> >   watchdog.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/watchdog.c b/watchdog.c
> > index 20830c3..ac5b656 100644
> > --- a/watchdog.c
> > +++ b/watchdog.c
> > @@ -49,11 +49,11 @@ static void watchdog_timeout_cb(struct uloop_timeout *t)
> >
> >   static int watchdog_open(bool cloexec)
> >   {
> > -char *env = getenv("WDTFD");
> > -
> >   if (wdt_fd >= 0)
> >   return wdt_fd;
> >
> > +char *env = getenv("WDTFD");
> > +
> >   if (env) {
> >   DEBUG(2, "Watchdog handover: fd=%s\n", env);
> >   wdt_fd = atoi(env);
>
> this breaks c99 compliance
>
>  John
>

Do you mean C89 compliance? This should compile just fine in C99.

C99 was released 20 years ago, and C89 30 years ago. I'm personally
not interested in supporting either.

The patch can be modified, or used as inspiration, by someone who is
concerned about C89/C99 compliance and would like to see the
watchdog_open() function improved in this way.

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


Re: [PATCH 4/5] initd: Don't search the environment list if the watchdog, fd is initialized

2020-09-29 Thread John Crispin


On 29.09.20 18:22, Michael Jones wrote:

Signed-off-by: Michael Jones 
---
  watchdog.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/watchdog.c b/watchdog.c
index 20830c3..ac5b656 100644
--- a/watchdog.c
+++ b/watchdog.c
@@ -49,11 +49,11 @@ static void watchdog_timeout_cb(struct uloop_timeout *t)
  
  static int watchdog_open(bool cloexec)

  {
-    char *env = getenv("WDTFD");
-
  if (wdt_fd >= 0)
      return wdt_fd;
  
+    char *env = getenv("WDTFD");

+
  if (env) {
      DEBUG(2, "Watchdog handover: fd=%s\n", env);
      wdt_fd = atoi(env);


this breaks c99 compliance

    John


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


RE: [PATCH] rtl838x: clean up build instructions

2020-09-29 Thread Adrian Schmutzler
Hi,

> -Original Message-
> From: openwrt-devel [mailto:openwrt-devel-boun...@lists.openwrt.org]
> On Behalf Of Sander Vanheule
> Sent: Dienstag, 29. September 2020 18:20
> To: openwrt-devel@lists.openwrt.org
> Cc: Sander Vanheule 
> Subject: [PATCH] rtl838x: clean up build instructions
> 
> The Device/Default recipe was defined, but never used. Move definitions
> that are not device-specific to Device/Default, and use it for allnet_all-
> sg8208m. This should make it more straightforward to add new devices.
> 
> The modified uImage recipe can also be simplified, similar to how
> ath79/common-netgear.mk does it.
> 
> Signed-off-by: Sander Vanheule 
> ---
>  target/linux/rtl838x/image/Makefile | 24 ++--
>  1 file changed, 10 insertions(+), 14 deletions(-)
> 
> diff --git a/target/linux/rtl838x/image/Makefile
> b/target/linux/rtl838x/image/Makefile
> index eef1fe0a33..0174e47449 100644
> --- a/target/linux/rtl838x/image/Makefile
> +++ b/target/linux/rtl838x/image/Makefile
> @@ -7,36 +7,32 @@ include $(INCLUDE_DIR)/image.mk  KERNEL_LOADADDR
> = 0x8000  KERNEL_ENTRY = 0x8400
> 
> -define Build/custom-uimage
> - mkimage -A $(LINUX_KARCH) \
> - -O linux -T kernel \
> - -C gzip -a $(KERNEL_LOADADDR) $(if $(UIMAGE_MAGIC),-M
> $(UIMAGE_MAGIC),) \
> - -e $(if
> $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
> - -n '$(1)' -d $@ $@.new
> - mv $@.new $@
> -endef
> +DEVICE_VARS += UIMAGE_MAGIC
> 
> +define Build/realtek-uImage
> + $(call Build/uImage,$(1) $(if $(UIMAGE_MAGIC),-M
> $(UIMAGE_MAGIC),))
> +endef

I like the idea, but don't like this hack with the argument.
Either we can move the if here into image-commands.mk (which won't work if we 
need UIMAGE_MAGIC only for certain recipes ...), or I'd keep the old one.

> 
>  define Device/Default
>PROFILES = Default
> -  KERNEL := kernel-bin | append-dtb | gzip | uImage gzip
> -  KERNEL_INITRAMFS := kernel-bin | append-dtb | gzip | uImage gzip
> +  KERNEL := kernel-bin | append-dtb | gzip | realtek-uImage gzip

So, can we assume that we always need the magic for this target?

> + KERNEL_INITRAMFS := $$(KERNEL)
>DEVICE_DTS_DIR := ../dts
>DEVICE_DTS = $$(SOC)_$(1)
>SUPPORTED_DEVICES := $(subst _,$(comma),$(1))
>IMAGES := sysupgrade.bin
> -  IMAGE/sysupgrade.bin := append-kernel | pad-to 64k | append-rootfs |
> pad-rootfs | \
> - append-metadata | check-size
> +  IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \
> +  append-metadata | check-size

I'm not sure whether this is correct, but it should be a separate change anyway.

>  endef
> 
>  define Device/allnet_all-sg8208m
> +  $(Device/Default)

Device/Default is added to all devices by default (if it's defined) 
automatically!

https://github.com/openwrt/openwrt/blob/master/include/image.mk#L696

So, this would actually add it a second time.

Best

Adrian

>SOC := rtl8382
>IMAGE_SIZE := 7168k
>DEVICE_VENDOR := ALLNET
>DEVICE_MODEL := ALL-SG8208M
>UIMAGE_MAGIC := 0x0006
> -  KERNEL := kernel-bin | append-dtb | gzip | custom-uimage 2.2.2.0
> -  KERNEL_INITRAMFS := kernel-bin | append-dtb | gzip | custom-uimage
> 2.2.2.0
> +  UIMAGE_NAME := 2.2.2.0
>DEVICE_PACKAGES := ip-full ip-bridge kmod-gpio-button-hotplug tc  endef
> TARGET_DEVICES += allnet_all-sg8208m
> --
> 2.26.2
> 
> 
> ___
> 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


[PATCH 1/5] initd: Add ubus argument to trigger watchdog tickle.

2020-09-29 Thread Michael Jones
Signed-off-by: Michael Jones 
---
 system.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/system.c b/system.c
index 0fb98f1..ef7943a 100644
--- a/system.c
+++ b/system.c
@@ -325,6 +325,7 @@ enum {
 WDT_TIMEOUT,
 WDT_MAGICCLOSE,
 WDT_STOP,
+    WDT_TICKLE,
 __WDT_MAX
 };
 
@@ -333,6 +334,7 @@ static const struct blobmsg_policy
watchdog_policy[__WDT_MAX] = {
 [WDT_TIMEOUT] = { .name = "timeout", .type = BLOBMSG_TYPE_INT32 },
 [WDT_MAGICCLOSE] = { .name = "magicclose", .type = BLOBMSG_TYPE_BOOL },
 [WDT_STOP] = { .name = "stop", .type = BLOBMSG_TYPE_BOOL },
+    [WDT_TICKLE] = { .name = "tickle", .type = BLOBMSG_TYPE_BOOL },
 };
 
 static int watchdog_set(struct ubus_context *ctx, struct ubus_object *obj,
@@ -367,6 +369,9 @@ static int watchdog_set(struct ubus_context *ctx,
struct ubus_object *obj,
     watchdog_timeout(timeout);
 }
 
+    if (tb[WDT_TICKLE] && blobmsg_get_bool(tb[WDT_TICKLE]))
+        watchdog_ping();
+
 if (tb[WDT_MAGICCLOSE])
     watchdog_set_magicclose(blobmsg_get_bool(tb[WDT_MAGICCLOSE]));
 
-- 
2.26.2


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


[PATCH 5/5] initd: Convert the watchdog_fd return value from char* to int

2020-09-29 Thread Michael Jones
This change improves the frequently called path of determining
if the watchdog is alive when responding to ubus transactions
at the expense of complicating the less frequently called code
of transitioning to the upgraded binary, and transitioning from
pre-init to procd.

Signed-off-by: Michael Jones 
---
 initd/preinit.c | 11 ---
 system.c    |  2 +-
 sysupgrade.c    |  8 +---
 watchdog.c  | 11 ++-
 watchdog.h  |  6 +++---
 5 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/initd/preinit.c b/initd/preinit.c
index 9dfe5c1..255ceeb 100644
--- a/initd/preinit.c
+++ b/initd/preinit.c
@@ -90,7 +90,7 @@ fail:
 static void
 spawn_procd(struct uloop_process *proc, int ret)
 {
-    char *wdt_fd = watchdog_fd();
+    int wdt_fd = watchdog_fd();
 char *argv[] = { "/sbin/procd", NULL};
 char dbg[2];
 
@@ -104,8 +104,13 @@ spawn_procd(struct uloop_process *proc, int ret)
 check_sysupgrade();
 
 DEBUG(2, "Exec to real procd now\n");
-    if (wdt_fd)
-        setenv("WDTFD", wdt_fd, 1);
+
+    if (wdt_fd >= 0) {
+        char fd_buf[12];
+        snprintf(fd_buf, sizeof(fd_buf), "%d", wdt_fd);
+        setenv("WDTFD", fd_buf, 1);
+    }
+
 check_dbglvl();
 if (debug > 0) {
     snprintf(dbg, 2, "%d", debug);
diff --git a/system.c b/system.c
index ef7943a..caae0ec 100644
--- a/system.c
+++ b/system.c
@@ -378,7 +378,7 @@ static int watchdog_set(struct ubus_context *ctx,
struct ubus_object *obj,
 if (tb[WDT_STOP])
     watchdog_set_stopped(blobmsg_get_bool(tb[WDT_STOP]));
 
-    if (watchdog_fd() == NULL)
+    if (watchdog_fd() < 0)
     status = "offline";
 else if (watchdog_get_stopped())
     status = "stopped";
diff --git a/sysupgrade.c b/sysupgrade.c
index fc588b0..20e1ef0 100644
--- a/sysupgrade.c
+++ b/sysupgrade.c
@@ -29,7 +29,7 @@ void sysupgrade_exec_upgraded(const char *prefix, char
*path,
           const char *backup, char *command,
           struct blob_attr *options)
 {
-    char *wdt_fd = watchdog_fd();
+    int wdt_fd = watchdog_fd();
 char *argv[] = { "/sbin/upgraded", NULL, NULL, NULL};
 struct blob_attr *option;
 int rem;
@@ -44,9 +44,11 @@ void sysupgrade_exec_upgraded(const char *prefix,
char *path,
 argv[1] = path;
 argv[2] = command;
 
-    if (wdt_fd) {
+    if (wdt_fd >= 0) {
+        char fd_buf[12];
+        snprintf(fd_buf, sizeof(fd_buf), "%d", wdt_fd);
     watchdog_set_cloexec(false);
-        setenv("WDTFD", wdt_fd, 1);
+        setenv("WDTFD", fd_buf, 1);
 }
 
 if (backup)
diff --git a/watchdog.c b/watchdog.c
index ac5b656..3c565d2 100644
--- a/watchdog.c
+++ b/watchdog.c
@@ -146,16 +146,9 @@ int watchdog_frequency(int frequency)
 return wdt_frequency;
 }
 
-char* watchdog_fd(void)
+int watchdog_fd(void)
 {
-    static char fd_buf[12];
-
-    if (wdt_fd < 0)
-        return NULL;
-
-    snprintf(fd_buf, sizeof(fd_buf), "%d", wdt_fd);
-
-    return fd_buf;
+    return wdt_fd;
 }
 
 void watchdog_init(int preinit)
diff --git a/watchdog.h b/watchdog.h
index 73c75d5..3c35d9a 100644
--- a/watchdog.h
+++ b/watchdog.h
@@ -19,7 +19,7 @@
 
 #ifndef DISABLE_INIT
 void watchdog_init(int preinit);
-char* watchdog_fd(void);
+int watchdog_fd(void);
 int watchdog_timeout(int timeout);
 int watchdog_frequency(int frequency);
 void watchdog_set_magicclose(bool val);
@@ -33,9 +33,9 @@ static inline void watchdog_init(int preinit)
 {
 }
 
-static inline char* watchdog_fd(void)
+static inline int watchdog_fd(void)
 {
-    return "";
+    return -1;
 }
 
 static inline int watchdog_timeout(int timeout)
-- 
2.26.2


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


[PATCH 2/5] initd: Re-use the watchdog_set_cloexec() function from, watchdog_open()

2020-09-29 Thread Michael Jones
Signed-off-by: Michael Jones 
---
 watchdog.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/watchdog.c b/watchdog.c
index 9d770b4..20b6e20 100644
--- a/watchdog.c
+++ b/watchdog.c
@@ -65,8 +65,7 @@ static int watchdog_open(bool cloexec)
 if (wdt_fd < 0)
     return wdt_fd;
 
-    if (cloexec)
-        fcntl(wdt_fd, F_SETFD, fcntl(wdt_fd, F_GETFD) | FD_CLOEXEC);
+    watchdog_set_cloexec(cloexec);
 
 return wdt_fd;
 }
-- 
2.26.2


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


[PATCH 3/5] initd: Ensure that watchdog frequency changes apply right away

2020-09-29 Thread Michael Jones
If the watchdog frequency is changed from high to low,
the watchdog won't be tickled again until the previous
period has expired, which may result in a watchdog timeout.
This change ensures that the new frequency is applied immediately.

Signed-off-by: Michael Jones 
---
 watchdog.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/watchdog.c b/watchdog.c
index 20b6e20..20830c3 100644
--- a/watchdog.c
+++ b/watchdog.c
@@ -140,6 +140,7 @@ int watchdog_frequency(int frequency)
 if (frequency) {
     DEBUG(4, "Set watchdog frequency: %ds\n", frequency);
     wdt_frequency = frequency;
+        watchdog_timeout_cb(_timeout);
 }
 
 return wdt_frequency;
-- 
2.26.2


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


[PATCH 4/5] initd: Don't search the environment list if the watchdog, fd is initialized

2020-09-29 Thread Michael Jones
Signed-off-by: Michael Jones 
---
 watchdog.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/watchdog.c b/watchdog.c
index 20830c3..ac5b656 100644
--- a/watchdog.c
+++ b/watchdog.c
@@ -49,11 +49,11 @@ static void watchdog_timeout_cb(struct uloop_timeout *t)
 
 static int watchdog_open(bool cloexec)
 {
-    char *env = getenv("WDTFD");
-
 if (wdt_fd >= 0)
     return wdt_fd;
 
+    char *env = getenv("WDTFD");
+
 if (env) {
     DEBUG(2, "Watchdog handover: fd=%s\n", env);
     wdt_fd = atoi(env);
-- 
2.26.2


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


[PATCH] rtl838x: clean up build instructions

2020-09-29 Thread Sander Vanheule
The Device/Default recipe was defined, but never used. Move definitions
that are not device-specific to Device/Default, and use it for
allnet_all-sg8208m. This should make it more straightforward to add new
devices.

The modified uImage recipe can also be simplified, similar to how
ath79/common-netgear.mk does it.

Signed-off-by: Sander Vanheule 
---
 target/linux/rtl838x/image/Makefile | 24 ++--
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/target/linux/rtl838x/image/Makefile 
b/target/linux/rtl838x/image/Makefile
index eef1fe0a33..0174e47449 100644
--- a/target/linux/rtl838x/image/Makefile
+++ b/target/linux/rtl838x/image/Makefile
@@ -7,36 +7,32 @@ include $(INCLUDE_DIR)/image.mk
 KERNEL_LOADADDR = 0x8000
 KERNEL_ENTRY = 0x8400
 
-define Build/custom-uimage
-   mkimage -A $(LINUX_KARCH) \
-   -O linux -T kernel \
-   -C gzip -a $(KERNEL_LOADADDR) $(if $(UIMAGE_MAGIC),-M 
$(UIMAGE_MAGIC),) \
-   -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
-   -n '$(1)' -d $@ $@.new
-   mv $@.new $@
-endef
+DEVICE_VARS += UIMAGE_MAGIC
 
+define Build/realtek-uImage
+   $(call Build/uImage,$(1) $(if $(UIMAGE_MAGIC),-M $(UIMAGE_MAGIC),))
+endef
 
 define Device/Default
   PROFILES = Default
-  KERNEL := kernel-bin | append-dtb | gzip | uImage gzip
-  KERNEL_INITRAMFS := kernel-bin | append-dtb | gzip | uImage gzip
+  KERNEL := kernel-bin | append-dtb | gzip | realtek-uImage gzip
+  KERNEL_INITRAMFS := $$(KERNEL)
   DEVICE_DTS_DIR := ../dts
   DEVICE_DTS = $$(SOC)_$(1)
   SUPPORTED_DEVICES := $(subst _,$(comma),$(1))
   IMAGES := sysupgrade.bin
-  IMAGE/sysupgrade.bin := append-kernel | pad-to 64k | append-rootfs | 
pad-rootfs | \
-   append-metadata | check-size
+  IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \
+  append-metadata | check-size
 endef
 
 define Device/allnet_all-sg8208m
+  $(Device/Default)
   SOC := rtl8382
   IMAGE_SIZE := 7168k
   DEVICE_VENDOR := ALLNET
   DEVICE_MODEL := ALL-SG8208M
   UIMAGE_MAGIC := 0x0006
-  KERNEL := kernel-bin | append-dtb | gzip | custom-uimage 2.2.2.0
-  KERNEL_INITRAMFS := kernel-bin | append-dtb | gzip | custom-uimage 2.2.2.0
+  UIMAGE_NAME := 2.2.2.0
   DEVICE_PACKAGES := ip-full ip-bridge kmod-gpio-button-hotplug tc
 endef
 TARGET_DEVICES += allnet_all-sg8208m
-- 
2.26.2


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


[PATCH 0/5] Improvements to the hardware watchdog code of procd

2020-09-29 Thread Michael Jones
This set of patches makes various minor improvements to the hardware
watchdog code of procd.

The first patch adds a new feature to allow the watchdog to be manually
tickled via ubus.

The other patches are minor optimizations and improvements.

Michael Jones (5):
  initd: Add ubus argument to trigger watchdog tickle.
  initd: Re-use the watchdog_set_cloexec() function from watchdog_open()
  initd: Ensure that watchdog frequency changes apply right away
  initd: Don't search the environment list if the watchdog fd is initialized
  initd: Convert the watchdog_fd return value from char* to int

 initd/preinit.c | 11 ---
 system.c    |  7 ++-
 sysupgrade.c    |  8 +---
 watchdog.c  | 19 ++-
 watchdog.h  |  6 +++---
 5 files changed, 28 insertions(+), 23 deletions(-)

-- 
2.26.2


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


Re: [PATCH] build, imagebuilder: Do not require compilers

2020-09-29 Thread Paul Spooren
On Sun Sep 27, 2020 at 11:07 AM HST, Sven Roederer wrote:
> The buildroot and SDK both require the compilers (gcc, g++) to be
> installed on the host system, however the ImageBuilder uses precompiled
> binaries.
>
> This patch changes the prerequirements checks to skip the checking for
> the compilers if running as ImageBuilder. A similar change has been
> made for libncurses-dev in 4a1a58a3e2d2.
>
> Signed-off-by: Sven Roederer 

Acked-by: Paul Spooren 

> ---
> include/prereq-build.mk | 4 
> 1 file changed, 4 insertions(+)
>
> diff --git a/include/prereq-build.mk b/include/prereq-build.mk
> index 4637c6ca50..f67a01299e 100644
> --- a/include/prereq-build.mk
> +++ b/include/prereq-build.mk
> @@ -26,6 +26,7 @@ $(eval $(call TestHostCommand,proper-umask, \
> Please build with umask 022 - other values produce broken packages, \
> umask | grep -xE 0?0[012][012]))
>  
> +ifndef IB
> $(eval $(call SetupHostCommand,gcc, \
> Please install the GNU C Compiler (gcc) 4.8 or later, \
> $(CC) -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?|10\.?)', \
> @@ -37,7 +38,9 @@ $(eval $(call TestHostCommand,working-gcc, \
> it appears to be broken, \
> echo 'int main(int argc, char **argv) { return 0; }' | \
> gcc -x c -o $(TMP_DIR)/a.out -))
> +endif
>  
> +ifndef IB
> $(eval $(call SetupHostCommand,g++, \
> Please install the GNU C++ Compiler (g++) 4.8 or later, \
> $(CXX) -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?|10\.?)', \
> @@ -50,6 +53,7 @@ $(eval $(call TestHostCommand,working-g++, \
> echo 'int main(int argc, char **argv) { return 0; }' | \
> g++ -x c++ -o $(TMP_DIR)/a.out - -lstdc++ && \
> $(TMP_DIR)/a.out))
> +endif
>  
> ifndef IB
> $(eval $(call TestHostCommand,ncurses, \
> --
> 2.20.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