sonyxperiadev / bug_tracker

Empty repository that is used as a bugtracker for Open Devices project
52 stars 13 forks source link

[discovery] - Android 8.1 - SD-Card support/reader broken #163

Closed Thaodan closed 6 years ago

Thaodan commented 6 years ago

Platform: sony-nile Device: 8.1 /Mer-Hybris Kernel version: 4.4.148-g49441d2181d0 Android version: no /dev/mmcblk1 device

Description The xperia open devices page states that only sdcards that are <=32GB are supported. What is missing on SDXC kernel support? Is there some firmware or specific Kconfig needed?

The issue is that my device doesn't find the card and just throws a gpio error every time. log: https://paste.kde.org/pgcqwzuyp

Symptoms Write the symptoms here.

How to reproduce Write how to reproduce here.

oshmoun commented 6 years ago

Not sure if that gpio error is relevant, as it also appears on loire yet sdcard works. did you check the paths in fstab and whether they are actually valid? maybe the sdcard path needs to be changed. Also, is the card exFAT formatted?

Thaodan commented 6 years ago

The card isn't even detected by the controller. i have an Xperia x and here the card works. The card is formatted as ext4. I booting twrp which uses the stock kernel (kernel copyleft ) and there the card is detected just fine.

Thaodan commented 6 years ago

the dmesg.output there is :

<6>[ 0.790033] mmcc-sdm660 c8c0000.clock-controller: Registered MMSS clocks <6>[ 4.699441] sdhci_msm c0c4000.sdhci: No vmmc regulator found <6>[ 4.706826] sdhci_msm c0c4000.sdhci: No vqmmc regulator found <6>[ 4.712930] mmc0: SDHCI controller on c0c4000.sdhci [c0c4000.sdhci] using 64-bit ADMA in CMDQ mode <6>[ 4.808493] mmc0: Out-of-interrupt timeout is 50[ms] <6>[ 4.808532] mmc0: eMMC FW version: 0xa5 <6>[ 4.812539] mmc0: CMDQ supported: depth: 32 <6>[ 4.816084] mmc0: cache barrier support 1 flush policy 1 <6>[ 4.833413] mmc0: CMDQ enabled on card <6>[ 4.845182] mmc0: new HS400 MMC card at address 0001 <6>[ 4.863351] mmcblk0: mmc0:0001 HBG4a2 29.1 GiB <6>[ 4.873252] mmcblk0rpmb: mmc0:0001 HBG4a2 partition 3 4.00 MiB <6>[ 4.880435] mmcblk0: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 p19 p20 p21 p22 p23 p24 p25 p26 p27 p28 p29 p30 p31 p32 p33 p34 p35 p36 p37 p38 p39 p40 p41 p42 p43 p44 p45 p46 p47 p48 p49 p50 p51 p52 p53 p54 p55 p56 p57 p58 p59 p60 p61 p62 p63 p64 p65 p66 p67 p68 p69 p70 p71 p72 p73 p74 p75 p76 p77 p78 p79 <6>[ 4.926716] sdhci_msm c084000.sdhci: No vmmc regulator found <6>[ 4.926752] sdhci_msm c084000.sdhci: No vqmmc regulator found <6>[ 4.931929] mmc1: SDHCI controller on c084000.sdhci [c084000.sdhci] using 64-bit ADMA in legacy mode <6>[ 5.328872] mmc1: new ultra high speed SDR104 SDXC card at address aaaa <6>[ 5.332794] mmcblk1: mmc1:aaaa ACLCF 119 GiB <6>[ 5.409709] mmcblk1: p1
jerpelea commented 6 years ago

SDR104 SDXC card at address aaaa

<6>[ 5.332794] mmcblk1: mmc1:aaaa ACLCF 119 GiB <6>[ 5.409709] mmcblk1: p1 the card is detected by kernel
Thaodan commented 6 years ago

That was the message with the stock (kernel copyleft) kernel. The message with the open devices kernel (just kernel here on github) was:

[    0.000000] Kernel command line: rcupdate.rcu_expedited=1 core_ctl_disable_cpumask=0-7 lpm_levels.sleep_disabled=1 display_status=on selinux=0 androidboot.selinux=permissive msm_rtb.filter=0x3F ehci-hcd.park=3 coherent_pool=8M sched_enable_power_aware=1 user_debug=31 androidboot.hardware=discovery androidboot.verifiedbootstate=orange androidboot.keymaster=1  androidboot.veritymode=enforcing root=/dev/dm-0 dm="system none ro,0 1 android-verity /dev/mmcblk0p78" androidboot.bootdevice=c0c4000.sdhci cei_project_id=BY22 cei_phase_id=MP cei_sku_id=GINA cei_simslot_id=ss cei_mainboard_id=SM22 androidboot.ceibootmode=0 cei_color_id= androidboot.baseband=sdm mdss_mdp.panel=1:dsi:0:qcom,mdss_dsi_td4322_innolux_fhd_cmd:config0:1:none:cfg:single_dsi androidboot.slot_suffix=_a skip_initramfs rootwait ro init=/init  androidboot.bootloader=xboot oemandroidboot.xboot=1310-0301_X_Boot_SDM630_LA1.0_O_121 androidboot.serialno=CQ300049KL startup=0x00008000 warmboot=0x77665501 oemandroidboot.babe08b3=500000
[    0.345406] mmcc-sdm660 c8c0000.clock-controller: Registered MMSS clocks
[    1.425556] ## mmc0: gpio_is_valid(pdata->uim2_gpio)=-2: failure
[    1.428891] ## mmc0: can't set uim2_gpio: -2
[    1.429563] sdhci_msm c0c4000.sdhci: No vmmc regulator found
[    1.429640] sdhci_msm c0c4000.sdhci: No vqmmc regulator found
[    1.430344] mmc0: SDHCI controller on c0c4000.sdhci [c0c4000.sdhci] using 64-bit ADMA in CMDQ mode
[    1.514447] mmc0: Out-of-interrupt timeout is 50[ms]
[    1.514581] mmc0: eMMC FW version: 0xa5
[    1.514650] mmc0: CMDQ supported: depth: 32
[    1.514717] mmc0: cache barrier support 1 flush policy 1
[    1.523514] mmc0: CMDQ enabled on card
[    1.523646] mmc0: new HS400 MMC card at address 0001
[    1.524924] mmcblk0: mmc0:0001 HBG4a2 29.1 GiB
[    1.525308] mmcblk0rpmb: mmc0:0001 HBG4a2 partition 3 4.00 MiB
[    1.527569]  mmcblk0: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 p19 p20 p21 p22 p23 p24 p25 p26 p27 p28 p29 p30 p31 p32 p33 p34 p35 p36 p37 p38 p39 p40 p41 p42 p43 p44 p45 p46 p47 p48 p49 p50 p51 p52 p53 p54 p55 p56 p57 p58 p59 p60 p61 p62 p63 p64 p65 p66 p67 p68 p69 p70 p71 p72 p73 p74 p75 p76 p77 p78 p79
[    1.538583] ## mmc1: gpio_is_valid(pdata->uim2_gpio)=-2: failure
[    1.552056] ## mmc1: can't set uim2_gpio: -2
[    1.553454] sdhci_msm c084000.sdhci: No vmmc regulator found
[    1.553530] sdhci_msm c084000.sdhci: No vqmmc regulator found
[    1.554124] mmc1: SDHCI controller on c084000.sdhci [c084000.sdhci] using 64-bit ADMA in legacy mode
[    4.076078] EXT4-fs (mmcblk0p78): mounted filesystem with ordered data mode. Opts: barrier=1
[    4.102156] EXT4-fs (mmcblk0p70): mounted filesystem with ordered data mode. Opts: barrier=1
[    4.102804] EXT4-fs (mmcblk0p79): mounted filesystem with ordered data mode. Opts: (null)
[    4.119289] EXT4-fs (mmcblk0p68): mounted filesystem with ordered data mode. Opts: barrier=1
[    4.122434] EXT4-fs (mmcblk0p44): mounted filesystem with ordered data mode. Opts: barrier=1,data=ordered,nodelalloc,errors=panic
[    4.134434] EXT4-fs (mmcblk0p2): warning: maximal mount count reached, running e2fsck is recommended
[    4.135431] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: barrier=1,data=ordered,nodelalloc,errors=panic
[    5.711334] droid-hal-init: Opened file '/d/mmc0/mmc0:0001/ext_csd', flags 0

No device file is created and no entry in sysfs.

jerpelea commented 6 years ago

the sdfat driver was added and configured as default https://github.com/ab123321/kernel/blob/7a4f7261a10169ca9cfdaaae4b6b93b0cdcc3893/fs/sdfat/Kconfig#L3

Thaodan commented 6 years ago

Is that even needed to detect the block file on the sdcard? My card is formated as ext4 and I even can't mount the file. To what are the gpio errors related to?

jerpelea commented 6 years ago

I am sorry but I missed the ext4 format no in this case is just the sdcard driver that needs some updates from copylefts can you diff the 2?

Thaodan commented 6 years ago

sure, bur which parts? I think the changes are to large for a full diff. Where is the driver specific to the controller?

jerpelea commented 6 years ago

I would start from kernel/drivers/mmc/host

Thaodan commented 6 years ago

which parts of that are specific to the soc of nile?

Thaodan commented 6 years ago

I think I've found the error line that triggers the message: https://github.com/mer-hybris/android_kernel_sony_msm/blob/hybris-sony-aosp-8.1.0_r35_20180714/drivers/mmc/host/sdhci-msm.c#L1847

Thaodan commented 6 years ago

Tested a 16GB(SDHC) card same error.

Thaodan commented 6 years ago

Any help on this?

oshmoun commented 6 years ago

did you confirm fstab is ok? maybe paths simply need adjusting

Thaodan commented 6 years ago

fstab is ok. Even when the fstab is wrong the card should be visible in dmesg?

Thaodan commented 6 years ago

Added log with CONFIG_MMC_DEBUG=y compiled in. dmesg.log

One thing I noticed was that the internal mmc gets re scanned several times but no the external. Is that intended?

jerpelea commented 6 years ago

I tested pioneer with 4.9 kernel on Android 9 and a 32Gb card pioneer:/ $ ls /dev/block/mmcblk1 /dev/block/mmcblk1

Thaodan commented 6 years ago

So the bug is only on discovery? Any further advice to debug this?

jerpelea commented 6 years ago

I will check the same device with 8.1 and kernel 4.4 then we can look at discovery

dimitar10 commented 6 years ago

I tested with 128GB ext4 formatted sdcard on Pioneer, with latest 4.4 prebuilt kernel and latest AOSP 8.1, and there's a format unsupported error. If the card is formatted within the device (to fat), everything works OK. I'm attaching the dmesg if it can be of any help.

sdcard-128GB-ext4-not-recognized-pioneer-dmesg.log

screenshot.zip

Thaodan commented 6 years ago

I will check the same device with 8.1 and kernel 4.4 then we can look at discovery

That works. I have someone here that tested it with bot 8GB and 64GB card (pioneer).

jerpelea commented 6 years ago

lets not mix the things we have to check first that the regular 32Gb card is detected

Thaodan commented 6 years ago

@dimitar10 have tried mounting the card by hand?

FAT-fs (mmcblk1p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck. Looks suspicions.

jerpelea commented 6 years ago

I tested Discovery on Android 9 and kernel 4.9 and the 32Gb sdcard is not detected

Thaodan commented 6 years ago

we have to check firt that the regular 32Gb card is detected.

On pioneer?

Thaodan commented 6 years ago

I tested Discovery on Android 9 and kernel 4.9 and the 32Gb sdcard is not detected

Can you build the pioneer kernel with MMC_DEBUG=y, that we have something to compare?

How is the card connected to the phone?

jerpelea commented 6 years ago

tests completed pioneer kernel 4.4 - OK kernel 4.9 - OK

discovery kernel 4.4 - NOK kernel 4.9 - NOK

jerpelea commented 6 years ago

@Thaodan I recommend looking here for a quirk then backport it (drivers/mmc/host/sdhci-msm.c) https://github.com/sonyxperiadev/kernel-copyleft/commit/ba16212af72a789c776900d35ba1483cce4e08d3

Thaodan commented 6 years ago

Ported that quirk back. Is there a more detailed explanation why this boards need the workaround? EDIT: is their an upstream version of cei?

Thaodan commented 6 years ago

I applied the quirk by using CONFIG_MACH_SONY_DISCOVERY instead of cei. But still no sdcard found. Should I have applied less of the patch or do I miss something?

https://github.com/Thaodan/android_kernel_sony_msm/commit/6d6fac80958af76e0091c67d9cbbc37fb9a5ffc9

dmesg|grep mmc1 whith CONFIG_MMC_DEBUG=y: https://paste.kde.org/penjpntqf#line-42

Thaodan commented 6 years ago

full dmesg dmesg.log

It looks like the initialisation of the mmcblk1 goes further than without the patch but after CMD1 it has 0 Hz.

Thaodan commented 6 years ago

@jerpelea did I used the right workaround? Is it possible to get more deeper information on why the workaround and how it was handled in the stock kernel?

jerpelea commented 6 years ago

I linked the stock kernel diff. Unfortunately, for the moment, I do not have time to look deeper at this issue

Thaodan commented 6 years ago

That's why I asked if I used the right part of the workaround. It feels like I miss something. Its bogus that such part is broken in this device but not in the sister device.

jerpelea commented 6 years ago

fix found and pushed https://github.com/sonyxperiadev/kernel/commit/103888a2221c4fa824ed29f5b6fe2d0326042a03

jerpelea commented 6 years ago

I tested both discovery and voyager and both are OK

Thaodan commented 6 years ago

Thanks! can you explain why this board is different in this regard compared to nile?

Thaodan commented 6 years ago

Can you merge this to 4.4.x too?

jerpelea commented 6 years ago

it is already merged and I will push the patch ASAP

Thaodan commented 6 years ago

Was already listed in arch/arm/boot/dts/qcom/sdm630-qrd.dtsi#L249 btw.

jerpelea commented 6 years ago

that is not your device !

Thaodan commented 6 years ago

I know but its the base/reference board device tree supplied by quallcomm.

jerpelea commented 6 years ago

the device tree contains several reference motherboards built on the same platform while nile a new board.

ghost commented 5 years ago

@Thaodan does TWRP work for you with unmodified open devices AOSP or do you have to use a different kernel, compile framdisk etc.? I'm asking because of this: https://twrp.me/sony/sonyxperiax.html (look at Notes About Sony Devices)

Thaodan commented 5 years ago

It did work for me with the twrp image posted on xda, it uses the kernel from the stock rom. However the open devices kernel should work now too. Everything else isn't changed.