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

Question/Issue: Invalid boot header magic 0xffffffff at address 0x5d5ff000 #16

Open
ErmakovDmitriy opened this issue Jul 20, 2023 · 0 comments

Comments

@ErmakovDmitriy
Copy link

Issue description

Hi,

I am trying to use OBFLR with U-Boot from Boufafalo Buildroot with Sipeed M1S Dock (BL808).
I am not an expert in low-level software development, so I might be very wrong in what I am writing below.

Buildroot Bouffalo's Readme recommends flashing the U-boot + OpenSBI + DTB image (merged by mergebin.py - https://github.com/openbouffalo/buildroot_bouffalo/blob/main/board/pine64/ox64/mergebin.py#L103) at flash address 0x800000 which is at 0x58800000.

My understanding is that the header should be at the 0x588000000 address in the flash but if I set
#define BOOT_HDR_SRC_ADDR 0x58800000 in d0_lowload/src/main.c build and flash the lowload and the u-boot image, I get error

[I][LowLoad] low_load start... 
[I][LowLoad] Header at 0x58800000
[E][LowLoad] invalid boot header magic: 0xffffffff

The same error I get when I use the 0x5d5ff000 BOOT_HDR_SRC_ADDR which is committed in this repo:

[I][LowLoad] low_load start... 
[I][LowLoad] Header at 0x5d5ff000
[E][LowLoad] invalid boot header magic: 0xffffffff
[I][LowLoad] load time: 654 us 

U-Boot + OpenSBI Image

Here is how I flashed the U-boot, OpenSBI and DTB "bin" firmware:

# cat flash_prog_u_boot_cfg.ini
[cfg]
# 0: no erase, 1:programmed section erase, 2: chip erase
erase = 1
# skip mode set first para is skip addr, second para is skip len, multi-segment region with ; separated
skip_mode = 0x0, 0x0
# 0: not use isp mode, #1: isp mode
boot2_isp_mode = 0

[FW]
filedir = /home/dev/project/poky/build/tmp/deploy/images/bl808/bl808-firmware.bin
address = 0x800000

Flash command: bl_mcu_sdk/tools/bflb_tools/bouffalo_flash_cube/BLFlashCommand --baudrate=2000000 --chipname=bl808 --port=/dev/ttyACM1 --config=/home/dev/project/bl808/lowload/OBLFR/apps/d0_lowload/flash_prog_u_boot_cfg.ini

and the "start" of the bl808-firmware.bin is (hexedit):

00000000   42 56 4D 4C  01 00 00 00  03 00 00 00  00 00 00 00  B2 81 23 5C  01 00 00 00  00 01 00 00  E6 38 00 00  B2 81 23 5C  BVML..............#\.........8....#\
00000024   02 00 00 00  00 01 01 00  28 AD 01 00  B2 81 23 5C  03 00 00 00  00 01 03 00  EB CD 04 00  FF FF FF FF  FF FF FF FF  ........(.....#\....................

seems to contain the boot header magic value 0x4c4d5642.

BOOT_HDR_SRC_ADDR which works

I used https://github.com/openbouffalo/OBLFR/blob/master/apps/d0_lowload/src/main.c#L141 loop to find an address which contains the magic value of the boot header and found it to be 0x5f800000. I have looked through the BL808 reference manual v1.3, section 1.4 - Address Mapping and I could not understand to which range the 0x5f800000 belongs, looks like not FlashA to my mind.

When I changed d0_lowload/src/main.c:

diff --git a/apps/d0_lowload/src/main.c b/apps/d0_lowload/src/main.c
index 54313c086802..c3f780118248 100644
--- a/apps/d0_lowload/src/main.c
+++ b/apps/d0_lowload/src/main.c
@@ -38,7 +38,10 @@ extern void unlz4(const void *aSource, void *aDestination, uint32_t FileLen);
 #define VM_LINUX_DST_ADDR 0x50000000
 #define OPENSBI_DST_ADDR 0x3EF80000
 #define DTB_DST_ADDR 0x51ff8000
-#define BOOT_HDR_SRC_ADDR 0x5d5ff000
+//#define BOOT_HDR_SRC_ADDR 0x58800000
+//#define BOOT_HDR_SRC_ADDR 0x5d5ff000
+#define BOOT_HDR_SRC_ADDR 0x5f800000
+
 
 static struct bflb_device_s *uart0;

built and flashed, the lowload started loading OpenSBI, U-boot and then Linux (built by Yocto).

Here is the successful boot:

[I][] 
[I][]   ____                   ____               __  __      _       
[I][]  / __ \                 |  _ \             / _|/ _|    | |      
[I][] | |  | |_ __   ___ _ __ | |_) | ___  _   _| |_| |_ __ _| | ___  
[I][] | |  | | '_ \ / _ \ '_ \|  _ < / _ \| | | |  _|  _/ _` | |/ _ \ 
[I][] | |__| | |_) |  __/ | | | |_) | (_) | |_| | | | || (_| | | (_) |
[I][]  \____/| .__/ \___|_| |_|____/ \___/ \__,_|_| |_| \__,_|_|\___/ 
[I][]        | |                                                      
[I][]        |_|                                                      
[I][] 
[I][] Powered by BouffaloLab
[I][] Build:09:37:21,Jul 20 2023
[I][] Copyright (c) 2023 OpenBouffalo team
[I][] Copyright (c) 2022 Bouffalolab team
[I][] dynamic memory init success,heap size [I][LowLoad] D0 start...
[I][LowLoad] low_load start... 
[I][LowLoad] Header at 0x5f800000
[I][LowLoad] Section dtb(1) - Start 0x5f800100, Size 14566
[I][LowLoad] Copying DTB to 0x51ff8000...0x51ffb8e6
[I][LowLoad] Done!
[I][LowLoad] Section OpenSBI(2) - Start 0x5f810100, Size 109864
[I][LowLoad] Copying OpenSBI to 0x3ef80000...0x3ef9ad28
[I][LowLoad] Done!
[I][LowLoad] Section Kernel(3) - Start 0x5f830100, Size 314859
[I][LowLoad] Uncompressing Kernel to 0x50000000...
[I][LowLoad] Done!
[I][LowLoad] CRC: 00000000
[I][LowLoad] load time: 62140 us 
[I][LowLoad] Setting PMP
[I][LowLoad] Booting OpenSBI at 0x000000003ef80000 with DTB at 0x51ff8000

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

Platform Name             : Pine64 Ox64 (D0)
Platform Features         : medeleg
Platform HART Count       : 1
Platform IPI Device       : aclint-mswi
Platform Timer Device     : aclint-mtimer @ 1000000Hz
Platform Console Device   : bflb_uart
Platform HSM Device       : ---
Platform PMU Device       : ---
Platform Reboot Device    : ---
Platform Shutdown Device  : ---
Firmware Base             : 0x3ef80000
Firmware Size             : 200 KB
Runtime SBI Version       : 1.0

Domain0 Name              : root
Domain0 Boot HART         : 0
Domain0 HARTs             : 0*
Domain0 Region00          : 0x00000000e4008000-0x00000000e400bfff (I)
Domain0 Region01          : 0x00000000e4000000-0x00000000e4007fff (I)
Domain0 Region02          : 0x000000003ef80000-0x000000003efbffff ()
Domain0 Region03          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000050000000
Domain0 Next Arg1         : 0x0000000051ff8000
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes

Boot HART ID              : 0
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 : 4096
Boot HART PMP Address Bits: 38
Boot HART MHPM Count      : 8
Boot HART MIDELEG         : 0x0000000000000222
Boot HART MEDELEG         : 0x000000000000b109


U-Boot 2023.04-rc2 (Feb 22 2023 - 03:14:23 +0000)

DRAM:  64 MiB
Core:  36 devices, 17 uclasses, devicetree: board
MMC:   mmc@20060000: 0
Loading Environment from FAT... sdhci_send_command: Timeout for status update!
Card did not respond to voltage select! : -110
** Bad device specification mmc 0 **
In:    serial@30002000
Out:   serial@30002000
Err:   serial@30002000
Net:   
Warning: emac@20070000 (eth0) using random MAC address - b6:17:93:57:6e:e5
eth0: emac@20070000
Hit any key to stop autoboot:  0

May I ask you, if you have time, to analyze the issue I have (highly likely there is no issue but my misunderstanding)?

Thank you in advance,
// Dmitrii.

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

1 participant