openbouffalo / buildroot_bouffalo

Linux Image for the BL808 CPU by Bouffalo Lab
128 stars 34 forks source link

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

Open wpwrak opened 1 year ago

wpwrak commented 1 year ago

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

eeucalyptus commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 10 months ago

In my case it fixed uboot but not linux

boot.txt