Olimex Support Forum

Others => TERES DIY Laptop => Topic started by: khumarahn on November 20, 2017, 07:13:26 pm

Title: Gentoo [26 September 2018] [deadline, encrypted home, squashed portage]
Post by: khumarahn on November 20, 2017, 07:13:26 pm
Hi all, I am new here!

I have built a Gentoo image for Teres 1. It runs the amazing LXDE, has chromium, latex, libreoffice, vlc, etc.

It is fun to build, even though it is a rather long process and there are quite a few complications. I set up a repo with the configs and the local overlay:
https://github.com/khumarahn/teres1-gentoo
(there is a torrent with a pre-built image if you want to try it out)

P.S.: is this the first community image for Teres? :-)
Title: Re: Gentoo!
Post by: zinoviev on November 22, 2017, 08:31:16 pm
This is great! What was the biggest difficulty?

BTW, the users of Chromium who care about their privacy should try Brave (https://brave.com/).
Title: Re: Gentoo!
Post by: khumarahn on November 22, 2017, 09:25:25 pm
Nothing was particularly difficult. It's just many smaller things.

Like setting up a cross tool chain, distcc, qemu, figuring out what works and what does not.

Specific things were: battery indication, disabling the keyboard when the lid is closed, setting up vdpau. I still do not know how to set up the audio so that with the headphones plugged in, there is no sound on the speakers.

There is quite a lot information available on the internet, for example for pine64 and cubieboard. It was really helpful.

There is quite a lot of browsers. Why Brave?
Title: Re: Gentoo!
Post by: d3f on November 22, 2017, 10:00:42 pm
Thanks for that image! It's really fast and a lot more suitable for such laptop than ubuntu mate in terms of lightweight OS.

I only have that problem with the touchpad(left click = right click, no right click) but I guess it doesn't depend on the linux distribution so I am waiting for new keyboard firmware.

-L
Title: Re: Gentoo!
Post by: khumarahn on November 22, 2017, 10:30:35 pm
I found that I forgot to save/restore the sound on suspend. Arghhh. It is not enough to rebuild the image, but if you downloaded it and would like to fix it, then change two files:
/etc/acpi/actions/suspend.sh and /etc/acpi/actions/powerbtn.sh
They should be as here:
https://github.com/khumarahn/teres1-gentoo/blob/master/etc/acpi/actions/
Related commit: https://github.com/khumarahn/teres1-gentoo/commit/89417d6514e38ce4384b6242f0967664c1df6122

P.S.: There is a thread here on the touchpad buttons. I had this problem and, at least in my case, it was hardware. Wasn't difficult to solve, but I used a soldering iron + hot air station, which you may or may not have. Look into the topic, try the diagnosis with a multimeter.

P.P.S.: Can it be that haveged helps wifi? I have strange problems, sometimes cannot connect to eduroam, and later it works perfectly with the same config. The signal is very strong and numerous other devices work well.
Title: Re: Gentoo!
Post by: d3f on November 23, 2017, 08:43:31 pm
So, what do you suggest? Should I burn the image again on the sd card and fix it then or I can only fixed these files directly.

In fact I just now realized that I don't have audio :-) even after shutdown/restart. It was there initially.

-L
Title: Re: Gentoo!
Post by: khumarahn on November 23, 2017, 09:01:38 pm
uh, no need to burn the image again.
to get the sound back, open the terminal and:
1. become root (root password was "olimex"):
# su -
2. download the sound state:
# wget https://raw.githubusercontent.com/OLIMEX/DIY-LAPTOP/master/SOFTWARE/A64-TERES/blobs/asound.state
3. apply it:
# alsactl -f asound.state restore

To fix this sound loss on suspend, you can run (also as root):
# cd /etc/acpi/actions
# rm powerbtn.sh suspend.sh
# wget https://raw.githubusercontent.com/khumarahn/teres1-gentoo/master/etc/acpi/actions/powerbtn.sh
# wget https://raw.githubusercontent.com/khumarahn/teres1-gentoo/master/etc/acpi/actions/suspend.sh
# chmod 755 powerbtn.sh
# chmod 755 suspend.sh

I will update the image also :-)
Title: Re: Gentoo!
Post by: d3f on November 23, 2017, 10:00:32 pm
Great! Thanks, it works  8)
Title: Re: Gentoo!
Post by: khumarahn on November 24, 2017, 01:08:29 am
cool, thanks, fixed. Also, you may want to rebuild the LED control program, it had an annoying bug fixed. Just run as root:
emerge -av teres1-ledctrl
(and later maybe cleanup the disproportionately large download by running rm -r /usr/portage/distfiles/*)

I uploaded a new version where these things are fixed.
Title: Re: Gentoo!
Post by: d3f on November 24, 2017, 09:06:35 am
did it! thanks!

Something that I tried and you may help here, should be easy cause I did it under ubuntu mate.

I am really interested to install kicad on teres but on Gentoo I am not sure how to fix the dependencies below:

emerge -av kicad

emerge: there are no ebuilds to satisfy ">=dev-libs/boost-1.61[context,nls,threads,python?,python_targets_python2_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python3_4(-),-python_single_target_python3_5(-),-python_single_target_python3_6(-),python_single_target_python2_7(+)]".
(dependency required by "sci-electronics/kicad-4.0.7::gentoo" [ebuild])
(dependency required by "kicad" [argument])


I resolved that under ubuntu by adding temporary the debian repos. Mainly the problem here is how to install the correct python version.

Many thanks!
-L
Title: Re: Gentoo!
Post by: LubOlimex on November 24, 2017, 09:44:16 am
About what you mentioned earlier for the audio:

QuoteI still do not know how to set up the audio so that with the headphones plugged in, there is no sound on the speakers.


Check what we uploaded here, it was missing previously:

https://github.com/OLIMEX/DIY-LAPTOP/tree/master/SOFTWARE/A64-TERES/teres1-audioselect

Best regards,
Lub/OLIMEX
Title: Re: Gentoo!
Post by: khumarahn on November 24, 2017, 12:12:31 pm
With kicad on gentoo, it seems to be OK with python, but it required boost built with context support, which is masked by default:
Code (/usr/portage/profiles/arch/base/package.use.mask) Select

# Sergey Popov <pinkbyte@gentoo.org> (27 Dec 2013)
# Mask because Boost.Context library does not work on most of arches
dev-libs/boost context

(you can see this if you do emerge -pv boost, then the context use flag with be in parenthesis, i.e. most probably masked)

You can install kicad by first unmasking context:
Code (/etc/portage/profile/package.use.mask) Select

dev-libs/boost -context


Then emerge -av kicad complains about keywords and use flags, so add a few likes to respective files:
Code (/etc/portage/package.keywords) Select

# kicad
sci-electronics/electronics-menu amd64 ~amd64
sci-electronics/kicad amd64 ~amd64

(this allows use of the versions which are stable or testing for amd64)

Code (/etc/portage/package.use) Select

# kicad
sci-electronics/kicad examples github
x11-libs/wxGTK opengl
dev-libs/boost context
dev-python/wxpython opengl

(not sure if you want kicad with examples and github support though)

Then emerge -av kicad works, though it may take quite some time and you need a lot of disk space (roughly 2.5 GB for build, 2.5 GB for the installed files, 500MB for the source files archives. I mounted /usr/portage and /var/tmp/portage out on a large and fast sd card so I can build large packages.

And after all this, kicad may or may not work :-) Let me try to install it, I will write back.
Title: Re: Gentoo!
Post by: khumarahn on November 24, 2017, 04:03:55 pm
Kicad works, here is the noisy inductor:

(https://raw.githubusercontent.com/khumarahn/teres1-gentoo/master/screen.2.png)
Title: Re: Gentoo!
Post by: d3f on November 24, 2017, 05:37:47 pm
WOW! Magic  :D

Can you share step-by-step how to install kicad on Teres? I think it will be very useful and may be we can move this discussion into new topic - Kicad on Gentoo..

-L
Title: Re: Gentoo!
Post by: khumarahn on November 24, 2017, 06:00:03 pm
You need to make changes to files in /etc/portage/, as in https://www.olimex.com/forum/index.php?topic=5966.msg24472#msg24472

Then run emerge -av kicad, and let it work for a few hours. Set up distcc on a big computer if you want to speed it up.

You may run out of space, so if you are running on an sd card, you should use 16 gb or larger, and resize the system partition (with gparted for example).
Title: Re: Gentoo!
Post by: khumarahn on November 27, 2017, 04:48:27 pm
Quote from: LubOlimex on November 24, 2017, 09:44:16 am
https://github.com/OLIMEX/DIY-LAPTOP/tree/master/SOFTWARE/A64-TERES/teres1-audioselect


It seems to work! I made a few cosmetic changes, will create a PR. E.g. there has to be the check for read()>0 again.
Thank you!
Title: Re: Gentoo!
Post by: khumarahn on November 28, 2017, 07:31:14 pm
Quote from: LubOlimex on November 24, 2017, 09:44:16 am
https://github.com/OLIMEX/DIY-LAPTOP/tree/master/SOFTWARE/A64-TERES/teres1-audioselect


@LubOlimex,

is there a way to query whether the headphones are plugged in or not? The audioselect program does not receive events if the headphones are removed while the computer is powered off or suspended, and then on poweron or resume, this may results in a no sound situation.
Title: Re: Gentoo!
Post by: khumarahn on November 29, 2017, 03:53:03 am
Gcc-7.2.0 is now "testing" in Gentoo. I rebuilt the image using the new compiler, links are updated on Github. It probably does not make any noticeable difference performance-wise, but why not upgrade.
Title: Re: Gentoo!
Post by: Brian on November 29, 2017, 11:10:47 am
sunxi_check_jack_type (https://github.com/OLIMEX/DIY-LAPTOP/blob/89bee96906f3d334b946d89bdc090217aa26fe7e/SOFTWARE/A64-TERES/linux-a64/sound/soc/sunxi/sunxi_sndcodec.c#L88)

Hope this help you
Title: Re: Gentoo!
Post by: Brian on November 29, 2017, 03:47:01 pm
I have tested that reading memory at address 0x01c22c00,0x319 return 0 when no headset is plugged and 0x0f/0x1f when headphones/headset is plugged. I tryed to add this check to teres1-audioselect service but this was not that  easy as look at first sight because this service is started before alsa state restoring, so will search for another way.
Title: Re: Gentoo!
Post by: khumarahn on November 29, 2017, 03:58:19 pm
Maybe you can use "After=alsa-restore.service" in the systemd service file?

How did you find the address 0x01c22c00,0x319, and is it variable?
Title: Re: Gentoo!
Post by: Brian on November 29, 2017, 04:16:11 pm
I found this address in Allwinner_A64_User_Manual (https://linux-sunxi.org/images/b/b4/Allwinner_A64_User_Manual_V1.1.pdf) page 323 3.20.5.52.
0x318 HMIC Status Register(Default Value: 0x00000000) bit 6:Jack Detect Status
I'ts readable for sure via /dev/mem and this is enough  8)
Title: Re: Gentoo!
Post by: khumarahn on February 16, 2018, 04:03:00 pm
There is an update available:
https://github.com/khumarahn/teres1-gentoo

Changes are substantial, but probably not easy to notice by a user.


Some bugs (e.g. with chromium https://bugs.gentoo.org/636758) have been fixed, and the build is now simpler. Most things just work.

I updated the headphones detection as in here: https://github.com/d3v1c3nv11/teres1-audioselect. It seems to work perfectly, if run as a daemon, and not-as-daemon after each resume.
Title: Re: Gentoo! [update Feb 15, 2018]
Post by: d3f on March 14, 2018, 09:35:24 pm
I've downloaded the last version and it seems faster and better.

Nevertheless I find some strange issue with Google Chrome, it doesn't load youtube or google.com - errors out with Ah, snap! ... that was not the case with thr previous image.

I see same error with Google Chrome and Olimex Ubuntu mate image.
Title: Re: Gentoo! [update Feb 15, 2018]
Post by: khumarahn on March 14, 2018, 09:52:31 pm
yes, there is this strange issue. I could not figure out where it comes from, but when I updated the system again, the issue was gone... I will upload a new image soon.

I learned how to make a binary package repo for gentoo (easy). If anyone is interested, I could open it to the internet, so the packages can be downloaded binary without compilation.
Title: Re: Gentoo! [update Feb 15, 2018]
Post by: d3f on March 15, 2018, 04:53:04 pm
That would be great.

I am really interested for binary repo cause right now any time I am trying to install/compile something I am getting an error that I couldn't resolve... I've just tried to install firefox and I got compile error pointing something MALLOC..
Title: Re: Gentoo! [update Feb 15, 2018]
Post by: khumarahn on March 15, 2018, 05:45:22 pm
I also cannot compile firefox, probably hitting this bug:
https://bugs.gentoo.org/649540

But chromium I use without any issues. Here is my repo:

teres ~
# cat /etc/portage/repos.conf/gentoo.conf
[DEFAULT]
main-repo = gentoo

[gentoo]
location = /usr/portage
sync-type = rsync
sync-uri = rsync://163.172.132.71/teres-portage
#sync-uri = rsync://rsync.gentoo.org/gentoo-portage
auto-sync = yes
sync-rsync-verify-metamanifest = yes
sync-openpgp-key-path = /var/lib/gentoo/gkeys/keyrings/gentoo/release/pubring.gpg



teres ~
# cat /etc/portage/make.conf
CHOST=aarch64-linux-gnu
CHOST_arm64="${CHOST}"

...

PORTAGE_BINHOST="rsync://163.172.132.71/teres-portage-full/packages"

...


To use the repo:


Then you should be able to install chromium-65 as a binary package with
emerge -av --getbinpkg chromium

The main recent changes are CHOST_arm64="${CHOST}" in make.conf (needed for correct clang prefix), and the patch for eselect-mesa (or opengl would silently fail, I spent two days searching the source of the problem).
Title: Re: Gentoo! [update 16 March 2018]
Post by: khumarahn on March 16, 2018, 10:13:40 pm
Finally I updated the image :-)

I gave up on compiling things on Teres. It is too slow, and I want to use it for other things. So I compile in a cross arch chroot, and pull compiled packages from a binary repo. I set up the image to sync and pull binaries from my repo. (Comment out the respective lines in /etc/portage/make.conf and /etc/portage/repos.d/gentoo to disable this.)

Now to install kicad-4.0.7, run

emerge -av --getbinpkg kicad

and there is no compilation involved.

I am looking forward to the mainline kernel! If I have some spare time, I will experiment with what is available.
Title: Re: Gentoo [16 March 2018] [now with binary repo]
Post by: d3f on March 17, 2018, 06:52:37 pm
Great work, works nice and smooth, many thanks!
Title: Re: Gentoo [26 April 2018] [now with binary repo and f2fs]
Post by: khumarahn on April 26, 2018, 08:12:48 pm
I experimented a bit with f2fs. On my old class 4 kingston sd card, the image with f2fs boots literally 2-3 times faster than with ext4. It takes 1:25-1:35 to boot and open my favorite web site in the browser, compared to 3-4 minutes with ext4!!

Thus I made a new release, with root on f2fs. Also, I aligned root partition to 4MiB. Not sure if this is necessary, but it may be good. I had to compile f2fs support in the kernel image (not as a loadable module).

f2fs is relatively raw in the old 3.10 kernel, but I did not encounter any real problems yet. I am impatiently waiting on the mainline to catch up with things like sound and suspend. I use my laptop for work when I travel, and these small things feel important.
Title: Re: Gentoo [26 April 2018] [now with binary repo and f2fs]
Post by: lambda on April 27, 2018, 10:43:08 pm
Quote from: khumarahn on April 26, 2018, 08:12:48 pm
I am impatiently waiting on the mainline to catch up with things like sound and suspend. I use my laptop for work when I travel, and these small things feel important.


I don't think anybody is looking into suspend issues, but since it probably is something fairly trivial, maybe you can try to debug this yourself ...

(I guess experimenting with the PMIC related patches mentioned in the other thread recently might be a good start ...)

HTH,
Harald
Title: Re: Gentoo [26 April 2018] [now with binary repo and f2fs]
Post by: khumarahn on April 29, 2018, 10:56:34 pm
Quote from: lambda on April 27, 2018, 10:43:08 pm
experimenting with the PMIC related patches might be a good start


thanks!! I may look at it, though this will hardly happen soon.
Title: Re: Gentoo [26 April 2018] [now with binary repo and f2fs]
Post by: d3f on May 06, 2018, 06:50:27 pm
I've downloaded the last your gentoo version. It looks nice and faster boot but how do you resize the root partition? Doesn't look so easy as ext3/4.

-L
Title: Re: Gentoo [26 April 2018] [now with binary repo and f2fs]
Post by: khumarahn on May 09, 2018, 02:54:59 pm
I did not have time recently to look at how the f2fs partitions are resized. Would gparted do it in gui somehow automatically?

In any case, you can save all the contents with rsync -aAxXhH, recreate the partition and copy the contents back.

Let me know if there are any issues.
Title: Re: Gentoo [26 September 2018] [deadline, encrypted home, squashed portage]
Post by: khumarahn on September 27, 2018, 04:45:09 pm
I have been procrastinating from doing my most important work by updating Gentoo on Teres. So here is a set of updated configuration files and a new image:
https://github.com/khumarahn/teres1-gentoo

New things:
* I used the `deadline` scheduler for the IO. It prioritizes reads, storing writes for later. On Teres, where IO is a major bottleneck, it seems to improve overall latency. Say, chromium feels much more responsive. Or is it a placebo?

* Home folder is now encrypted with encfs, the password is asked at boot. I use my laptop on travel, and would not want to lose it with all those paypal cookies and passwords saved in my browser. This takes a toll on the IO, but not too much.

* Everything is rebuilt with newer compilers (gcc-8, clang-7). Many programs are updated, e.g. kicad to version 5.0.0.

* Portage is compressed into squashfs with squashmount; this frees up aroung 1GB. (Portage stores loads of small files in the filesystem; this is largely inefficient but not a problem on most modern computers.)