apritzel / u-boot

various u-boot patches
24 stars 13 forks source link

h6 atf hangs at the axp805 probe on some h6 devices #5

Open hexdump0815 opened 4 years ago

hexdump0815 commented 4 years ago

hello,

i just built a fresh mainline u-boot (2020.01) and mainline atf (head as of today from the github mirror) and on a h6 tv box without an axp805 the resulting u-boot with that atf in it will hang:

U-Boot SPL 2020.01-dirty (Jan 15 2020 - 21:56:28 +0100)                                   
DRAM:MBUS port 0 cfg0 0100000d cfg1 00640080                                              
MBUS port 1 cfg0 06000009 cfg1 01000578                                                   
MBUS port 2 cfg0 0200000d cfg1 00600100                                                   
MBUS port 3 cfg0 01000009 cfg1 00500064                                                   
MBUS port 4 cfg0 20000209 cfg1 1388157c                                                   
MBUS port 5 cfg0 00640209 cfg1 00200040                                                   
MBUS port 6 cfg0 00640209 cfg1 00200040                                                   
MBUS port 8 cfg0 01000009 cfg1 00400080                                                   
MBUS port 11 cfg0 01000009 cfg1 00640080                                                  
MBUS port 14 cfg0 04000009 cfg1 00400100                                                  
MBUS port 16 cfg0 2000060d cfg1 09600af0                                                  
MBUS port 25 cfg0 0064000d cfg1 00200040                                                  
MBUS port 26 cfg0 20000209 cfg1 1388157c                                                  
MBUS port 37 cfg0 01000009 cfg1 00400080
MBUS port 38 cfg0 00640209 cfg1 00200040
MBUS port 39 cfg0 20000209 cfg1 1388157c
MBUS port 40 cfg0 00640209 cfg1 00200040
 2048 MiB
Trying to boot from MMC1
NOTICE:  BL31: v2.2(debug):v2.2-321-g743600b2
NOTICE:  BL31: Built : 21:53:49, Jan 15 2020
NOTICE:  BL31: Detected Allwinner H6 SoC (1728)
NOTICE:  BL31: Found U-Boot DTB at 0xc07ae70, model: Eachlink H6 Mini
INFO:    ARM GICv2 driver initialized
INFO:    PMIC: Probing AXP805 on I2C
IN

if i comment out the apx805 probing, it works perfectly fine:

diff --git a/plat/allwinner/sun50i_h6/sunxi_power.c b/plat/allwinner/sun50i_h6/sunxi_power.c
index 443015ba..a1e4d692 100644
--- a/plat/allwinner/sun50i_h6/sunxi_power.c
+++ b/plat/allwinner/sun50i_h6/sunxi_power.c
@@ -55,16 +55,16 @@ int axp_write(uint8_t reg, uint8_t val)

 static int axp805_probe(void)
 {
-       int ret;
-
-       /* Switch the AXP805 to master/single-PMIC mode. */
-       ret = axp_write(0xff, 0x0);
-       if (ret)
-               return ret;
-
-       ret = axp_check_id();
-       if (ret)
-               return ret;
+//     int ret;
+//
+//     /* Switch the AXP805 to master/single-PMIC mode. */
+//     ret = axp_write(0xff, 0x0);
+//     if (ret)
+//             return ret;
+//
+//     ret = axp_check_id();
+//     if (ret)
+//             return ret;

        return 0;
 }

resulting working boot:

U-Boot SPL 2020.01-dirty (Jan 15 2020 - 22:04:24 +0100)
DRAM:MBUS port 0 cfg0 0100000d cfg1 00640080
MBUS port 1 cfg0 06000009 cfg1 01000578
MBUS port 2 cfg0 0200000d cfg1 00600100
MBUS port 3 cfg0 01000009 cfg1 00500064
MBUS port 4 cfg0 20000209 cfg1 1388157c
MBUS port 5 cfg0 00640209 cfg1 00200040
MBUS port 6 cfg0 00640209 cfg1 00200040
MBUS port 8 cfg0 01000009 cfg1 00400080
MBUS port 11 cfg0 01000009 cfg1 00640080
MBUS port 14 cfg0 04000009 cfg1 00400100
MBUS port 16 cfg0 2000060d cfg1 09600af0
MBUS port 25 cfg0 0064000d cfg1 00200040
MBUS port 26 cfg0 20000209 cfg1 1388157c
MBUS port 37 cfg0 01000009 cfg1 00400080
MBUS port 38 cfg0 00640209 cfg1 00200040
MBUS port 39 cfg0 20000209 cfg1 1388157c
MBUS port 40 cfg0 00640209 cfg1 00200040
 2048 MiB
Trying to boot from MMC1
NOTICE:  BL31: v2.2(debug):v2.2-321-g743600b2-dirty
NOTICE:  BL31: Built : 22:03:55, Jan 15 2020
NOTICE:  BL31: Detected Allwinner H6 SoC (1728)
NOTICE:  BL31: Found U-Boot DTB at 0xc07ae70, model: Eachlink H6 Mini
INFO:    ARM GICv2 driver initialized
INFO:    PMIC: Probing AXP805 on I2C                                                      
WARNING: PMIC: No PMIC DT node, skipping setup                                            
INFO:    BL31: Platform setup done                                                        
INFO:    BL31: Initializing runtime services                                              
INFO:    BL31: cortex_a53: CPU workaround for 855873 was applied                          
INFO:    BL31: Preparing for EL3 exit to normal world                                     
INFO:    Entry point address = 0x4a000000                                                 
INFO:    SPSR = 0x3c9                                                                     

U-Boot 2020.01-dirty (Jan 15 2020 - 22:04:24 +0100) Allwinner Technology                  

CPU:   Allwinner H6 (SUN50I)                                                              
Model: Eachlink H6 Mini                                                                   
DRAM:  2 GiB                                                                              
MMC:   mmc@4020000: 0, mmc@4022000: 1                                                     
Loading Environment from FAT... Unable to use mmc 1:1... In:    serial@5000000            
Out:   serial@5000000                                                                     
Err:   serial@5000000                                                                     
Net:   No ethernet found.
Hit any key to stop autoboot:  0 
...

maybe the axp805 probing should be made optional by some atf compile time option?

a lot of thanks in advance and best wishes - hexdump

apritzel commented 4 years ago

Sorry, just saw your comment. Thanks for the report, indeed there are H6 devices without an AXP chip. Ideally the I2C scan should come back without a result, but apparently there is some problem with that. I will look into a solution, I guess it goes along the lines of checking the DT for an AXP node first. I don't really want to introduce build time options. Or we find a stable way of running the I2C scan anyway. Will try to reproduce this on my Eachlink box.

apritzel commented 4 years ago

So it worked as expected on my Eachlink H6 Mini:

U-Boot SPL 2020.01-00626-g0edb2b9852 (Jan 19 2020 - 00:12:34 +0000)
DRAM: 4096 MiB
Trying to boot from MMC1
NOTICE:  BL31: v2.2(debug):v2.2-353-g38aac6d40
NOTICE:  BL31: Built : 23:25:03, Jan 18 2020
NOTICE:  BL31: Detected Allwinner H6 SoC (1728)
NOTICE:  BL31: Found U-Boot DTB at 0xc0801f0, model: Eachlink H6 Mini
INFO:    ARM GICv2 driver initialized
INFO:    PMIC: Probing AXP805 on I2C
ERROR:   Start clear bit timeout
ERROR:   PMIC: Cannot write AXP805 register ff
INFO:    BL31: Platform setup done
INFO:    BL31: Initializing runtime services
INFO:    BL31: cortex_a53: CPU workaround for 855873 was applied
INFO:    BL31: Preparing for EL3 exit to normal world
INFO:    Entry point address = 0x4a000000
INFO:    SPSR = 0x3c9

U-Boot 2020.01-00626-g0edb2b9852 (Jan 19 2020 - 00:12:34 +0000) Allwinner Technology

CPU:   Allwinner H6 (SUN50I)
Model: Eachlink H6 Mini
DRAM:  3 GiB
...

I see that you have DEBUG defined for the SPL DRAM driver. Do you have any other changes in your SPL, especially the DRAM driver? And does it really stop after the first two letters of the next INFO statement? Does it hang at this point? Do you know if anything is connected to PL0 or PL1? It could only be GPIOs or I2C on those two pins, AFAICS.

hexdump0815 commented 4 years ago

checking the dt for an axp node sounds like a good idea. regarding the dram driver in the spl i tried to get the timing stable with @jernejsk - we tried some patches but in the end it always resets a few times, but after a while gets through it and runs stable then - the story starts here: https://forum.armbian.com/topic/12372-h6-allwinner-tv-box-need-help/?do=findComment&comment=92283 ... but i think the atf problems are not related to that, as i get the same atf hang if i use a u-boot compiled with your libdram binary blob code (with the only difference, that there is no resetting at the beginning in that case) ... regarding the hanging: yes, it really simply hangs reliably after those two letters each time ... here is the dtb extracted from that box: https://forum.armbian.com/topic/12372-h6-allwinner-tv-box-need-help/?do=findComment&comment=92389 - hopefully this will tell you enough about how things are wired up

best wishes - hexdump

apritzel commented 4 years ago

I am still somewhat puzzled by that "IN" output, because it hints that the next output would have been an INFO line, which does not make much sense unless there is an AXP detected (compare the outputs in the other cases).

And we actually already check for the AXP DT node (see the output with your patch applied), it's just we should do it a bit earlier. I need to think how to write this properly, since this is partly Allwinner generic code. Technically we should check for a valid I2C bus in the DT, but this harder to do properly.

maartenjd commented 6 months ago

Hello. Is this issue maybe related? sunxi_power.c has changed considerably since 2020.