Samsung Galaxy A5 2017 (samsung-a5y17lte)

== Contributors ==
* dsankouski
== Maintainer(s) ==
== Users owning this device ==
== How to enter flash mode ==
When the device is fully powered off, hold Power, Volume Down and Home for a few seconds.
A (turquoise) download mode warning screen should appear, press Volume Up to confirm.
== Installation ==
It is recommended to sideload an android recovery zip through TWRP for the easiest process, since heimdall freaks out about the subpartitions in SYSTEM and won't move past ~7%.
You can use pmbootstrap flasher flash_kernel and then use netcat or similar to flash SYSTEM, but this is a longer and more redundant method.
$ pmbootstrap install --android-recovery-zip
$ pmbootstrap flasher --method=adb sideload
== Notes ==
=== USB ===
Device is equipped with usb type-c receptacle. No UART JIG mode cable schematic available as of 04.01.2020. However, it is possible to use chainloaded u-boot to get uart on usb. See u-boot port readme for instructions 
Available MUIC info:
* The receptacle is managed by s2mu004 kernel module. Module is capable to manage non type-c receptacles (see CONFIG_MUIC_S2MU004_NON_USB_C_TYPE option)
* Receptacle has non standard pinout: B12 (considering, A row facing top, B row facing bottom side of the phone) pin is not connected to the ground.
* Device can detect water in usb receptacle, by measuring resistance between B12 pin and ground. 
* Device can detect plug attach, with ALL pins unconnected, including GND and VBUS pins. How?
* Attaching 619K resistor to B12 pin results in ADC_JIG_UART_ON value in ADC register, during water detection sequence.
* Enter UART mode by attaching resistors should be possible in NON type-c mode. (file s2mu004-muic.c ,lines 2835,2797)
* Device has no USB type-c debug accessory mode(tried both with rd/rd and rp/rp resistors)
* UART mode detection most likely is implemented in muic firmware, if exists, or chip logic.
Open questions:
* How device can detect plug attach, when ALL plug pins are unconnected.
* How device detects UART debug cable attach?
Muic driver sysfs attributes are in /sys/devices/virtual/sec/switch folder
=== Wlan ===
wifi module gets initialized after 180 seconds. This is due to missing firmware files, and 60 secs timeout.
To connect, use wpa_supplicant:
==== Create wpa supplicant config ====
 /etc/wpa_supplicant/wpa_supplicant.conf
 ctrl_interface=/run/wpa_supplicant
 update_config=1
==== Add wlan access point authentication ====
 wpa_passphrase <access point> <password> >> /etc/wpa_supplicant/wpa_supplicant.conf
==== Launch wpa supplicant ====
 sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
 sudo dhclient wlan0
=== UART cable ===
Attention: Author is not responsible for any damage to your devices. Signal level is 1.8V. You may fry your board, using standard 3.3V - 5V UART.
It is possible to connect to UART port(/dev/ttySAC2) on the mainboard. It is located on pins 1(RX), 2(TX) of the test port, and used by bootloader to log loading process. 
==== Bill of materials ====
* Adhesive tape
* Precise soldering equipment
* USB - UART converter (you need also level shifter, if converter does not support 1.8V signals. I used schematic on two transistors)
* Breadboard
* Wires
* Thermal glue
File:A5y17lte uart wires.jpg|Wires, soldered to UART port.
File:A5y17lte uart assembly.jpg|a5y17lte, connected to USB - UART converter via level shifter.
==== Enabling console output ====
===== Downstream kernel =====
* Build kernel with options:
**CONFIG_CMDLINE="earlycon=exynos,0x13820000,115200n8 console=ttySAC2,115200"
**CONFIG_CMDLINE_EXTEND=y
* Optional (enable login console on ttySAC2):
=== UART USB-debug cable schematic ===
Currently there's no automatic way to switch MUIC on debug uart. It may be done with u-boot custom port.
Phone--------------------------------------PC
USB type-c---------------------------------UART adapter
A6 (D+, Rx)--------------------------------Tx
A7 (D-, Tx)--------------------------------Rx
A1 and / or (B1) --------------------------GND
A4 and / or (A9, B4, B9)-------------------5V charging
=== Main board ===
File:A5y17lte test port.jpg|Test port pin numbering
=== Mainlining ===
==== Exynos calibration table driver (ect_parser.c) ====
Exynos calibration table driver - simple driver, that reads and parses predefined cpu address range. It has voltage, cpu, gpu frequency tables, and more. 
Legacy driver uses __raw_read macro to access data.
Calibration table resides in volatile cpu address region (probably loaded there by bootloader into RAM?). One can write to ect cpu address region
=== U-boot ===
Has support in main tree.
See also u-boot docs 
== Hardware ==
Component 	Model 	Notes
Flash 	Samsung BJTD4R 	32GB
Charging 	Samsung s2mu004 	
Touchscreen 	Zinitix BT532 	
Touchkeys 	Abov FT1804 	
Gyroscope/Accelerometer	STMicroelectronics K6DS3TR 	
Light/Proximity sensor 	ams TMD3725 	
Magnetometer 	AKM (Asahi Kasei Microdevices) AK09916C	
Barometer 	STMicroelectronics LPS25H 	
FM Radio 	Silicon Labs si47xx 	
Wi-Fi/Bluetooth 	Qualcomm Atheros ar6k 	Exact model unknown, could be one from this table
Fingerprint 	EgisTec ET5XX 	Connected via SPI
Rear camera 	Samsung S5K3P8 	Phone reports "s5k3p8sx" as front camera
Lens actuator 	(Samsung?) AK7372 	
== See also ==
* U-boot port
* 
*