Issue #1755
openGT-N7100 sensors don't work
0%
Description
Running Replicant version 4.2.0004
The screen does not rotate when the phone is tipped, even with auto screen rotation enabled.
While in a call, the screen does not turn off/go numb when held to face, which leads to unfortunate cheek-dialing or hangups.
SatStat shows no readings for all sensors.
The sensors worked properly on the stock firmware that shipped with the phone.
Probably the same as http://redmine.replicant.us/issues/1167 but that one is closed.
Thanks!
Files
Related issues
Updated by CyberLeo Kitsana about 8 years ago
Oh yeah: the screen brightness also doesn't respond to ambient brightness; but I don't use that feature, so I didn't notice right away.
Updated by CyberLeo Kitsana about 8 years ago
Flashed CyanogenMod 10.1.3 to gather more information on this bug, and it fixed the problem.
This is in dmesg when the sensors don't work:
<6>[ 2.049180] c3 [SSP] ssp_load_fw_bootmode <6>[ 2.049204] c3 [SSP] ssp_load_fw start!!!
This is in dmesg when the sensors do:
<6>[ 1.996943] c0 [SSP] MPU Firm Rev. : Old = 92800, New = 92800 <6>[ 1.997255] c0 [SSP] MCU device ID = 85, reading ID = 85 <6>[ 1.997292] c0 [SSP] Sensor Posision A : 7, G : 7, M: 7, P: 0 <6>[ 1.998614] c0 [SSP] FUSE ROM Data 157 , 159, 151 <6>[ 2.004517] c1 input: accelerometer_sensor as /devices/virtual/input/input4 <6>[ 2.005061] c1 input: gyro_sensor as /devices/virtual/input/input5 <6>[ 2.005531] c1 input: pressure_sensor as /devices/virtual/input/input6 <6>[ 2.006023] c1 input: light_sensor as /devices/virtual/input/input7 <6>[ 2.006504] c1 input: proximity_sensor as /devices/virtual/input/input8 <6>[ 2.006999] c1 [SSP]: requesting IRQ 352 <6>[ 2.009829] c1 input: Unspecified device as /devices/virtual/input/input9 <6>[ 2.010356] c1 wake enabled for irq 352 <6>[ 2.010381] c1 [SSP]: ssp_probe - probe success!
I can 'break' the sensors again by booting the original Marshmallow kernel that came with the phone.
Since the kernel doesn't even expose the sensors when they're 'broken', and simply booting a working kernel is enough to bring them back, I suspect something in the Replicant kernel is unable to properly update the SSP device.
Updated by Wolfgang Wiedmeyer over 7 years ago
Actually this is the relevant part where the firmware loading fails in Replicant:
<3>[ 62.560658] c3 [SSP]: load_fw_bootmode - Unable to open firmware ssp.fw <6>[ 62.560734] c2 failed to copy MFC F/W during init <6>[ 65.355064] c0 pet_watchdog_timer_fn kicking...b86f <3>[ 66.563186] c3 [SSP]: waiting_wakeup_mcu - MCU Wakeup Timeout!! <3>[ 66.563311] c0 [SSP]: ssp_i2c_read - i2c transfer error -6! retry... <3>[ 66.573431] c0 [SSP]: ssp_i2c_read - i2c transfer error -6! retry... <3>[ 66.583534] c0 [SSP]: ssp_i2c_read - i2c transfer error -6! retry... <3>[ 66.593554] c0 [SSP]: get_firmware_rev - i2c fail -1 <6>[ 66.593583] c0 [SSP] MPU Firm Rev. : Old = 99999, New = 92800 <3>[ 67.591721] c0 [SSP]: waiting_wakeup_mcu - MCU Wakeup Timeout!! <6>[ 67.591839] c0 [SSP] MCU device ID = 85, reading ID = -6 <3>[ 67.591870] c0 [SSP]: initialize_mcu - MCU is not working : 0xfffffffa <3>[ 67.591904] c0 [SSP]: ssp_probe - initialize_mcu failed <3>[ 67.591934] c0 [SSP]: ssp_probe - probe failed!
CyberLeo Kitsana wrote:
I can 'break' the sensors again by booting the original Marshmallow kernel that came with the phone.
Was there a Marshmallow update for the n7100? I thought KitKat was the last version released for the device by Samsung.
Updated by CyberLeo Kitsana over 7 years ago
You're right. I just checked the firmware backup I made before flashing to Replicant and build.prop says it is 4.4.2.
Updated by Wolfgang Wiedmeyer over 7 years ago
For Replicant 6.0, I updated the kernel drivers which should solve this issue.
You can test it with the images from this post to the mailing list:
http://lists.osuosl.org/pipermail/replicant/Week-of-Mon-20170227/001199.html
Updated by Wolfgang Wiedmeyer over 7 years ago
- Category set to Sensors
- Status changed from New to Feedback
Updated by CyberLeo Kitsana over 7 years ago
- File 4.2-to-6.0-dmesg 4.2-to-6.0-dmesg added
- File 4.4-to-6.0-dmesg 4.4-to-6.0-dmesg added
Got a chance to try the new build this weekend. Not quite ready for primetime (hardware face button didn't work at all), but I was able to confirm that moving from the stock Samsung firmware to Replicant 6.0 did indeed work; whereas moving from Replicant 4.2 to Replicant 6.0 did not. Likewise for vice versa: going from Replicant 6.0 with working sensors to Replicant 4.2 broke the sensors again, but booting a CM10 kernel once restored functionality for Replicant 4.2.
dmesg dumps attached for Replicant kernels; nothing for CM or stock kernels, as the kernel message log is restricted on production builds.
Updated by Wolfgang Wiedmeyer over 7 years ago
- Target version set to Replicant 6.0
Did you do a factory reset before moving from Replicant 4.2 to Replicant 6.0? Looks like when going from Replicant 4.2 to Replicant 6.0, a firmware update mode is triggered and the firmware can't be found. I guess this is expected as the firmware is not available in the update folder on Replicant. Maybe the issue can be fixed if the update mode is disabled in the driver. The only question is if the newer drivers would then work with the older firmware.
It is expected that going from Replicant 6.0 to Replicant 4.2 doesn't work as the older drivers can't handle the newer firmware.
Although it is not really part of the issue, why do you think it's "not quite ready for primetime" and what is the "hardware face button"?
Updated by CyberLeo Kitsana over 7 years ago
Yes, I wiped the phone completely (boot/system/cache/dalvik/data) when installing Replicant 6.0. Since merely booting the proprietary kernel (without a valid system partition) makes the sensors work, I suspect the firmware may actually be in the initramfs for the kernel rather than the system partition as with all the other firmwares (wifi, etc). My main test was whether going from stock Samsung to Replicant 6.0 would work properly, and it appears to go smoothly without having to boot alternate kernels to get the firmware update in there.
Going from Replicant 6.0 to Replicant 4.2 was just a confirmation that everything still acts as detailed in this bug when I restored my most recent backup.
As for primetime, I can be more detailed in a separate bug after I have had time to play with it more. My initial fifteen-minute impression was that almost everything worked, but there were a few app crashes (that I will grab stacktraces for as soon as I have more time) and that the physical clicky button on the front bottom center of the device does not have any effect. On Replicant 4.2, a short press returns the phone to the 'home' screen and a long press brings up a list of the previous apps for switching or closing. On Replicant 6.0, a short press does absolutely nothing and a long press just makes the phone buzz a little bit. A different proprietary Marshmallow phone to which I have access lacks the hardware button, but shows icons on the bottom of the screen instead that perform these functions, so I have no reason to believe these functions have been removed.
Thanks!
Updated by CyberLeo Kitsana about 7 years ago
I finally got a chance to try this again. With the 6.0 0002 build on a factory reset phone, everything works well except for the sensors. It looks like the stock firmware has SSP MCU firmware revision 123106, which is subtly incompatible with the 123109 version expected in Replicant 6.0.
I was able to pull ssp.fw and ssp_crashed.fw from the upstream source drop and place them temporarily into /system/etc/firmware/, and after two full reboots the problem is fixed and the files could be removed. All other features work well.
Updated by Kurtis Hanna about 5 years ago
- Related to Issue #1167: Samsung Galaxy Note 2 N7100 - Screen rotation not working added
Updated by Kurtis Hanna almost 5 years ago
Some documentation about a likely fix was written on the n7100 installation page here: https://redmine.replicant.us/projects/replicant/wiki/GalaxyNote2N7100Installation#Sensor-issues
CyberLeo's solution directly above is likely a better fix so we should keep this issue open until we document a more elegent solution.
Updated by Kurtis Hanna over 4 years ago
Since ssp.fw and ssp_crashed.fw are nonfree software, Replicant can't redistribute them, so CyberLeo Kitsana's solution doesn't seem to be one that our project can officially support in our documentation.
As CyberLeo Kitsana mentioned, they do seem to be available in LineageOS' android_kernel_samsung_smdk4412 firmware repo.
"Since these firmwares are non-free software, we do not recommend using them nor do we distribute them." https://redmine.replicant.us/projects/replicant/wiki/GalaxyNote2N7100LoadedFirmwares
However, the Note II sensors coprocessor, which is the AT32UC3L0128 chip on the device's logic board, already stores these proprietary firmware files in the AT32UC3L0128 chips' memory. Due to this, I believe that the FSF considers these two firmwares to be hardware instead of software.
These firmware files are only requested if the firmware version in the AT32UC3L0128 memory (probably flash) doesn't match the version number coded into the kernel. See drivers/sensorhub/stm/ssp_firmware.c
My assumption is that we should educate users on how to find out if they are using the most up to date firmware in our installation instructions before they flash Replicant. If they aren't, we should instruct them on how to upgrade to the most up-to-date firmware version before installing Replicant in order to prevent this bug from continuing to occur. A method is outlined in "this depreciated wiki" on how to update to the most up to date firmware by downloading the most up to date stock Android Note II Rom here: https://redmine.replicant.us/projects/replicant/wiki/GalaxyNote2N7100Installation#Sensor-issues This method seems to be a bit of a heavy burden on users since they have to download quite a large file and is not free software.
This same issue has been confirmed to occur on both the i317 and t889 versions of the Note II as well as the n7100. It is assumed that it can occur on the n7105 as well as all other Note II versions out there.
Updated by Kurtis Hanna almost 4 years ago
CyberLeo Kitsana wrote in #note-10:
Since merely booting the proprietary kernel (without a valid system partition) makes the sensors work, I suspect the firmware may actually be in the initramfs for the kernel rather than the system partition as with all the other firmwares (wifi, etc).
I don't quite understand what this means or if CyberLeo Kitsana was on the right path here but here are some links I found while trying to do some research on this today:
Stock n7100 initramfs dump: https://github.com/seltaeb/n7100-initramfs-stock
Random N7100 defconfig referencing initramfs: https://github.com/cattleprod/GT-N7100/blob/8aebc4099a76db5bd9853772d3afe53f985430bd/arch/arm/configs/t0_04_defconfig#L102
This n7100 / n7105 / i317 kernel talks different revisions of the kernel being built with different Initramfs versions, namely the XXDMB4, XXDMB5, XXDMB6, and XXDMC3: https://forum.xda-developers.com/t/kernel-19-jul-n7100-n7105-i317-2-7-adam-kernel.2170184/
While this wasn't sensor related, I found while researching this that pmOS is finally starting to try to engage with the midas mainline kernel! They mentioned initramfs in their initial commit: https://gitlab.com/postmarketOS/pmaports/-/merge_requests/1634 Here's a small blurb about it in their blog post last month: https://postmarketos.org/blog/2020/11/06/postmarketOS-in-2020-11-part-1/#mainline-all-the-phones-and-tablets
Also, some non-initramfs related Note II sensor links...
List of commits that Wolfgang ported from the i9300 sensors that were supposed to include various fixes: https://git.replicant.us/replicant/device_samsung_n7100/commit/sensors?id=a1ae70bdae481f5a09f527b8e49995677132b357
Might not help with this Replicant 6.0 issue, but here's a blog post about frustrations with Note II sensors on Pie: https://comicoteam.github.io/blog/Note_II_Pie/ May 23, 2019
Suggestion that it was fixed: "Big thanks to my fried @ChronoMonochrome (Victor) who discovered the problem in SensorBase class with the delays." https://www.patreon.com/Comico Jan 3, 2020 (side note: interesting to see that Comico was using Patreon to fund his android dev work on the Note 8.0 and Note II. hadn't noticed that before. i reached out to them on twitter today asking if they would be interested in collaborating with us on mainline kernel development)
The patch with the fix is likely here: https://github.com/ComicoTeam/android_device_samsung_n7100/commits/lineage-17.1/libsensors
Updated by Kurtis Hanna almost 4 years ago
"The Samsung Galaxy Note II is the first smart phone with a sensor hub, which was launched in 2012." https://en.wikipedia.org/wiki/Sensor_hub
"Atmel Corporation (ATML) declared that its AVR UC3L microcontroller has recently been chosen by leading telecommunication equipment maker Samsung to support its latest Galaxy Note II. With the association, the company’s AVR UC3L microcontroller, powered by picoPower technology, will be particularly used as a sensor hub management solution for Galaxy Note II.
[...]
The tablet has various features such as detect motion sensor, accelerometer, RGB light, digital compass, proximity, gyro and barometer. Now with the inclusion of Atmel’s AVR UC3L controller, Galaxy Note II’s real-time direction accuracy will improve; its performance will be enhanced by proper orientation and inclination of data and the product’s total battery life will get a boost from minimized power consumption.
Management at Atmel expressed confidence stating that Samsung is considered to be a key provider of motion sensing features and applications. Atmel’s advanced solution through Real-Time Sensor Fusion Processing will enable tablet users to experience superior motion-related applications such as Gaming, Navigation and Virtual Reality." https://finance.yahoo.com/news/atmels-solution-samsung-160906103.html
"Samsung has selected Atmel's AVR UC3L microcontroller with patented ultra-low power picoPower technology as its sensor hub management solution for the recently launched Galaxy Note II.
Powered by a 1.6GHz quad-core processor, Samsung's Galaxy Note II runs on Android's 4.1 operating system (also known as Jelly Bean), and comes with a 5.5-inch, high-definition super AMOLED display with 1,280 x 720 resolution.
The Galaxy Note II includes several sensors that detect motion, including an accelerometer, RGB light, digital compass, proximity, gyro and barometer. Atmel's AVR UC3L sensor hub solution combines the input from these multiple sensors to provide real-time direction, orientation and inclination data." https://evertiq.com/design/28906
On Page 7 of this document I found a link to the Atmel AVR UC3L datasheet along with links to a number of other documents: http://ww1.microchip.com/downloads/en/AppNotes/doc32184.pdf
Measured power question on StackExchange: https://electronics.stackexchange.com/questions/17727/atmel-avr32-uc3l-measured-power
Updated by Kurtis Hanna almost 4 years ago
More recently published version of the Atmel AVR UC3L datasheet, but has a lot less pages: https://web.archive.org/web/20110904203803/http://www.atmel.com/dyn/resources/prod_documents/32099S.pdf
Updated by Kurtis Hanna almost 4 years ago
Third time is a charm...
I looked at the FCC datasheet for the i317/t889/i317m and it says that it uses this specific version of the Atmel AVR UC3L: AT32UC3L0128-D1HR
So this looks to be the correct datasheet, as opposed to the two I linked to in the posts above: https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-32145-32-bit-Flash-MCU-UCL0_datasheet.pdf
I don't see anything D1HR specific in it though.
Updated by Denis 'GNUtoo' Carikli over 3 years ago
- Device Galaxy Note 2 (GT-N7100) added