fix: orangepi3 higher-half boot with uImage

This commit is contained in:
2021-10-11 18:36:08 +03:00
parent 2362ce6cd4
commit 7ac20b1841
4 changed files with 30 additions and 10 deletions
+14 -6
View File
@@ -25,7 +25,7 @@ ifeq ($(ARCH),x86_64)
$(error TODO)
else
ifeq ($(MACH),qemu)
QEMU_OPTS+=-kernel $(O)/kernel.bin \
QEMU_OPTS+=-kernel $(O)/kernel \
-M virt,virtualization=off \
-cpu cortex-a72 \
-m 512 \
@@ -53,12 +53,20 @@ all: kernel
kernel:
cd kernel && cargo build $(CARGO_BUILD_OPTS)
ifeq ($(ARCH),aarch64)
$(OBJCOPY) -O binary $(O)/kernel $(O)/kernel.bin
endif
ifeq ($(MACH),orangepi3)
# $(LLVM_BASE)/llvm-strip $(O)/kernel
$(LLVM_BASE)/llvm-size $(O)/kernel
$(LLVM_BASE)/llvm-strip -o $(O)/kernel.strip $(O)/kernel
$(LLVM_BASE)/llvm-size $(O)/kernel.strip
$(OBJCOPY) -O binary $(O)/kernel.strip $(O)/kernel.bin
$(MKIMAGE) \
-A arm64 \
-O linux \
-T kernel \
-C none \
-a 0x48000000 \
-e 0x48000000 \
-n kernel \
-d $(O)/kernel.bin \
$(O)/uImage
endif
clean:
+1 -1
View File
@@ -1,7 +1,7 @@
ENTRY(_entry);
KERNEL_OFFSET = 0xFFFFFF8000000000;
BASE_OFFSET = 0x42000000;
BASE_OFFSET = 0x48000000;
SECTIONS {
. = BASE_OFFSET;
+10 -3
View File
@@ -8,7 +8,7 @@ use cortex_a::registers::{DAIF, SCTLR_EL1, VBAR_EL1, CurrentEL};
use tock_registers::interfaces::{ReadWriteable, Writeable, Readable};
#[no_mangle]
fn __aa64_bsp_main(fdt_base: usize) {
extern "C" fn __aa64_bsp_main(fdt_base: usize) {
// Disable FP instruction trapping
CPACR_EL1.modify(CPACR_EL1::FPEN::TrapNone);
@@ -34,8 +34,15 @@ fn __aa64_bsp_main(fdt_base: usize) {
machine::init_board().unwrap();
// let fdt = DeviceTree::from_phys(fdt_base + 0xFFFFFF8000000000).expect("Failed to obtain a device tree");
// fdt.dump();
if fdt_base != 0 {
debugln!("fdt_base = {:#x}", fdt_base);
let fdt = DeviceTree::from_phys(fdt_base + 0xFFFFFF8000000000);
if let Ok(fdt) = fdt {
fdt.dump();
} else {
debugln!("Failed to init FDT");
}
}
debugln!("Machine init finished");
+5
View File
@@ -77,3 +77,8 @@ __aa64_entry_upper:
bsp_stack_bottom:
.skip 32768
bsp_stack_top:
.section .data
.p2align 4
fdt_base_phys:
.skip 8