oe-alliance / ofgwrite

ofgwrite from Betacentauri: Based upon: mtd-utils-native-1.5.1
GNU General Public License v2.0
7 stars 16 forks source link

Segmentation fault #21

Closed Dima73 closed 10 months ago

Dima73 commented 11 months ago

vusolo2 login: root root@vusolo2:~# /usr/bin/ofgwrite -k -r '/media/hdd/downloaded_images/openpli-9.0-rc-vusolo2-20231007_usb.unzipped/vuplus/solo2' mkdir: can't create directory '/newroot': File exists /usr/bin/ofgwrite: line 6: 749 Segmentation fault /newroot/ofgwrite_bin "$@" root@vusolo2:~#

update makefile add -latomic to fix build with old mipsel It is exactly this which is causing the error.

WanWizard commented 11 months ago

@betacentauri ?

betacentauri commented 11 months ago

It's not my code that Captain has committed! At first sight I see no reason why -latomic is needed. Maybe ssl/crypto needs it. @atvcaptain Did you test binary on OpenATV on e.g. vusolo2 box like Dima73?

WanWizard commented 11 months ago

I know that, but we where getting no response on either this issue, or on the commit made on the commit itself.

So I'd tought I'd ping you, as it is your baby :smile:

betacentauri commented 11 months ago

Yes, my baby, but currently I have no idea how to fix it. Maybe add -latomic only in cases it is really needed. @atvcaptain For which box was it needed?

atvcaptain commented 11 months ago

i flash latest version mipsel works with openatv 7.3 i test a old mipsel red eagle twin lcd crash only with vusolo2 ?

atvcaptain commented 11 months ago

vu solo2 works here too

INIT: Switching to runlevel: 2 INIT: Sending processes configured via /etc/inittab the TERM signal INIT: no more processes left in this runlevel Oct 12 03:00:14 vusolo2 user.info ofgwrite: Move mountpoint of image files Oct 12 03:00:14 vusolo2 user.info ofgwrite: Moving /oldroot/media/hdd to /media/hdd Oct 12 03:00:14 vusolo2 user.info ofgwrite: umounting: /media/autofs Oct 12 03:00:14 vusolo2 user.info ofgwrite: umounting: /sys/fs/fuse/connections Oct 12 03:00:14 vusolo2 user.info ofgwrite: umounting: /proc/fs/nfsd Oct 12 03:00:14 vusolo2 user.info ofgwrite: umounting: /media Oct 12 03:00:14 vusolo2 user.info ofgwrite: Error starting autofs Oct 12 03:00:17 vusolo2 user.info ofgwrite: Execute: fuser -k -m /oldroot/ Oct 12 03:00:17 vusolo2 user.info ofgwrite: found vu or gb or octagon or ntfs process /oldroot/usr/bin/dvb_server -> don't kill Oct 12 03:00:17 vusolo2 user.info ofgwrite: found vu or gb or octagon or ntfs process /oldroot/usr/bin/init_client -> don't kill ofgwrite: umount not successful UBIFS: background thread "ubifs_bgt0_0" stops ofgwrite: Creating directory recursively ofgwrite: Found NAND flash ofgwrite: Flashing rootfs: ubiformat /dev/mtd0 -f /media/hdd/images/openatv-7.3-vusolo2-20231011_usb.unzipped/vuplus/solo2/root_cfe_auto.bin ofgwrite: ubiformat: mtd0 (nand), size ofgwrite: 235929600 bytes ofgwrite: (225.0 MiB ofgwrite: ) ofgwrite: , 1800 eraseblocks of ofgwrite: 131072 bytes ofgwrite: (128.0 KiB ofgwrite: ) ofgwrite: , min. I/O size 2048 bytes ofgwrite: ofgwrite: ubiformat: 1790 eraseblocks have valid erase counter, mean value is 98 ofgwrite: ubiformat: 10 bad eraseblocks found, numbers: ofgwrite: 23 ofgwrite: , 976 ofgwrite: , 1007 ofgwrite: , 1039 ofgwrite: , 1408 ofgwrite: , 1575 ofgwrite: , 1796 ofgwrite: , 1797 ofgwrite: , 1798 ofgwrite: , 1799 ofgwrite: ofgwrite: ofgwrite: Format end ofgwrite: Successfully flashed rootfs! ofgwrite: Flashing kernel ... ofgwrite: Found NAND flash ofgwrite: Erasing kernel: flash_erase /dev/mtd2 0 0 ofgwrite: Flashing kernel: nandwrite -pm /dev/mtd2 /media/hdd/images/openatv-7.3-vusolo2-20231011_usb.unzipped/vuplus/solo2/kernel_cfe_auto.bin ofgwrite: Writing data to block 0 at offset 0x0 ofgwrite: Writing data to block 1 at offset 0x20000 ofgwrite: Writing data to block 2 at offset 0x40000 ofgwrite: Writing data to block 3 at offset 0x60000 ofgwrite: Writing data to block 4 at offset 0x80000 ofgwrite: Writing data to block 5 at offset 0xa0000 ofgwrite: Writing data to block 6 at offset 0xc0000 ofgwrite: Writing data to block 7 at offset 0xe0000 ofgwrite: Writing data to block 8 at offset 0x100000 ofgwrite: Writing data to block 9 at offset 0x120000 ofgwrite: Writing data to block 10 at offset 0x140000 ofgwrite: Writing data to block 11 at offset 0x160000 ofgwrite: Writing data to block 12 at offset 0x180000 ofgwrite: Writing data to block 13 at offset 0x1a0000 ofgwrite: Writing data to block 14 at offset 0x1c0000 ofgwrite: Writing data to block 15 at offset 0x1e0000 ofgwrite: Writing data to block 16 at offset 0x200000 ofgwrite: Writing data to block 17 at offset 0x220000 ofgwrite: Writing data to block 18 at offset 0x240000 ofgwrite: Writing data to block 19 at offset 0x260000 ofgwrite: Writing data to block 20 at offset 0x280000 ofgwrite: Writing data to block 21 at offset 0x2a0000 ofgwrite: Writing data to block 22 at offset 0x2c0000 ofgwrite: Writing data to block 23 at offset 0x2e0000 ofgwrite: Writing data to block 24 at offset 0x300000 ofgwrite: Writing data to block 25 at offset 0x320000 ofgwrite: Writing data to block 26 at offset 0x340000 ofgwrite: Writing data to block 27 at offset 0x360000 ofgwrite: Writing data to block 28 at offset 0x380000 ofgwrite: Writing data to block 29 at offset 0x3a0000 ofgwrite: Writing data to block 30 at offset 0x3c0000 ofgwrite: Writing data to block 31 at offset 0x3e0000 ofgwrite: Writing data to block 32 at offset 0x400000 ofgwrite: Writing data to block 33 at offset 0x420000 ofgwrite: Successfully flashed kernel! ofgwrite: Successfully flashed image Rebooting in 3 seconds... reboot: Restarting system

atvcaptain commented 11 months ago

looks openpli have a build issue i start only the binary root@vusolo2:/# ofgwrite /usr/bin/ofgwrite: line 6: 846 Segmentation fault /newroot/ofgwrite_bin "$@"

i use ofgwrite vusolo2 from openatv 7.3 root@vusolo2:/# ofgwrite

ofgwrite Utility v4.6.7 Author: Betacentauri Based upon: mtd-utils-native-1.5.1 and busybox 1.24.1 Use at your own risk! Make always a backup before use! Don't use it if you use multiple ubi volumes in ubi layer!

Usage: ofgwrite Options: -a --android create Android boot image header -k --kernel flash kernel with automatic device recognition(default) -kmtdx --kernel=mtdx use mtdx device for kernel flashing -ksdx --kernel=sdx use sdx device for kernel flashing -kmmcblkxpx --kernel=mmcblkxpx use mmcblkxpx device for kernel flashing -r --rootfs flash rootfs with automatic device recognition(default) -rmtdy --rootfs=mtdy use mtdy device for rootfs flashing -rmmcblkxpx --rootfs=mmcblkxpx use mmcblkxpx device for rootfs flashing -sNN --slotname=NN user defined slot name -mx --multi=x flash multiboot partition x (x= 1, 2, 3,...). Only supported by some boxes. -n --nowrite show only found image and mtd partitions (no write) -f --force force kill e2 -q --quiet show less output -h --help show help

atvcaptain commented 11 months ago

use with openpli the same compiler switches see https://github.com/oe-alliance/oe-alliance-core/blob/5.3/meta-oe/recipes-extended/ofgwrite/ofgwrite.bb

WanWizard commented 11 months ago

Taking the easy way out?

OpenPLi never used any EXTRA_OEMAKE, you didn't make changes to yours, so what change in your commut has caused this to break exactly?

Huevos commented 11 months ago

__

Taking the easy way out?

OpenPLi never used any EXTRA_OEMAKE, you didn't make changes to yours, so what change in your commut has caused this to break exactly?

https://github.com/oe-alliance/oe-alliance-core/commit/49c6887c853cc95753a9d5c8bd54572c2d451d11

WanWizard commented 11 months ago

I'm pretty sure that is not the problem, I've tested that, I've added the openssl dependency., and if it can't find openssl, the build stops with a link error.

WanWizard commented 11 months ago

To double check, I've build the ofgwrite.ipk with the EXTRA_OEMAKE line (the openssl depends we already had) but that doesn't make any difference, the user still reports it segfaulting.

WanWizard commented 11 months ago

Also, removing atomic doesn't fix the problem.

betacentauri commented 11 months ago

Why is the issue closed? Did you find a way to fix it?

WanWizard commented 11 months ago

No, not fixed.

I tried everything I could, it compiles fine, but it crashes on the VU Solo 2. I haven't had time to test other MIPSEL boxes to see if it is box specific or ARCH specific. My gut feeling tells me (without any evidence) that it might be related to differences in OpenSSL versions?

WanWizard commented 11 months ago

User reports that all his other VU+ MIPSEL boxes show the same problem.

atvcaptain commented 11 months ago

test again i remove this for other box models https://github.com/oe-alliance/ofgwrite/commit/d170a1547db68a4d4aa2daaccc9ced6ec8ccf830

betacentauri commented 11 months ago

Don't think this will fix it as it contains only system calls which are done when ofwrite starts the flashing and seg fault takes place when ofgwrite starts.

I think it's more openssl or compiler version.

betacentauri commented 11 months ago

Can you please try this: https://github.com/openssl/openssl/issues/13872 So this "Add -Wl,--whole-archive -lpthread -Wl,--no-whole-archive to your compile command."

WanWizard commented 11 months ago

I have already added -lpthread -ldl, otherwise it won't build at all.

I've added an EXTRA_OEMAKE with these flags now, and asked the user to test the result.

WanWizard commented 11 months ago

Nope...

openpli 9.0-rc vusolo2

vusolo2 login: root
Last login: Sun Oct 15 20:02:08 CEST 2023 on pts/0
root@vusolo2:~# opkg install /tmp/ofgwrite_4.x+git204+d170a15-r0.0_mips32el.ipk --force-reinstall
Upgrading ofgwrite (4.x+git202+fb54e5d-r0.0) to ofgwrite (4.x+git204+d170a15) on root
Configuring ofgwrite.
root@vusolo2:~# ofgwrite
mkdir: can't create directory '/newroot': File exists
/usr/bin/ofgwrite: line 6:  1416 Segmentation fault      /newroot/ofgwrite_bin "$@"
root@vusolo2:~#`
betacentauri commented 10 months ago

For me on a et8500 it fixes the problems. I have committed it: https://github.com/OpenPLi/openpli-oe-core/commit/88880278db433c24e4946112be551ebf7c713cb5 Please test also on other boxes

WanWizard commented 10 months ago

Just built an OpenPLi develop image for the XP1000, after flash:

root@xp1000:~# ofgwrite
mkdir: can't create directory '/newroot': File exists
/usr/bin/ofgwrite: line 6: 21603 Segmentation fault      /newroot/ofgwrite_bin "$@"

no change,

atvcaptain commented 10 months ago

i build a openpli for a old mipsel and ofgwrite works with last update

WanWizard commented 10 months ago

I've arranged a Vu Duo2, I'll flash a develop image on it tomorrow.

Can't explain it for now, differences in host environment?

atvcaptain commented 10 months ago

i use ubunto 22_04 lts

WanWizard commented 10 months ago

Too new for us, due to the fact we have to be able to build older OE versions.

So for the moment we're stuck on 20.04 (to build Hartknott based images) and 18.04 (to build OpenPLi 7). And my own build machine runs Almalinux-9.

WanWizard commented 10 months ago

The current build runs ok on the Duo2. So it seems to be limited to mips32el-nf builds now. Less of an urgency.

atvcaptain commented 10 months ago

last box with was dm800 very old model all other mipsel use mips32el with hardfloat, softfloat not needed you can switch

betacentauri commented 10 months ago

Ok, I just tested again and now see your comments. I can confirm that ofgwrite from latest develop image runs on et8500.

@WanWizard Please try this openssl patch: https://github.com/openssl/openssl/commit/9362a1b32b7330e24d3bca230b412557caea095b I hope it helps. I cannot test as I don't have a mips32el-nf box here.