Samsung Galaxy Tab 2 10.1 (3G and Wifi) (samsung-espresso10)

__TOC__
== Contributors ==
* WilliamO7
* Archbtw
== Maintainer(s) ==
* Mighty17
== Users owning this device ==
== What works ==
* Display
* Weston
* Touchscreen
* USB
* Wifi (if started up manually, there's still some problems on boot)
* FDE
* Battery (Gnome 3 can read the battery percentage, whether it is discharging or charging. One small issue is that Gnome 3 cannot detect the battery time remaining)
* Bluetooth service
== What does not work ==
* RIL (hasn't been setup yet, but Replicant got it going on the android side so it should be possible.)
* 2D + 3D acceleration (so most UIs slow down to a crawl, such as plasma-mobile).
** Note: There is community-patch to achieve this, but it's using non-free BLOBS. You may check out their website, but be aware that you do this on your own risk. This project is not associated with postmarketOS!! 
* Bluetooth service crashes; Running sudo service bluetooth start and then sudo service bluetooth status returns "crashed"
* Audio does not work with built-in speakers, bluetooth headphones, or the headphone jack (Tested with Gnome 3)
== To test/do ==
* Audio
* Graphics Acceleration
* GPS/Compass/Sensors
* RIL
== Known issues ==
=== WiFi not working after reboot ===
workaround : always boot the device to TWRP first, then from there, reboot to system.
See 
Fixes with patch in kernel: https://github.com/hansemro/kc1-linux/blob/v5.16.x/patches/0006-Add-clk32kg-to-twl6030.patch
=== Graphic desktop not launching ===
The device's GPU is not supported by postmarketOS because it requires proprietary blobs. These are kept outside of pmaports, in the PVRports repository on Gitlab.
If you use them, please do not report issues related to PowerVR on the postmarketOS issue tracker. Open/report the issue in the pvrports issue tracker instead. If discussing it on Matrix/IRC, we recommend using the offtopic room(s).
SGX540 blobs also seem to be missing some EGL configs, so UIs like plasma-mobile do not work.
Video decoding does not work as it is done by Ducati subsystem.
=== always shutdown the device from the Linux interface ===
otherwise (buttons or TWRP) it will immediately reboot to system
If you want to charge the device while it is off, plug the tablet in before you shutdown from the Linux interface, because plugging the USB charger in will cause the device to boot into the system.
=== Never let the battery fall down to 0% ===
because of the partially functional charging feature
otherwise even plugged to an USB power supply, the device will enter in an endless bootloop. 
and you will have to open the device, disconnect the motherboard from the charge module to wait some times, letting the battery charging in peace
== How to enter flash mode ==
* to enter into download/odin mode : Hold + .
* to enter into recovery/TWRP mode : Hold + , and release when you see the Samsung logo for the second time.
== The 6 ways to build pmos for samsung-espresso10 and flash it to the device (tested by Piero-e) ==
=== Preparation ===
==== you will need to install pmbootstrap on your Linux Computer ====
* From package manager 
Use the package manager of your distribution to install pmbootstrap:
Alpine Linux, postmarketOS:
# apk add pmbootstrap
Arch Linux:
# pacman -S pmbootstrap
Debian (unstable):
# apt install pmbootstrap
Fedora:
# dnf install pmbootstrap
Void Linux:
# xbps-install -S pmbootstrap
* From git 
Follow this section if your Linux distribution doesn't have pmbootstrap packaged, or its version of pmbootstrap is too old, or you would like to change the code. Run the following to clone and install pmbootstrap from git.
$ git clone https://git.sr.ht/~postmarketos/pmbootstrap
$ mkdir -p ~/.local/bin
$ ln -s "$PWD/pmbootstrap/pmbootstrap.py" ~/.local/bin/pmbootstrap
==== then open a new terminal, or restart your session or restart your computer... ====
and run :
$ pmbootstrap --version
it must return something like
1.52.1
Follow the pmbootstrap article to build your own image
==== you may need to : ====
* Install adb on your host Linux distribution (usually in an android-tools-adb package that you can install with your distribution's package manager), 
* Install heimdall on your host Linux distribution (usually in a heimdall-flash package that you can install with your distribution's package manager), or install odin if using windows
in a way to 
* install TWRP on the device (you can download Galaxy Tab 2 common TWRP by Android-Andi)
==== each days before building ====
Run
$ pmbootstrap pull
$ pmbootstrap status
.
=== 1. The pure pmbootstrap classic way (partial) ===
.
this will create 
"/home/username/.local/var/pmbootstrap/chroot_native/home/pmos/rootfs/samsung-espresso10.img"
and 
"/home/username/.local/var/pmbootstrap/chroot_rootfs_samsung-espresso10/boot/boot.img"
then push it to the device
==== generate some partitions images for the device (works) ====
run : 
$ pmbootstrap init
$ pmbootstrap install
 if you want to enable Full Disk Encryption 
add the " --fde" suffix to the command :
$ pmbootstrap init
$ pmbootstrap install --fde
==== flash pmos.img to the /system partition (broken ?) ====
This action wraps various flash programs (e.g. fastboot and heimdall) with a common syntax, and automatically fills out the paths to the files previously generated during pmbootstrap install. 
Boot your phone into the downloading mode (also called Odin mode), typically by holding the special button combination 
 + while booting up then 
and run :
$ pmbootstrap flasher flash_rootfs
By default, this will target the /FACTORYFS partition of your Galaxy Tab 2.
 Beware that this will overwrite the existing installation and data on your phone!
or
==== if you prefer, flash pmos.img to the /data partition instead (broken ?) ====
because the default partition (typically "/system", here /FACTORYFS) is became too small for the generated image, it is possible to flash to another partition. Just be sure to erase any previous installations of postmarketOS in other partitions, because the init script will start with the first one that it encounters. (To delete a previous version simply install the known working OS, e.g. Android, on it, or wipe or format the partitions using TWRP if installed). And if you really know what you are doing, you might consider using dd command). Using multiple partitions with LVM is planned ().
$ pmbootstrap flasher flash_rootfs --partition DATAFS
this will target the /DATAFS partition of your Galaxy Tab 2.
 Beware that this will overwrite the existing installation and data on your phone!
==== flash the boot.img to the /boot partition ====
$ pmbootstrap flasher flash_kernel
reboot the device and enjoy...
.
=== 2. The alternative Heimdall method (partial) ===
.
==== generate some partitions images for the device (works) ====
. this will create : 
"/home/username/.local/var/pmbootstrap/chroot_native/home/pmos/rootfs/samsung-espresso10.img"
and
"/home/username/.local/var/pmbootstrap/chroot_rootfs_samsung-espresso10/boot/boot.img" 
run : 
$ pmbootstrap init
$ pmbootstrap install
 if you want to enable Full Disk Encryption 
add the " --fde" suffix to the command :
$ pmbootstrap init
$ pmbootstrap install --fde
==== flash pmos.img to the /system partition (broken ?) ====
$ heimdall flash --FACTORYFS samsung-espresso10.img
or
==== flash pmos.img to the /data partition (broken ?) ====
$ heimdall flash --DATAFS samsung-espresso10.img
==== flash the boot.img to the /boot partition (works) ====
$ heimdall flash --KERNEL boot.img
.
=== 3. The alternative Odin method (not documented) ===
.
==== generate some partitions images for the device (works) ====
run : 
$ pmbootstrap init
$ pmbootstrap install
 if you want to enable Full Disk Encryption 
add the " --fde" suffix to the command :
$ pmbootstrap init
$ pmbootstrap install --fde
==== create some .TAR files from the generated partitions images ====
==== flash a pmos.tar to the AP section (not tested) ====
==== flash a boot.tar to the AP section (not tested) ====
or better
==== create a .TAR files including the generated partitions images ====
==== flash the pmos.tar to the AP section (not tested) ====
.
=== 4. The alternative "dd" method (not documented) (should work) ===
.
==== generate some partitions images for the device (works) ====
run : 
$ pmbootstrap init
$ pmbootstrap install
 if you want to enable Full Disk Encryption 
add the " --fde" suffix to the command :
$ pmbootstrap init
$ pmbootstrap install --fde
==== flash the pmos.img to the device (not tested) ==== 
* to the /system partition (not tested)
or 
* to the /userdata partition (not tested)
==== flash the boot.img to the /boot partition (not tested) ====
.
=== 5. The recommanded TWRP method (works) ===
this will create
"/home/user/.local/var/pmbootstrap/chroot_buildroot_armv7/var/lib/postmarketos-android-recovery-installer/pmos-samsung-espresso10.zip"
==== generate a recovery flashable .ZIP targeting /system partition (works) ====
Note that the /system-partition is likely too small (1,4 GB), which will -for example- prevent the lightdm-windowmanager from starting up. The recovery-zip should be built to target the data partition!
according to Installation from recovery mode page.
$ pmbootstrap init
$ pmbootstrap install --android-recovery-zip
By default, this will target the /FACTORYFS partition of your Galaxy Tab 2.
If your want Full Disk Encryption add the --fde argument.
$ pmbootstrap init
$ pmbootstrap install --android-recovery-zip --fde
or
==== generate a recovery flashable .ZIP targeting /data partition (works) ====
Note that the /system-partition is likely too small (1,4 GB), which will -for example- prevent the lightdm-windowmanager from starting up. The recovery-zip should be built to target the data partition!
$ pmbootstrap init
$ pmbootstrap install --android-recovery-zip --recovery-install-partition=data
this will target the /DATAFS partition of your Galaxy Tab 2.
==== sideload the pmos.zip using pmbootstrap + TWRP (broken ?) ====
This allows pushing the zip file on the fly directly from your computer.
* Boot the device into TWRP mode
* Unmount the partitions (Click on "Mount", then unselect all checkboxes)
* Click on "Advanced / ADB Sideload", then "Swipe to start sideload"
* Connect your phone to your PC
* Start the sideloading process from your PC:
$ pmbootstrap flasher --method=adb sideload
reboot and enjoy
or
==== sideload the pmos.zip using ADB + TWRP (works) ====
This allows pushing the zip file on the fly directly from your computer. 
$ pmbootstrap export
[07:48:04] NOTE: To export the rootfs image, run 'pmbootstrap install' first (without the 'sdcard' parameter).
[07:48:07] Export symlinks to: /tmp/postmarketOS-export
[07:48:07] * initramfs-samsung-espresso10 (Initramfs)
[07:48:07] * boot.img-samsung-espresso10 (TWRP flashable boot.img file, contains initramfs and kernel)
[07:48:07] * vmlinuz-samsung-espresso10 (Linux kernel)
[07:48:07] * pmos-samsung-espresso10.zip (Android recovery flashable zip)
[07:48:07] NOTE: chroot is still active (use 'pmbootstrap shutdown' as necessary)
[07:48:07] Done
* Boot device into TWRP mode
* Unmount the partitions (Click on "Mount, then unselect all checkboxes)
* Click on "Advanced / ADB Sideload", then "Swipe to start sideload"
* Connect your phone to your PC
* Start the sideloading process from your PC:
run the following commands. The special cd is necessary, because adb can't resolve the symlink on its own. :
$ cd $(dirname $(readlink /tmp/postmarketOS-export/pmos-samsung-espresso10.zip))
$ adb sideload pmos-samsung-espresso10.zip
loading: 'pmos-samsung-espresso10.zip'...
connecting...
Total xfer: 1.08x
reboot and enjoy...
or
==== installing the pmos.zip using TWRP via a SDcard (works) ====
Instead of sideloading, you can run 
$ pmbootstrap export
[07:48:04] NOTE: To export the rootfs image, run 'pmbootstrap install' first (without the 'sdcard' parameter).
[07:48:07] Export symlinks to: /tmp/postmarketOS-export
[07:48:07] * initramfs-samsung-espresso10 (Initramfs)
[07:48:07] * boot.img-samsung-espresso10 (TWRP flashable boot.img file, contains initramfs and kernel)
[07:48:07] * vmlinuz-samsung-espresso10 (Linux kernel)
[07:48:07] * pmos-samsung-espresso10.zip (Android recovery flashable zip)
[07:48:07] NOTE: chroot is still active (use 'pmbootstrap shutdown' as necessary)
[07:48:07] Done
copy the pmos-samsung-esspresso10.zip file to a SDcard. 
Insert it into your phone, 
* Boot the device into TWRP mode
* Unmount the partitions (Click on "Mount, then unselect all checkboxes)
* select "Install" Then navigate to the zip file and flash it.
reboot and enjoy...
.
=== 6. The recommanded running from the /external_sd method (works) ===
insert a MicroSDcard into your computer and find its name by running
$ lsblk
make sure it is the right one as you will overwrite everything on it. Use a path without partition number at the end,
such as /dev/mmcblk0, or /dev/sdd 
.
==== generate pmos directly on a MicroSDcard (works) ====
$ pmbootstrap init
$ pmbootstrap install --sdcard=/dev/name-of-your-SDcard
 if you want to enable Full Disk Encryption 
add the " --fde" suffix to the command :
$ pmbootstrap init
$ pmbootstrap install --sdcard=/dev/name-of-your-SDcard --fde
==== flash the boot.img to the /boot partition using pmbootstrap (warning ?) ====
insert the MicroSDcard into the device and boot into downloading mode 
(also called Odin mode), by holding the special button combination 
 + while booting up then 
$ pmbootstrap flasher flash_kernel
now reboot and enjoy...
or
==== flash the boot.img to the /boot partition using Heimdall (works) ====
insert the MicroSDcard into the device and boot into downloading mode 
(also called Odin mode), by holding the special button combination 
 + while booting up then 
$ heimdall flash --KERNEL boot.img 
reboot the device and enjoy...
or
==== flash the boot.img to the /boot partition using TWRP (works) ====
insert the MicroSDcard into your device, and boot it in recovery mode by holding the special button combination 
 + while booting up, then release when you sée thé Samsung logo for the second time. 
using the mount feature, unselect all /partitions except "MicroSDcard", 
using the install feature, switch to "install image" rather than "install ZIP"
navigate to the "/external_sd/boot.img", and flash it to the /boot partition
reboot system and enjoy...
.
== How to use Community pre-built image AND "dualboot" androidOS / postmarketOS (Piero-e 's contribution) ==
==== works if running postmarketOS from a SD card ====
as explained in Installation - Flashing - From SD Card 
Our device can boot SD card, USB stick or other external storage.
==== 1. preparation in a way to easily switch between Android_OS and PostmarketOS ====
from your actual Android_OS install file (AP_Stock_Samsung_Firmware.tar.md5 or Custom_Android_Based_OS.zip), extract the boot.img and copy it to your TWRP folder in internal storage (/sdcard/TWRP)
==== Download the pmOS pre-built image on your computer ====
from the download page
==== insert a MicroSDcard into your Computer ====
and find its name by running
$ lsblk
make sure it is the right one as you will overwrite everything on it. Use a path without partition number at the end, 
such as /dev/mmcblk0, or /dev/sdd
==== decompress the downloaded file and write it to your MicroSDcard : ====
$ xz --decompress --stdout path-to-pmos-samsung-espresso7.img.xz | sudo dd of=/dev/name-of-your-SDcard bs=4M status=progress
Wait until the command completes (could be very long) and eject the SD card.
==== 2. Install Postmarket on your device ====
insert the MicroSDcard into your device, and boot it into TWRP
using the mount feature, unselect all /partitions except "MicroSDcard", 
using the install feature, switch to "install image" rather than "install ZIP"
navigate to the "/external_sd/boot.img", and flash it to the /boot partition
==== reboot system ====
The rootfs image will boot right into postmarketOS. You are done with installing postmarketOS, congratulations! default login is "user" and password is "147147"
==== 3. to restore your Android_OS ====
boot the device into TWRP mode, 
and simply using the install feature, switch to "install image" rather than "install ZIP"
navigate to the previously stored "/sdcard/TWRP/boot.img", and flash it to the /boot partition
==== 4. to restore your PostmarketOS ====
boot the device into TWRP mode, 
and simply using the install feature, switch to "install image" rather than "install ZIP"
navigate to the "/external_sd/boot.img", and flash it to the /boot partition
== Photos ==
File:Gnome3_on_expresso10.jpeg|thumb|left|Gnome 3 on Samsung Galaxy Tab 2 10.1
== Partition layout ==
galaxytab2:~# fdisk -l -o Device,Start,End,Sectors,Size,Name /dev/mmcblk1
 Disk /dev/mmcblk1: 14.68 GiB, 15758000128 bytes, 30777344 sectors
 Units: sectors of 1 * 512 = 512 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disklabel type: gpt
 Disk identifier: 52444E41-494F-2044-4D4D-43204449534B
 
 Device Start End Sectors Size Name
 /dev/mmcblk1p1 8192 49151 40960 20M EFS
 /dev/mmcblk1p2 49152 53247 4096 2M SBL1
 /dev/mmcblk1p3 53248 57343 4096 2M SBL2
 /dev/mmcblk1p4 57344 73727 16384 8M PARAM
 /dev/mmcblk1p5 73728 90111 16384 8M KERNEL
 /dev/mmcblk1p6 90112 106495 16384 8M RECOVERY
 /dev/mmcblk1p7 106496 1540095 1433600 700M CACHE
 /dev/mmcblk1p8 1540096 1581055 40960 20M MODEM
 /dev/mmcblk1p9 1581056 4448255 2867200 1.4G FACTORYFS
 /dev/mmcblk1p10 4448256 29728733 25280478 12.1G DATAFS
 /dev/mmcblk1p11 29728734 30777309 1048576 512M HIDDEN
galaxytab2:~# mount
 /dev/mapper/mmcblk1p10p2 on / type ext4 (rw,relatime)
 /dev/dm-0 on /boot type ext4 (rw,relatime)
 proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
 tmpfs on /run type tmpfs (rw,nosuid,nodev,size=203440k,nr_inodes=819200,mode=755)
 dev on /dev type devtmpfs (rw,nosuid,noexec,relatime,size=10240k,nr_inodes=124636,mode=755)
 mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime)
 devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
 shm on /dev/shm type tmpfs (rw,nosuid,nodev,noexec,relatime)
 sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
 debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,relatime)
 configfs on /sys/kernel/config type configfs (rw,nosuid,nodev,noexec,relatime)
 fusectl on /sys/fs/fuse/connections type fusectl (rw,nosuid,nodev,noexec,relatime)
 pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
 tmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,size=4096k,nr_inodes=1024,mode=755)
 cgroup2 on /sys/fs/cgroup/unified type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
 cgroup on /sys/fs/cgroup/elogind type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/libexec/elogind/elogind-cgroups-agent,name=elogind)
 tmpfs on /run/user/10000 type tmpfs (rw,nosuid,nodev,relatime,size=101716k,nr_inodes=25429,mode=700,uid=10000,gid=10000)
== Links ==
PostmarketOS
* Samsung Galaxy Tab 2 7.0" (samsung-espresso7)
LineageOS:
* 3G Edition 
* Wifi Edition
* Replicant's 3G and Wifi Edition
* Device package
* Kernel package
Mainline kernel:
* WIP dts here