日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

QEMU模拟器启arm64 ATF(arm trust firmware) BL1, uboot方法

發布時間:2023/12/20 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 QEMU模拟器启arm64 ATF(arm trust firmware) BL1, uboot方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

目的:

使用QEMU(3.0版本以上)模擬一個arm64 virt平臺,在virt平臺上配置兩個cfi flash. Flash0當作BootRom使用,“燒錄”ATF(arm trust firmware)的BL1;Flash1上放置打包為ATF FIP格式的Image(包含了BL2, BL31, BL33(u-boot))。最終BootRom(BL1)開始執行,從Flash1 FIP.bin中加載BL2,BL2再加載BL31, BL33,最終到u-boot的命令行(cli)界面

?

準備環境:

  • OS:
  • 4.15.0-62-generic #69~16.04.1-Ubuntu SMP Fri Sep 6 02:43:35 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

  • QEMU(至少3.0以上版本,我使用的是4.0之后的):
  • Refer to https://blog.csdn.net/jasonLee_lijiaqi/article/details/80967912

    Download:

    git clone https://git.qemu.org/git/qemu.git

    cd qemu

    git submodule init

    git submodule update –recursive

    ?????? Compile:

    ????????????? ./configure --target-list=aarch64-softmmu

    ????????????? Make

  • Cross compile tool
  • gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz

  • U-boot
  • Compile:

    make mrproper

    export CROSS_COMPILE=YourGNU_path/aarch64-linux-gnu-

    make qemu_arm64_defconfig

    make menuconfig

  • ARM architectureàGenerate position-independent pre-relocation code
  • 將POSITION_INDEPENDENT項設置為yes

    2. /u-boot/common/board_r.c 文件注釋 initr_flash 否則u-boot crash)

    Make

    { 我使用的版本

    ?????? commit 504bf790da08db9b4a443566cf6ef577f9c7996a

    Merge: 8c66fb8 c23b33f

    Author: Tom Rini <trini@konsulko.com>

    Date:?? Wed May 8 16:21:43 2019 -0400

    ?

    ??? Merge branch 'master' of git://git.denx.de/u-boot-sunxi

    ???

    ??? - H6 Beelink GS1 board (Clément)

    ??? - Olimex A64-Teres-I board (Jonas)

    ??? - sunxi build fix for CONFIG_CMD_PXE|DHCP (Ondrej)

    ??? - Change include order (Jagan)

    ??? - EPHY clock changes (Jagan)

    ??? - EMAC enablement on Cubietruck Plus, BPI-M3 (Chen-Yu Tsai)

    }

  • ATF:
  • git clone https://github.com/ARM-software/arm-trusted-firmware.git

    Compile:

    export ARCH=arm64

    export CROSS_COMPILE=YourGNU_path/aarch64-linux-gnu-

    ??????? make PLAT=qemu BL33=uboot_path/u-boot.bin all fip

    ??????? (編譯完成后,可以看到bl1.bin和fip.bin)

    ?????? { 我使用的版本

    ????????????? commit 44e8d5ebc36950943d70f3517d7756e210fc42ab

    Merge: 7cc287d 7bdc469

    Author: Paul Beesley <paul.beesley@arm.com>

    Date:?? Tue Aug 20 14:47:56 2019 +0000

    ?

    ??? Merge "plat/arm: Introduce corstone700 platform." into integration

    ?????? }

    ?

    運行:

    YourQEMU_path/qemu-system-aarch64 \

    ?????? -nographic \

    ?????? -smp 2 \

    ?????? -machine virt,secure=on -cpu cortex-a57 \

    ?????? -d unimp -semihosting-config enable,target=native \

    ?????? -m 1057 \

    ?????? -bios ./bl1.bin

    這個時候你能夠看到BL1級別的串口輸出,但是BL2等都還沒有被調用

    ?

    ?

    QEMU修改

    為了實現FIP(BL2, BL31, uboot)的加載,需要稍微修改下qemu中的代碼,將fip.bin image直接塞入flash1中。

  • 找到文件/hw/arm/virt.c,修改如下代碼(+為我新增代碼)
  • ???? BlockBackend *pflash_blk0;

    +??? BlockBackend *pflash_blk1;

    ?

    +??? char fipname[] = "fip.bin";

    ???? /* Map legacy -drive if=pflash to machine properties */

    ???? for (i = 0; i < ARRAY_SIZE(vms->flash); i++) {

    ???????? pflash_cfi01_legacy_drive(vms->flash[i],

    @@ -1030,7 +1034,37 @@ static bool virt_firmware_init(VirtMachineState *vms,

    ???????????? exit(1);

    ???????? }

    ???? }

    +??? //aded by customer

    +??? pflash_blk1 = pflash_cfi01_get_blk(vms->flash[1]);

    ?

    +??? if (fipname != NULL) {

    +??????? char *fname;

    +??????? MemoryRegion *mr;

    +??????? int image_size;

    +

    +??????? if (pflash_blk1) {

    +??????????? error_report("jun:The contents of the second flash device may be "

    +???????????????????????? "specified with -bios or with -drive if=pflash... "

    +?????????????? ??????????"but you cannot use both options at once");

    +??????????? exit(1);

    +??????? }

    +

    +??????? /* Fall back to -bios */

    +

    +??????? fname = qemu_find_file(QEMU_FILE_TYPE_BIOS, fipname);

    +??????? if (!fname) {

    +??????????? error_report("Could not find ROM image '%s'", fipname);

    +??????????? exit(1);

    +??????? }

    +??????? mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(vms->flash[1]), 0);

    +??????? image_size = load_image_mr(fname, mr);

    +??????? g_free(fname);

    +??????? if (image_size < 0) {

    +??????????? error_report("Could not load fip image '%s'", fipname);

    +??????????? exit(1);

    +??????? }

    +??? }

    +??? //end

    ?

  • 保存編譯 make
  • ?

    最終效果

    qemu-system-aarch64 -nographic -smp 2 -machine virt,secure=on -cpu cortex-a57 -d unimp -semihosting-config enable,target=native -m 1057 -bios ./bl1.bin

    NOTICE:? Booting Trusted Firmware

    NOTICE:? BL1: v2.1(release):v2.1-599-g4968468-dirty

    NOTICE:? BL1: Built : 15:28:30, Sep 19 2019

    NOTICE:? BL1: Booting BL2

    NOTICE:? BL2: v2.1(release):v2.1-599-g4968468-dirty

    NOTICE:? BL2: Built : 15:28:30, Sep 19 2019

    NOTICE:? BL1: Booting BL31

    NOTICE:? BL31: v2.1(release):v2.1-599-g4968468-dirty

    NOTICE:? BL31: Built : 15:28:30, Sep 19 2019

    ?

    ?

    U-Boot 2019.07-rc1-00350-ga11c1c0-dirty (Sep 19 2019 - 16:10:12 +0800)

    ?

    DRAM:? 1 GiB

    Relocation Offset is: 82044000

    Relocating to 82044000, new gd at 81003de8, sp at 81000e90

    *** Warning - bad CRC, using default environment

    ?

    In:??? pl011@9000000

    Out:?? pl011@9000000

    Err:?? pl011@9000000

    Net:?? No ethernet found.

    Hit any key to stop autoboot:? 0

    =>

    ?

    總結

    以上是生活随笔為你收集整理的QEMU模拟器启arm64 ATF(arm trust firmware) BL1, uboot方法的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。