diff --git a/doc/platform_phytium_pi.md b/doc/platform_phytium_pi.md index e748747d68..09d8072718 100644 --- a/doc/platform_phytium_pi.md +++ b/doc/platform_phytium_pi.md @@ -33,7 +33,19 @@ We can ignore select dtb step by pressing `enter` directly. ArceOS dose not supp Then the cmdline will wait for you to put board power on or reset. -You can modify config in `.project.toml` to change the default behavior. +`Ctrl+C` to exit. + +Modify config in `.project.toml` to change platform for phytium pi. + +Find `shell=[[ ... "make A=examples/helloworld ARCH=aarch64" ]]`, add `PLATFORM` like: + + `"make A=examples/helloworld PLATFORM=aarch64-phytium-pi"`. + +Find `elf = "examples/helloworld/helloworld_aarch64-qemu-virt.elf"` and change to: + +`elf = "examples/helloworld/helloworld_aarch64-phytium-pi.elf"`. + +Then run `ostool run uboot` again. When see `等待 U-Boot 启动...` , put board power on or reset. If everything goes well, you will see the following output: diff --git a/modules/axhal/linker.lds.S b/modules/axhal/linker.lds.S index 2ec5f00a62..23e2794850 100644 --- a/modules/axhal/linker.lds.S +++ b/modules/axhal/linker.lds.S @@ -76,6 +76,8 @@ SECTIONS } _ekernel = .; + + _kernel_size = _ekernel - _skernel; /DISCARD/ : { *(.comment) *(.gnu*) *(.note*) *(.eh_frame*) diff --git a/modules/axhal/src/platform/aarch64_common/boot.rs b/modules/axhal/src/platform/aarch64_common/boot.rs index 31a5e222db..b275f2e837 100644 --- a/modules/axhal/src/platform/aarch64_common/boot.rs +++ b/modules/axhal/src/platform/aarch64_common/boot.rs @@ -100,11 +100,45 @@ unsafe fn init_boot_page_table() { crate::platform::mem::init_boot_page_table(addr_of_mut!(BOOT_PT_L0), addr_of_mut!(BOOT_PT_L1)); } -/// The earliest entry point for the primary CPU. +/// The Linux Header. #[naked] #[unsafe(no_mangle)] #[unsafe(link_section = ".text.boot")] unsafe extern "C" fn _start() -> ! { + core::arch::naked_asm!( + " + // code0/code1 + nop + b _start_entry + + // text_offset + .quad 0x80000 + + // image_size + .quad _kernel_size + + // flags + .quad 0 + + // Reserved fields + .quad 0 + .quad 0 + .quad 0 + + // magic - yes 0x644d5241 is the same as ASCII string \"ARM\\x64\" + .ascii \"ARM\\x64\" + + // Another reserved field at the end of the header + .byte 0, 0, 0, 0 + " + ) +} + +/// The earliest entry point for the primary CPU. +#[naked] +#[unsafe(no_mangle)] +#[unsafe(link_section = ".text.boot")] +unsafe extern "C" fn _start_entry() -> ! { // PC = 0x8_0000 // X0 = dtb core::arch::naked_asm!("