Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try to fix SD card problems by adding SDH clock overrides to U-Boot and the kernel #59

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

wpwrak
Copy link
Contributor

@wpwrak wpwrak commented Apr 20, 2023

Note: this PR is not intended as a direct submission for upstreaming, but for review and evaluation.
This adds:

  • U-Boot commands "bflb_sdh sdh" and "bflb_sdh bus" to override clock dividers
  • sdhci-bflr module parameter "sdhci-bflb.bus_div" to override the SD bus clock divider also in the kernel
  • passing of boot command line arguments in U-Boot with the variable bootargs
  • change the boot process to try, if mmc probe fails, with the following overrides:
    bflb_sdh sdh 8; bflb_sdh bus 1; setenv bootargs ${bootargs} sdhci-bflb.bus_div=1

@eeucalyptus
Copy link

eeucalyptus commented Apr 20, 2023

Could you provide prebuilt binaries? I dont have the capacity to build it right now but i would like to contribute my findings

EDIT: nvm, i'm dumb, there is a continous delivery for that :D Sorry!

@dotsam
Copy link

dotsam commented Apr 20, 2023

The u-boot changes alone (I didn't re-flash my SD card) seem to have resolved the issue for my where my 0x64 could not boot.

Here's the full boot log:
CoolTerm Capture 2023-04-20 12-18-25.txt

@wpwrak
Copy link
Contributor Author

wpwrak commented Apr 20, 2023

Could you provide prebuilt binaries?

In case anyone needs my versions, I've uploaded them here:
https://almesberger.net/bl808/20230420-19.tar.bz2

@wpwrak
Copy link
Contributor Author

wpwrak commented Apr 20, 2023

Here's the full boot log: [CoolTerm Capture 2023-04-20 12-18-25.txt]

Interesting ! In your case, the kernel did indeed do nothing new. So we have at least three scenarios:

  1. Everything worked already.
  2. U-Boot and Linux need overrides.
  3. U-Boot needs overrides, but the kernel somehow doesn't. (But I suppose it doesn't mind if we override there as well.)

@dotsam
Copy link

dotsam commented Apr 20, 2023

3. U-Boot needs overrides, but the kernel somehow doesn't. (But I suppose it doesn't mind if we override there as well.)

Hmmm, or maybe not. I had 3 or 4 successful boots earlier, but trying again now, the kernel is indeed not able to mount the SD card.

[    0.198160] Waiting for root device PARTLABEL=rootfs...
[    0.529575] mmc0: error -110 whilst initialising SD card
[    0.649391] mmc0: problem reading SD Status register
[    0.652484] mmc0: error -110 whilst initialising SD card

I'll flash the new FS in a bit to confirm that it fixes things

@dotsam
Copy link

dotsam commented Apr 21, 2023

With the patched kernel, I've had good results getting successful full boots, but maybe 2 times in 20, I've still had issues with u-boot reading from the SD card. But if u-boot can read the card, I've had no issues with the kernel booting.

U-Boot 2023.04-rc2 (Apr 20 2023 - 13:44:15 +0000)

DRAM:  64 MiB
Core:  36 devices, 17 uclasses, devicetree: board
MMC:   mmc@20060000: 0
Loading Environment from FAT... Card did not respond to voltage select! : -110
** Bad device specification mmc 0 **
Loading Environment from nowhere... OK
In:    serial@30002000
Out:   serial@30002000
Err:   serial@30002000
Net:   
Warning: emac@20070000 (eth0) using random MAC address - 7a:01:80:ca:69:c4
eth0: emac@20070000
Hit any key to stop autoboot:  0 
Card did not respond to voltage select! : -110
SDH_CFG0: 0x00002000 -> 0x00002e00
SDHCI_CLOCK_CONTROL: 0x0000 -> 0x0000
SDH_CFG0: 0x00002e00 -> 0x00002e00
SDHCI_CLOCK_CONTROL: 0x0000 -> 0x0000
SDH_CFG0: 0x00002e00 -> 0x00002e00
SDHCI_CLOCK_CONTROL: 0xffc7 -> 0x0007
Card did not respond to voltage select! : -110
SDH_CFG0: 0x00002e00 -> 0x00002e00
SDHCI_CLOCK_CONTROL: 0x0000 -> 0x0000
SDH_CFG0: 0x00002e00 -> 0x00002e00
SDHCI_CLOCK_CONTROL: 0x0000 -> 0x0000
SDH_CFG0: 0x00002e00 -> 0x00002e00
SDHCI_CLOCK_CONTROL: 0xffc7 -> 0x0007
Card did not respond to voltage select! : -110
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3

Abort
missing environment variable: pxefile_addr_r
=> mmc info
SDH_CFG0: 0x00002e00 -> 0x00002e00
SDHCI_CLOCK_CONTROL: 0x0000 -> 0x0000
SDH_CFG0: 0x00002e00 -> 0x00002e00
SDHCI_CLOCK_CONTROL: 0x0000 -> 0x0000
SDH_CFG0: 0x00002e00 -> 0x00002e00
SDHCI_CLOCK_CONTROL: 0xffc7 -> 0x0007
Card did not respond to voltage select! : -110
=> 

@wpwrak
Copy link
Contributor Author

wpwrak commented Apr 25, 2023

Thanks for testing ! The register values are what I also have.
How do you start the system ? By pressing the reset button, by supplying USB power, ... ? And do you have an Ox64 or an M1s (or both) ?
Mine is an M1s and I always use the reset button to start the system. My usual card is a 16 GB Toshiba M203 HC UHS-I.
Considering some of the failure modes I saw with other register values, I think there is more going on inside SDH. Maybe a PLL. Maybe some tuning of bus parameters. But the juicy bits are vendor-specific, and the current BL808 documentation doesn't really give us a lot of clues. So the best I'm hoping for right now is to have a procedure that:

  1. works most of the time with at least some cards for everyone, even if it may need a few retries/resets/... in some cases, and
  2. doesn't make things worse for anyone.

@ErmakovDmitriy
Copy link

Hi all,

@wpwrak , thank you for your patch!
I am testing it with Sipeed M1S dock and Yocto Linux. It seems to be working at the first glance.

P.S. I ported your pull request to a Yocto layer ( https://github.com/ErmakovDmitriy/meta-bl808-mmc-clock ).

@fgaz
Copy link

fgaz commented Jan 15, 2024

In my case it fixed uboot but not linux

boot.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants