Experimental Gentoo Image

For anyone building packages on device here’s a trick to save unnecessary wear to your system storage.

You can tell Portage to set building environment on the NVME, USB attached storage or even in RAM (via tmpfs) with the following environment parameter:

PORTAGE_TMPDIR="/path/to/alternative/disk/mountpoint"

Portage will then setup its building environment for packages to be /path/to/alternative/disk/mountpoint/portage.

The variable can be placed in /etc/portage/make.conf or set by the shell (prioritized when both are present). This will limit the amount of writes to the system drive Portage does to downloading tarballs and transferring successfully built packages.

https://wiki.gentoo.org/wiki//etc/portage/make.conf#PORTAGE_TMPDIR

1 Like

You can also install Gentoo on your NVME drive or other media.
In my case I copied /dev/mmcblk0p4 to a partition on my NVME and configured the sdcard to boot using that partition as root.

label l2
menu label Gentoo GNU/Linux 6.6.20-starfive
linux /vmlinuz-6.6.20-starfive
initrd /initrd.img-6.6.20-starfive

    fdtdir /dtbs/6
    append  root=/dev/nvme0n1 rw console=tty0 console=ttyS0,115200 earlycon rootwait stmmaceth=chain_mode:1 selinux=0 pcie_aspm.policy=performance pcie_aspm=off pcie_port_pm=off nvme_core.default_ps_max_latency_us=0 nvme_core.io_timeout=255 nvme_core.max_retries=10 nvme_core.shutdown_timeout=10
1 Like

I did get KDE running once but it was impractical to use as GPU acceleration didn’t seem to be working even with media-libs/mesa::bingch installed. This was a while ago so I should try again.

Is bings overlay still necessary to get GPU drivers?

@rvcray @bing I suggest asking Bing.
I think that mesa 24.1.0 is getting closer to what we need.
I have been experimenting with this code meson.build · orcjit · Yukari Chiba / mesa · GitLab as Its still to be merged with the official source. It allowed me to use the OPENCL GPU drivers as well.

I also suggest using a lightweight Desktop

Good question for a newbie like me! I’ve finished the upgrade to the v23 profile, made a backup of my sdcard :smiley: and next thing would be to get the GPU working to have some HDMI output at boot time and a console visible via HDMI. But I’ve not understand the necessary steps for this. Do I need to copy the binary IMG drivers to some folder or is the overlay from bing a must?

Have a look at the README in bing c / gentoo-overlay · GitLab

I personally manually copy the GPU files myself but using the bingch ebuilds make it easier if you are just starting out. You can also reach out to Bing if you have questions about his ebuilds.

As Far as Desktop environments here are a few to choose from.
https://wiki.gentoo.org/wiki/Desktop_environment

If you like the standard desktop that the Debian Starfive image has then you may want to install the same desktop they use.

1 Like

@martin.wozenilek you do need to manually patch mesa to work with VF2’s pvr GPU binary as mesa ebuild in gentoo repo doesn’t have those patches. So using my overlay will save you from these hassle. BTW I am running normal GNOME 45 desktop on VF2, it’s quite usable on 1920x1080 resolution wayland session.

1 Like

@bing When you run es2gears_x11 or es2gears_wayland what is the FPS you are getting? Also what FPS do you get with glxgears

Mmmh … not as easy as i hoped for:

>>> Compiling source in /var/tmp/portage/media-video/vf2vpudev-5.11.3/work/soft_3rdpart-JH7110_VF2_6.1_v5.11.3 ...
 * Preparing jpu module
make -j4 HOSTCC=riscv64-unknown-linux-gnu-gcc 'LDFLAGS=-m elf64lriscv' KERNELDIR=/usr/src/linux clean default 
make	-C /usr/src/linux	M=/var/tmp/portage/media-video/vf2vpudev-5.11.3/work/soft_3rdpart-JH7110_VF2_6.1_v5.11.3/codaj12/jdi/linux/driver LDDINCDIR=/var/tmp/portage/media-video/vf2vpudev-5.11.3/work/soft_3rdpart-JH7110_VF2_6.1_v5.11.3/codaj12/jdi/linux/driver/../include modules
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
 * ACCESS DENIED:  fopen_wr:           /usr/src/linux-5.15.0-starfive/arch/riscv/kernel/vdso/vdso.lds
 * ACCESS DENIED:  unlink:             /usr/src/linux-5.15.0-starfive/arch/riscv/kernel/vdso/vdso.lds
cc1: fatal error: opening output file arch/riscv/kernel/vdso/vdso.lds: Permission denied
compilation terminated.
make[2]: *** [scripts/Makefile.build:392: arch/riscv/kernel/vdso/vdso.lds] Error 1
make[2]: *** Waiting for unfinished jobs....
 * ACCESS DENIED:  fopen_wr:           /usr/src/linux-5.15.0-starfive/arch/riscv/kernel/vdso/.rt_sigreturn.o.d
 * ACCESS DENIED:  fopen_wr:           /usr/src/linux-5.15.0-starfive/arch/riscv/kernel/vdso/.getcpu.o.d
arch/riscv/kernel/vdso/rt_sigreturn.S:17: fatal error: opening dependency file arch/riscv/kernel/vdso/.rt_sigreturn.o.d: Permission denied
compilation terminated.
make[2]: *** [scripts/Makefile.build:379: arch/riscv/kernel/vdso/rt_sigreturn.o] Error 1
arch/riscv/kernel/vdso/getcpu.S:19: fatal error: opening dependency file arch/riscv/kernel/vdso/.getcpu.o.d: Permission denied
compilation terminated.
make[2]: *** [scripts/Makefile.build:379: arch/riscv/kernel/vdso/getcpu.o] Error 1
 * ACCESS DENIED:  fopen_wr:           /usr/src/linux-5.15.0-starfive/arch/riscv/kernel/vdso/.vgettimeofday.o.d
arch/riscv/kernel/vdso/vgettimeofday.c:31:1: fatal error: opening dependency file arch/riscv/kernel/vdso/.vgettimeofday.o.d: Permission denied
   31 | }
      | ^
compilation terminated.

I’m running this as root. So “ACCESS DENIED” is maybe misleading? Working with the kernel sources which came with andrews image …

I will defer to @bing but it may be the Portage Sandbox Feature that is blocking it from writing there.

Running the following will show the currently enabled features
portageq envvar FEATURES | xargs -n 1

1 Like

@martin.wozenilek @bing Try to override the Sandbox FEATURES to see if that is the problem.

Run the following
FEATURES=“-sandbox - usersandbox” emerge --ask --verbose media-video/vf2vpudev

Les us know the results.

1 Like

sandbox is indeed an enabled feature. Will override it and try again this evening. Thanks!

The Sandbox should normally be enabled.
Make sure you have a good backup incase of any problems.
Going forward @bing should update the ebuild to work without overriding the sandbox.

1 Like

I got ~52FPS for both es2gear_wayland in gnome wayland session and the same FPS in gnome X11 session, but in X11 session the running gear has visible stuttering. glxgears won’t work at all as it segfault. I don’t think pvr binary has proper opengl support

@martin.wozenilek you will normally need to disable sandbox if you compile your kernel as normal user other than portage. Take a look at the etc/portage-risc folder under my moverlay for other setting as reference.

1 Like

@bing I will email you a copy of the ebuild I use that will not segfault.
It is based on mesa 23

@martin.wozenilek I do not recommend disabling the sandbox feature on a global basis.
I suggest only DISABLE it on a Temporary basis for specific ebuilds that fail due to it being on.

This Disables the sandbox just for this emerge.
FEATURES=“-sandbox - usersandbox” emerge --ask --verbose media-video/vf2vpudev

1 Like

Hi @andrew and @bing ! Thank you for your help! I guess you have better things to do rather to help a newbie take his first gentoo/vf2 steps :smiley:

FEATURES="-sandbox -usersandbox" emerge media-video/vf2vpudev

Results in the same errors:

>>> Compiling source in /var/tmp/portage/media-video/vf2vpudev-5.11.3/work/soft_3rdpart-JH7110_VF2_6.1_v5.11.3 ...
 * Preparing jpu module
make -j4 HOSTCC=riscv64-unknown-linux-gnu-gcc 'LDFLAGS=-m elf64lriscv' KERNELDIR=/usr/src/linux clean default 
make	-C /usr/src/linux	M=/var/tmp/portage/media-video/vf2vpudev-5.11.3/work/soft_3rdpart-JH7110_VF2_6.1_v5.11.3/codaj12/jdi/linux/driver LDDINCDIR=/var/tmp/portage/media-video/vf2vpudev-5.11.3/work/soft_3rdpart-JH7110_VF2_6.1_v5.11.3/codaj12/jdi/linux/driver/../include modules
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
cc1: fatal error: opening output file arch/riscv/kernel/vdso/vdso.lds: Permission denied
compilation terminated.

The info from

emerge --info '=media-video/vf2vpudev-5.11.3::bingch'

shows

Portage 3.0.64 (python 3.12.3-final-0, default/linux/riscv/23.0/rv64/lp64d/desktop/plasma/systemd, gcc-14, glibc-2.39-r7, 5.15.0-starfive riscv64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-5.15.0-starfive-riscv64-with-glibc2.39
KiB Mem:     8118100 total,   1580960 free
KiB Swap:    8388604 total,   8388604 free
Timestamp of repository gentoo: Sun, 02 Jun 2024 08:00:00 +0000
Head commit of repository gentoo: 9f3ccf216b8999d9b48b2e7e68d70476e65fdb25
Head commit of repository bingch: 8ae251ece2c0e2f4ffb641135e9ef84faf7697ba

sh bash 5.2_p26-r3
ld GNU ld (Gentoo 2.42 p3) 2.42.0
app-misc/pax-utils:        1.3.7::gentoo
app-shells/bash:           5.2_p26-r3::gentoo
dev-build/autoconf:        2.72-r1::gentoo
dev-build/automake:        1.16.5-r2::gentoo
dev-build/cmake:           3.29.3::gentoo
dev-build/libtool:         2.4.7-r4::gentoo
dev-build/make:            4.4.1-r1::gentoo
dev-build/meson:           1.4.1::gentoo
dev-lang/perl:             5.38.2-r6::gentoo
dev-lang/python:           3.11.9-r1::gentoo, 3.12.3-r1::gentoo, 3.13.0_beta1_p3::gentoo
dev-lang/rust-bin:         1.78.0::gentoo
sys-apps/baselayout:       2.15::gentoo
sys-apps/sandbox:          2.38::gentoo
sys-apps/systemd:          255.7::gentoo
sys-devel/binutils:        2.42-r1::gentoo
sys-devel/binutils-config: 5.5::gentoo
sys-devel/gcc:             14.1.1_p20240518::gentoo
sys-devel/gcc-config:      2.11::gentoo
sys-devel/llvm:            17.0.6::gentoo, 18.1.6::gentoo
sys-kernel/linux-headers:  6.9::gentoo (virtual/os-headers)
sys-libs/glibc:            2.39-r7::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    volatile: False
    sync-rsync-extra-opts: 
    sync-rsync-verify-jobs: 1
    sync-rsync-verify-metamanifest: yes
    sync-rsync-verify-max-age: 24

bingch
    location: /var/db/repos/bingch
    sync-type: git
    sync-uri: https://gitlab.com/bingch/gentoo-overlay.git
    masters: gentoo
    volatile: True

ACCEPT_KEYWORDS="riscv ~riscv"
ACCEPT_LICENSE="@FREE"
CBUILD="riscv64-unknown-linux-gnu"
CFLAGS="-march=rv64imafdc_zicsr_zba_zbb -mcpu=sifive-u74 -mtune=sifive-7-series -O2 -pipe"
CHOST="riscv64-unknown-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/sandbox.d"
CXXFLAGS="-march=rv64imafdc_zicsr_zba_zbb -mcpu=sifive-u74 -mtune=sifive-7-series -O2 -pipe"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-march=rv64imafdc_zicsr_zba_zbb -mcpu=sifive-u74 -mtune=sifive-7-series -O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync merge-wait multilib-strict news parallel-fetch pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-march=rv64imafdc_zicsr_zba_zbb -mcpu=sifive-u74 -mtune=sifive-7-series -O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="C.UTF8"
LC_ALL="C"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LEX="flex"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
SHELL="/bin/bash"
USE="X a52 aac acl acpi activities alsa bluetooth branding bzip2 cairo cdda cdr crypt cups dbus declarative dri dts dvd dvdr encode exif flac gdbm gif gpm gtk gui iconv icu ipv6 jpeg kde kwallet lcms libnotify mad mng mp3 mp4 mpeg ncurses networkmanager nls ogg opengl openmp pam pango pcre pdf pipewire plasma png policykit ppds pulseaudio qml qt5 readline riscv screencast sdl seccomp semantic-desktop sound spell ssl startup-notification svg systemd test-rust tiff truetype udev udisks unicode upower usb vorbis vulkan wayland widgets wxwidgets x264 xattr xcb xft xml xv xvid zlib" ADA_TARGET="gcc_12" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_anon authn_dbm authn_file authz_dbm authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir env expires ext_filter file_cache filter headers include info log_config logio mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 ntrip navcom oceanserver oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 tsip tripmate tnt ublox" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz glk hd44780 lb216 lcdm001 mtxorb text" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php8-2" POSTGRES_TARGETS="postgres15" PYTHON_SINGLE_TARGET="python3_12" PYTHON_TARGETS="python3_12" RUBY_TARGETS="ruby31 ruby32" VIDEO_CARDS="fbdev" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipp2p iface geoip fuzzy condition tarpit sysrq proto logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EMERGE_DEFAULT_OPTS, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LD, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, MAKEOPTS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PYTHONPATH, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS

Also I’m not able to compile the kernel from @bing repo. When I try to make the kernel (/usr/src/linux-JH7110_VF2_6.6_v5.12.0) I get

AR      drivers/gpu/drm/img/built-in.a
make[7]: *** .NOTINTERMEDIATE and .SECONDARY are mutually exclusive.  Stop.
make[6]: *** [scripts/Makefile.build:480: drivers/gpu/drm/img/img-rogue] Error 2
make[5]: *** [scripts/Makefile.build:480: drivers/gpu/drm/img] Error 2
make[4]: *** [scripts/Makefile.build:480: drivers/gpu/drm] Error 2
make[3]: *** [scripts/Makefile.build:480: drivers/gpu] Error 2
make[3]: *** Waiting for unfinished jobs....

Seems to me this problem?

https://lists.yoctoproject.org/g/meta-ti/message/17220

After all I’m currently in doubt if the VF2 is the appropriate board to get started with Gentoo as it is quite hard to find a complete documentation :confused:

That is progress as you are no longer getting the ACCESS DENIED error.There is another feature you need to disable but I am not sure which one.

For your last error try the following.

Comment out the last few lines in /usr/src/linux/scripts/Kbuild.include
to disable the .NOTINTERMEDIATE and .SECONDARY

Then it should look like this

# do not delete intermediate files automatically
#
# .NOTINTERMEDIATE is more correct, but only available on newer Make versions.
# Make 4.4 introduced .NOTINTERMEDIATE, and it appears in .FEATURES, but the
# global .NOTINTERMEDIATE does not work. We can use it on Make > 4.4.
# Use .SECONDARY for older Make versions, but "newer-prereq" cannot detect
# deleted files.
#ifneq ($(and $(filter notintermediate, $(.FEATURES)),$(filter-out 4.4,$(MAKE_VERSION))),)
#.NOTINTERMEDIATE:
#else
#.SECONDARY:
#endif
       
1 Like

@martin.wozenilek
For the Permission Denied run
portageq envvar FEATURES | xargs -n 1

portageq envvar FEATURES | xargs -n 1
assume-digests
binpkg-docompress
binpkg-dostrip
binpkg-logs
binpkg-multi-instance
binpkg-request-signature
buildpkg-live
ccache
config-protect-if-modified
distlocks
ebuild-locks
fixlafiles
merge-sync
merge-wait
multilib-strict
news
parallel-fetch
pkgdir-index-trusted
preserve-libs
protect-owned
qa-unresolved-soname-deps
sandbox
sfperms
strict
unknown-features-warn
unmerge-logs
unmerge-orphans
userfetch
userpriv
usersandbox
usersync
xattr

Make a note of all the FEATURES
Then try adding them to the Emerge with a - in front of each feature

EG FEATURES="-sandbox -usersandbox -<newfeature>" emerge media-video/vf2vpudev

Try adding one and if it does not work try another one

1 Like