From d51665904faa31c39106e4b2afa7541615072e72 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Fri, 29 Nov 2024 22:17:13 +0100 Subject: Allow the kernel to run as a Linux image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In order to run on real hardware, it's actually easier to re-use workflows from existing bootloaders than loading things in memory manually. In order to achieve this two things had to be settled: 1. The image has to have a Linux header as defined in the RISC-V port. This header will be taken into consideration by bootloaders in order to know where to jump, the image offset, the endianness of the image, etc. 2. The image cannot just be an ELF executable. Rather, we must translate it into binary form via `objcopy`. With all of this at hand, I was able to make the kernel run on a Starfive VisionFive 2 board, and I have recorded an example so it's available as documentation. Signed-off-by: Miquel Sabaté Solà --- doc/vf2.svg | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/vf2.svg (limited to 'doc/vf2.svg') diff --git a/doc/vf2.svg b/doc/vf2.svg new file mode 100644 index 0000000..0936ea2 --- /dev/null +++ b/doc/vf2.svg @@ -0,0 +1 @@ +mssola:~$mssola:~$sudoscreen/dev/ttyUSB1115200[sudo]contrasenyaperaroot:U-BootSPL2021.10(May092024-22:42:02+0800)LPDDR4:8Gversion:g8ad50857.TryingtobootfromSPIOpenSBIv1.2__________________/__\/____|_\__|||||_________|(___||_)|||||||'_\/_\'_\\___\|_<||||__|||_)|__/|||____)||_)|||_\____/|.__/\___|_||_|_____/|___/_____||||_|PlatformName:StarFiveVisionFiveV2PlatformFeatures:medelegPlatformHARTCount:5PlatformPlatformIPIDevice:aclint-mswiPlatformTimerDevice:aclint-mtimer@4000000HzPlatformConsoleDevice:uart8250PlatformHSMDevice:---PlatformPMUDevice:---PlatformRebootDevice:pm-resetPlatformShutdownDevice:pm-resetPlatformSuspendDevice:---FirmwareBase:0x40000000FirmwareSize:392KBFirmwareRWOffset:0x40000RuntimeSBIVersion:1.0Domain0Name:rootDomain0BootHART:1Domain0HARTs:0*,1*,2*,3*,4*Domain0Region00:0x0000000002000000-0x000000000200ffffM:(I,R,W)S/U:()Domain0Region01:0x0000000040000000-0x000000004003ffffM:(R,X)S/U:()Domain0Region02:0x0000000040040000-0x000000004007ffffM:(R,W)S/U:()Domain0Region03:0x0000000000000000-0xffffffffffffffffM:(R,W,X)S/U:(R,W,X)Domain0NextAddress:0x0000000040200000Domain0NextArg1:0x0000000042200000Domain0NextMode:S-modeDomain0SysReset:yesDomain0SysSuspend:yesBootHARTID:1BootHARTDomain:rootBootHARTPrivVersion:v1.11BootHARTBaseISA:rv64imafdcbxBootHARTISAExtensions:noneBBootHARTPMPCount:8BootHARTPMPGranularity:4096BootHARTPMPAddressBits:34BootHARTMHPMCount:2BootHARTMIDELEG:0x0000000000000222BootHARTMEDELEG:0x000000000000b109U-Boot2021.10(May092024-22:42:02+0800),Build:jenkins-github_visionfive2-24CPU:rv64imacu_zba_zbbModel:StarFiveVisionFiveV2DRAM:8GiBMMC:sdio0@16010000:0,sdio1@16020000:1LoadingEnvironmentfromSPIFlash...SF:Detectedgd25lq128withpagesize256Bytes,erasesize4KiB,total16MiB***Warning-badCRC,usingdefaultenvironmentStarFiveEEPROMformatv2--------EEPROMINFO--------Vendor:StarFiveTechnologyCo.,Ltd.ProductfullSN:VF7110B1-2318-D008E000-18004831dataversion:0x2PCBrevision:0xb2BOMrevision:AEthernetMAC0address:6c:cf:39:00:b8:4cEthernetMAC1address:6c:cf:39:00:b8:4dIn:serialOut:serialErr:serialNet:eth0:ethernet@16030000,eth1:ethernet@16040000Hitanykeytostopautoboot:2Hitanykeytostopautoboot:0CarddidnotrespondtovoltageCarddidnotrespondtovoltageselect!:-110starfive_pciepcie@2B000000:Portlinkup.starfive_pciepcie@2B000000:StarfivePCIebusprobed.PCI:Failedautoconfigbar10starfive_pciepcie@2C000000:Portlinkup.starfive_pciepcie@2C000000:StarfivePCIebusprobed.Device0:Vendor:0xc0a9Rev:P8CR002Prod:234444C8444AType:HardDiskCapacity:476940.0MB=465.7GB(976773168x512)...isnowcurrentdeviceTrybootingfromNVME0...Failedtoload'vf2_uEnv.txt'##Warning:Inputdataexceeds1##Warning:Inputdataexceeds1048576bytes-truncated##Inf##Info:inputdatasize=1048578=0##Info:inputdatasize=1048578=0x100002##Error:"boot2"notd##Error:"boot2"notdefinedTringbootingdistro...419bytesreadin4ms(101.6KiB/s)Retrievingfile:/extlinux/extlinux.conf838bytesreadin4ms(204.1KiB/s)U-Bootmenu1:DebianGNU/Linuxbookworm/sid6.12.0mssola2:DebianGNU/Linuxbookworm/sid6.12.0mssola(rescuetarget)3:FizzBuzzOSEnterchoice:3Retrievingfile:/initramfs.cpio6656bytesreadin4ms(1.6MiB/s)Retrievingfile:/fbos14444bytesreadin4ms(3.4MiB/s)Retrievingfile:/dtbs/6.12.0mssola/starfive/jh7110-starfive-visionfive-2-v1.3b.dtb38025bytesreadin5ms(7.3MiB/s)libfdtfdt_path_offset()returnedFDT_ERR_NOTFOUND##FlattenedDeviceTreeblobat46000000Bootingusingthefdtblobat0x46000000UsingDeviceTreeinplaceat0000000046000000,end000000004600c488Startingkernel...clku2_dw_i2c_clk_corealreadydisabledclku2_dw_i2c_clk_apbalreadydisabledclku5_dw_i2c_clk_corealreadydisabledclku5_dw_i2c_clk_apbalreadydisabledclku0_mipitx_dphy_clk_txescalreadydisabledWelcometoFizzBuzzOS!Runningon:StarFiveVisionFive2v1.3Bfizzbuzzfizzbuzz[screenisterminating]TerminatU-BootSPL2021.10(May09202____//__\/____|||||_______||||||||'_\/_\'_\\___\|_<|||__|||_)|__/|||___\____/|.__/\PlatformName:StarPlatformFeaPlatforPlatformTimerDevice:aclPlPPlatformRebootDevice:pm-rPlatformShutdownDevicePlatformSuspendDevFirmwareBaseFirmwareSiFirmwarRuDomain0Name:rooDomain0HARTs:0*Domain0Region00Domain0Region00:0x0000000002000000-0x0Domain0Region00:0x0000000002000000-0x000000000200ffffM:(I,R,W)S/U:Domain0Region01:Domain0Region01:0x0000000040000000-0x00000000400Domain0Domain0Region02:0x0000000040Domain0Region02:0x0000000040040000-0x000000004007ffffM:(R,Domain0Region03Domain0Region03:0x0000000000000000-0xfffDomain0Region03:0x0000000000000000-0xffffffffffffffffM:(R,W,X)S/U:(RDomain0NextAddressDomain0NDomain0NextArg1:0x00000000422Domain0NextModeDomain0SysResetDomain0SysSuspendBootHARTIDBootHARTDomainBootHARTPrivVBootHARTBasBooBoBootHARTMIDELEG:0x000BootHARTMEDELEGU-Boot2021.10(May092024U-Boot2021.10(May092024-22:42:02+0800),Build:jenkinCPU:Model:StarDRAM:MMC:MMC:sdio0@16010000:0,sdio1@1602000LoadingEnvironmentfromSLoadingEnvironmentfromSPIFlash...LoadingEnvironmentfromSPIFlash...SF:Detectedgd25lq128withpageLoadingEnvironmentfromSPIFlash...SF:Detectedgd25lq128withpagesize256Bytes,erasesize4Ki***Warning-badCRC,usingdef---VendorProductfullSN:VF7110B1-2318dataversionBOMrEthernetMAC0addresEthernetMIErrModel:StarFiveVisiNet:Net:eth0:ethernet@16030000Hitanykeytostopautoboot:1starfive_pciepcie@2B000000:Porstarfive_pciepcie@2B000000:Stastarfive_pciepcie@2C000000:Porstarfive_pciepcie@2C000000:StaDevice0:Vendor:0xc0a9Rev:Capacity:476940.0TryFailedDevice0:Vendor:0xc0Device0:Vendor:0xc0a9Rev:P8CR002Prod:234444C84Type:HCapacity:Capacity:476940.0MB=465.7GB(97677316...isnowcurrentdevDevice0:VendDevice0:Vendor:0xc0a9Rev:P8CR002Prod:2CaCapacity:476940.0MB=465.7GB(...isnowcurTrybootingfromNV419bytesreadin4ms(101.6KiRetrievingfile:/extlinux838bytesreadin4ms(204.1Ki1:DebianGNU2:DebianGNU/Linuxbookworm/sEnterchoice:Retrievingfil6656bytesreadin4ms(1.6MiB14444bytesreadin4ms(3.4MiRetrievingfile:/dtbs/6.1Retrievingfile:/dtbs/6.12.0mssola/starfive/jh7110-starfi38025bytesreadin5ms(7.3Milibfdtfdt_path_offset()rlibfdtlibfdtfdt_path_offset()returnedFDT_libfdtfdt_path_oflibfdtfdt_path_offset()returlibfdtfdtlibfdtfdt_path_offset()returnedFDT_ERR_libfdtfdt_path_offset####FlattenedDeviceTreeblobat4BootingusingthefdUsingDUsingDeviceTreeinplaceat000000004clku2_clku2_dw_i2c_clk_apbalreadyclku5_dw_i2c_clk_coreclku5_dw_i2cclku0_mipitx_dphy_clk_txescalrWelcometoFizzBuRunningon:StarFiveVismssola:~$exit \ No newline at end of file -- cgit v1.2.3