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

Newly-built EDK2/GRUB crashes #110

Open
orlitzky opened this issue Sep 11, 2024 · 4 comments
Open

Newly-built EDK2/GRUB crashes #110

orlitzky opened this issue Sep 11, 2024 · 4 comments

Comments

@orlitzky
Copy link

I'm trying to document the EDK2/GRUB build process but haven't been able to build a working SG2042.fd yet. It builds successfully, but then crashes when I reboot. This is on a Pioneer Box:

sg2042:v0.3

sg2042 work in single socket mode
chip0 ddr info: raw data=0x5050505, 
    ddr0 size:0x800000000
    ddr1 size:0x800000000
    ddr2 size:0x800000000
    ddr3 size:0x800000000
SD initializing 100000000Hz (transfer frequency at 25000000Hz)
sd card init ok
0:riscv64/conf.ini file size is 114
read config from sd
rv boot from sd card
SD initializing 100000000Hz (transfer frequency at 25000000Hz)
sd card init ok
0:riscv64/fw_dynamic.bin file size is 270032
0:riscv64/SG2042.fd file size is 8060928
0:riscv64/mango-milkv-pioneer.dtb file size is 44551
sd read file ok
chip0 ddr node in dtb:
    base:0x0000000000, len:0xc0000000
    base:0x0100000000, len:0x700000000
    base:0x0800000000, len:0x800000000
    base:0x1000000000, len:0x800000000
    base:0x1800000000, len:0x800000000
use default mac address
main core sbi jump to 0x0, dynamic info:40019840

OpenSBI v1.2-117-g3745939
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|___/_____|
        | |
        |_|

Platform Name             : Sophgo Mango
Platform Features         : medeleg
Platform HART Count       : 64
Platform IPI Device       : aclint-mswi
Platform Timer Device     : aclint-mtimer @ 50000000Hz
Platform Console Device   : uart8250
Platform HSM Device       : ---
Platform PMU Device       : 
Platform Reboot Device    : mango-reset
Platform Shutdown Device  : mango-reset
Platform Suspend Device   : ---
Firmware Base             : 0x0
Firmware Size             : 1376 KB
Firmware RW Offset        : 0x40000
Runtime SBI Version       : 1.0

Domain0 Name              : root
Domain0 Boot HART         : 6
Domain0 HARTs             : 0*,1*,2*,3*,4*,5*,6*,7*,8*,9*,10*,11*,12*,13*,14*,15*,16*,17*,18*,19*
Domain0 Region00          : 0x0000007094000000-0x0000007094003fff M: (I,R,W) S/U: ()
Domain0 Region01          : 0x0000000000000000-0x000000000003ffff M: (R,X) S/U: ()
Domain0 Region02          : 0x0000000000000000-0x00000000001fffff M: (R,W) S/U: ()
Domain0 Region03          : 0x00000070ac000000-0x00000070ac3fffff M: (I,R,W) S/U: ()
Domain0 Region04          : 0x0000000000000000-0xffffffffffffffff M: (R,W,X) S/U: (R,W,X)
Domain0 Next Address      : 0x0000000002000000
Domain0 Next Arg1         : 0x000000004009fe38
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes
Domain0 SysSuspend        : yes

Boot HART ID              : 6
Boot HART Domain          : root
Boot HART Priv Version    : v1.11
Boot HART Base ISA        : rv64imafdcvx
Boot HART ISA Extensions  : time
Boot HART PMP Count       : 8
Boot HART PMP Granularity : 2048
Boot HART PMP Address Bits: 38
Boot HART MHPM Count      : 29
Boot HART MIDELEG         : 0x0000000000020222
Boot HART MEDELEG         : 0x000000000000b109
PROGRESS CODE: V03040003 I0
PROGRESS CODE: V03040002 I0
PROGRESS CODE: V03040003 I0
PROGRESS CODE: V03040002 I0
PROGRESS CODE: V03040003 I0
PROGRESS CODE: V03040002 I0
!!!! RISCV64 Exception Type - 0000000000000007(EXCEPT_RISCV_STORE_AMO_ACCESS_FAULT) !!!!
     t0 = 0x000000000047FFB78        t1 = 0x000000000047FFB80
     t2 = 0x00000000000002000        t3 = 0x00000000000000000
     t4 = 0x00000000000000010        t5 = 0x0000000000013DDCC
     t6 = 0x00000000000000004        s0 = 0x000000000047FF950
     s1 = 0x00000000000000044        s2 = 0x00000000000002000
     s3 = 0x00000000002000000        s4 = 0x00000000000000006
     s5 = 0x0000000004009FE38        s6 = 0x08000000A00006880
     s7 = 0x00000000000040040        s8 = 0x00000000000004000
     s9 = 0x0000000000004EAD0       s10 = 0x00000000000000000
    s11 = 0x00000000000000000        a0 = 0x000000000BFFDEC10
     a1 = 0x00000000000000001        a2 = 0x00000000000000000
     a3 = 0x00000000000000000        a4 = 0x00000000000000002
     a5 = 0x000000000BFFDEC10        a6 = 0x00000000000000003
     a7 = 0x00000000000000010      zero = 0x00000000000000000
     ra = 0x000000000BFEB2606        sp = 0x00100000003D3F3A4
     gp = 0x00000000000000000        tp = 0x0000000000013E000
   sepc = 0x000000000BFEB265E   sstatus = 0x08000000200006120
  stval = 0x00000000000000000

If I take SG2042.fd from one of the pre-built Fedora images, it works, so there must be something going wrong in the build. (I am following the steps in envsetup.sh.)

@alitariq4589
Copy link

@orlitzky From which distro did you get the already compiled SG2042.fd? Can you give me the link and also the path where it is stored in the archive file?

@orlitzky
Copy link
Author

(I answered on the mailing list, but just in case someone else needs this...)

At the time of writing, the latest SOPHGO Fedora image is,

After decompressing that, you will be left with fedora-sophgo.img, which is a raw disk image (containing multiple partitions) of a Fedora installation. The SG2042.fd file is on the first partition, corresponding to /boot/efi.

On linux, you can use losetup to create loopback devices corresponding to those partitions, and then mount the first one somewhere:

$ losetup -P -f fedora-sophgo.img 
$ mkdir /mnt/fedora-efi
$ mount /dev/loop0p1 /mnt/fedora-efi

Now the file you want should be under /mnt/fedora-efi

@alitariq4589
Copy link

@orlitzky I have tried the SG2042.d file from the fedora image which you just provided above and now I am getting following exception during boot.

  • I have copied vmlinuz-6.1.31 from the Fedora distribution to the sd card root directory (it is currently the working kernel)
  • I have copied the the mango-milkv-pioneer.dtb from the installed fedora 38 distribution to the sd card
  • I have changed the grub/grub.cfg just for the menuentry so that it picks /vmlinuz-6.1.31 instead of the gentoo kernel
set default=0
set timeout_style=menu
set timeout=2

set debug="linux,loader,mm"
set term="vt100"
set pager=1

menuentry 'Gentoo 6.1.80+' {
    linux /vmlinuz-6.1.31 root=/dev/nvme0n1p3 rootfstype=ext4 rootwait rw earlycon selinux=0 LANG=en_US.UTF-8 console=tty1
    devicetree /riscv64/mango-milkv-pioneer.dtb

My conf.ini is as follows:

[sophgo-config]

[devicetree]
name = mango-milkv-pioneer.dtb

[kernel]
name = SG2042.fd

[eof]

The directory tree of the SD card is as follows:

.
├── EFI
│   └── BOOT
│       └── BOOTRISCV64.EFI
├── fip.bin
├── grub
│   └── grub.cfg
├── riscv64
│   ├── conf.ini
│   ├── fw_dynamic.bin
│   ├── mango-milkv-pioneer.dtb
│   ├── riscv64_Image
│   └── SG2042.fd
├── vmlinuz-6.1.31
└── zsbl.bin

I am getting following error during boot process (the exception is different from yours, it is EXCEPT_RISCV_STORE_ACCESS_PAGE_FAULT):

SOPHGO ZSBL
sg2042:v0.3

sg2042 work in single socket mode
chip0 ddr info: raw data=0x5050505, 
    ddr0 size:0x800000000
    ddr1 size:0x800000000
    ddr2 size:0x800000000
    ddr3 size:0x800000000
SD initializing 100000000Hz (transfer frequency at 25000000Hz)
sd card init ok
0:riscv64/conf.ini file size is 95
read config from sd
rv boot from sd card
SD initializing 100000000Hz (transfer frequency at 25000000Hz)
sd card init ok
0:riscv64/fw_dynamic.bin file size is 270032
0:riscv64/SG2042.fd file size is 7995392
0:riscv64/mango-milkv-pioneer.dtb file size is 46008
sd read file ok
chip0 ddr node in dtb:
fdt: failed to add memory node [0, c0000000], error(-2)
    base:0x0100000000, len:0x700000000
    base:0x0800000000, len:0x800000000
    base:0x1000000000, len:0x800000000
    base:0x1800000000, len:0x800000000
use default mac address
main core sbi jump to 0x0, dynamic info:400198f0

OpenSBI v1.2-117-g3745939
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|___/_____|
        | |
        |_|

Platform Name             : Sophgo Mango
Platform Features         : medeleg
Platform HART Count       : 64
Platform IPI Device       : aclint-mswi
Platform Timer Device     : aclint-mtimer @ 50000000Hz
Platform Console Device   : uart8250
Platform HSM Device       : ---
Platform PMU Device       : 
Platform Reboot Device    : mango-reset
Platform Shutdown Device  : mango-reset
Platform Suspend Device   : ---
Firmware Base             : 0x0
Firmware Size             : 1376 KB
Firmware RW Offset        : 0x40000
Runtime SBI Version       : 1.0

Domain0 Name              : root
Domain0 Boot HART         : 3
Domain0 HARTs             : 0*,1*,2*,3*,4*,5*,6*,7*,8*,9*,10*,11*,12*,13*,14*,15*,16*,17*,18*,19*,20*,21*,22*,23*,24*,25*,26*,27*,28*,29*,30*,31*,32*,33*,34*,35*,36*,37*,38*,39*,40*,41*,42*,43*,44*,45*,46*,47*,48*,49*,50*,51*,52*,53*,54*,55*,56*,57*,58*,59*,60*,61*,62*,63*
Domain0 Region00          : 0x0000007094000000-0x0000007094003fff M: (I,R,W) S/U: ()
Domain0 Region01          : 0x0000000000000000-0x000000000003ffff M: (R,X) S/U: ()
Domain0 Region02          : 0x0000000000000000-0x00000000001fffff M: (R,W) S/U: ()
Domain0 Region03          : 0x00000070ac000000-0x00000070ac3fffff M: (I,R,W) S/U: ()
Domain0 Region04          : 0x0000000000000000-0xffffffffffffffff M: (R,W,X) S/U: (R,W,X)
Domain0 Next Address      : 0x0000000002000000
Domain0 Next Arg1         : 0x00000000400a0008
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes
Domain0 SysSuspend        : yes

Boot HART ID              : 3
Boot HART Domain          : root
Boot HART Priv Version    : v1.11
Boot HART Base ISA        : rv64imafdcvx
Boot HART ISA Extensions  : time
Boot HART PMP Count       : 8
Boot HART PMP Granularity : 2048
Boot HART PMP Address Bits: 38
Boot HART MHPM Count      : 29
Boot HART MIDELEG         : 0x0000000000020222
Boot HART MEDELEG         : 0x000000000000b109
!!!! RISCV64 Exception Type - 000000000000000F(EXCEPT_RISCV_STORE_ACCESS_PAGE_FAULT) !!!!
     t0 = 0x08000000200006100	     t1 = 0x000000000047FFB80
     t2 = 0x00000000000002000	     t3 = 0x00000000000000010
     t4 = 0x00000000000149DDC	     t5 = 0x0000000000000000B
     t6 = 0x00000000000000027	     s0 = 0x000000000047FFC20
     s1 = 0x00000000000000001	     s2 = 0x00000000000000000
     s3 = 0x00000000002000000	     s4 = 0x00000000000000003
     s5 = 0x000000000400A0008	     s6 = 0x08000000A00006880
     s7 = 0x00000000000040040	     s8 = 0x00000000000004000
     s9 = 0x0000000000004EAC4	    s10 = 0x00000000000000000
    s11 = 0x00000000000000000	     a0 = 0x08000000001FFF626
     a1 = 0x00000000000000004	     a2 = 0x00000000000000004
     a3 = 0x00000000000000000	     a4 = 0x08000000001FFF626
     a5 = 0x08000000001FFF626	     a6 = 0x00000000000000000
     a7 = 0x00000000000000010	   zero = 0x00000000000000000
     ra = 0x00000001FFFE10B34	     sp = 0x0FFFFFFFFFFFFFFFF
     gp = 0x00000000000000000	     tp = 0x0000000000014A000
   sepc = 0x00000001FFFE1357A	sstatus = 0x08000000200006100
  stval = 0x000000000027A00B8

@orlitzky
Copy link
Author

Unfortunately these error messages don't mean much to me. I did notice an earlier error in your output,

fdt: failed to add memory node [0, c0000000], error(-2)

that I would be suspicious of. That message is coming from https://github.com/sophgo/zsbl/blob/master/plat/sg2042/boot.c#L617 and the error can be traced back through libfdt. I think it's coming from

offset = fdt_subnode_offset_namelen(fdt, parentoffset, name, namelen);
if (offset >= 0)
        return -FDT_ERR_EXISTS;

because

#define FDT_ERR_EXISTS          2
/* FDT_ERR_EXISTS: Attempted to create a node or property which                                                                
* already exists */

is the error code you see. If it were me, I would try:

to see if that error goes away. But I am 100% guessing.

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

No branches or pull requests

2 participants