[CHROOT] Debian Jessie armel image

Here are software that related with Samsung H series TVs.
Post Reply

User avatar
mad_ady
SamyGO Project Donor
Posts: 243
Joined: Sun May 03, 2015 10:42 am

[CHROOT] Debian Jessie armel image

Post by mad_ady » Sun Nov 13, 2016 1:32 pm

Hello everyone,

I was looking for a way to compile programs for my H-Series TV (H6400), and first I tried to move over ubuntu binaries from a armhf system (Odroid C1) and run them on the TV. However, they didn't run (also created a minimal rootfs from ubuntu 16.04 armhf):

Code: Select all

[root@tv apps]# cd /dtv/usb/sdc/nfs/192.168.1.5/Kits/samygo/ubuntu-base/
[root@tv ubuntu-base]# cd ..
[root@tv samygo]# chroot ubuntu-base/ /bin/bash
bash: /usr/bin/groups: cannot execute binary file: Exec format error
root@(none):/#
root@(none):/# ls -l
bash: /bin/ls: cannot execute binary file: Exec format error
root@(none):/# exit
exit
So, I reverted to using armel. The difference between armhf and armel is that armhf has "hard-float" support (a.k.a a FPU), while armel does floating-point calculations in software and thus is slower. How much slower, you ask? Well, I ran sysbench on my TV (quad core CPU, unknown frequency) and on Odroid C1 (quad core, Cortex A5 @ 1500MHz) and the tv finished calculating 20000 prime numbers in 1224 seconds, while the C1 finished in 110 seconds, so that's an order of magnitude...

Anyway, here is the link to the debian image: http://www.mediafire.com/?l7b63bv7vw9z8
The compressed image is about 170MB. Uncompressed it is about 750MB, with ~300MB used and ~400MB free.

You can download it, save it to a USB drive (or network share), extract it on your tv (

Code: Select all

unxz /path/to/debian.img.xz
). Also, download these two helper scripts: https://github.com/mad-ady/samygo-debian and edit them to fit your needs.

prepareChroot.sh assumes your image is in /dtv/usb/sda1/debian.img, so edit it if necessary. Also you will need to create a mount point (by default it's in /mnt/debian).
To chroot into the image do:

Code: Select all

chroot /mnt/debian /bin/bash
#/init
To clean up when you're done, run the disconnectChroot.sh script.

When inside the chroot you can use standard debian commands and install debian packages through apt (e.g. I installed htop). Alternatively, you can follow the guide here https://forum.samygo.tv/viewtopic.php?t=7898, and even start a desktop environment (did I mention it was slow)?

Image
Enjoy!
H6400, firmware 2602.2 downgraded to 2130

zoelechat
SamyGO Moderator
Posts: 7853
Joined: Fri Apr 12, 2013 7:32 pm
Location: France

Re: [CHROOT] Debian Jessie armel image

Post by zoelechat » Sun Nov 13, 2016 1:40 pm

mad_ady wrote:So, I reverted to using armel. The difference between armhf and armel is that armhf has "hard-float" support (a.k.a a FPU), while armel does floating-point calculations in software and thus is slower. How much slower, you ask? Well, I ran sysbench on my TV (quad core CPU, unknown frequency) and on Odroid C1 (quad core, Cortex A5 @ 1500MHz) and the tv finished calculating 20000 prime numbers in 1224 seconds, while the C1 finished in 110 seconds, so that's an order of magnitude...
...and Samsung persist in using softfloat even on Tizen TVs despite hardware hardfloat support for ages (at least from E-series). It's just needed to change linker name to notice it...
However I think in "real life conditions", the difference is much less noticeable than what shows your hf dedicated benchmark. Still shame though, as if arm wasn't lagging behind enough :)
I do NOT receive any PM. Please use forum.

User avatar
mad_ady
SamyGO Project Donor
Posts: 243
Joined: Sun May 03, 2015 10:42 am

Re: [CHROOT] Debian Jessie armel image

Post by mad_ady » Sun Nov 13, 2016 2:07 pm

Interesting...
On my Samsung TV, the linker is called:

Code: Select all

[root@tv cjpeg]# ls -l /lib/ld-linux.so.3
lrwxrwxrwx    1 root     root            15 Jan  1  1970 /lib/ld-linux.so.3 -> libs/ld-2.17.so
While on my armhf box it's:

Code: Select all

adrianp@odroid:~/bin$ ls -l /lib/ld-linux-armhf.so.3
lrwxrwxrwx 1 root root 30 Oct 14 13:32 /lib/ld-linux-armhf.so.3 -> arm-linux-gnueabihf/ld-2.23.so
Unfortunately, /lib is readonly, and I can't trick it by bind-mounting on top of anything... But, even if I could, if I were to drop that armhf loader and its symlink, would armhf programs magically start to work? Hmm, maybe LD_LIBRARY_PATH could help this... I'm not sure if the kernel needs to be "armhf"-enabled or not. I guess it could run just armel code all day long and let userspace use the FPU.

In terms of performance - it depends on what you're doing. I'm not planning on cracking passwords or calculating PI, but, for example, converting images to jpeg can benefit from the FPU (it does a lot of divisions).

Yeah, it's a pity Samsung willfully limits their architectures

Edit: Unfortunately the LD_LIBRARY_PATH trick does not work for the loader. It's hardcoded in the binary. I'll try to edit it with a hex editor :)

Code: Select all

adrianp@odroid:~/bin$ ldd /usr/bin/cjpeg
        libjpeg.so.8 => /usr/lib/arm-linux-gnueabihf/libjpeg.so.8 (0xb6ee9000)
        libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6dfd000)
        /lib/ld-linux-armhf.so.3 (0xb6f3a000)
Last edited by mad_ady on Sun Nov 13, 2016 2:12 pm, edited 1 time in total.
H6400, firmware 2602.2 downgraded to 2130

zoelechat
SamyGO Moderator
Posts: 7853
Joined: Fri Apr 12, 2013 7:32 pm
Location: France

Re: [CHROOT] Debian Jessie armel image

Post by zoelechat » Sun Nov 13, 2016 2:11 pm

Well, tries I did were just to show proof-of-concept, on binaries without lib dependencies, and hex-edit of linker name inside it :D
Turning system into hf is no more than hopeless I guess. :)
I do NOT receive any PM. Please use forum.

User avatar
bugficks
Official SamyGO Developer
Posts: 1047
Joined: Tue Jun 25, 2013 3:56 pm

Re: [CHROOT] Debian Jessie armel image

Post by bugficks » Mon Nov 14, 2016 3:22 am

you need to patch and recompile openssl libs w/o arm cpu support detection. check exink logs, there should be tons of errors if you use e.g. apt :)

User avatar
mad_ady
SamyGO Project Donor
Posts: 243
Joined: Sun May 03, 2015 10:42 am

Re: [CHROOT] Debian Jessie armel image

Post by mad_ady » Tue Jul 18, 2017 2:40 pm

I've played a bit with the debian chroot image and I seem to run into some "Illegal instructions" when I run certain python apps inside the chroot (pip, virtualenv):

Code: Select all

$ virtualenv 
Illegal instruction
$ dmesg
[    0.000000] [show_info] It's not show_info() case for Process Name[virtualenv], Thread Name[virtualenv], PC = 0xb5b23008, LR = 0xb5b1f4f8 .
[    0.000000] ##### send signal from KERNEL, SIG : 4, virtualenv, PID:17075, force_sig_info 
[    0.000000] Backtrace: 
[    0.000000] Function entered at [<c00164e8>] from [<c029ece0>]
[    0.000000]  r6:b5b23008 r5:00000004 r4:d7195f40 r3:c036e940
[    0.000000] Function entered at [<c029ecc8>] from [<c0035980>]
[    0.000000] Function entered at [<c0035944>] from [<c00173a4>]
[    0.000000]  r8:00000000 r7:d1b51fb0 r6:b5b23008 r5:d1b51f08 r4:d1b50000
[    0.000000] Function entered at [<c0017350>] from [<c00082d4>]
[    0.000000]  r5:ee190f1d r4:c036d67c
[    0.000000] Function entered at [<c0008194>] from [<c0013058>]
[    0.000000] Exception stack(0xd1b51fb0 to 0xd1b51ff8)
[    0.000000] 1fa0:                                     00000000 00000000 b5c4f0dc 00000008
[    0.000000] 1fc0: b5c4efd8 b5c4f164 00000001 00000000 be0e5078 00000002 00000000 be0e51cc
[    0.000000] 1fe0: b5c4f040 be0e4f60 b5b1f4f8 b5b23008 60000150 ffffffff 00000000
[    0.000000]  r8:00000f00 r7:00000001 r6:d1b50050 r5:60000150 r4:b5b23008
[    0.000000] ##### send signal SIG : 4, virtualenv(17075)->virtualenv(17075) __send_signal
[    0.000000]  ##### ignored user defined signal (4) handler, call kernel default handler
[    0.000000] ##### deliver signal SIG : 4, virtualenv(17075) get_signal_to_deliver
[    0.000000] [VDLP COREDUMP] SIGNR:4

[    0.000000] FATAL: minimal core: Unable to open /mtd_rwcommon directory
[    0.000000] FATAL: minimal core: Unable to open /mtd_rwcommon/error_log/ directory

Are these caused because libc doesn't support armhf and the app tries to do CPU feature detection as @bugficks suggested? Or is it because the packages are broken in debian/python repositories?
H6400, firmware 2602.2 downgraded to 2130

zoelechat
SamyGO Moderator
Posts: 7853
Joined: Fri Apr 12, 2013 7:32 pm
Location: France

Re: [CHROOT] Debian Jessie armel image

Post by zoelechat » Tue Jul 18, 2017 4:46 pm

No idea if broken or whatever, but I got same problem on K/Jessie/chroot with apt python, had to recompile myself.
I do NOT receive any PM. Please use forum.

User avatar
mad_ady
SamyGO Project Donor
Posts: 243
Joined: Sun May 03, 2015 10:42 am

Re: [CHROOT] Debian Jessie armel image

Post by mad_ady » Wed Jul 19, 2017 7:25 am

Ok, thanks. Did you recompile it locally, or did you cross compile it? If you compiled it locally, did you have to add swap? Also, roughly how much disk space did you have to use to compile python?
H6400, firmware 2602.2 downgraded to 2130

zoelechat
SamyGO Moderator
Posts: 7853
Joined: Fri Apr 12, 2013 7:32 pm
Location: France

Re: [CHROOT] Debian Jessie armel image

Post by zoelechat » Wed Jul 19, 2017 8:53 am

Locally with Tizen toolchain built for ARM and installed as alternative, the rest I didn't ask myself questions, it just compiled :)
For info though, TV owns 2GB RAM, 1GB swap by default and chroot is on ~16GB USB ext4 partition, but no idea how much were used.
Toolchain I built on my "dev board" :mrgreen: , good option to avoid cross compilation and if you lack resources on TV.
I do NOT receive any PM. Please use forum.

Post Reply

Return to “[H] Software”