Samsung Galaxy J7 Prime (samsung-on7xelte)

Samsung Galaxy J7 Prime, also known Samsung Galaxy On Nxt and Samsung Galaxy On7 Prime, is an Exynos 7870 device released by Samsung in 2016.
== Contributors ==
* naproxen
== Users owning this device ==
== How to enter flash mode ==
When the phone is powered off, hold the , and buttons to boot into download mode. A turquoise colored screen will appear, asking for confirmation. Press to confirm. Your device is ready for flashing via a front-end such as Odin or Heimdall.
To boot into recovery, hold the , and buttons. 
== Installation ==
=== Prerequisites ===
Make sure your phone:
* Has its bootloader unlocked.
=== Preparation ===
Choose the following in the pmbootstrap init wizard:
 Vendor: samsung
 Device codename: on7xelte
To proceed with the installation run:
 $ pmbootstrap install
This will begin preparing your installation in your host computer.
=== Flashing ===
After the installation process is completed, get your phone booted into download mode, Then run:
 $ pmbootstrap flasher flash_kernel
The kernel gets flashed to your device. Now, the device will reboot automatically. Hold the key combination to reboot into download mode. Then run:
 $ pmbootstrap flasher flash_rootfs
The rootfs is flashed and the device gets rebooted.
It should reboot to postmarketOS now.
== Partial features ==
=== Battery ===
The fuelgauge driver (reports the charge percentage) works fine, but there's no charger driver which is responsible for reporting charge status and control.
=== Screen ===
Display works with simple-framebuffer, so brightness control is non-functional. Samsung DECON/DSIM driver for Exynos 7870 is a work-in-progress, which will properly initialize and use the display.
== Problems ==
=== USB Networking ===
At least on some operating systems, the host doesn't receive network packets from the device, unless the host sends packets to the device. Due to this behavior, SSH (among other things) doesn't work well. A workaround is to have ping -Aq <IP> run in the background while you interact with the device (replace <IP> with the device IP address).
=== Wi-Fi ===
Wi-Fi behaves very erratically (practically unusable) when the SDIO is probed in DMA mode. The driver fails to communicate with the SDIO, reporting timeout errors. As a workaround, the SDIO is forced to be probed in PIO mode.
== Debugging (retrieving kernel logs) ==
=== Serial UART ===
As with most Samsung devices, UART is exposed in the micro-USB connector of the device, a resistance is applied between the ID and GND pins, which makes it switch to UART mode. More information is provided at this article about serial debugging.
The VCC voltage level is 3.3V, and the multiplexing resistance for UART is 150kΩ (±1% is acceptable).
You also need to change the cmdline arguments provided to the kernel. This is managed by S-BOOT, Samsung's proprietary primary bootloader. Sadly, S-BOOT forces its arguments over ones which could be possibly set by postmarketOS. There's a way to refuse bootloader arguments from the kernel, but it does more harm than good.
Connect the host and the device using the USB-TTL adapter, and open up a modem terminal emulator (for instance, minicom). Boot the phone by holding . When the bootloader starts printing logs, start spamming the enter key. This will abort autoboot and S-BOOT's console will open.
 S-BOOT # printenv
This command will print all environment variables in S-BOOT. You should find such a variable called CMDLINE, which defaults to console=ram loglevel=4. We're supposed to edit this to redirect the console path to the UART device. To set the variable:
 S-BOOT # setenv CMDLINE console=ttySAC2,115200
The variable can also be saved, so that the change remains persistent.
 S-BOOT # saveenv
Now, you may resume booting by:
 S-BOOT # load_kernel
 S-BOOT # boot
Note that this will display a warning about CMDLINE being changed in the bootloader logs and the screen. It will stay until it's reverted.
=== Persistent store ===
Kernel logs are also exposed via ramoops. The downstream kernel uses ramoops only during panics. The mainline kernel uses the same memory region to store generic logs.
From recovery, the kernel logs can be found in /sys/fs/pstore/dmesg-ramoops-0. S-BOOT passes loglevel=4 in the kernel's cmdline (see here), so only warnings and errors (and worse) are logged.
== Downstream kernel ==
A port based on the downstream kernel exists which has been archived in favor of the mainline kernel. More information is available in older revisions of this page.
== See also ==
 Initial merge request
 (Downstream → Mainline)