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

ofgwrite fails with framebuffer not available #13

Open technic opened 2 years ago

technic commented 2 years ago

Hi, I am trying to use online flash in openatv 6.4 image on axashistwin. After launching ofgwrite it goes until init 2 stage, and then I see black screen. After ssh to the box I see that no ofgwrite and no enigma2 process is running. According to enigma2 log I have

[Console] command: /usr/bin/ofgwrite -r -k '/media/hdd/images/openatv-6.4-axashistwin-20210919_usb.unzipped/axas/axashistwin'

There is the following message in the /var/log/messages:

Sep 28 14:44:49 axashistwin user.info ofgwrite:  ofgwrite Utility v4.5.6
Sep 28 14:44:49 axashistwin user.info ofgwrite: Author: Betacentauri
Sep 28 14:44:49 axashistwin user.info ofgwrite: Based upon: mtd-utils-native-1.5.1 and busybox 1.24.1
Sep 28 14:44:49 axashistwin user.info ofgwrite: Use at your own risk! Make always a backup before use!
Sep 28 14:44:49 axashistwin user.info ofgwrite: Don't use it if you use multiple ubi volumes in ubi layer!
Sep 28 14:44:49 axashistwin user.info ofgwrite: Flashing rootfs
Sep 28 14:44:49 axashistwin user.info ofgwrite: Flashing kernel
Sep 28 14:44:49 axashistwin user.info ofgwrite: Searching image files in /media/hdd/images/openatv-6.4-axashistwin-20210919_usb.unzipped/axas/axashistwin resolved to /media/hdd/images/openatv-6.4-axashistwin-20210919_usb.unzipped/axas/axashistwin
Sep 28 14:44:49 axashistwin user.info ofgwrite: Found kernel file: /media/hdd/images/openatv-6.4-axashistwin-20210919_usb.unzipped/axas/axashistwin/uImage
Sep 28 14:44:49 axashistwin user.info ofgwrite: Found rootfs file: /media/hdd/images/openatv-6.4-axashistwin-20210919_usb.unzipped/axas/axashistwin/rootfs.bin
Sep 28 14:44:49 axashistwin user.info ofgwrite: Found UBIFS rootfs
Sep 28 14:44:49 axashistwin user.info ofgwrite: Found mounted /newroot
Sep 28 14:44:49 axashistwin user.info ofgwrite: Found mounted /newroot
Sep 28 14:44:49 axashistwin user.info ofgwrite: Found mountpoint for rootfs file: /media/hdd
Sep 28 14:44:49 axashistwin user.info ofgwrite:
Sep 28 14:44:49 axashistwin user.info ofgwrite: Found /proc/mtd entries:
Sep 28 14:44:49 axashistwin user.info ofgwrite: Device:   Size:     Erasesize:  Name:                   Image:
Sep 28 14:44:49 axashistwin user.info ofgwrite: mtd0:     00100000  00020000    "boot"
Sep 28 14:44:49 axashistwin user.info ofgwrite:
Sep 28 14:44:49 axashistwin user.info ofgwrite: mtd1:     00080000  00020000    "bootargs"
Sep 28 14:44:49 axashistwin user.info ofgwrite:
Sep 28 14:44:49 axashistwin user.info ofgwrite: mtd2:     00040000  00020000    "baseparam"
Sep 28 14:44:49 axashistwin user.info ofgwrite:
Sep 28 14:44:49 axashistwin user.info ofgwrite: mtd3:     00040000  00020000    "pqparam"
Sep 28 14:44:49 axashistwin user.info ofgwrite:
Sep 28 14:44:49 axashistwin user.info ofgwrite: mtd4:     00100000  00020000    "logo"
Sep 28 14:44:49 axashistwin user.info ofgwrite:
Sep 28 14:44:49 axashistwin user.info ofgwrite: mtd5:     00080000  00020000    "deviceinfo"
Sep 28 14:44:49 axashistwin user.info ofgwrite:
Sep 28 14:44:49 axashistwin user.info ofgwrite: mtd6:     00080000  00020000    "softwareinfo"
Sep 28 14:44:49 axashistwin user.info ofgwrite:
Sep 28 14:44:49 axashistwin user.info ofgwrite: mtd7:     00800000  00020000    "loader"
Sep 28 14:44:49 axashistwin user.info ofgwrite:
Sep 28 14:44:49 axashistwin user.info ofgwrite: mtd8:     00800000  00020000    "kernel"
Sep 28 14:44:49 axashistwin user.info ofgwrite:   ->  /media/hdd/images/openatv-6.4-axashistwin-20210919_usb.unzipped/axas/axashistwin/uImage
Sep 28 14:44:49 axashistwin user.info ofgwrite: mtd9:     0ec00000  00020000    "rootfs"
Sep 28 14:44:49 axashistwin user.info ofgwrite:   ->  /media/hdd/images/openatv-6.4-axashistwin-20210919_usb.unzipped/axas/axashistwin/rootfs.bin
Sep 28 14:44:49 axashistwin user.info ofgwrite: Using kernel mtd device: /dev/mtd8
Sep 28 14:44:49 axashistwin user.info ofgwrite: Using rootfs mtd device: /dev/mtd9
Sep 28 14:44:49 axashistwin user.info ofgwrite:
Sep 28 14:44:50 axashistwin user.info ofgwrite: Syncing filesystem
Sep 28 14:44:52 axashistwin user.info ofgwrite: daemonize
Sep 28 14:44:52 axashistwin user.info ofgwrite:  successful
Sep 28 14:44:52 axashistwin user.info ofgwrite: start umount_rootfs
Sep 28 14:44:53 axashistwin user.info ofgwrite: Switching to user mode 2
Sep 28 14:44:53 axashistwin daemon.info init: Switching to runlevel: 2
Sep 28 14:44:53 axashistwin user.info ofgwrite: Checking E2 is running...
Sep 28 14:44:53 axashistwin user.info ofgwrite: Execute: ps
Sep 28 14:44:53 axashistwin user.warn kernel: hdmi_cec_release
Sep 28 14:44:55 axashistwin user.info ofgwrite: E2 still running
Sep 28 14:44:55 axashistwin user.info ofgwrite: Execute: ps
Sep 28 14:44:55 axashistwin user.info ofgwrite: E2 is stopped
Sep 28 14:44:55 axashistwin user.warn kernel: [15:05:22:973 ERROR-HI_FB]:OPTM_GfxOpenLayer[2334]:you should initial and open display first, open fb0 failure!
Sep 28 14:44:55 axashistwin user.warn kernel: [15:05:22:983 ERROR-HI_FB]:DRV_HIFB_Open[5579]:failed to open layer0 !
Sep 28 14:44:55 axashistwin user.warn kernel: [15:05:23:197 ERROR-HI_FB]:DRV_HIFB_Open[5661]:hifb open failed
Sep 28 14:44:55 axashistwin user.info ofgwrite: framebuffer not available.
betacentauri commented 2 years ago

Does it work if you first stop e2 and then execute ofgwrite via telnet (complete command see above in the log).

technic commented 2 years ago

Does it work if you first stop e2 and then execute ofgwrite via telnet (complete command see above in the log).

yes

betacentauri commented 2 years ago

I know that some boxes prevent opening the frame buffer twice. Therefore I close and open the frame buffer again after e2 has stopped.

https://github.com/oe-alliance/ofgwrite/blob/master/ofgwrite.c#L854

So at the moment I don’t have an idea how to fix that. Maybe wait a little bit more?

betacentauri commented 2 years ago

Maybe add some more debug messages. Are you able to do that? Or should I offer a binary? (May take some days)

technic commented 2 years ago

thanks for your answers. I can take a closer look at this during the weekends. Interestingly, this issue does not occur 100% of the time, but I didn't find the reason yet. I don't have a toolchain at hand now, but I can compile it, it will be easier to experiment then. If you have ideas where to put more printfs, send me a binary or a patch.

betacentauri commented 2 years ago

I would try to add a “sleep(1)” or similar before opening the framebuffer. And also some debug messages before opening the framebuffer to exactly see which statement cause the problem and what the return value from e.g. open_framebuffer is. https://github.com/oe-alliance/ofgwrite/blob/master/fb.c#L586

If eg open_framebuffer is really successful and the driver afterwards “says” framebuffer is not open, then it would be a driver bug for me…

technic commented 2 years ago

Actually I don't see why it stops working when there is a framebuffer error, because the return code is ignored.

technic commented 2 years ago

So when there is a framebuffer not available. error the program crashes with SIGSEGV

...
user.warn kernel: [21:14:36:727 ERROR-HI_FB]:OPTM_GfxOpenLayer[2334]:you should initial and open display first, open fb0 failure!
user.warn kernel: [21:14:36:737 ERROR-HI_FB]:DRV_HIFB_Open[5579]:failed to open layer0 !
user.warn kernel: [21:14:36:950 ERROR-HI_FB]:DRV_HIFB_Open[5661]:hifb open failed
user.info ofgwrite: framebuffer not available.
user.info kernel: potentially unexpected fatal signal 11.
user.warn kernel: CPU: 0 PID: 1993 Comm: ofgwrite_bin Tainted: P         C O    4.4.35 #1
user.warn kernel: Hardware name: bigfish
user.warn kernel: task: cf20d980 ti: cf3d4000 task.ti: cf3d4000
user.warn kernel: PC is at 0x1b270
user.warn kernel: LR is at 0x0
user.warn kernel: pc : [<0001b270>]    lr : [<00000000>]    psr: 800f0010
user.warn kernel: sp : be74d1b0  ip : 00000001  fp : 00000000
user.warn kernel: r10: 00000000  r9 : 000c1be8  r8 : 000be180
user.warn kernel: r7 : 00090bb3  r6 : 000c1b48  r5 : 00000000  r4 : b601e000
user.warn kernel: r3 : 000002d0  r2 : 00000500  r1 : 00000000  r0 : 00000000
user.warn kernel: Flags: Nzcv  IRQs on  FIQs on  Mode USER_32  ISA ARM  Segment user
user.warn kernel: Control: 10c53c7d  Table: 10850059  DAC: 00000055
user.warn kernel: CPU: 0 PID: 1993 Comm: ofgwrite_bin Tainted: P         C O    4.4.35 #1
user.warn kernel: Hardware name: bigfish
user.warn kernel: [<c001e830>] (unwind_backtrace) from [<c001b064>] (show_stack+0x20/0x24)
user.warn kernel: [<c001b064>] (show_stack) from [<c036cef0>] (dump_stack+0x24/0x28)
user.warn kernel: [<c036cef0>] (dump_stack) from [<c0017b50>] (show_regs+0x1c/0x20)
user.warn kernel: [<c0017b50>] (show_regs) from [<c0038c60>] (get_signal+0x594/0x598)
user.warn kernel: [<c0038c60>] (get_signal) from [<c001a6c8>] (do_signal+0xd0/0x410)
user.warn kernel: [<c001a6c8>] (do_signal) from [<c001abe4>] (do_work_pending+0xac/0xbc)
user.warn kernel: [<c001abe4>] (do_work_pending) from [<c00165b4>] 

So maybe there is subsequent read or write which goes wrong

technic commented 2 years ago

Ok, it is quite clear that mmap_fb did not succeed and all subsequent writes to fb will crash. Maybe we should check init_framebuffer exit code?

betacentauri commented 2 years ago

And then? Stop ofgwrite or flash without showing the progress on the TV screen?

init_framebuffer is called 2 times. Can you see which call fails? I guess the second one.

Well, not very good coding from me :-( But I would like to see more debug messages to understand what goes wrong exactly. I'll prepare a patch for you...

betacentauri commented 2 years ago

ofgwrite_issue_13.zip

I hope the binary works (is build for ARM boxes). If not, patch is included.

technic commented 2 years ago

And then?

Maybe go to reboot,... well, there is no easy way to report an error actually

I guess the second one.

I think it's this one https://github.com/oe-alliance/ofgwrite/blob/master/ofgwrite.c#L854 but I am not sure. Thanks for the binary. This issue popups not every time, I will try to get a new log.

betacentauri commented 2 years ago

Line 854: Yes, I think so, too.

The binary tries now to open the framebuffer 2 times with 5 seconds delay after first try. So even if it’s successful, please look into the log whether first try failed.

technic commented 2 years ago

I'll let you know later, it's not compatible with armv7

betacentauri commented 2 years ago

Was for a sf8008 as build env was ready for this box and I thought all hisi boxes use similar arm chip...

I'll try to build new binary...

betacentauri commented 2 years ago

ofgwrite_framebuffer_log.zip Now it should work. Replace the ofgwrite_bin in /usr/bin/ with the unzipped ofgwrite_bin.

betacentauri commented 2 years ago

Any feedback regarding this?

technic commented 2 years ago

Hi, Sorry, I got occupied with other things. Thanks for the reminder I hope I can check it after holidays.