Re: Rock64 configuration fails to boot for main 22c4ab6cb015 but worked for main 06bd74e1e39c (Nov 21): e.MMC mishandled?

From: Mark Millard via freebsd-arm <freebsd-arm_at_freebsd.org>
Date: Fri, 10 Dec 2021 20:59:04 UTC
On 2021-Dec-10, at 01:51, Kornel Dulęba <mindal@semihalf.com> wrote:

> On Thu, Dec 9, 2021 at 11:54 PM Mark Millard <marklmi@yahoo.com> wrote:
>> 

. . . [History deleted] . . .

>> Well, I've tried Armbian 21.08 (Linux 5.10.60-rockchip64) and its first
>> boot reports the sequence ended up using HS200 at 150 MHz:
>> 
>> # dmesg | grep mmc
>> [    3.195642] vcc18_emmc: supplied by vcc_io
>> [    3.227180] dwmmc_rockchip ff520000.mmc: IDMAC supports 32-bit address mode.
>> [    3.227187] dwmmc_rockchip ff500000.mmc: IDMAC supports 32-bit address mode.
>> [    3.227225] dwmmc_rockchip ff520000.mmc: Using internal DMA controller.
>> [    3.227234] dwmmc_rockchip ff500000.mmc: Using internal DMA controller.
>> [    3.227244] dwmmc_rockchip ff520000.mmc: Version ID is 270a
>> [    3.227259] dwmmc_rockchip ff500000.mmc: Version ID is 270a
>> [    3.227342] dwmmc_rockchip ff520000.mmc: DW MMC controller at irq 42,32 bit host data width,256 deep fifo
>> [    3.227390] dwmmc_rockchip ff500000.mmc: DW MMC controller at irq 41,32 bit host data width,256 deep fifo
>> [    3.229762] mmc_host mmc0: card is non-removable.
>> [    3.241627] mmc_host mmc1: Bus speed (slot 0) = 400000Hz (slot req 400000Hz, actual 400000HZ div = 0)
>> [    3.241860] mmc_host mmc0: Bus speed (slot 0) = 400000Hz (slot req 400000Hz, actual 400000HZ div = 0)
>> 
>> Note the below 3 lines:
> 
>> 
>> [    3.327640] mmc_host mmc0: Bus speed (slot 0) = 150000000Hz (slot req 150000000Hz, actual 150000000HZ div = 0)
>> [    3.730166] dwmmc_rockchip ff520000.mmc: Successfully tuned phase to 245
>> [    3.730397] mmc0: new HS200 MMC card at address 0001
>> 
>> Note the "tuned phase to 245" as part of that.
> 
> Yep, it looks like in Linux they're doing some custom tuning logic
> specific to this controller.
> FreeBSD only executes generic tuning code, which apparently is not enough.

Based on this and some more exchanges with Andriy off list,
I went looking in Linux source, something I'd been avoiding.

Sure enough: dw_mci_rk3288_execute_tuning explores, looking
for the widest range of phase settings that work and picking
the middle of the range as the value to leave in place. That
code is what generates the "Successfully tuned phase to"
notice that Linux was reporting. (There is a default used if
all settings work.) The code for doing this uses CMD21 to
evaluate the phase settings.

If this sort of thing is (sometimes?) normal (to have some
context-specific implicit parameter assignment involved for
the CMD21 use), I've not yet noticed how FreeBSD allows for
getting to device-specific code that establishes the
assignment. 

But, clearly, I'm far from knowledgable about how things
work/fit. I've just been reading understand some about the
problem.

>> 
>> [    3.732538] mmcblk0: mmc0:0001 DJNB4R 116 GiB
>> [    3.733510] mmcblk0boot0: mmc0:0001 DJNB4R partition 1 4.00 MiB
>> [    3.734513] mmcblk0boot1: mmc0:0001 DJNB4R partition 2 4.00 MiB
>> [    3.734917] mmcblk0rpmb: mmc0:0001 DJNB4R partition 3 4.00 MiB, chardev (243:0)
>> [    3.746005]  mmcblk0: p1
>> [    4.880861] EXT4-fs (mmcblk0p1): mounted filesystem with writeback data mode. Opts: (null)
>> [    6.686795] EXT4-fs (mmcblk0p1): re-mounted. Opts: commit=600,errors=remount-ro
>> [   12.767622] EXT4-fs (mmcblk0p1): resizing filesystem from 479232 to 30224384 blocks
>> [   22.791358] EXT4-fs (mmcblk0p1): resized to 16252928 blocks
>> [   31.531320] EXT4-fs (mmcblk0p1): resized filesystem to 30224384
>> 
>> So, as far as I can tell, if FreeBSD wants to support HS200 at 150 MHz
>> on the Rock64, it can be done, voltage changing and tuning apparently
>> involved.
>> 
>> That is not to say that any FreeBSD developer wants to be supporting such.
>> Sticking to 52 MHz and possibly 3V for the Rock 64 eMMC use would again
>> make things operational.
> 
> Yes, imho marking HS200 in this controller as broken is the right
> choice, unless someone(TM) writes the missing code.

Seems appropriate to me.

>> I'll note that Armbian's U-Boot reports itself as:
>> 
>> U-Boot 2020.10-armbian (Aug 08 2021 - 18:02:43 +0200)
>> 
>> I'll also note that rebooting swapped which was mmc0 vs. mmc1:
>> 
>> # dmesg | grep mmc
>> [    3.198267] vcc18_emmc: supplied by vcc_io
>> [    3.229498] dwmmc_rockchip ff500000.mmc: IDMAC supports 32-bit address mode.
>> [    3.229547] dwmmc_rockchip ff500000.mmc: Using internal DMA controller.
>> [    3.229566] dwmmc_rockchip ff500000.mmc: Version ID is 270a
>> [    3.229665] dwmmc_rockchip ff500000.mmc: DW MMC controller at irq 41,32 bit host data width,256 deep fifo
>> [    3.229762] dwmmc_rockchip ff520000.mmc: IDMAC supports 32-bit address mode.
>> [    3.229799] dwmmc_rockchip ff520000.mmc: Using internal DMA controller.
>> [    3.229817] dwmmc_rockchip ff520000.mmc: Version ID is 270a
>> [    3.229896] dwmmc_rockchip ff520000.mmc: DW MMC controller at irq 42,32 bit host data width,256 deep fifo
>> [    3.231547] mmc_host mmc1: card is non-removable.
>> [    3.243883] mmc_host mmc0: Bus speed (slot 0) = 400000Hz (slot req 400000Hz, actual 400000HZ div = 0)
>> [    3.244767] mmc_host mmc1: Bus speed (slot 0) = 400000Hz (slot req 400000Hz, actual 400000HZ div = 0)
>> [    3.327505] mmc_host mmc1: Bus speed (slot 0) = 150000000Hz (slot req 150000000Hz, actual 150000000HZ div = 0)
>> [    3.834347] dwmmc_rockchip ff520000.mmc: Successfully tuned phase to 251
>> [    3.834477] mmc1: new HS200 MMC card at address 0001
>> [    3.836188] mmcblk1: mmc1:0001 DJNB4R 116 GiB
>> [    3.837140] mmcblk1boot0: mmc1:0001 DJNB4R partition 1 4.00 MiB
>> [    3.838155] mmcblk1boot1: mmc1:0001 DJNB4R partition 2 4.00 MiB
>> [    3.838599] mmcblk1rpmb: mmc1:0001 DJNB4R partition 3 4.00 MiB, chardev (243:0)
>> [    3.841290]  mmcblk1: p1
>> [    4.876902] EXT4-fs (mmcblk1p1): mounted filesystem with writeback data mode. Opts: (null)
>> [    6.614516] EXT4-fs (mmcblk1p1): re-mounted. Opts: commit=600,errors=remount-ro
>> 
> 


===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)