U-boot could not initialize timer

I am trying to deploy Keystone Enclave on VF2. By following this guide I manage to boot u-boot spl → opensbi (with sm monitor extension) → u-boot proper, but u-boot crashes displaying this error.

U-Boot SPL 2023.07-rc2-00170-g62df7a3944-dirty (Jun 27 2023 - 15:03:29 +0300)
DDR version: dc2e84f0.
Trying to boot from MMC2

OpenSBI v1.1
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |

[SM] Initializing ... hart [1]
[SM] Keystone security monitor has been initialized!
Platform Name             : StarFive VisionFive 2 v1.3B
Platform Features         : medeleg
Platform HART Count       : 5
Platform IPI Device       : aclint-mswi
Platform Timer Device     : aclint-mtimer @ 4000000Hz
Platform Console Device   : uart8250
Platform HSM Device       : ---
Platform Reboot Device    : ---
Platform Shutdown Device  : ---
Firmware Base             : 0x80000000
Firmware Size             : 388 KB
Runtime SBI Version       : 1.0

Domain0 Name              : root
Domain0 Boot HART         : 1
Domain0 HARTs             : 0*,1*,2*,3*,4*
Domain0 Region00          : 0x0000000002000000-0x000000000200ffff (I)
Domain0 Region01          : 0x0000000080000000-0x000000008007ffff ()
Domain0 Region02          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000040200000
Domain0 Next Arg1         : 0x0000000040287d48
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes

Boot HART ID              : 1
Boot HART Domain          : root
Boot HART Priv Version    : v1.11
Boot HART Base ISA        : rv64imafdcbx
Boot HART ISA Extensions  : none
Boot HART PMP Count       : 8
Boot HART PMP Granularity : 4096
Boot HART PMP Address Bits: 34
Boot HART MHPM Count      : 2
Boot HART MIDELEG         : 0x0000000000000222
Boot HART MEDELEG         : 0x000000000000b109
initcall: 000000004024c9e6

U-Boot 2023.07-rc2-00170-g62df7a3944-dirty (Jun 27 2023 - 15:03:29 +0300)

initcall: 0000000040215dba
U-Boot code: 40200000 -> 40287D60  BSS: -> 4028E738
initcall: 0000000040215c90
initcall: 0000000040215e90
CPU:   rv64imafdc_zba_zbb
initcall: 0000000040216510
Model: StarFive VisionFive 2 v1.3B
initcall: 0000000040215e60
initcall: 0000000040215e48
DRAM:  initcall: 0000000040200fda
initcall: 00000000402161b4
Monitor len: 0008E738
Ram size: 200000000
Ram top: 100000000
initcall: 0000000040215e40
initcall: 0000000040215c80
initcall: 0000000040215f10
initcall: 0000000040215f14
initcall: 0000000040215f18
initcall: 0000000040215d70
Reserving 569k for U-Boot at: fff71000
initcall: 0000000040215fe4
Reserving 8316k for malloc() at: ff752000
initcall: 0000000040215f38
Reserving 112 Bytes for Board Info at: ff751f90
initcall: 0000000040215d42
Reserving 392 Bytes for Global Data at: ff751e00
initcall: 0000000040215f80
Reserving 30432 Bytes for FDT at: ff74a720
initcall: 0000000040215f1c
initcall: 0000000040215f20
initcall: 0000000040215f30
initcall: 0000000040216226
initcall: 0000000040200fde
initcall: 0000000040216014

RAM Configuration:
Bank #0: 40000000 8 GiB

DRAM:  8 GiB
initcall: 0000000040216240
initcall: 0000000040215d26
New Stack Pointer is: ff74a710
initcall: 0000000040215de6
initcall: 0000000040215f24
initcall: 0000000040215f28
initcall: 0000000040215cb6
Relocation Offset is: bfd71000
Relocating to fff71000, new gd at ff751e00, sp at ff74a710
initcall: 0000000040215f34
initcall: 0000000040215f04
initcall: 0000000040215c94
Could not initialize timer (err -19)

resetting ...
reset not supported yet
### ERROR ### Please RESET the board ###

I also found this mailing list describing a similar error on a different SoC.

Does anyone have a solution?

1 Like

I got the same problem this week trying to boot with upstream u-boot.
The timer is not yet initialized, I also sent a mail to the u-boot mailing list (but it is held back for moderation?).

I figured out, that the timer is implemented in riscv_timer, and this driver will only initialize the timer, when the boot hart CPU driver is loaded.
Unfortunately it seems this never happens.

I managed to set up JTAG, and I will try to debug the code some more.


Also there were some problems in the guide around creating a bootable sd card, it did not work for me, or would load a SPL from somewhere else on the SD card.

After fixing this timer issue I will probably send some patches upstream for the bug + update the documentation with my findings regarding creating an actually bootable sd card image reliably.


For reference, here is my post to the mailing list with more details:


Btw, you say that

the boot ROM searches for the SPL by looking for the offset of its partition in the GPT with a specific GUID. Not sure where this information comes from, but testing showed, that its probably not true.

What actually happens?

Also, seems there are already some discussions about that initcall sequence problem: [v4,00/11] Add ethernet driver for StarFive JH7110 SoC - Patchwork


It seems like its just reading the first two sectors, and parsing a header there.
The header can point to a backup sector in case its crc is bad.

Unfortunately the first two sectors are protective MBR and GPT header, so thats a bit unfortunate. The Tools/spl_tool at master · starfive-tech/Tools · GitHub can patch these two first sectors with the -i option. It makes it both a valid GPT header + a SPL header that points to the backup sector (usually in a partition with the Sifive BBL GUID).


It looks for the GPT GUID of the partition
(For the JH7100, but this part is the same as the JH7110):

And this shows that it actually is the same, from the JH7110 Boot Guide:

secondary boot GPT GUID primary: 2E54B353-1271-4842-806F-E436D6AF6985
AKA as partition type 198 or “HiFive BBL”
(if the primary is corrupt, fails CRC, then it “should”, but may not, look for the backup):
secondary boot GPT GUID backup: 2E54B353-1271-4842-806F-E436D6AF6984

From U-boot:

#define TYPE_GUID_LOADER1 5B193300-FC78-40CD-8002-E86C45580B47
#define TYPE_GUID_LOADER2 2E54B353-1271-4842-806F-E436D6AF6985
#define TYPE_GUID_SYSTEM  0FC63DAF-8483-4772-8E79-3D69D8477DE4

partition type 197 or “HiFive FSBL”

partition type 198 or “HiFive BBL”

partition type 20 or “Linux filesystem”


I tried reverting the patch mentioned in the thread, and it seems like it is working!

Thanks for finding it.


A fix series for this problem are sent by someone, maybe you could try and and add a tested-by? [v2,0/2] introduce EVT_DM_POST_INIT_R to fix VF2 boot fail - Patchwork

Took a look at it, works perfectly with both the defconfig, and my custom config.
I already responded on the mailing list (but its held for review for whatever reason…)