Re: [LEDE-DEV] CPU locked at lowest frequency on BCM2078 targets
On 13-05-17 14:48, Bryan Mayland wrote: > Hello, I work on an open source project which uses the Raspberry Pi > with LEDE as the host board. I've noticed that the kernel config does > not include the BCM2835 cpufreq driver and therefore the CPU remains > locked at the frequency set by the bootloader. This severely degrades > the performance of these devices as the bootloader sets the CPU at the > lowest frequency. I've run some nbench-byte benchmarks on bcm2708 and > bcm2709 (32-bit) platforms: > Hi, thanks for pointing that out. > Can we get cpufreq, ondemand scaler, and default=ondemand for this > platform / two targets? If needed I can submit a patch / signoff, or > if there is a reason this should not be done I'd love to start a > discussion about it. Please test a build from my staging tree: https://git.lede-project.org/?p=lede/stintel/staging.git;a=summary Thanks, Stijn ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
Re: [LEDE-DEV] convention on uid/gid for packages
Hi Val, On Sat, May 13, 2017 at 06:23:29PM -0400, Val Kulkov wrote: > Is there any convention on the use of uid and gid when creating new > users or groups? Can someone point me to it, if it exists? > > I noticed that two packages, icecast and postfix, compete for the same uid=87: > > icecast's Makefile: > USERID:=icecast=87:icecast=87 > > postfix's postfix.init: > user_exists postfix || user_add postfix 87 This looks wrong to me (user_add in the init script)... > > There may be more packages competing for the same uid/gid's, I have > not fully researched it. > > I am preparing a new package, opendkim, which should be run as a > non-privileged user. For this, > USERID:=opendkim=:opendkim= seems appropriate, > but what numbers should I assign? I run into this issue before and believe that we should have a wiki page which allows registering static UIDs/GIDs at least for the packages which actually need that (ie. if a specific UID or GID is referenced in other packages, or scripts like firewall rules, ...). Grep'ing for USERID allows to automatically generate that list based on the currently available packages very easily. Examples from elsewhere for inspiration: FreeBSD got those lists https://svnweb.freebsd.org/ports/head/UIDs?view=markup https://svnweb.freebsd.org/ports/head/GIDs?view=markup linuxfromscratch got a much smaller list for essential/system UIDs/GIDs http://linuxfromscratch.org/blfs/view/svn/postlfs/users.html Cheers Daniel ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
Re: [LEDE-DEV] Sysupgrade on Mikrotik RB912
Hello, On Fri, May 12, 2017 at 2:35 PM, Felix Fietkauwrote: > On 2017-05-12 12:47, Edwin van Drunen wrote: >> Hello Sergey, >> >> When using sysupgrade on an RB912 running a full LEDE 17.01.1 to install a >> custom image made with the image builder, the kernel is installed just fine. >> Before and after the sysupgrade I booted OpenWRT so I could mount the YAFFS >> kernel partition and could verify that the kernel was updated and other >> files on the partition were removed (as a test I added a text file before). >> This shows that a partition image is successfully written to mtd5 when >> executing sysupgrade from a fully installed LEDE. >> >> So it seems to only be a problem when running sysupgrade from an initramfs >> image, which would be the way to go for a fresh install. >> I used the following initramfs image: >> https://downloads.lede-project.org/releases/17.01.1/targets/ar71xx/mikrotik/lede-17.01.1-ar71xx-mikrotik-vmlinux-initramfs.elf >> >> Is there something missing in the default initramfs image? >> Because I have no serial console and the ssh session is broken immediately >> after starting the sysupgrade, I also cannot see any error messages. > Hi Edwin, > > Based on the information you provided, I just found out that nand-utils > is missing in the initramfs image. I've just pushed a fix to master and > the 17.01 branch, so the next build should take care of this issue. > > https://git.lede-project.org/c536c50171 > Wow, good catch! Seem like that this is the real root cause of issue. I completely missed the fact that initramfs could be built without using of the nand-utils package, since I always use custom build images. -- Sergey ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
Re: [LEDE-DEV] convention on uid/gid for packages
On 05/13/2017 06:23 PM, Val Kulkov wrote: > Is there any convention on the use of uid and gid when creating new > users or groups? Can someone point me to it, if it exists? > > I noticed that two packages, icecast and postfix, compete for the same uid=87: > > icecast's Makefile: > USERID:=icecast=87:icecast=87 > > postfix's postfix.init: > user_exists postfix || user_add postfix 87 > > There may be more packages competing for the same uid/gid's, I have > not fully researched it. > > I am preparing a new package, opendkim, which should be run as a > non-privileged user. For this, > USERID:=opendkim=:opendkim= seems appropriate, > but what numbers should I assign? > > Val I think that it is possible to allow the package installer to randomly assign the UID/GID. "USERID:=user:group" This didn't work for all releases, so I didn't try it for Unbound. Maybe it is time to give it a chance. - Eric ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
[LEDE-DEV] convention on uid/gid for packages
Is there any convention on the use of uid and gid when creating new users or groups? Can someone point me to it, if it exists? I noticed that two packages, icecast and postfix, compete for the same uid=87: icecast's Makefile: USERID:=icecast=87:icecast=87 postfix's postfix.init: user_exists postfix || user_add postfix 87 There may be more packages competing for the same uid/gid's, I have not fully researched it. I am preparing a new package, opendkim, which should be run as a non-privileged user. For this, USERID:=opendkim=:opendkim= seems appropriate, but what numbers should I assign? Val ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
Re: [LEDE-DEV] [PATCH] ipq806x: Add nand boot support for ipq40xx AP-DK04.1-C1
On Sat, May 13, 2017 at 10:36 AM, Christian Lamparterwrote: > Hello Ram, > > On Thursday, May 11, 2017 8:39:46 PM CEST Christian Lamparter wrote: >> On Thursday, May 11, 2017 10:15:58 PM CEST Ram Chandra Jangir wrote: >> > I added nand pinmux in https://patchwork.ozlabs.org/patch/761243/ , >> > Could you please try with this, if it helps you. >> Thanks, I'll forward it to Chris Blake. He can test it once >> he returns. I'll let you know how it turned out. > > Chris reported: > [1.40] nand: device found, Manufacturer ID: 0x01, Chip ID: 0xf1 > [1.007580] nand: AMD/Spansion S34ML01G2 > [1.014146] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB > size: 64 > [1.018135] 11 ofpart partitions found on MTD device qcom_nand.0 > [1.025449] Creating 11 MTD partitions on "qcom_nand.0": > > so, it's working now. > > Regards, > Christian > > Hello Ram, First off, thank you very much for this patch and your work on the ipq40xx platform. I have been doing more testing, and it seems that some of the pins in pinctl are not defined to the correct function. This is what I am currently seeing on the board: [1.278649] ipq4019-pinctrl 100.pinctrl: invalid group "gpio57" for function "qpic_pad" [1.279841] ipq4019-pinctrl 100.pinctrl: invalid group "gpio58" for function "qpic_pad" [1.288214] ipq4019-pinctrl 100.pinctrl: invalid group "gpio59" for function "qpic_pad" [1.296508] ipq4019-pinctrl 100.pinctrl: invalid group "gpio60" for function "qpic_pad" [1.304905] ipq4019-pinctrl 100.pinctrl: invalid group "gpio64" for function "qpic_pad" [1.313190] ipq4019-pinctrl 100.pinctrl: invalid group "gpio65" for function "qpic_pad" [1.321522] ipq4019-pinctrl 100.pinctrl: invalid group "gpio66" for function "qpic_pad" [1.329856] ipq4019-pinctrl 100.pinctrl: invalid group "gpio67" for function "qpic_pad" [1.338190] ipq4019-pinctrl 100.pinctrl: invalid group "gpio68" for function "qpic_pad" With that said, NAND still inits and works. I was also able to clear up the errors by fixing the groups for each GPIO in my DTS with the help of Christian. Example of this is at https://pastebin.com/rQDY3z9c. Is this something specific with my board, or some other variation with your patch? I am new to this arch so please excuse me if any of this is noobish. :) Regards, Chris Blake ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
[LEDE-DEV] [PATCH v2 15/19] x86: sysupgrade: move partition table change check to platform_check_image
The staged sysupgrade will prevent us from using ask_bool in platform_do_upgrade; therefore, the check is moved to platform_check_image. Signed-off-by: Matthias Schiffer--- .../linux/x86/base-files/lib/upgrade/platform.sh | 29 +++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh index d3e9f360aa..81b349a818 100644 --- a/target/linux/x86/base-files/lib/upgrade/platform.sh +++ b/target/linux/x86/base-files/lib/upgrade/platform.sh @@ -1,13 +1,37 @@ platform_check_image() { + local diskdev partdev diff [ "$#" -gt 1 ] && return 1 case "$(get_magic_word "$1")" in - eb48|eb63) return 0;; + eb48|eb63) ;; *) echo "Invalid image type" return 1 ;; esac + + export_bootdevice && export_partdevice diskdev 0 || { + echo "Unable to determine upgrade device" + return 1 + } + + get_partitions "/dev/$diskdev" bootdisk + + #extract the boot sector from the image + get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b 2>/dev/null + + get_partitions /tmp/image.bs image + + #compare tables + diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)" + + rm -f /tmp/image.bs /tmp/partmap.bootdisk /tmp/partmap.image + + if [ -n "$diff" ]; then + echo "Partition layout has changed. Full image will be written." + ask_bool 0 "Abort" && exit 1 + return 0 + fi } platform_copy_config() { @@ -36,9 +60,6 @@ platform_do_upgrade() { #compare tables diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)" if [ -n "$diff" ]; then - echo "Partition layout is changed. Full image will be written." - ask_bool 0 "Abort" && exit - get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync return 0 fi -- 2.13.0 ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
[LEDE-DEV] [PATCH v2 16/19] x86: sysupgrade: refactor platform_do_upgrade
By returning early when no upgrade device can be found and handling the SAVE_PARTITIONS=0 case differently, we can get rid of two levels of if. Signed-off-by: Matthias Schiffer--- .../linux/x86/base-files/lib/upgrade/platform.sh | 69 +++--- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh index 81b349a818..4fa71999be 100644 --- a/target/linux/x86/base-files/lib/upgrade/platform.sh +++ b/target/linux/x86/base-files/lib/upgrade/platform.sh @@ -47,40 +47,43 @@ platform_copy_config() { platform_do_upgrade() { local diskdev partdev diff - if export_bootdevice && export_partdevice diskdev 0; then - sync - if [ "$SAVE_PARTITIONS" = "1" ]; then - get_partitions "/dev/$diskdev" bootdisk - - #extract the boot sector from the image - get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b - - get_partitions /tmp/image.bs image - - #compare tables - diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)" - if [ -n "$diff" ]; then - get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync - return 0 - fi - - #iterate over each partition from the image and write it to the boot disk - while read part start size; do - if export_partdevice partdev $part; then - echo "Writing image to /dev/$partdev..." - get_image "$@" | dd of="/dev/$partdev" ibs="512" obs=1M skip="$start" count="$size" conv=fsync - else - echo "Unable to find partition $part device, skipped." - fi - done < /tmp/partmap.image - - #copy partition uuid - echo "Writing new UUID to /dev/$diskdev..." - get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync + export_bootdevice && export_partdevice diskdev 0 || { + echo "Unable to determine upgrade device" + return 1 + } + + sync + + if [ "$SAVE_PARTITIONS" = "1" ]; then + get_partitions "/dev/$diskdev" bootdisk + + #extract the boot sector from the image + get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b + + get_partitions /tmp/image.bs image + + #compare tables + diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)" + else + diff=1 + fi + + if [ -n "$diff" ]; then + get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync + return 0 + fi + + #iterate over each partition from the image and write it to the boot disk + while read part start size; do + if export_partdevice partdev $part; then + echo "Writing image to /dev/$partdev..." + get_image "$@" | dd of="/dev/$partdev" ibs="512" obs=1M skip="$start" count="$size" conv=fsync else - get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync + echo "Unable to find partition $part device, skipped." fi + done < /tmp/partmap.image - sleep 1 - fi + #copy partition uuid + echo "Writing new UUID to /dev/$diskdev..." + get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync } -- 2.13.0 ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
[LEDE-DEV] [PATCH v2 19/19] sunxi: sysupgrade: sync with x86
sunxi sysupgrade was based on the x86 implementation; sync fixes and other changes from the current x86 version: x86: fix sysupgrades on disks with 4k block size x86: sysupgrade: move partition table change check to platform_check_image x86: sysupgrade: refactor platform_do_upgrade x86: sysupgrade: explicitly rescan disk after writing partition table Signed-off-by: Matthias Schiffer--- target/linux/sunxi/Makefile| 2 +- .../linux/sunxi/base-files/lib/upgrade/platform.sh | 120 - 2 files changed, 72 insertions(+), 50 deletions(-) diff --git a/target/linux/sunxi/Makefile b/target/linux/sunxi/Makefile index 3c2f14b841..f8b8aa750a 100644 --- a/target/linux/sunxi/Makefile +++ b/target/linux/sunxi/Makefile @@ -28,6 +28,6 @@ KERNELNAME:=zImage dtbs include $(INCLUDE_DIR)/target.mk DEFAULT_PACKAGES += uboot-envtools -DEFAULT_PACKAGES += mkf2fs e2fsprogs +DEFAULT_PACKAGES += partx-utils mkf2fs e2fsprogs $(eval $(call BuildTarget)) diff --git a/target/linux/sunxi/base-files/lib/upgrade/platform.sh b/target/linux/sunxi/base-files/lib/upgrade/platform.sh index 776bdf53bf..88ef4790e9 100644 --- a/target/linux/sunxi/base-files/lib/upgrade/platform.sh +++ b/target/linux/sunxi/base-files/lib/upgrade/platform.sh @@ -1,5 +1,28 @@ platform_check_image() { - true + local diskdev partdev diff + + export_bootdevice && export_partdevice diskdev -2 || { + echo "Unable to determine upgrade device" + return 1 + } + + get_partitions "/dev/$diskdev" bootdisk + + #extract the boot sector from the image + get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b 2>/dev/null + + get_partitions /tmp/image.bs image + + #compare tables + diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)" + + rm -f /tmp/image.bs /tmp/partmap.bootdisk /tmp/partmap.image + + if [ -n "$diff" ]; then + echo "Partition layout has changed. Full image will be written." + ask_bool 0 "Abort" && exit 1 + return 0 + fi } platform_copy_config() { @@ -13,55 +36,54 @@ platform_copy_config() { } platform_do_upgrade() { - local diskdev partdev ibs diff - - if export_bootdevice && export_partdevice diskdev -2; then - sync - if [ "$SAVE_PARTITIONS" = "1" ]; then - get_partitions "/dev/$diskdev" bootdisk - - #get block size - if [ -f "/sys/block/$diskdev/queue/physical_block_size" ]; then - ibs="$(cat "/sys/block/$diskdev/queue/physical_block_size")" - else - ibs=512 - fi - - #extract the boot sector from the image - get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b - - get_partitions /tmp/image.bs image - - #compare tables - diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)" - if [ -n "$diff" ]; then - echo "Partition layout is changed. Full image will be written." - ask_bool 0 "Abort" && exit - - get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync - return 0 - fi - - #write uboot image - get_image "$@" | dd of="$diskdev" bs=1024 skip=8 seek=8 count=1016 conv=fsync - #iterate over each partition from the image and write it to the boot disk - while read part start size; do - part="$(($part - 2))" - if export_partdevice partdev $part; then - echo "Writing image to /dev/$partdev..." - get_image "$@" | dd of="/dev/$partdev" ibs="$ibs" obs=1M skip="$start" count="$size" conv=fsync - else - echo "Unable to find partition $part device, skipped." - fi - done < /tmp/partmap.image - - #copy partition uuid - echo "Writing new UUID to /dev/$diskdev..." - get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync + local diskdev partdev diff + + export_bootdevice && export_partdevice diskdev -2 || { + echo "Unable to determine upgrade device" + return 1 + } + + sync + + if [ "$SAVE_PARTITIONS" = "1" ]; then + get_partitions "/dev/$diskdev" bootdisk + + #extract the boot sector from the image +
[LEDE-DEV] [PATCH v2 17/19] x86: sysupgrade: explicitly rescan disk after writing partition table
This should ensure that the kernel partition can be mounted in platform_copy_config when its size has changed. Signed-off-by: Matthias Schiffer--- target/linux/x86/base-files/lib/upgrade/platform.sh | 6 ++ 1 file changed, 6 insertions(+) diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh index 4fa71999be..439ba8f512 100644 --- a/target/linux/x86/base-files/lib/upgrade/platform.sh +++ b/target/linux/x86/base-files/lib/upgrade/platform.sh @@ -70,6 +70,12 @@ platform_do_upgrade() { if [ -n "$diff" ]; then get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync + + # Separate removal and addtion is necessary; otherwise, partition 1 + # will be missing if it overlaps with the old partition 2 + partx -d - "/dev/$diskdev" + partx -a - "/dev/$diskdev" + return 0 fi -- 2.13.0 ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
[LEDE-DEV] [PATCH v2 07/19] base-files: always use staged sysupgrade
Support for the -d and -p options is dropped; it may be added again at some point by adding these flags to the ubus sysupgrade call. A downside of this is that we get a lot less information about the progress of the upgrade: as soon as the actual upgrade starts, all shell sessions are killed to allow unmounting the root filesystem. Signed-off-by: Matthias Schiffer--- package/base-files/files/lib/upgrade/common.sh | 123 +++-- package/base-files/files/lib/upgrade/nand.sh | 60 ++-- package/base-files/files/lib/upgrade/stage2| 50 ++ package/base-files/files/sbin/sysupgrade | 77 +--- 4 files changed, 162 insertions(+), 148 deletions(-) create mode 100755 package/base-files/files/lib/upgrade/stage2 diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh index e3519ca2cb..17248c2b1d 100644 --- a/package/base-files/files/lib/upgrade/common.sh +++ b/package/base-files/files/lib/upgrade/common.sh @@ -56,7 +56,6 @@ run_ramfs() { # [...] /bin/rm /usr/bin/basename /bin/kill /bin/chmod /usr/bin/find \ /bin/mknod - install_bin /bin/uclient-fetch /bin/wget install_bin /sbin/mtd install_bin /sbin/mount_root install_bin /sbin/snapshot @@ -96,51 +95,37 @@ run_ramfs() { # [...] exec /bin/busybox ash -c "$*" } -kill_remaining() { # [ ] +kill_remaining() { # [ [ ] ] local sig="${1:-TERM}" + local loop="${2:-0}" + local run=true + local stat + echo -n "Sending $sig to remaining processes ... " - local my_pid=$$ - local my_ppid=$(cut -d' ' -f4 /proc/$my_pid/stat) - local my_ppisupgraded= - grep -q upgraded /proc/$my_ppid/cmdline >/dev/null && { - local my_ppisupgraded=1 - } - - local stat - for stat in /proc/[0-9]*/stat; do - [ -f "$stat" ] || continue - - local pid name state ppid rest - read pid name state ppid rest < $stat - name="${name#(}"; name="${name%)}" - - local cmdline - read cmdline < /proc/$pid/cmdline - - # Skip kernel threads - [ -n "$cmdline" ] || continue - - if [ $$ -eq 1 ] || [ $my_ppid -eq 1 ] && [ -n "$my_ppisupgraded" ]; then - # Running as init process, kill everything except me - if [ $pid -ne $$ ] && [ $pid -ne $my_ppid ]; then - echo -n "$name " - kill -$sig $pid 2>/dev/null - fi - else - case "$name" in - # Skip essential services - *procd*|*ash*|*init*|*watchdog*|*ssh*|*dropbear*|*telnet*|*login*|*hostapd*|*wpa_supplicant*|*nas*|*relayd*) : ;; - - # Killable process - *) - if [ $pid -ne $$ ] && [ $ppid -ne $$ ]; then - echo -n "$name " - kill -$sig $pid 2>/dev/null - fi - ;; - esac - fi + while $run; do + run=false + for stat in /proc/[0-9]*/stat; do + [ -f "$stat" ] || continue + + local pid name state ppid rest + read pid name state ppid rest < $stat + name="${name#(}"; name="${name%)}" + + # Skip PID1, ourself and our children + [ $pid -ne 1 -a $pid -ne $$ -a $ppid -ne $$ ] || continue + + local cmdline + read cmdline < /proc/$pid/cmdline + + # Skip kernel threads + [ -n "$cmdline" ] || continue + + echo -n "$name " + kill -$sig $pid 2>/dev/null + + [ $loop -eq 1 ] && run=true + done done echo "" } @@ -175,28 +160,31 @@ v() { [ "$VERBOSE" -ge 1 ] && echo "$@" } +json_string() { + local v="$1" + v="${v//\\/}" + v="${v//\"/\\\"}" + echo "\"$v\"" +} + rootfs_type() { /bin/mount | awk '($3 ~ /^\/$/) && ($5 !~ /rootfs/) { print $5 }' } get_image() { # [ ] local from="$1" - local conc="$2" - local cmd - - case "$from" in - http://*|ftp://*) cmd="wget -O- -q";; - *) cmd="cat";; - esac - if [ -z "$conc" ]; then - local magic="$(eval $cmd \"$from\" 2>/dev/null | dd bs=2 count=1 2>/dev/null | hexdump -n 2 -e '1/1 "%02x"')" + local cat="$2" + + if [ -z
[LEDE-DEV] [PATCH v2 18/19] sunxi: sysupgrade: don't write partitions twice
When existing partitions are retained, the dd call writing the uboot image in the space before the first partition was accidentally writing the whole image, making the code for individual partitions redundant. Limit the copy to 1016KiB (the first 8KiB are skipped, and the first partition starts at 1024KiB). In addition, conv=notrunc is replaced with conv=fsync. It seems this was an oversight, as notrunc doesn't make sense for block devices and all other dd commands use conv=fsync. Signed-off-by: Matthias Schiffer--- target/linux/sunxi/base-files/lib/upgrade/platform.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/sunxi/base-files/lib/upgrade/platform.sh b/target/linux/sunxi/base-files/lib/upgrade/platform.sh index f2cd970d42..776bdf53bf 100644 --- a/target/linux/sunxi/base-files/lib/upgrade/platform.sh +++ b/target/linux/sunxi/base-files/lib/upgrade/platform.sh @@ -43,7 +43,7 @@ platform_do_upgrade() { fi #write uboot image - get_image "$@" | dd of="$diskdev" bs=1024 skip=8 seek=8 conv=notrunc + get_image "$@" | dd of="$diskdev" bs=1024 skip=8 seek=8 count=1016 conv=fsync #iterate over each partition from the image and write it to the boot disk while read part start size; do part="$(($part - 2))" -- 2.13.0 ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
[LEDE-DEV] [PATCH v2 11/19] procd: init: add support for sysupgrades triggered from preinit
This will allow to add sysupgrade support via upgraded for failsafe mode. Signed-off-by: Matthias SchifferNote: obviously, this patch should go into the procd repo when it is actually applied; it is provided like this for now to allow easier testing of the whole series. --- ...pport-for-sysupgrades-triggered-from-prei.patch | 278 + 1 file changed, 278 insertions(+) create mode 100644 package/system/procd/patches/0005-init-add-support-for-sysupgrades-triggered-from-prei.patch diff --git a/package/system/procd/patches/0005-init-add-support-for-sysupgrades-triggered-from-prei.patch b/package/system/procd/patches/0005-init-add-support-for-sysupgrades-triggered-from-prei.patch new file mode 100644 index 00..4e825a0d30 --- /dev/null +++ b/package/system/procd/patches/0005-init-add-support-for-sysupgrades-triggered-from-prei.patch @@ -0,0 +1,278 @@ +From 177e491edc944f48b701b75ab5467743594cf89a Mon Sep 17 00:00:00 2001 +Message-Id: <177e491edc944f48b701b75ab5467743594cf89a.1493040735.git.mschif...@universe-factory.net> +In-Reply-To: <3462ccc0c91964ec92c1c61cde803a6504b2fb24.1493040735.git.mschif...@universe-factory.net> +References: <3462ccc0c91964ec92c1c61cde803a6504b2fb24.1493040735.git.mschif...@universe-factory.net> +From: Matthias Schiffer +Date: Mon, 24 Apr 2017 00:40:27 +0200 +Subject: [PATCH 5/5] init: add support for sysupgrades triggered from preinit + +This will allow to add sysupgrade support via upgraded for failsafe mode. + +Signed-off-by: Matthias Schiffer +--- + CMakeLists.txt | 4 ++-- + initd/preinit.c | 46 +- + system.c| 35 --- + sysupgrade.c| 49 + + sysupgrade.h| 21 + + watchdog.h | 2 ++ + 6 files changed, 119 insertions(+), 38 deletions(-) + create mode 100644 sysupgrade.c + create mode 100644 sysupgrade.h + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 0729459..7d05e97 100644 +--- a/CMakeLists.txt b/CMakeLists.txt +@@ -18,7 +18,7 @@ INSTALL(TARGETS setlbf + ) + + +-SET(SOURCES procd.c signal.c state.c inittab.c rcS.c ubus.c system.c ++SET(SOURCES procd.c signal.c state.c inittab.c rcS.c ubus.c system.c sysupgrade.c + service/service.c service/instance.c service/validate.c service/trigger.c service/watch.c + utils/utils.c) + IF(NOT DISABLE_INIT) +@@ -54,7 +54,7 @@ INCLUDE_DIRECTORIES(${ubox_include_dir}) + IF(DISABLE_INIT) + ADD_DEFINITIONS(-DDISABLE_INIT) + ELSE() +-ADD_EXECUTABLE(init initd/init.c initd/early.c initd/preinit.c initd/mkdev.c watchdog.c ++ADD_EXECUTABLE(init initd/init.c initd/early.c initd/preinit.c initd/mkdev.c sysupgrade.c watchdog.c + utils/utils.c ${SOURCES_ZRAM}) + TARGET_LINK_LIBRARIES(init ${LIBS}) + INSTALL(TARGETS init +diff --git a/initd/preinit.c b/initd/preinit.c +index 729978e..dda6576 100644 +--- a/initd/preinit.c b/initd/preinit.c +@@ -27,6 +27,7 @@ + + #include "init.h" + #include "../watchdog.h" ++#include "../sysupgrade.h" + + static struct uloop_process preinit_proc; + static struct uloop_process plugd_proc; +@@ -49,23 +50,58 @@ check_dbglvl(void) + } + + static void ++check_sysupgrade(void) ++{ ++ char *prefix = NULL, *path = NULL, *command = NULL; ++ size_t n; ++ ++ if (chdir("/")) ++ return; ++ ++ FILE *sysupgrade = fopen("/tmp/sysupgrade", "r"); ++ if (!sysupgrade) ++ return; ++ ++ n = 0; ++ if (getdelim(, , 0, sysupgrade) < 0) ++ goto fail; ++ n = 0; ++ if (getdelim(, , 0, sysupgrade) < 0) ++ goto fail; ++ n = 0; ++ if (getdelim(, , 0, sysupgrade) < 0) ++ goto fail; ++ ++ fclose(sysupgrade); ++ ++ sysupgrade_exec_upgraded(prefix, path, command); ++ ++ while (true) ++ sleep(1); ++ ++fail: ++ fclose(sysupgrade); ++ free(prefix); ++ free(path); ++ free(command); ++} ++ ++static void + spawn_procd(struct uloop_process *proc, int ret) + { + char *wdt_fd = watchdog_fd(); + char *argv[] = { "/sbin/procd", NULL}; +- struct stat s; + char dbg[2]; + + if (plugd_proc.pid > 0) + kill(plugd_proc.pid, SIGKILL); + +- if (!stat("/tmp/sysupgrade", )) +- while (true) +- sleep(1); +- + unsetenv("INITRAMFS"); + unsetenv("PREINIT"); + unlink("/tmp/.preinit"); ++ ++ check_sysupgrade(); ++ + DEBUG(2, "Exec to real procd now\n"); + if (wdt_fd) + setenv("WDTFD", wdt_fd, 1); +diff --git a/system.c b/system.c +index dc509ff..8b8cdbc 100644 +--- a/system.c b/system.c +@@ -28,6 +28,7 @@ + #include + + #include "procd.h" ++#include "sysupgrade.h" + #include "watchdog.h" + + static struct blob_buf b; +@@ -346,34 +347,6 @@ static
[LEDE-DEV] [PATCH v2 12/19] base-files: sysupgrade cleanup
Some functions only used by stage2 are moved there from common.sh. One piece that could still use more cleanup is platform_pre_upgrade: many targets reference files from there are aren't available in the ramfs, so we need to evaluate it before the switch; conversely, flash writes happen in that function on some targets. Targets that do the latter should be fixed eventually to use platform_do_upgrade for that purpose. Signed-off-by: Matthias Schiffer--- package/base-files/files/lib/upgrade/common.sh | 100 --- package/base-files/files/lib/upgrade/stage2| 105 - package/base-files/files/sbin/sysupgrade | 2 - 3 files changed, 102 insertions(+), 105 deletions(-) diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh index 17248c2b1d..fc59bf2323 100644 --- a/package/base-files/files/lib/upgrade/common.sh +++ b/package/base-files/files/lib/upgrade/common.sh @@ -30,106 +30,6 @@ install_bin() { # [ ... ] }; done } -supivot() { # - /bin/mount | grep "on $1 type" 2>&- 1>&- || /bin/mount -o bind $1 $1 - mkdir -p $1$2 $1/proc $1/sys $1/dev $1/tmp $1/overlay && \ - /bin/mount -o noatime,move /proc $1/proc && \ - pivot_root $1 $1$2 || { - /bin/umount -l $1 $1 - return 1 - } - - /bin/mount -o noatime,move $2/sys /sys - /bin/mount -o noatime,move $2/dev /dev - /bin/mount -o noatime,move $2/tmp /tmp - /bin/mount -o noatime,move $2/overlay /overlay 2>&- - return 0 -} - -run_ramfs() { # [...] - install_bin /bin/busybox /bin/ash /bin/sh /bin/mount /bin/umount \ - /sbin/pivot_root /sbin/reboot /bin/sync /bin/dd /bin/grep \ - /bin/cp /bin/mv /bin/tar /usr/bin/md5sum "/usr/bin/[" /bin/dd \ - /bin/vi /bin/ls /bin/cat /usr/bin/awk /usr/bin/hexdump \ - /bin/sleep /bin/zcat /usr/bin/bzcat /usr/bin/printf /usr/bin/wc \ - /bin/cut /usr/bin/printf /bin/sync /bin/mkdir /bin/rmdir \ - /bin/rm /usr/bin/basename /bin/kill /bin/chmod /usr/bin/find \ - /bin/mknod - - install_bin /sbin/mtd - install_bin /sbin/mount_root - install_bin /sbin/snapshot - install_bin /sbin/snapshot_tool - install_bin /usr/sbin/ubiupdatevol - install_bin /usr/sbin/ubiattach - install_bin /usr/sbin/ubiblock - install_bin /usr/sbin/ubiformat - install_bin /usr/sbin/ubidetach - install_bin /usr/sbin/ubirsvol - install_bin /usr/sbin/ubirmvol - install_bin /usr/sbin/ubimkvol - install_bin /usr/sbin/partx - install_bin /usr/sbin/losetup - install_bin /usr/sbin/mkfs.ext4 - for file in $RAMFS_COPY_BIN; do - install_bin ${file//:/ } - done - install_file /etc/resolv.conf /lib/*.sh /lib/functions/*.sh /lib/upgrade/*.sh $RAMFS_COPY_DATA - - [ -L "/lib64" ] && ln -s /lib $RAM_ROOT/lib64 - - supivot $RAM_ROOT /mnt || { - echo "Failed to switch over to ramfs. Please reboot." - exit 1 - } - - /bin/mount -o remount,ro /mnt - /bin/umount -l /mnt - - grep /overlay /proc/mounts > /dev/null && { - /bin/mount -o noatime,remount,ro /overlay - /bin/umount -l /overlay - } - - # spawn a new shell from ramdisk to reduce the probability of cache issues - exec /bin/busybox ash -c "$*" -} - -kill_remaining() { # [ [ ] ] - local sig="${1:-TERM}" - local loop="${2:-0}" - local run=true - local stat - - echo -n "Sending $sig to remaining processes ... " - - while $run; do - run=false - for stat in /proc/[0-9]*/stat; do - [ -f "$stat" ] || continue - - local pid name state ppid rest - read pid name state ppid rest < $stat - name="${name#(}"; name="${name%)}" - - # Skip PID1, ourself and our children - [ $pid -ne 1 -a $pid -ne $$ -a $ppid -ne $$ ] || continue - - local cmdline - read cmdline < /proc/$pid/cmdline - - # Skip kernel threads - [ -n "$cmdline" ] || continue - - echo -n "$name " - kill -$sig $pid 2>/dev/null - - [ $loop -eq 1 ] && run=true - done - done - echo "" -} - run_hooks() { local arg="$1"; shift for func in "$@"; do diff --git a/package/base-files/files/lib/upgrade/stage2 b/package/base-files/files/lib/upgrade/stage2 index 4e2aa3a23c..cc8047d988 100755 --- a/package/base-files/files/lib/upgrade/stage2 +++ b/package/base-files/files/lib/upgrade/stage2 @@ -24,6 +24,104 @@
[LEDE-DEV] [PATCH v2 10/19] procd: remove code that has become unnecessary after sysupgrade changes
Signed-off-by: Matthias SchifferNote: obviously, this patch should go into the procd repo when it is actually applied; it is provided like this for now to allow easier testing of the whole series. --- ...-that-has-become-unnecessary-after-sysupg.patch | 120 + 1 file changed, 120 insertions(+) create mode 100644 package/system/procd/patches/0004-Remove-code-that-has-become-unnecessary-after-sysupg.patch diff --git a/package/system/procd/patches/0004-Remove-code-that-has-become-unnecessary-after-sysupg.patch b/package/system/procd/patches/0004-Remove-code-that-has-become-unnecessary-after-sysupg.patch new file mode 100644 index 00..f54d651727 --- /dev/null +++ b/package/system/procd/patches/0004-Remove-code-that-has-become-unnecessary-after-sysupg.patch @@ -0,0 +1,120 @@ +From b776d938d6eeb0a6c005e1a6ea2fa2c0d18ba986 Mon Sep 17 00:00:00 2001 +Message-Id: +In-Reply-To: <3462ccc0c91964ec92c1c61cde803a6504b2fb24.1493040735.git.mschif...@universe-factory.net> +References: <3462ccc0c91964ec92c1c61cde803a6504b2fb24.1493040735.git.mschif...@universe-factory.net> +From: Matthias Schiffer +Date: Sun, 23 Apr 2017 19:06:12 +0200 +Subject: [PATCH 4/5] Remove code that has become unnecessary after sysupgrade + changes + +Signed-off-by: Matthias Schiffer +--- + procd.h | 1 - + service/instance.c | 2 -- + system.c| 12 + upgraded/upgraded.c | 10 +- + 4 files changed, 5 insertions(+), 20 deletions(-) + +diff --git a/procd.h b/procd.h +index 6a3..5aa3aea 100644 +--- a/procd.h b/procd.h +@@ -27,7 +27,6 @@ + #define __init __attribute__((constructor)) + + extern char *ubus_socket; +-extern int upgrade_running; + + void procd_connect_ubus(void); + void procd_reconnect_ubus(int reconnect); +diff --git a/service/instance.c b/service/instance.c +index 677f8eb..e5c4830 100644 +--- a/service/instance.c b/service/instance.c +@@ -525,8 +525,6 @@ instance_exit(struct uloop_process *p, int ret) + runtime = tp.tv_sec - in->start.tv_sec; + + DEBUG(2, "Instance %s::%s exit with error code %d after %ld seconds\n", in->srv->name, in->name, ret, runtime); +- if (upgrade_running) +- return; + + uloop_timeout_cancel(>timeout); + service_event("instance.stop", in->srv->name, in->name); +diff --git a/system.c b/system.c +index 69ba57e..dc509ff 100644 +--- a/system.c b/system.c +@@ -34,8 +34,6 @@ static struct blob_buf b; + static int notify; + static struct ubus_context *_ctx; + +-int upgrade_running = 0; +- + static int system_board(struct ubus_context *ctx, struct ubus_object *obj, + struct ubus_request_data *req, const char *method, + struct blob_attr *msg) +@@ -235,14 +233,6 @@ static int system_info(struct ubus_context *ctx, struct ubus_object *obj, + return UBUS_STATUS_OK; + } + +-static int system_upgrade(struct ubus_context *ctx, struct ubus_object *obj, +- struct ubus_request_data *req, const char *method, +- struct blob_attr *msg) +-{ +- upgrade_running = 1; +- return 0; +-} +- + static int system_reboot(struct ubus_context *ctx, struct ubus_object *obj, +struct ubus_request_data *req, const char *method, +struct blob_attr *msg) +@@ -413,11 +403,9 @@ procd_subscribe_cb(struct ubus_context *ctx, struct ubus_object *obj) + static const struct ubus_method system_methods[] = { + UBUS_METHOD_NOARG("board", system_board), + UBUS_METHOD_NOARG("info", system_info), +- UBUS_METHOD_NOARG("upgrade", system_upgrade), + UBUS_METHOD_NOARG("reboot", system_reboot), + UBUS_METHOD("watchdog", watchdog_set, watchdog_policy), + UBUS_METHOD("signal", proc_signal, signal_policy), +- UBUS_METHOD("nandupgrade", sysupgrade, sysupgrade_policy), + UBUS_METHOD("sysupgrade", sysupgrade, sysupgrade_policy), + }; + +diff --git a/upgraded/upgraded.c b/upgraded/upgraded.c +index 303edb7..79ebd37 100644 +--- a/upgraded/upgraded.c b/upgraded/upgraded.c +@@ -41,10 +41,10 @@ static void upgrade_proc_cb(struct uloop_process *proc, int ret) + + static void sysupgrade(char *path, char *command) + { +- char *args[] = { "/sbin/sysupgrade", "nand", NULL, NULL, NULL }; ++ char *args[] = { "/lib/upgrade/stage2", NULL, NULL, NULL }; + +- args[2] = path; +- args[3] = command; ++ args[1] = path; ++ args[2] = command; + upgrade_proc.cb = upgrade_proc_cb; + upgrade_proc.pid = fork(); + if (!upgrade_proc.pid) { +@@ -81,14 +81,14 @@ int main(int argc, char **argv) + } + close(fd); + +- if (argc != 2 && argc != 3) { ++ if (argc != 3) { + fprintf(stderr, "sysupgrade stage
[LEDE-DEV] [PATCH v2 05/19] procd: upgraded: add support for passing a "command" argument to stage2
This allows us to make use of upgraded in "snapshot convert" as well. Signed-off-by: Matthias SchifferNote: obviously, this patch should go into the procd repo when it is actually applied; it is provided like this for now to allow easier testing of the whole series. --- ...d-support-for-passing-a-command-argument-.patch | 104 + 1 file changed, 104 insertions(+) create mode 100644 package/system/procd/patches/0003-upgraded-add-support-for-passing-a-command-argument-.patch diff --git a/package/system/procd/patches/0003-upgraded-add-support-for-passing-a-command-argument-.patch b/package/system/procd/patches/0003-upgraded-add-support-for-passing-a-command-argument-.patch new file mode 100644 index 00..2a5b258608 --- /dev/null +++ b/package/system/procd/patches/0003-upgraded-add-support-for-passing-a-command-argument-.patch @@ -0,0 +1,104 @@ +From a90626d588abf71426f57513174427b0bf8feeab Mon Sep 17 00:00:00 2001 +Message-Id: +In-Reply-To: <3462ccc0c91964ec92c1c61cde803a6504b2fb24.1493040735.git.mschif...@universe-factory.net> +References: <3462ccc0c91964ec92c1c61cde803a6504b2fb24.1493040735.git.mschif...@universe-factory.net> +From: Matthias Schiffer +Date: Sun, 23 Apr 2017 19:04:25 +0200 +Subject: [PATCH 3/5] upgraded: add support for passing a "command" argument to + stage2 + +This allows us to make use of upgraded in "snapshot convert" as well. + +Signed-off-by: Matthias Schiffer +--- + system.c| 10 +++--- + upgraded/upgraded.c | 13 +++-- + 2 files changed, 14 insertions(+), 9 deletions(-) + +diff --git a/system.c b/system.c +index 193c9b0..69ba57e 100644 +--- a/system.c b/system.c +@@ -346,19 +346,21 @@ static int proc_signal(struct ubus_context *ctx, struct ubus_object *obj, + enum { + SYSUPGRADE_PATH, + SYSUPGRADE_PREFIX, ++ SYSUPGRADE_COMMAND, + __SYSUPGRADE_MAX + }; + + static const struct blobmsg_policy sysupgrade_policy[__SYSUPGRADE_MAX] = { + [SYSUPGRADE_PATH] = { .name = "path", .type = BLOBMSG_TYPE_STRING }, + [SYSUPGRADE_PREFIX] = { .name = "prefix", .type = BLOBMSG_TYPE_STRING }, ++ [SYSUPGRADE_COMMAND] = { .name = "command", .type = BLOBMSG_TYPE_STRING }, + }; + + static void +-procd_exec_upgraded(const char *prefix, char *path) ++procd_exec_upgraded(const char *prefix, char *path, char *command) + { + char *wdt_fd = watchdog_fd(); +- char *argv[] = { "/sbin/upgraded", NULL, NULL}; ++ char *argv[] = { "/sbin/upgraded", NULL, NULL, NULL}; + + if (chroot(prefix)) { + fprintf(stderr, "Failed to chroot for upgraded exec.\n"); +@@ -366,6 +368,7 @@ procd_exec_upgraded(const char *prefix, char *path) + } + + argv[1] = path; ++ argv[2] = command; + + DEBUG(2, "Exec to upgraded now\n"); + if (wdt_fd) { +@@ -395,7 +398,8 @@ static int sysupgrade(struct ubus_context *ctx, struct ubus_object *obj, + return UBUS_STATUS_INVALID_ARGUMENT; + + procd_exec_upgraded(blobmsg_get_string(tb[SYSUPGRADE_PREFIX]), +- blobmsg_get_string(tb[SYSUPGRADE_PATH])); ++ blobmsg_get_string(tb[SYSUPGRADE_PATH]), ++ tb[SYSUPGRADE_COMMAND] ? blobmsg_get_string(tb[SYSUPGRADE_COMMAND]) : NULL); + return 0; + } + +diff --git a/upgraded/upgraded.c b/upgraded/upgraded.c +index aa0b4ff..303edb7 100644 +--- a/upgraded/upgraded.c b/upgraded/upgraded.c +@@ -39,11 +39,12 @@ static void upgrade_proc_cb(struct uloop_process *proc, int ret) + uloop_end(); + } + +-static void sysupgrade(char *folder) ++static void sysupgrade(char *path, char *command) + { +- char *args[] = { "/sbin/sysupgrade", "nand", NULL, NULL }; ++ char *args[] = { "/sbin/sysupgrade", "nand", NULL, NULL, NULL }; + +- args[2] = folder; ++ args[2] = path; ++ args[3] = command; + upgrade_proc.cb = upgrade_proc_cb; + upgrade_proc.pid = fork(); + if (!upgrade_proc.pid) { +@@ -80,14 +81,14 @@ int main(int argc, char **argv) + } + close(fd); + +- if (argc != 2) { +- fprintf(stderr, "sysupgrade stage 2 failed, no folder specified\n"); ++ if (argc != 2 && argc != 3) { ++ fprintf(stderr, "sysupgrade stage 2 failed, invalid command line\n"); + return -1; + } + + uloop_init(); + watchdog_init(0); +- sysupgrade(argv[1]); ++ sysupgrade(argv[1], (argc == 3) ? argv[2] : NULL); + uloop_run(); + + reboot(RB_AUTOBOOT); +-- +2.12.2 + -- 2.13.0 ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
[LEDE-DEV] [PATCH v2 06/19] procd: remove procd-nand package
We always want to support staged upgrades now, so it's better to include upgraded into the main package. /lib/upgrade/nand.sh is moved to base-files. The procd-nand-firstboot package is removed for now, it may return later as a separate package. Signed-off-by: Matthias Schiffer--- package/base-files/Makefile| 13 +-- .../files => base-files/files/lib/upgrade}/nand.sh | 0 package/system/procd/Makefile | 41 ++ package/system/procd/files/nand-preinit.sh | 21 --- 4 files changed, 14 insertions(+), 61 deletions(-) rename package/{system/procd/files => base-files/files/lib/upgrade}/nand.sh (100%) delete mode 100644 package/system/procd/files/nand-preinit.sh diff --git a/package/base-files/Makefile b/package/base-files/Makefile index 512fa66ca7..912449c85a 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -18,7 +18,9 @@ PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ PKG_BUILD_DEPENDS:=usign/host PKG_LICENSE:=GPL-2.0 -PKG_CONFIG_DEPENDS := CONFIG_SIGNED_PACKAGES CONFIG_TARGET_INIT_PATH CONFIG_TARGET_PREINIT_DISABLE_FAILSAFE +PKG_CONFIG_DEPENDS := \ + CONFIG_SIGNED_PACKAGES CONFIG_TARGET_INIT_PATH CONFIG_TARGET_PREINIT_DISABLE_FAILSAFE \ + CONFIG_NAND_SUPPORT include $(INCLUDE_DIR)/package.mk @@ -30,7 +32,7 @@ endif define Package/base-files SECTION:=base CATEGORY:=Base system - DEPENDS:=+netifd +libc +procd +jsonfilter +SIGNED_PACKAGES:usign +SIGNED_PACKAGES:lede-keyring +fstools +fwtool + DEPENDS:=+netifd +libc +procd +jsonfilter +SIGNED_PACKAGES:usign +SIGNED_PACKAGES:lede-keyring +NAND_SUPPORT:ubi-utils +fstools +fwtool TITLE:=Base filesystem for Lede URL:=http://openwrt.org/ VERSION:=$(PKG_RELEASE)-$(REVISION) @@ -105,9 +107,16 @@ ifdef CONFIG_SIGNED_PACKAGES endef endif +ifeq ($(CONFIG_NAND_SUPPORT),) + define Package/base-files/nand-support + rm -f $(1)/lib/upgrade/nand.sh + endef +endif + define Package/base-files/install $(CP) ./files/* $(1)/ $(Package/base-files/install-key) + $(Package/base-files/nand-support) if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \ $(CP) $(GENERIC_PLATFORM_DIR)/base-files/* $(1)/; \ fi diff --git a/package/system/procd/files/nand.sh b/package/base-files/files/lib/upgrade/nand.sh similarity index 100% rename from package/system/procd/files/nand.sh rename to package/base-files/files/lib/upgrade/nand.sh diff --git a/package/system/procd/Makefile b/package/system/procd/Makefile index 43ea23aab0..d7b8a058a9 100644 --- a/package/system/procd/Makefile +++ b/package/system/procd/Makefile @@ -22,11 +22,9 @@ PKG_LICENSE_FILES:= PKG_MAINTAINER:=John Crispin -PKG_FLAGS:=nonshared - PKG_CONFIG_DEPENDS:= \ CONFIG_TARGET_INIT_PATH CONFIG_KERNEL_SECCOMP \ - CONFIG_NAND_SUPPORT CONFIG_PROCD_SHOW_BOOT CONFIG_PROCD_ZRAM_TMPFS \ + CONFIG_PROCD_SHOW_BOOT CONFIG_PROCD_ZRAM_TMPFS \ CONFIG_KERNEL_NAMESPACES CONFIG_PACKAGE_procd-ujail CONFIG_PACKAGE_procd-seccomp include $(INCLUDE_DIR)/package.mk @@ -42,7 +40,7 @@ TARGET_LDFLAGS += $(if $(CONFIG_USE_GLIBC),-lrt) define Package/procd SECTION:=base CATEGORY:=Base system - DEPENDS:=+ubusd +ubus +libjson-script +ubox +USE_GLIBC:librt +libubox +libubus +NAND_SUPPORT:procd-nand + DEPENDS:=+ubusd +ubus +libjson-script +ubox +USE_GLIBC:librt +libubox +libubus TITLE:=OpenWrt system process manager endef @@ -60,20 +58,6 @@ define Package/procd-seccomp TITLE:=OpenWrt process seccomp helper + utrace endef -define Package/procd-nand - SECTION:=utils - CATEGORY:=Utilities - DEPENDS:=@NAND_SUPPORT +ubi-utils - TITLE:=OpenWrt sysupgrade nand helper -endef - -define Package/procd-nand-firstboot - SECTION:=utils - CATEGORY:=Utilities - DEPENDS:=procd-nand - TITLE:=OpenWrt firstboot nand helper -endef - define Package/procd/config menu "Configuration" depends on PACKAGE_procd @@ -91,10 +75,6 @@ endmenu endef -ifeq ($(CONFIG_NAND_SUPPORT),y) - CMAKE_OPTIONS += -DBUILD_UPGRADED=1 -endif - ifeq ($(CONFIG_PROCD_SHOW_BOOT),y) CMAKE_OPTIONS += -DSHOW_BOOT_ON_CONSOLE=1 endif @@ -114,7 +94,7 @@ endif define Package/procd/install $(INSTALL_DIR) $(1)/sbin $(1)/etc $(1)/lib/functions - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/{init,procd,askfirst,udevtrigger} $(1)/sbin/ + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/{init,procd,askfirst,udevtrigger,upgraded} $(1)/sbin/ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libsetlbf.so $(1)/lib $(INSTALL_BIN) ./files/reload_config $(1)/sbin/ $(INSTALL_DATA) ./files/hotplug*.json $(1)/etc/ @@ -133,21 +113,6 @@ define Package/procd-seccomp/install $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libpreload-trace.so $(1)/lib endef -define Package/procd-nand/install - $(INSTALL_DIR)
[LEDE-DEV] [PATCH v2 14/19] ramips: sysupgrade: move nand_do_upgrade call to platform_do_upgrade
All targets with NAND support should gradually move their nand_do_upgrade calls from platform_pre_upgrade to platform_do_upgrade. Signed-off-by: Matthias Schiffer--- target/linux/ramips/base-files/lib/upgrade/platform.sh | 9 + 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh b/target/linux/ramips/base-files/lib/upgrade/platform.sh index 32bc453497..5df16f21ce 100755 --- a/target/linux/ramips/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh @@ -279,7 +279,7 @@ platform_nand_pre_upgrade() { esac } -platform_pre_upgrade() { +platform_do_upgrade() { local board=$(ramips_board_name) case "$board" in @@ -288,13 +288,6 @@ platform_pre_upgrade() { ubnt-erx) nand_do_upgrade "$ARGV" ;; - esac -} - -platform_do_upgrade() { - local board=$(ramips_board_name) - - case "$board" in *) default_do_upgrade "$ARGV" ;; -- 2.13.0 ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
[LEDE-DEV] [PATCH v2 08/19] fstools: clean up trailing whitespace in snapshot script
Signed-off-by: Matthias Schiffer--- package/system/fstools/files/snapshot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/system/fstools/files/snapshot b/package/system/fstools/files/snapshot index c1a5b733f3..baf24f1e3e 100644 --- a/package/system/fstools/files/snapshot +++ b/package/system/fstools/files/snapshot @@ -42,7 +42,7 @@ do_snapshot_upgrade() { opkg list-upgradable [ $? -eq 0 ] || exit 2 - + UPDATES=`opkg list-upgradable | cut -d" " -f1` [ -z "${UPDATES}" ] && exit 0 -- 2.13.0 ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
[LEDE-DEV] [PATCH v2 00/19] Universal staged sysupgrade and assorted fixes
Text from my RFC mail: --- When talking about https://bugs.lede-project.org/index.php?do=details_id=685 with jow and lynxis, we came to the conclusion that the best way to fix sysupgrades would be to generalize the staged sysupgrade used on NAND devices to work on all targets. That is what this patchset does, with some nice extras like staged sysupgrade support from failsafe mode (which did not work at all on NAND devices before). I have tested these patches on ar71xx (squashfs+jffs2), ramips (squashfs+ ubifs) and x86 (ext4), and they seems to work perfectly; they should be tested on a lot more targets before they are applied though. The same patchset can be found the "sysupgrade" branch of my staging tree at https://git.lede-project.org/?p=lede/neoraider/staging.git;a=summary Note: the diffstat looks a lot scarier than it should; most of the added lines are the procd patches that I have included in the LEDE repo for now to facilitate testing the series. --- Some highlights of v2: * split whitespace fixes into separate patches * add missing include guards to new procd header sysupgrade.h * support sysupgrade -p again (suggested by from Daniel Golle) * various x86 sysupgrade fixes (now sysupgrade with growing kernel partition actually works) * apply x86 sysupgrade fixes to sunxi as well It would be great if someone with access to sunxi hardware could test my changes, the sunxi patches were not tested at all. Thanks for the feedback I got so far. Matthias Matthias Schiffer (19): procd: clean up trailing whitespace in nand.sh procd: prepare NAND sysupgrade for making upgraded dynamically linked procd: system: always support staged sysupgrade procd: upgraded: link dynamically, chroot during exec procd: upgraded: add support for passing a "command" argument to stage2 procd: remove procd-nand package base-files: always use staged sysupgrade fstools: clean up trailing whitespace in snapshot script fstools: snapshot: handle jffs2 conversion using upgraded procd: remove code that has become unnecessary after sysupgrade changes procd: init: add support for sysupgrades triggered from preinit base-files: sysupgrade cleanup base-files: add support for staged sysupgrades from failsafe mode ramips: sysupgrade: move nand_do_upgrade call to platform_do_upgrade x86: sysupgrade: move partition table change check to platform_check_image x86: sysupgrade: refactor platform_do_upgrade x86: sysupgrade: explicitly rescan disk after writing partition table sunxi: sysupgrade: don't write partitions twice sunxi: sysupgrade: sync with x86 package/base-files/Makefile| 13 +- .../files/lib/preinit/40_run_failsafe_hook | 6 +- .../files/lib/preinit/99_10_failsafe_login | 11 +- package/base-files/files/lib/upgrade/common.sh | 167 +++-- .../files => base-files/files/lib/upgrade}/nand.sh | 63 + package/base-files/files/lib/upgrade/stage2| 149 +++ package/base-files/files/sbin/sysupgrade | 77 +++--- package/system/fstools/Makefile| 2 +- package/system/fstools/files/snapshot | 16 +- package/system/procd/Makefile | 41 +-- package/system/procd/files/nand-preinit.sh | 21 -- ...1-system-always-support-staged-sysupgrade.patch | 112 + ...raded-link-dynamically-chroot-during-exec.patch | 231 + ...d-support-for-passing-a-command-argument-.patch | 104 ...-that-has-become-unnecessary-after-sysupg.patch | 120 + ...pport-for-sysupgrades-triggered-from-prei.patch | 278 + .../ramips/base-files/lib/upgrade/platform.sh | 9 +- target/linux/sunxi/Makefile| 2 +- .../linux/sunxi/base-files/lib/upgrade/platform.sh | 120 + .../linux/x86/base-files/lib/upgrade/platform.sh | 104 +--- 20 files changed, 1259 insertions(+), 387 deletions(-) rename package/{system/procd/files => base-files/files/lib/upgrade}/nand.sh (89%) create mode 100755 package/base-files/files/lib/upgrade/stage2 delete mode 100644 package/system/procd/files/nand-preinit.sh create mode 100644 package/system/procd/patches/0001-system-always-support-staged-sysupgrade.patch create mode 100644 package/system/procd/patches/0002-upgraded-link-dynamically-chroot-during-exec.patch create mode 100644 package/system/procd/patches/0003-upgraded-add-support-for-passing-a-command-argument-.patch create mode 100644 package/system/procd/patches/0004-Remove-code-that-has-become-unnecessary-after-sysupg.patch create mode 100644 package/system/procd/patches/0005-init-add-support-for-sysupgrades-triggered-from-prei.patch -- 2.13.0 ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
[LEDE-DEV] [PATCH v2 02/19] procd: prepare NAND sysupgrade for making upgraded dynamically linked
Use install_bin to copy upgraded with all dependencies. The old name /tmp/upgraded is temporarily retained as a symlink to avoid breaking things. Signed-off-by: Matthias Schiffer--- package/system/procd/files/nand.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package/system/procd/files/nand.sh b/package/system/procd/files/nand.sh index b5f86e0301..9c831df3b4 100644 --- a/package/system/procd/files/nand.sh +++ b/package/system/procd/files/nand.sh @@ -333,7 +333,7 @@ nand_upgrade_stage1() { [ "$SAVE_CONFIG" != 1 -a -f "$CONF_TAR" ] && rm $CONF_TAR - ubus call system nandupgrade "{\"path\": \"$path\" }" + ubus call system nandupgrade "{\"prefix\": \"$RAM_ROOT\", \"path\": \"$path\" }" exit 0 } } @@ -370,6 +370,7 @@ nand_do_platform_check() { # $(1): file to be used for upgrade nand_do_upgrade() { echo -n $1 > /tmp/sysupgrade-nand-path - cp /sbin/upgraded /tmp/ + install_bin /sbin/upgraded + ln -s "$RAM_ROOT"/sbin/upgraded /tmp/upgraded nand_upgrade_stage1 } -- 2.13.0 ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
[LEDE-DEV] [PATCH v2 04/19] procd: upgraded: link dynamically, chroot during exec
The chroot ensures we don't reference anything on the rootfs and is reverted after the upgraded exec. While we're at it, also improve error handling and logging at bit. This change also required changes to sysupgrade, as the dynamically linked version is expected at a different location, and libraries need to be made available. Signed-off-by: Matthias SchifferNote: obviously, this patch should go into the procd repo when it is actually applied; it is provided like this for now to allow easier testing of the whole series. --- ...raded-link-dynamically-chroot-during-exec.patch | 231 + 1 file changed, 231 insertions(+) create mode 100644 package/system/procd/patches/0002-upgraded-link-dynamically-chroot-during-exec.patch diff --git a/package/system/procd/patches/0002-upgraded-link-dynamically-chroot-during-exec.patch b/package/system/procd/patches/0002-upgraded-link-dynamically-chroot-during-exec.patch new file mode 100644 index 00..2e52713bd3 --- /dev/null +++ b/package/system/procd/patches/0002-upgraded-link-dynamically-chroot-during-exec.patch @@ -0,0 +1,231 @@ +From d212b2f6a5e2e2779f3fc4bfb5fe217fdeed03a8 Mon Sep 17 00:00:00 2001 +Message-Id: +In-Reply-To: <3462ccc0c91964ec92c1c61cde803a6504b2fb24.1493040735.git.mschif...@universe-factory.net> +References: <3462ccc0c91964ec92c1c61cde803a6504b2fb24.1493040735.git.mschif...@universe-factory.net> +From: Matthias Schiffer +Date: Sun, 23 Apr 2017 02:28:13 +0200 +Subject: [PATCH 2/5] upgraded: link dynamically, chroot during exec + +The chroot ensures we don't reference anything on the rootfs and is +reverted after the upgraded exec. While we're at it, also improve error +handling a bit. + +This change also required changes to sysupgrade, as the dynamically linked +version is expected at a different location, and libraries need to be made +available. + +Signed-off-by: Matthias Schiffer +--- + system.c| 25 +++-- + upgraded/CMakeLists.txt | 10 +- + upgraded/upgraded.c | 26 +- + watchdog.c | 9 +++-- + watchdog.h | 4 ++-- + 5 files changed, 50 insertions(+), 24 deletions(-) + +diff --git a/system.c b/system.c +index bb2abe5..193c9b0 100644 +--- a/system.c b/system.c +@@ -345,27 +345,40 @@ static int proc_signal(struct ubus_context *ctx, struct ubus_object *obj, + + enum { + SYSUPGRADE_PATH, ++ SYSUPGRADE_PREFIX, + __SYSUPGRADE_MAX + }; + + static const struct blobmsg_policy sysupgrade_policy[__SYSUPGRADE_MAX] = { + [SYSUPGRADE_PATH] = { .name = "path", .type = BLOBMSG_TYPE_STRING }, ++ [SYSUPGRADE_PREFIX] = { .name = "prefix", .type = BLOBMSG_TYPE_STRING }, + }; + + static void +-procd_spawn_upgraded(char *path) ++procd_exec_upgraded(const char *prefix, char *path) + { + char *wdt_fd = watchdog_fd(); +- char *argv[] = { "/tmp/upgraded", NULL, NULL}; ++ char *argv[] = { "/sbin/upgraded", NULL, NULL}; ++ ++ if (chroot(prefix)) { ++ fprintf(stderr, "Failed to chroot for upgraded exec.\n"); ++ return; ++ } + + argv[1] = path; + + DEBUG(2, "Exec to upgraded now\n"); + if (wdt_fd) { +- watchdog_no_cloexec(); ++ watchdog_set_cloexec(false); + setenv("WDTFD", wdt_fd, 1); + } + execvp(argv[0], argv); ++ ++ /* Cleanup on failure */ ++ fprintf(stderr, "Failed to exec upgraded.\n"); ++ unsetenv("WDTFD"); ++ watchdog_set_cloexec(true); ++ chroot("."); + } + + static int sysupgrade(struct ubus_context *ctx, struct ubus_object *obj, +@@ -378,11 +391,11 @@ static int sysupgrade(struct ubus_context *ctx, struct ubus_object *obj, + return UBUS_STATUS_INVALID_ARGUMENT; + + blobmsg_parse(sysupgrade_policy, __SYSUPGRADE_MAX, tb, blob_data(msg), blob_len(msg)); +- if (!tb[SYSUPGRADE_PATH]) ++ if (!tb[SYSUPGRADE_PATH] || !tb[SYSUPGRADE_PREFIX]) + return UBUS_STATUS_INVALID_ARGUMENT; + +- procd_spawn_upgraded(blobmsg_get_string(tb[SYSUPGRADE_PATH])); +- fprintf(stderr, "Yikees, something went wrong. no /sbin/upgraded ?\n"); ++ procd_exec_upgraded(blobmsg_get_string(tb[SYSUPGRADE_PREFIX]), ++ blobmsg_get_string(tb[SYSUPGRADE_PATH])); + return 0; + } + +diff --git a/upgraded/CMakeLists.txt b/upgraded/CMakeLists.txt +index 093dba2..00d8ce5 100644 +--- a/upgraded/CMakeLists.txt b/upgraded/CMakeLists.txt +@@ -2,16 +2,8 @@ cmake_minimum_required(VERSION 2.6) + + PROJECT(upgraded C) + ADD_DEFINITIONS(-Os -ggdb -Wall -Werror --std=gnu99 -Wmissing-declarations) +-set(CMAKE_EXE_LINKER_FLAGS "-static -fPIC") +-set(CMAKE_FIND_LIBRARY_SUFFIXES .a) +-set(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS)
[LEDE-DEV] [PATCH v2 01/19] procd: clean up trailing whitespace in nand.sh
Signed-off-by: Matthias Schiffer--- package/system/procd/files/nand.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/system/procd/files/nand.sh b/package/system/procd/files/nand.sh index 01dba61644..b5f86e0301 100644 --- a/package/system/procd/files/nand.sh +++ b/package/system/procd/files/nand.sh @@ -194,7 +194,7 @@ nand_upgrade_prepare_ubi() { nand_do_upgrade_success() { local conf_tar="/tmp/sysupgrade.tgz" - + sync [ -f "$conf_tar" ] && nand_restore_config "$conf_tar" echo "sysupgrade successful" @@ -231,7 +231,7 @@ nand_upgrade_ubifs() { local rootfs_length=`(cat $1 | wc -c) 2> /dev/null` nand_upgrade_prepare_ubi "$rootfs_length" "ubifs" "0" "0" - + local ubidev="$( nand_find_ubi "$CI_UBIPART" )" local root_ubivol="$(nand_find_volume $ubidev rootfs)" ubiupdatevol /dev/$root_ubivol -s $rootfs_length $1 -- 2.13.0 ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
[LEDE-DEV] [PATCH v2 03/19] procd: system: always support staged sysupgrade
In preparation for switching all targets to the staged sysupgrade mechanism, upgraded is always built, and the "nandupgrade" ubus method is renamed to "sysupgrade". To make the migration easier, support for the old name "nandupgrade" and the "upgrade" method that will become unused with the staged sysupgrade is retained for now. Signed-off-by: Matthias SchifferNote: obviously, this patch should go into the procd repo when it is actually applied; it is provided like this for now to allow easier testing of the whole series. --- ...1-system-always-support-staged-sysupgrade.patch | 112 + 1 file changed, 112 insertions(+) create mode 100644 package/system/procd/patches/0001-system-always-support-staged-sysupgrade.patch diff --git a/package/system/procd/patches/0001-system-always-support-staged-sysupgrade.patch b/package/system/procd/patches/0001-system-always-support-staged-sysupgrade.patch new file mode 100644 index 00..b3bae02f91 --- /dev/null +++ b/package/system/procd/patches/0001-system-always-support-staged-sysupgrade.patch @@ -0,0 +1,112 @@ +From 3462ccc0c91964ec92c1c61cde803a6504b2fb24 Mon Sep 17 00:00:00 2001 +Message-Id: <3462ccc0c91964ec92c1c61cde803a6504b2fb24.1493040735.git.mschif...@universe-factory.net> +From: Matthias Schiffer +Date: Fri, 21 Apr 2017 20:06:59 +0200 +Subject: [PATCH 1/5] system: always support staged sysupgrade + +In preparation for switching all targets to the staged sysupgrade +mechanism, upgraded is always built, and the "nandupgrade" ubus method is +renamed to "sysupgrade". + +To make the migration easier, support for the old name "nandupgrade" and +the "upgrade" method that will become unused with the staged sysupgrade is +retained for now. + +Signed-off-by: Matthias Schiffer +--- + CMakeLists.txt | 4 +--- + system.c | 31 +-- + 2 files changed, 14 insertions(+), 21 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 444dd20..0729459 100644 +--- a/CMakeLists.txt b/CMakeLists.txt +@@ -40,9 +40,7 @@ IF(ZRAM_TMPFS) + SET(SOURCES_ZRAM initd/zram.c) + ENDIF() + +-IF(BUILD_UPGRADED) +- add_subdirectory(upgraded) +-ENDIF() ++add_subdirectory(upgraded) + + ADD_EXECUTABLE(procd ${SOURCES}) + TARGET_LINK_LIBRARIES(procd ${LIBS}) +diff --git a/system.c b/system.c +index 1e31ce6..bb2abe5 100644 +--- a/system.c b/system.c +@@ -344,12 +344,12 @@ static int proc_signal(struct ubus_context *ctx, struct ubus_object *obj, + } + + enum { +- NAND_PATH, +- __NAND_MAX ++ SYSUPGRADE_PATH, ++ __SYSUPGRADE_MAX + }; + +-static const struct blobmsg_policy nand_policy[__NAND_MAX] = { +- [NAND_PATH] = { .name = "path", .type = BLOBMSG_TYPE_STRING }, ++static const struct blobmsg_policy sysupgrade_policy[__SYSUPGRADE_MAX] = { ++ [SYSUPGRADE_PATH] = { .name = "path", .type = BLOBMSG_TYPE_STRING }, + }; + + static void +@@ -368,20 +368,20 @@ procd_spawn_upgraded(char *path) + execvp(argv[0], argv); + } + +-static int nand_set(struct ubus_context *ctx, struct ubus_object *obj, +- struct ubus_request_data *req, const char *method, +- struct blob_attr *msg) ++static int sysupgrade(struct ubus_context *ctx, struct ubus_object *obj, ++struct ubus_request_data *req, const char *method, ++struct blob_attr *msg) + { +- struct blob_attr *tb[__NAND_MAX]; ++ struct blob_attr *tb[__SYSUPGRADE_MAX]; + + if (!msg) + return UBUS_STATUS_INVALID_ARGUMENT; + +- blobmsg_parse(nand_policy, __NAND_MAX, tb, blob_data(msg), blob_len(msg)); +- if (!tb[NAND_PATH]) ++ blobmsg_parse(sysupgrade_policy, __SYSUPGRADE_MAX, tb, blob_data(msg), blob_len(msg)); ++ if (!tb[SYSUPGRADE_PATH]) + return UBUS_STATUS_INVALID_ARGUMENT; + +- procd_spawn_upgraded(blobmsg_get_string(tb[NAND_PATH])); ++ procd_spawn_upgraded(blobmsg_get_string(tb[SYSUPGRADE_PATH])); + fprintf(stderr, "Yikees, something went wrong. no /sbin/upgraded ?\n"); + return 0; + } +@@ -400,9 +400,8 @@ static const struct ubus_method system_methods[] = { + UBUS_METHOD_NOARG("reboot", system_reboot), + UBUS_METHOD("watchdog", watchdog_set, watchdog_policy), + UBUS_METHOD("signal", proc_signal, signal_policy), +- +- /* must remain at the end as it ia not always loaded */ +- UBUS_METHOD("nandupgrade", nand_set, nand_policy), ++ UBUS_METHOD("nandupgrade", sysupgrade, sysupgrade_policy), ++ UBUS_METHOD("sysupgrade", sysupgrade, sysupgrade_policy), + }; + + static struct ubus_object_type system_object_type = +@@ -431,12 +430,8 @@ procd_bcast_event(char *event, struct blob_attr *msg) + + void ubus_init_system(struct ubus_context *ctx) + { +- struct stat s; + int ret; + +- if (stat("/sbin/upgraded", )) +-
Re: [LEDE-DEV] mwan3 not working
Hi Mauro, 2017-05-13 4:51 GMT-07:00 Mauro Mozzarelli: > Thanks Yousong, Merci Etienne, > > > I updated and rebuilt with the fix r4117 and I already communicated to > Etienne that this fixes MWAN Interface Systemlog (this now shows), but both > my interfaces remain marked as offline and red, when they are in fact up and > connected. > > Backing to r4041 (which is the last I had built and saved previously) > resolves the issue for the time being > > I have seen in the issue log that Etienne pointed me to that he updated the > "ip" command path. > > There are other errors being logged by uhttpd due to missing /usr/bin/ip. > > When I create a symbolic link: > > /usr/bin/ip -> /sbin/ip-tiny > > The mwan3 problem seems to go away so there must be something else looking > for /usr/bin/ip that Etienne might have missed. > Sorry I was not precise enough, I just merged this PR https://github.com/openwrt/packages/pull/4353, I'm not the author nor the maintainer Please open an issue here https://github.com/openwrt/packages/issues/new or here https://github.com/openwrt/luci/issues/new with all your findings and ping mwan3 / luci-app-mwan3 maintainers Regards Etienne > > I wonder if other packages will have the same issue as it is common practice > to hardcode binaries' full path in scripts rather than setting the PATH > variable. > > > Mauro > > > > On 13/05/17 12:27, Yousong Zhou wrote: >> >> On 13 May 2017 at 19:15, Mauro Mozzarelli wrote: >>> >>> It looks like the problem extends also to other systems and might be >>> traced >>> back to the relocation of >>> >>> /usr/bin/ip >>> >>> to >>> >>> /sbin/ip >>> >> For your information, fix for mwan3 has just been pushed to packages >> feed a while ago (https://github.com/openwrt/packages/issues/4325) >> >> >>> Here are more errors related to this issue: >>> >>> May 13 12:11:40 volta uhttpd[2297]: sh: /usr/bin/ip: not found >>> May 13 12:11:45 volta uhttpd[2297]: sh: /usr/bin/ip: not found >>> May 13 12:11:50 volta uhttpd[2297]: sh: /usr/bin/ip: not found >>> >> Previously ip-full, ip-tiny, busybox ip applet all installed to >> different locations to avoid conflict >> (https://bugs.lede-project.org/index.php?do=details_id=428). >> >> Only recently after alternatives support was added to LEDE master, it >> will be available as a symbolic link from /sbin/ip to /sbin/ip-tiny, >> /sbin/ip-full, /bin/busybox. Packages requiring ip utility from >> iproute2 should make the dependency relationship explicit in the >> DEPNDS spec. Checking existence of /usr/bin/ip or /usr/sbin/ip will >> not work now with LEDE master. >> >> Regards, >> yousong > > > > ___ > Lede-dev mailing list > Lede-dev@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/lede-dev ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
Re: [LEDE-DEV] [PATCH 2/3] ramips-mt7621: add GPIO-config for Ubiquiti-EdgeRouterX(-SFP)
On Montag, 8. Mai 2017 08:23:50 CEST Mathias Kresin wrote: > 07.05.2017 23:24, Sven Roederer: > > On Sonntag, 7. Mai 2017 12:25:39 CEST you wrote: > >> Just an opinion: being able to disable/enable PoE for each port is really > >> useful when you want to remotely reboot a device plugged into your PoE > >> switch/router. Most PoE-capable devices expose this option with the > >> stock > >> firmware. > >> > >> Does your approach with the gpio-export node allow to change the state of > >> the GPIO at runtime? (i.e. probably from userspace) > > > > Baptiste, > > > > right, that's the point I'm also looking for. To have da clean way of > > controlling the state of the PoE-voltage (24V passive PoE) for the ports. > > As it's passive PoE there might be a big risk that having the power > > enabled > > all the time might cause some problems. > > > > When defining in dts I don't see them in uci or even in /sys/class/gpio. > > So via "board.d/03_gpio_switches" seems the best way to bring them to > > userspace for user-interaction. > > If you use the gpio-export node in the device tree source file, the gpio > pin should appear at /sys/class/gpio/. Most likely you have done > something wrong. Could it be that you used exactly the same gpio pin > number as you have it in your 03_gpio_export file? You need to decrement > the gpio pin number by the gpio base as it is done for all gpios in the dts. > > Correct me if I'm wrong, but as far I can see (and confirmed by testing > it) the exported gpio in UCI doesn't have any benefit for your restart > usecase. If I change the gpio value via uci and restart > /etc/init.d/system the gpio value is still the same. Means, the value is > only set during the actual export (on boot). > > Mathias Mathias, for the "gpio in dts" I used this branch https://github.com/SvenRoederer/lede-project-source/commits/ERX-SFP_gpio-in-dts --> see the last 2 commits. Code only changed for ERX for this test. Did I miss something? You are correct, that this uci-config only gets applied on boot. but changing uci and calling "reload-config" will do the "magic". Sven ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
Re: [LEDE-DEV] [PATCH] ipq806x: Add nand boot support for ipq40xx AP-DK04.1-C1
The sender domain has a DMARC Reject/Quarantine policy which disallows sending mailing list messages using the original "From" header. To mitigate this problem, the original message has been wrapped automatically by the mailing list software.--- Begin Message --- Hello Ram, On Thursday, May 11, 2017 8:39:46 PM CEST Christian Lamparter wrote: > On Thursday, May 11, 2017 10:15:58 PM CEST Ram Chandra Jangir wrote: > > I added nand pinmux in https://patchwork.ozlabs.org/patch/761243/ , > > Could you please try with this, if it helps you. > Thanks, I'll forward it to Chris Blake. He can test it once > he returns. I'll let you know how it turned out. Chris reported: [1.40] nand: device found, Manufacturer ID: 0x01, Chip ID: 0xf1 [1.007580] nand: AMD/Spansion S34ML01G2 [1.014146] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [1.018135] 11 ofpart partitions found on MTD device qcom_nand.0 [1.025449] Creating 11 MTD partitions on "qcom_nand.0": so, it's working now. Regards, Christian --- End Message --- ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
[LEDE-DEV] CPU locked at lowest frequency on BCM2078 targets
Hello, I work on an open source project which uses the Raspberry Pi with LEDE as the host board. I've noticed that the kernel config does not include the BCM2835 cpufreq driver and therefore the CPU remains locked at the frequency set by the bootloader. This severely degrades the performance of these devices as the bootloader sets the CPU at the lowest frequency. I've run some nbench-byte benchmarks on bcm2708 and bcm2709 (32-bit) platforms: Raspberry Pi Zero W (2708) - Standard LEDE TEST: Iterations/sec. : Old Index : New Index : : Pentium 90* : AMD K6/233* :--:-: NUMERIC SORT: 231.72 : 5.94 : 1.95 STRING SORT : 6.6755 : 2.98 : 0.46 - With cpufreq enabled (ondemand scaler) NUMERIC SORT: 322.87 : 8.28 : 2.72 STRING SORT : 9.561 : 4.27 : 0.66 Raspberry Pi 3 (2709) - Standard LEDE TEST: Iterations/sec. : Old Index : New Index : : Pentium 90* : AMD K6/233* :--:-: NUMERIC SORT: 344 : 8.82 : 2.90 STRING SORT : 9.7163 : 4.34 : 0.67 - With cpufreq enabled (ondemand scaler) NUMERIC SORT: 683.62 : 17.53 : 5.76 STRING SORT : 19.446 : 8.69 : 1.34 Can we get cpufreq, ondemand scaler, and default=ondemand for this platform / two targets? If needed I can submit a patch / signoff, or if there is a reason this should not be done I'd love to start a discussion about it. -- Bryan Mayland ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
Re: [LEDE-DEV] mwan3 not working
Thanks Yousong, Merci Etienne, I updated and rebuilt with the fix r4117 and I already communicated to Etienne that this fixes MWAN Interface Systemlog (this now shows), but both my interfaces remain marked as offline and red, when they are in fact up and connected. Backing to r4041 (which is the last I had built and saved previously) resolves the issue for the time being I have seen in the issue log that Etienne pointed me to that he updated the "ip" command path. There are other errors being logged by uhttpd due to missing /usr/bin/ip. When I create a symbolic link: /usr/bin/ip -> /sbin/ip-tiny The mwan3 problem seems to go away so there must be something else looking for /usr/bin/ip that Etienne might have missed. I wonder if other packages will have the same issue as it is common practice to hardcode binaries' full path in scripts rather than setting the PATH variable. Mauro On 13/05/17 12:27, Yousong Zhou wrote: On 13 May 2017 at 19:15, Mauro Mozzarelliwrote: It looks like the problem extends also to other systems and might be traced back to the relocation of /usr/bin/ip to /sbin/ip For your information, fix for mwan3 has just been pushed to packages feed a while ago (https://github.com/openwrt/packages/issues/4325) Here are more errors related to this issue: May 13 12:11:40 volta uhttpd[2297]: sh: /usr/bin/ip: not found May 13 12:11:45 volta uhttpd[2297]: sh: /usr/bin/ip: not found May 13 12:11:50 volta uhttpd[2297]: sh: /usr/bin/ip: not found Previously ip-full, ip-tiny, busybox ip applet all installed to different locations to avoid conflict (https://bugs.lede-project.org/index.php?do=details_id=428). Only recently after alternatives support was added to LEDE master, it will be available as a symbolic link from /sbin/ip to /sbin/ip-tiny, /sbin/ip-full, /bin/busybox. Packages requiring ip utility from iproute2 should make the dependency relationship explicit in the DEPNDS spec. Checking existence of /usr/bin/ip or /usr/sbin/ip will not work now with LEDE master. Regards, yousong ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
Re: [LEDE-DEV] mwan3 not working
On 13 May 2017 at 19:15, Mauro Mozzarelliwrote: > It looks like the problem extends also to other systems and might be traced > back to the relocation of > > /usr/bin/ip > > to > > /sbin/ip > For your information, fix for mwan3 has just been pushed to packages feed a while ago (https://github.com/openwrt/packages/issues/4325) > > Here are more errors related to this issue: > > May 13 12:11:40 volta uhttpd[2297]: sh: /usr/bin/ip: not found > May 13 12:11:45 volta uhttpd[2297]: sh: /usr/bin/ip: not found > May 13 12:11:50 volta uhttpd[2297]: sh: /usr/bin/ip: not found > Previously ip-full, ip-tiny, busybox ip applet all installed to different locations to avoid conflict (https://bugs.lede-project.org/index.php?do=details_id=428). Only recently after alternatives support was added to LEDE master, it will be available as a symbolic link from /sbin/ip to /sbin/ip-tiny, /sbin/ip-full, /bin/busybox. Packages requiring ip utility from iproute2 should make the dependency relationship explicit in the DEPNDS spec. Checking existence of /usr/bin/ip or /usr/sbin/ip will not work now with LEDE master. Regards, yousong ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
Re: [LEDE-DEV] mwan3 not working
It looks like the problem extends also to other systems and might be traced back to the relocation of /usr/bin/ip to /sbin/ip Here are more errors related to this issue: May 13 12:11:40 volta uhttpd[2297]: sh: /usr/bin/ip: not found May 13 12:11:45 volta uhttpd[2297]: sh: /usr/bin/ip: not found May 13 12:11:50 volta uhttpd[2297]: sh: /usr/bin/ip: not found On 12/05/17 23:09, Etienne Champetier wrote: Hi Mauro, Please open a ticket at https://github.com/openwrt/packages/ If you can put mwan3 version (not lede) that would help a lot Regards Etienne 2017-05-12 15:03 GMT-07:00 Mauro Mozzarelli: The last time I built lede it was r4041 Today I updated to r4116 and mwan3 no longer works. In: cgi-bin/luci/admin/network/mwan I have all interfaces showing offline and red with the following: MWAN Interface Systemlog *No MWAN systemlog history found* Since sometimes feeds might not be updated properly I did also a fresh git pull, and I built lede from scratch again. Unfortunately same result. Flashing back r4041 resolved the issue. ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
Re: [LEDE-DEV] [PATCH v2] ramips: add support for GL-inet GL-MT300N-V2
On Fri, May 12, 2017 at 05:51:18PM -0500, L. D. Pinney wrote: > On Fri, May 12, 2017 at 5:29 PM, Mathias Kresinwrote: > > 12.05.2017 03:37, kyson lok: > >> > >> On Fri, May 12, 2017 at 6:18 AM, L. D. Pinney wrote: > > + { > + status = "okay"; > + > + m25p80@0 { > + #address-cells = <1>; > + #size-cells = <1>; > + compatible = "jedec,spi-nor"; > + reg = <0>; > + spi-max-frequency = <1000>; > + m25p,chunked-io = <32>; > + > + partition@0 { > + label = "u-boot"; > + reg = <0x0 0x3>; > + read-only; > + }; > + > + partition@3 { > + label = "u-boot-env"; > + reg = <0x3 0x1>; > + read-only; > >>> > >>> > >>> Is there a reason that users can not or should not write to the > >>> uboot-env partition? > > > > > > Yes, to prevent the user to shout them self into the foot. If it ain't broke > > don't fix it. > > "Unix was not designed to stop you from doing stupid things, because > that would also stop you from doing clever things." > Doug Gwyn > > In this case using the uboot-envtools package... I generally agree with that philosophy, however, in this case there are hardly any options other shooting yourself into the foot. The ramips-version of U-Boot doesn't really allow for any fancy things to be done with it -- and people who really want to risk ending up with a device which no longer boots and is only recoverable via serial console can as well change the device-tree to have unprotected access to the flash. Also note that most (if not nearly all) other ramips target got the u-boot-env partition set to be read-only for that reason. > >>> Is this correct? other mt76x8 devices with 16MB SPI Flash use : > >>> > >>> partition@5 { > >>> label = "firmware"; > >>> reg = <0x5 0xfb>; > >>> > >> > >> I think it doesn't matter. I only use 15MB for firmware. > > > > > > But why don't you use all available flash space? As far as I can see, there > > isn't anything in the last 704 KB of the flash. If possible expand the > > firmware partition to use all of the remaining flash space. > > > > Please update the IMAGE_SIZE in the build code to the value set here. Yes, please use the whole flash chip and don't leave behind unused areas. ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev