User:Minou/Arm64

From Gentoo Wiki
Jump to:navigation Jump to:search

create cross tools

root #emerge --ask sys-devel/crossdev
root #crossdev --target aarch64-unknown-linux-gnu
root #crossdev --target arm-linux-gnueabihf
Warning
Improperly using crossdev may "pollute" ebuild repositories: crossdev operates by adding packages to an ebuild repository, so care must be taken to ensure crossdev adds packages to a separate repository. If you do not have an overlay created you need to follow the instructions given in the crossdev wiki page. Here I have an overlay which I call catu so that is not needed.
Beagleplay u-boot creation needs these
root #emerge --ask dev-python/cryptography
root #emerge --ask dev-python/pyelftools
root #emerge --ask dev-util/yamllint
root #emerge --ask dev-python/jsonschema

Create gentoo rootfs

The rootfs directory is created on /usr/src/arm64

root #cd /usr/src
root #mkdir arm64
root #cd arm64
root #mkdir rootfs-arm64
root #cd rootfs-arm64
Once the rootfs is built we compress it in a file that can later be used
to create a gentoo installation for a particular arm64 board
We then make specific updates for that particular board

Download stage3 and decompress in rootfs directory

root #tar --numeric-owner --xattrs -xvJpf stage3-arm64-desktop-openrc-20250126T230320Z.tar.xz
root #rm -f stage3-arm64-desktop-openrc-20250126T230320Z.tar.xz
root #cp /etc/resolv.conf etc
root #cd ..
Add the script 16-set-alias.bash on /usr/src/riscv64/rootfs-riscv64/etc/bashrc.d
# /etc/bash/bashrc.d/16-set-alias.bash
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

alias dir='ls -la -N --color'

alias rm='rm -i'
alias del='rm -i'

alias rd=rmdir
alias md='mkdir -p'

Prepare for chroot

In order to chroot on a arm64 rootfs a few things have to be done.
First you need to make sure that the kernel supports it and emerge needed support
The build system's kernel must support miscellaneous binary formats.
This can be enabled  with CONFIG_BINFMT_MISC=m 
or CONFIG_BINFMT_MISC=y in the the kernel's .config file. 
Tip
A system restart is required after building this module before it can be used.
KERNEL Enable CONFIG_BINFMT_MISC
Executable file formats  --->
  <*> Kernel support for MISC binaries
Important
app-emulation/qemu must be emerged with USE=static-user to use user targets.
Warning
QEMU_SOFTMMU_TARGETS and QEMU_USER_TARGETS are empty by default and must be defined to utilize user targets.
Note
Activating the static-user will require supporting libraries to be build with static-libs support.
FILE /etc/portage/package.use/qemuEnable all user targets and static-libs in supporting libraries.
# Enable static-user and add the arm64 and other targets
app-emulation/qemu static-user QEMU_SOFTMMU_TARGETS: * QEMU_USER_TARGETS: *
# required by app-emulation/qemu::gentoo[static,static-user]
# required by qemu (argument)
dev-libs/glib static-libs
# required by app-emulation/qemu::gentoo[-static,static-user]
# required by qemu (argument)
sys-libs/zlib static-libs
# required by app-emulation/qemu::gentoo[-static,static-user,xattr]
# required by qemu (argument)
sys-apps/attr static-libs
# required by dev-libs/glib::gentoo
# required by app-emulation/qemu::gentoo[-static,static-user]
# required by qemu (argument)
dev-libs/libpcre2 static-libs

Emerge needed packages

root #emerge --ask sys-block/bmap-tools sys-fs/genimage dev-libs/libyaml sys-fs/mtools
root #emerge --ask app-emulation/qemu --update --newuse --deep
root #emerge --ask sys-apps/arch-chroot
root #emerge --ask sys-fs/dosfstools
root #cd /usr/bin
root #ln -s mkfs.vfat mkdosfs
root #cd ~

Start the qemu-binfmt service

To start the qemu-binfmt service:

root #rc-service qemu-binfmt start

It may be wise for the services to be started by default on boot:

root #rc-update add qemu-binfmt default

To be able to chroot into a arm64 rootfs while using an amd64 system, the QEMU static-user binary must be copied into the environment.

cp /usr/bin/qemu-aarch64 /usr/src/arm64/rootfs-arm64/usr/bin/

chroot in rootfs directory

Once the environment has been prepared, sys-apps/arch-chroot can be used:

root #arch-chroot /usr/src/arm64/rootfs-arm64
You will likely get this message which is nonsense. 
I have done this for years without any issue. 
Once the compiling is done I create a compressed file which will be decompressed
on the  micro SD.
 
==> WARNING: /usr/src/arm64/rootfs-arm64 is not a mountpoint. 
This may have undesirable side effects.
root #env-update
root #export PS1="(chroot) $PS1"
root #source /etc/profile

emerge needed files

root #emerge-webrsync
root #emerge --sync

Edit /etc/portage/make.conf file

FILE /etc/portage/make.conf
COMMON_FLAGS="-O2 -pipe"
 CFLAGS="${COMMON_FLAGS}"
 CXXFLAGS="${COMMON_FLAGS}"
 FCFLAGS="${COMMON_FLAGS}"
 FFLAGS="${COMMON_FLAGS}"
 
 CHOST="aarch64-unknown-linux-gnu"

 LINGUAS="fr fr_CA en en_US es es_AR es_BO es_CL es_CO es_CR es_CU
 es_DO es_EC es_ES es_GT es_HN es_MX es_NI es_PA es_PE
 es_PR es_PY es_SV es_US es_UY es_VE
 zh zh_CN zh_HK zh_SG zh_TW"
 
 L10N="fr fr-CA en en-US es es-AR es-BO es-CL es-CO es-CR es-CU
 es-DO es-EC es-ES es-GT es-HN es-MX es-NI es-PA es-PE
 es-PR es-PY es-SV es-US es-UY es-VE
 zh zh-CN zh-HK zh-SG zh-TW"
 
 ACCEPT_LICENSE="*"
 # NOTE: This stage was built with the bindist USE flag enabled
 
 # This sets the language of build output to English.
 # Please keep this setting intact when reporting bugs.
 LC_MESSAGES=C.utf8
 FEATURES="-test -pid-sandbox -network-sandbox -sandbox -usersandbox -ipc-sandbox -selinux -sesandbox -collision-detect"
 
 USE="${ARCH} -zeitgeist -beagle -pcmcia -selinux -bindist buildpkg -pid-sandbox 
     -network-sandbox -sandbox -usersandbox -ipc-sandbox -sesandbox -seccomp -systemd dbus
      X elogind jpeg a52 gif xinerama x265 x264 -test pulseaudio qt6 tinfo gtk++ -bindist
      scanner -audit"

 I also added a list of mirrors which the wiki editor won't allow me 
 to put in here not realizing that those links are all gentoo links
 GENTOO_MIRRORS=" List of mirrors sites"

 PORTDIR_OVERLAY="/usr/local/portage/catu"

Setup locales

You need to uncomment the lines for the languages that you may want to use in the future in the locale.gen/usr/src/arm64/rootfs-armv64/usr/bin/

root #locale-gen]
After this you need to set the locale that you want 
If the locales aren't seen run locale-gen again
root #locale -a
If the default is not the one you want, you will need to change it
In my case I want the French Canadian locale to be set
root #eselect locale list
 [1]   C
 [2]   C.utf8
 [3]   POSIX
 [4]   en_AG
 [5]   en_AG.utf8
 [6]   en_AU.utf8
 [7]   en_BW.utf8
 [8]   en_CA.utf8
 [9]   en_DK.utf8
 [10]  en_GB.utf8
 [11]  en_HK.utf8
 [12]  en_IE.utf8
 [13]  en_IN
 [14]  en_IN.utf8
 [15]  en_NG
 [16]  en_NG.utf8
 [17]  en_NZ.utf8
 [18]  en_PH.utf8
 [19]  en_SG.utf8
 [20]  en_US.utf8
 [21]  en_ZA.utf8
 [22]  en_ZM
 [23]  en_ZM.utf8
 [24]  en_ZW.utf8
 [25]  es_AR.utf8
 [26]  es_BO.utf8
 [27]  es_CL.utf8
 [28]  es_CO.utf8
 [29]  es_CR.utf8
 [30]  es_CU
 [31]  es_CU.utf8
 [32]  es_DO.utf8
 [33]  es_EC.utf8
 [34]  es_ES.utf8
 [35]  es_GT.utf8
 [36]  es_HN.utf8
 [37]  es_MX.utf8
 [38]  es_NI.utf8
 [39]  es_PA.utf8
 [40]  es_PE.utf8
 [41]  es_PR.utf8
 [42]  es_PY.utf8
 [43]  es_SV.utf8
 [44]  es_US.utf8
 [45]  es_UY.utf8
 [46]  es_VE.utf8
 [47]  fr_BE.utf8
 [48]  fr_CA.utf8
 [49]  fr_FR.utf8
 [50]  fr_LU.utf8
 [51]  zh_CN
 [52]  zh_CN.gb18030
 [53]  zh_CN.gb2312
 [54]  zh_CN.gbk
 [55]  zh_CN.utf8
 [56]  zh_HK
 [57]  zh_HK.big5hkscs
 [58]  zh_HK.utf8
 [59]  zh_SG
 [60]  zh_SG.gb2312
 [61]  zh_SG.gbk
 [62]  zh_SG.utf8
 [63]  zh_TW
 [64]  zh_TW.big5
 [65]  zh_TW.euctw
 [66]  zh_TW.utf8
 [67]  fr_CA.UTF-8 *
 [ ]   (free form)
The one with a * is the default one 
For example if you want to switch to Mandarin
You would select one of 51 to 55
I selected 48 as I want the French Canadian locale
root #eselect locale set 48
Setting LANG to fr_CA.utf8 ...
Run ". /etc/profile" to update the variable in your shell.
root #. /etc/profile
FILE /etc/env.d/02locale
Since I changed the locale from C.UTF8 I need to change something
  in the 02locale file on /etc/env.d
  
  The original content is this :
  LANG="fr_CA.utf8"

  I added one line to satisfy some program who do not recognize locales correctly
  and changed the utf8 line because a few programs do not recognize the .utf8 form

  LANG="fr_CA.UTF-8"
  LC_COLLATE="C.UTF-8"

  If you do not use the us keyboard you need to change /etc/conf.d/keymaps
  I changed 3 lines  
  Use French Canadian keyboard
   keymap="cf"
  Use the windows key to go to the command line
   windowkeys="yes"
  I have family in France so that is usefull to have 
  the € character by typing altgr and E
   fix_euro="yes"

Add new Turbo Vision package

 Add tvision ebuild to /etc/local/portage/catu/dev-libs/
 The local portage directory is not created by default
 On /usr/local/portage/catu/profiles 
 a file named repo_name with the text "catu" needs to be created
 On /usr/local/portage/catu/metadata
 a file named layout.conf with the text "masters = gentoo" need to be created
 If you want a different name make sure that the /etc/portage/make.conf 
 is updated to use the new name
   
root #cd /usr/local/portage/catu
root #tar xvf tvision.tar.gz
root #rm tvision.tar.gz

Unmask packages

Most usefull applications are masked by default because the gentoo maintainers
do not know if those applications work. So they assume that they do not work
and just like Microsoft they protect you against yourself.
You need to add some information in two directories on /etc/portage/
On directory package.accept_keywords you enter this in a file, 
I name the file misc but the name is not important:
>=mate-base/caja-1.26.1 **
>=mate-base/libmatekbd-1.26.0 **
>=mate-base/mate-1.26.0 **
>=mate-base/mate-applets-1.26.1 **
>=mate-base/mate-applets-meta-1.26.0 **
>=mate-base/mate-common-1.26.0 **
>=mate-base/mate-control-center-1.26.1 **
>=mate-base/mate-desktop-1.26-1 **
>=mate-base/mate-menus-1.26.1 **
>=mate-base/mate-panel-1.26.3 **
>=mate-base/mate-session-manager-1.26.0-r1 **
>=mate-base/mate-settings-daemon-1.26.0-r1 **
>=mate-extra/mate-calc-1.26.0 **
>=mate-extra/mate-indicator-applet-1.26.0-r1 **
>=mate-extra/mate-media-1.26.0 **
>=mate-extra/mate-netbook-1.26.0 **
>=mate-extra/mate-polkit-1.26.0-r1 **
>=mate-extra/mate-power-manager-1.26.0 **
>=mate-extra/mate-screensaver-1.26.1-r1 **
>=mate-extra/mate-sensors-applet-1.26.0-r1 **
>=mate-extra/mate-system-monitor-1.26.0 **
>=mate-extra/mate-user-guide-1.26.0 **
>=mate-extra/mate-user-share-1.26.0 **
>=mate-extra/mate-utils-1.26.0 **
>=mate-extra/caja-extensions-1.26.1 **
>=mate-extra/caja-admin-0.0.5 **
>=mate-extra/caja-dropbox-1.26.0-r1 **
>=x11-themes/mate-themes-3.22.23 **
>=x11-themes/mate-backgrounds-1.26.0 **
>=x11-themes/mate-icon-theme-1.26.0 **
>=x11-misc/mozo-1.26.2 *
>=x11-wm/marco-1.26.2-r1 **
>=x11-terms/mate-terminal-1.26.0 **
>=x11-misc/mate-notification-daemon-1.26.0-r1 **
>=app-arch/engrampa-1.26.1 **
>=app-editors/pluma-1.26.0-r1 **
>=app-text/atril-1.26-r1 **
>=media-gfx/eom-1.26.1 **
>=app-editors/xemacs-21.5.35 **
>=media-libs/audiofile-0.3.6-r5 **
>=app-xemacs/xemacs-base-2.47 **
>=app-editors/joe-4.6 **
>=app-admin/sudo-1.9.14_p3 **
>=virtual/mta-1-r2 **
>=mail-mta/nullmailer-2.2-r2 **
>=sys-kernel/genkernel-4.3.6 **
>=sys-kernel/linux-firmware-20230804 **
>=x11-misc/icon-naming-utils-0.8.90-r2 **
>=dev-perl/XML-Simple-2.250.0-r1 **
>=dev-perl/XML-SAX-Expat-0.510.0-r3 **
>=sys-auth/polkit-0.123 **
>=media-libs/libcanberra-0.30-r7 **
>=dev-libs/libpeas-1.36.0 **
>=app-text/yelp-tools-42.1 **
>=app-text/rarian-0.8.4 **
>=dev-libs/tinyxml-2.6.2-r4 **
>=dev-cpp/glibmm-2.26.68.1 **
>=dev-cpp/gtkmm-3.24.5 **
>=dev-libs/libsigc++-3.4.0 **
>=dev-cpp/atkmm-2.28.3 **
>=dev-cpp/cairomm-1.16.2 **
>=dev-cpp/pangomm-2.50.1 **
>=x11-apps/xrandr-1.5.2 **
>=x11-libs/libfakekey-0.3-r1 **
>=app-text/poppler-23.08.0 **
>=app-text/libspectre-0.2.11 **
>=x11-libs/gtksourceview-3.24.11 **
>=x11-themes/gtk-engines-2.20.2 **
>=x11-themes/gtk-engines-murrine-0.98.2-r1 **
>=x11-themes/murrine-themes-0.98.2-r3 **
>=media-libs/libmatemixer-1.26.0-r1 **
>=x11-apps/xmodmap-1.0.11 **
>=dev-libs/libmateweather-1.26.1 **
>=net-wireless/wireless-tools-30_pre9-r1 **
>=sys-power/cpupower-6.2 **
>=sys-apps/pciutils-3.9.0 **
>=x11-apps/xdpyinfo-1.3.4 **
>=dev-util/librnp-0.17.0-r2 **
>=media-video/xine-ui-0.99.13 **
>=media-video/mpv-0.36.0-r1 **
>=dev-libs/tvision-2.3.0 **
>=dev-lang/tk-8.6.13 **
In the directory package.use

# required by x11-misc/lightdm-1.32.0-r2::gentoo[elogind]
# required by x11-misc/lightdm-gtk-greeter-2.0.8-r1::gentoo
>=sys-auth/elogind-252.9 pam
# required by mate-base/caja-1.26.1::gentoo
# required by mate-base/mate-applets-1.26.1::gentoo
# required by mate-base/mate-applets-meta-1.26.0::gentoo
# required by mate-base/mate-1.26.0::gentoo[base]
# required by mate-base/mate (argument)
>=gnome-base/gvfs-1.50.6 udisks
# required by app-text/atril-1.26.1-r1::gentoo
# required by mate-base/mate-1.26.0::gentoo[extras]
# required by mate-base/mate (argument)
>=app-text/poppler-9999 cairo
# required by gnome-base/gnome-keyring-42.1-r2::gentoo
# required by virtual/secret-service-0::gentoo
# required by app-crypt/libsecret-0.20.5-r3::gentoo
>=app-crypt/gcr-3.41.1-r2:0 gtk
# required by app-office/libreoffice-7.5.5.2::gentoo
# required by libreoffice (argument)
>=dev-libs/xmlsec-1.3.1 nss
# required by app-office/libreoffice-7.5.5.2::gentoo
# required by libreoffice (argument)
>=media-libs/harfbuzz-8.1.1 icu
# required by net-print/cups-filters-1.28.17-r2::gentoo[postscript]
# required by net-print/cups-2.4.6::gentoo
# required by app-office/libreoffice-7.5.5.2::gentoo[cups]
# required by libreoffice (argument)
>=app-text/ghostscript-gpl-10.01.2 cups
# required by x11-misc/xdg-utils-1.1.3_p20210805-r1::gentoo
# required by app-office/libreoffice-7.5.5.2::gentoo
# required by libreoffice (argument)
>=app-text/xmlto-0.0.28-r10 text
# required by media-gfx/gimp-2.10.34-r2::gentoo
# required by gimp (argument)
>=media-libs/gegl-0.4.46 cairo
# required by www-client/firefox-102.14.0::gentoo[system-libvpx]
# required by firefox (argument)
>=media-libs/libvpx-1.12.0-r1 postproc
# required by dev-libs/libayatana-appindicator-0.5.93::gentoo
# required by mate-base/mate-control-center-1.28.0-r1::gentoo
# required by mate-base/mate-1.28.0::gentoo[base]
# required by mate-base/mate (argument)
>=dev-libs/libdbusmenu-16.04.0-r2 gtk3
Those were the ones I used in a year or two ago on another arm64 board
They may need to be updated if you have issues

Update system

This might take a while, perhaps 12 hours or more, it will emerge a lot of packages
Assigning more cores to chroot might help to speed things up. 
root #emerge -avuDN @world

Set time zone

root #ln -sf /usr/share/zoneinfo/America/Detroit /etc/localtime
root #date
mer 29 jan 2025 09:45:08 EST

install packages

root #emerge app-editors/joe
root #emerge dev-vcs/git subversion
root #emerge x11-base/xorg-drivers
root #rc-update add dbus default
root #emerge net-misc/dhcpcd
root #rc-update add dhcpcd default
root #emerge net-misc/openssh
root #rc-update add sshd default
root #emerge x11-misc/lightdm
root #emerge gui-libs/display-manager-init
root #emerge mate-base/mate
root #emerge vlc
root #emerge tvision

Set LightDM as the default display manager

FILE /etc/lightdm/lightdm.conf"
Set the session to mate
 user-session=mate

To have autologin add your user to the autologin line

autologin-user= _your_user_
FILE /etc/conf.d/display-manager
DISPLAYMANAGER="lightdm"
root #exit
Add and start the display manager only after you boot on the micro SD
The reason is that you will need to create a user first

root #rc-update add display-manager default

Compress rootfs

root #cd /usr/src/arm64
root #rm -f /usr/src/arm64/rootfs-arm64/var/cache/distfiles/*
root #tar cvfz rootfs-arm64-20250129.tar.gz rootfs-arm64

Select arm64 board

BeaglePlay board
BeagleY-AI board
Beaglebone-AI-64 board
YY3568 board
RPI-5 board
RPI-400 board
RPI-500 board