narmstrong changed the topic of #linux-amlogic to: Amlogic mainline kernel development discussion - our wiki http://linux-meson.com/ - ml linux-amlogic@lists.infradead.org - official channel moved from Freenode - publicly logged on https://libera.irclog.whitequark.org/linux-amlogic
BlueMatt has quit [Ping timeout: 276 seconds]
BlueMatt has joined #linux-amlogic
luka177 has quit [Ping timeout: 264 seconds]
vagrantc has quit [Quit: leaving]
JohnnyonFlame has quit [Read error: Connection reset by peer]
Consolatis has quit [Quit: ZNC 1.8.2+deb2+b1 - https://znc.in]
Consolatis has joined #linux-amlogic
hexdump0815 has quit [Ping timeout: 252 seconds]
hexdump0815 has joined #linux-amlogic
GNUtoo has quit [Remote host closed the connection]
GNUtoo has joined #linux-amlogic
GNUtoo has quit [Remote host closed the connection]
GNUtoo has joined #linux-amlogic
zsoltiv_ has quit [Ping timeout: 256 seconds]
zsoltiv_ has joined #linux-amlogic
<narmstrong> f_: you still need to reset the emmc, if the rom boot from emmc then the rom does it before running bl2, if you boot from usb you’ll have to reset emmc from uboot, look at the emmc pwrseq
psydroid2 has joined #linux-amlogic
zsoltiv_ has quit [Quit: Left]
zsoltiv_ has joined #linux-amlogic
<f_> narmstrong: I boot from eMMC
<f_> anyway I'll take a look at PWRSEQ.
<narmstrong> Oh then it should work !
<f_> I'll take a look at pwrseq anyway
<f_> I wonder if Kwiboo's pwrseq patch got applied
<f_> hmm doesn't seem to have been applied.
<f_> so I'll apply it myself.
<f_> I'm still afraid that my tree becomes a huge pile of downstream patches
<f_> not upstreamable..
<f_> Hmm Kwiboo's patch doesn't seem to work?
<f_> >/usr/lib/gcc/aarch64-linux-gnu/13.2.0/../../../../aarch64-linux-gnu/bin/ld: /tmp/ccBP0NBD.ltrans0.ltrans.o: in function `meson_mmc_probe':
<f_> >./u-boot/spl/../drivers/mmc/meson_gx_mmc.c:301:(.text.meson_mmc_probe+0x1d0): undefined reference to `pwrseq_set_power'
vkoskiv has quit [Ping timeout: 260 seconds]
zsoltiv_ has quit [Ping timeout: 264 seconds]
<f_> $ ls spl/drivers/misc
<f_> ls: cannot access 'spl/drivers/misc': No such file or directory
<f_> Seems like despite this:
<f_> $ grep SPL_PWRSEQ .config
<f_> CONFIG_SPL_PWRSEQ=y
luka177 has joined #linux-amlogic
<f_> It doesn't compile..weird
camus has joined #linux-amlogic
<f_> Kwiboo: Hi, did U-Boot compile with your patch?
<f_> *u-boot spl
<f_> hmm seems like mmc PWRSEQ isn't needed anyway..
<f_> mmc_pwrseq_get_power() returns non-zero
<f_> I see mmc@74000 which should be the eMMC..
<f_> besides, what a tiny device tree! :)
minute has quit [Ping timeout: 240 seconds]
vkoskiv has joined #linux-amlogic
vkoskiv has quit [Ping timeout: 255 seconds]
<f_> I wonder why. MMC2 looks like it's correct?
<f_> I don't have much choice after all..it's either MMC2 or MMC2_2
vkoskiv has joined #linux-amlogic
<f_> oh, forgot to mention. I tried MMC2_2 and it also didn't work
minute has joined #linux-amlogic
<f_> I confirmed MMC2 is indeed eMMC
<f_> Trying to boot from MMC2
<f_> mmc regbase: 0xd0074000
<xdarklight> f_: mmc@74000 would be the right MMC controller. can you print the status register in the meson_gx_mmc driver after the loop?
<f_> Sure
<xdarklight> also cmd->cmdidx would be interesting, because it may be timing out for example while switching to a higher speed
<f_> xdarklight: looking at `status` it seems like it returned a timeout
<f_> oh, and sometimes it doesn't return a timeout.
<xdarklight> ah, so print the command (cmdidx) as well so we can figure out which command times out
<f_> Seems like that depends on the command sent.
<f_> Both cmd 8 and 55 timeout.
<f_> and 1 too.
<xdarklight> looking at your .dts: how does u-boot know about the voltages? there's no regulator in there (it's referenced as vqmmc-supply, with phandle 0x2a but that's not defined in the .dts)
<xdarklight> supported voltages that is
<f_> I wonder if the spl build scrubs that
<f_> Oh, which dts?
<f_> The one I sent?
<xdarklight> yes
<xdarklight> I think it's also worth printing the configuration register in meson_dm_mmc_set_ios
<xdarklight> or at least the input parameters (bus width, clock rate)
<xdarklight> I'm wondering if it tries to tell the MMC controller to switch to an 8 bit bus but then pinctrl is not set up for that (not sure what bootrom uses but I'd expect it to try with a 1 or 4 bit bus width)
<f_> I did notice something in BL2. It seems to do at least some init on eMMC.
<f_> Looks like a new change. On GXBB, BL2 didn't init anything eMMC/SD-related at all.
<f_> Still have to take a closer look at that.
<f_> storage_init() in BL2 only did NAND init before
<f_> But seeing how it already tries to read some things from eMMC..still wondering if it really is initialisation code..
<f_> xdarklight: I dumped both the register and meson_mmc_cfg (not sure how useful that is)
vkoskiv has quit [Ping timeout: 256 seconds]
<xdarklight> f_: interesting, can you share the dumped register? if I read that GXL bl2 code right then it'll be using an 8-bit bus even
<f_> That's in the paste link I sent
<xdarklight> ah, missed that, sorry
<f_> Np
<narmstrong> It probably tries to set the wrong voltage
<narmstrong> Or something else…
<xdarklight> f_: so looking at the dumped MESON_SD_EMMC_CFG registers: it starts with a 1-bit bus width then goes to 4-bit
<xdarklight> f_: to experiment, can you change bus-width to = <1> and drop all of: cap-mmc-highspeed, mmc-ddr-1_8v, mmc-hs200-1_8v from the .dts
<xdarklight> f_: if that doesn't help then we'll look at the voltages that u-boot sends to the card
<f_> hm bus_width is set to 8 though
<f_> narmstrong: possible
vkoskiv has joined #linux-amlogic
<f_> xdarklight: I wonder if it just ignores that?
<xdarklight> f_: hmm okay. can you drop all of the 3.3V bits from https://git.vitali64.duckdns.org/misc/u-boot-kii-pro.git/tree/drivers/mmc/meson_gx_mmc.c#n277
<xdarklight> (meaning: only keep MMC_VDD_165_195)
<xdarklight> oh and I don't know if it needs to be set manually but https://git.vitali64.duckdns.org/misc/u-boot-kii-pro.git/tree/drivers/mmc/meson_gx_mmc.c?h=wip%2Fspl#n279 doesn't have MMC_MODE_1BIT
<f_> Yup, noticed that.
<f_> Still no lock.
<f_> *luck
<f_> Dropped all of the 3.3V bits and also tried adding MMC_MODE_1BIT
<xdarklight> :-(
<xdarklight> are there any debug bits that you can enable in SPL? Linux has some debug option that prints every MMC command, all of the parameters and all card responses
<f_> Probably, but I'm afraid that won't fit in 44K
<f_> I can enable CONFIG_MMC_TRACE if you wish
<xdarklight> let's try and see if it fits
<f_> It seems to fit
<f_> at least binman didn't complain.
<f_> ^ with MMC_TRACE enabled
<xdarklight> something is odd here. CMD 8 is MMC_CMD_SEND_EXT_CSD
<xdarklight> and arg is 0 (hard-coded) according to https://elixir.bootlin.com/u-boot/latest/source/drivers/mmc/mmc.c#L796
<xdarklight> but we get arg = 0xaa, which seems more like https://elixir.bootlin.com/u-boot/latest/source/drivers/mmc/mmc.c#L2704 (SD init sequence)
<xdarklight> not sure if that's normal - it's just odd to my brain
<f_> SD init sequence?
<xdarklight> iirc there's some differences in how SD cards and eMMC are initialized
<xdarklight> so SD = SD card
<f_> I know SD means SD card
<f_> but yes, IIRC it should be a little different at leas
<f_> *least
<f_> xdarklight: Oh I also forgot to mention that it uses MMC_TINY
<f_> If that helps..
<xdarklight> f_: haven't heard about that. I'm just relying on u-boot developers to be sane (which they are in my experience) :)
<xdarklight> f_: https://elixir.bootlin.com/linux/v6.6/source/drivers/mmc/core/sd_ops.c#L176 - this is from Linux I know, but just to give some more ideas. here test_pattern is 0xaa (which we're also seeing) but: OCR is zero in u-boot (OCR has the available voltages)
<f_> It uses a tiny mmc framework
<xdarklight> can you compare the flow to your GXBB board?
<xdarklight> the MMC controller on GXBB and GXL are 100% identical (AFAIK)
<f_> I can't really test eMMC on my gxbb board.
Consolatis has quit [Ping timeout: 276 seconds]
Consolatis has joined #linux-amlogic
<f_> Oh I just remembered
<f_> I ignore clk_get_bulk's return value if it's -ENOSYS
<xdarklight> one would expect bootrom / BL2 to leave those clocks enabled
<f_> Except SPL runs as BL2
<f_> <narmstrong> It probably tries to set the wrong voltage
<f_> hmm
luka177 has quit [Ping timeout: 256 seconds]
luka177 has joined #linux-amlogic
<narmstrong> The sd init sequence won’t work, it should try the mmc sequence in fallback
<f_> Yeah thought about that..but shouldn't U-Boot (SPL) do that already?
<f_> At least U-Boot proper seems to do that
<narmstrong> Maybe there’s an option ?
<f_> Haven't seen any option related to SD cards.
<f_> Investigating
<xdarklight> ah, narmstrong is correct - it tries SD init but if that times out it falls back to eMMC: https://elixir.bootlin.com/u-boot/v2023.10/source/drivers/mmc/mmc.c#L2895
<f_> Alright
<f_> What if I increase the timeout limit...
<xdarklight> if increasing the timeout doesn't work then I'd try changing https://elixir.bootlin.com/u-boot/v2023.10/source/drivers/mmc/mmc.c#L699 to just say "if (!mmc_host_is_spi(mmc))" (which is what Linux does basically: https://elixir.bootlin.com/linux/v6.7-rc1/source/drivers/mmc/core/mmc_ops.c#L234 )
<f_> Increasing the timeout doesn't work.
<f_> I'll try your suggestion
<f_> and that also doesn't work.
<xdarklight> do you still have CONFIG_MMC_TRACE enabled? if so, can you share the log?
<xdarklight> aha
<f_> Did you notice too?
<xdarklight> I think none of the OCR bits are set
<f_> Ah that
<f_> Could be that
<xdarklight> according to https://linux.codingbelief.com/zh/storage/flash_memory/emmc/emmc_device_registers.html BIT(7) means 1.70-1.95V which is what we want for 1.8V eMMC cards. can you hard-code an extra "| BIT(7)" for cmd.args in https://elixir.bootlin.com/u-boot/v2023.10/source/drivers/mmc/mmc.c#L700
<f_> hm still doesn't work.
<xdarklight> still -ETIMEDOUT ?
<f_> Yup
<f_> I tried removing that `if` (having that cmdarg set like so everytime) and it still doesn't work
<xdarklight> can you dump the clock register (register offset 0x0 inside the SD_EMMC controller registers) so we can see if something unexpected is in there?
<xdarklight> (I'd dump it right after we get the timeout)
<f_> Think it's a clock issue?
<xdarklight> at least we should check / rule it out
<f_> oh I disabled clock support
<xdarklight> but I think SPL doesn't have clock support anyways (looking at your .dtb again)?
<xdarklight> https://git.vitali64.duckdns.org/misc/u-boot-kii-pro.git/tree/drivers/clk/meson/gxbb.c?h=wip/spl#n897 - I think this makes all SD_EMMC controller's derive their clock from XTAL (24MHz), set a divider of 1 and gate (= disable) the clocks. maybe dump the HHI_SD_EMMC_CLK_CNTL register too
<f_> SD_EMMC clock register: 0x23f
<f_> HHI_SD_EMMC_CLK_CNTL: 0x800080
<xdarklight> HHI_SD_EMMC_CLK_CNTL is good, it means SD_EMMC_C (eMMC) is enabled and running at 24MHz (exactly what our driver expects)
camus has quit [Quit: camus]
<f_> What about MESON_SD_EMMC_CLOCK?
<xdarklight> 0x23f means: divider = 63 + 1 (so we're running at 24MHz / 64 = 375kHz - which is good, we're expecting around 400kHz), clock source = 0 (effectively meaning: 24MHz in this case)
<xdarklight> also CLK_CO_PHASE_180 is set, which is what I'd expect from meson_mmc_config_clock()
<xdarklight> can you also dump the HHI_SD_EMMC_CLK_CNTL register *before* the meson_gx_mmc driver does anything?
<f_> Sure, one sec.
<f_> SD_EMMC clock register: 0x1000204
<f_> HHI_SD_EMMC_CLK_CNTL: 0x800080
<xdarklight> interesting
<xdarklight> HHI_SD_EMMC_CLK_CNTL[24] is called CLK_V2_ALWAYS_ON in the Linux driver
<xdarklight> and the Linux driver is setting it
<f_> I guess u-boot doesn't set it?
<xdarklight> it seems it's missing there (or I can't find where it does that)
<xdarklight> add it to meson_mmc_config_clock but be careful: for newer SoCs (can be detected using MMC_COMPATIBLE_SM1) this has moved to BIT(28) instead of BIT(24) (see the Linux driver)
<f_> ah yes
<f_> Still doesn't work.
<xdarklight> can you undo any changes we did to drivers/mmc/mmc.c to make sure we didn't break anything there?
<f_> Done.
<xdarklight> still no luck?
<f_> I didn't try yet
<f_> Nope.
<f_> No luck
<xdarklight> :-(
<f_> :(
<f_> Ok so in u-boot proper it works
<f_> I was starting to worry about if it wouldn't work at all.
<xdarklight> what if you remove the pinctrl nodes and try with fat u-boot? if it breaks then maybe we need to do the pinmuxing in SPL
<f_> fat u-boot?
<xdarklight> the full blown one, not running with the tiny SPL
<f_> u-boot proper you mean?
<f_> Ok
<xdarklight> if that's the correct term then yes :)
<f_> ISTR that SPL ignores pinctrl nodes
<xdarklight> yep, my thought is: what if bootrom does something weird and switches the pinmux back to GPIO instead of eMMC? so if we can reproduce the fault by removing the pinctrl nodes with u-boot proper then it may be the cause within SPL
<f_> and you're right!
<f_> Card did not respond to voltage select! : -110
<f_> ^ u-boot proper with the pinctrl nodes commented out
<f_> So that must be it!
<xdarklight> hmm, there's CONFIG_SPL_PINCTRL
<f_> good catch
<f_> Then I just need to remove pinctrl nodes from the list of "nodes to be stripped"
<f_> hope that it'll all fit..
<f_> get an ld error
<f_> "u-boot-spl section `.rodata' will not fit in region `.sram'"
<narmstrong> pinctrl driver is quite big
<f_> yup
<f_> and we only have 44K max for SPL.
<narmstrong> perhaps the pinctrl driver could be stripped to just the pinctrl entries for SPL
<f_> Just enabling CONFIG_SPL_PINCTRL makes the binary take a lot of space, so pinctrl is probably a no-go..
<f_> ugh
<f_> I wonder if there's a stripped down pinctrl driver specifically for spl..
<f_> >region `.sram' overflowed by 19360 bytes
<f_> It's just too much.
<xdarklight> if I've calculated right then 0xc88344cc would be the right pinmux register. can you dump it's contents from SPL and u-boot proper?
<f_> Sure
<xdarklight> bits 28-31 are the relevant ones for eMMC
<f_> poking at it from the u-boot shell: c88344cc: f0000000
<xdarklight> exactly what we want: eMMC pinmux (clk, cmd, data[0:7] and ds) is enabled
<f_> indeed. Bits 28-31 are enabled
JohnnyonFlame has joined #linux-amlogic
<f_> xdarklight: pinmux: 0xda0344cc
<f_> ^ pinmux register dump in SPL
<xdarklight> BIT(29) is the eMMC CMD function
<f_> and bit 29 is disabled, yes
<f_> I could try forcefully setting that bit
<xdarklight> can you hack together something: (register & ~0x3cff) | 0xf0000000
<xdarklight> ~0x3cff disables the NOR and NAND pinmux - those share some pads with eMMC (so I think we should disable them to make sure the signals are routed correctly within the SoC)
<xdarklight> note that all of this applies to GXL only, pinmux registers on GXBB are different
<xdarklight> that said, I'm starving and so I'm off for dinner. good luck and talk to you later
<f_> Sure, thanks for your help!
<f_> Alright, a different error..
<f_> mmc_load_image_raw_sector: mmc block read error
<f_> Trying something else
<f_> alright that didn't work either (writing 0xf0000000 directly)
<f_> I'll investigate more tomorrow.
ChanServ has quit [shutting down]
ChanServ has joined #linux-amlogic
buzzmarshall has joined #linux-amlogic
vagrantc has joined #linux-amlogic
psydroid2 has quit [Quit: KVIrc 5.0.0 Aria http://www.kvirc.net/]
adamg_ has quit [Quit: Connection closed for inactivity]