在linux上移植sgdisk

 1.下载代码

git clone https://git.code.sf.net/p/gptfdisk/code gptfdisk

2.编译指令

make sgdisk 
CC=aarch64-none-linux-gnu-gcc 
CXX=aarch64-none-linux-gnu-g++ 
CFLAGS="--sysroot=rootfs_sdk/aarch64-buildroot-linux-gnu/sysroot" 
CXXFLAGS="--sysroot=rootfs_sdk/aarch64-buildroot-linux-gnu/sysroot" 
LDFLAGS="--sysroot=rootfs_sdk/aarch64-buildroot-linux-gnu/sysroot -Lrootfs_sdk/aarch64-buildroot-linux-gnu/sysroot/usr/lib"

将上式中的rootfs_sdk替换成sdk编译出来的sysroot的绝对路径,比如/home/zhongshan/SDK_V1.1/build/out/demo_emmc/objs/buildroot/rootfs_sdk

并将这些合成一行输入,

注意-Lrootfs_sdk里面的rootfs_sdk也要替换掉。比如-L/home/zhongshan/SDK_V1.1/build/out/demo_emmc/objs/buildroot/rootfs_sdk

3.将编译生成的sgdisk复制到板子上,并执行如下命令,查看分区情况

scp ./sgdisk root@192.168.1.202:/tmp/

 

root@mxx:/tmp # ./sgdisk -p /dev/mmcblk0
Disk /dev/mmcblk0: 61079552 sectors, 29.1 GiB
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 493DDFCA-B275-4783-B265-21CD15E365D0
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 61079518
Partitions will be aligned on 32-sector boundaries
Total free space is 58055037 sectors (27.7 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048            2303   128.0 KiB   0700  sbl_a
   2            2304            2559   128.0 KiB   0700  sbl_b
   3            2560            2815   128.0 KiB   0700  hsm_a
   4            2816            3071   128.0 KiB   0700  hsm_b
   5            3072            3327   128.0 KiB   0700  metadata
   6            3328            3583   128.0 KiB   0700  metadata_bak
   7            3584            4607   512.0 KiB   0700  spl_a
   8            4608            5631   512.0 KiB   0700  spl_b
   9            5632            9727   2.0 MiB     0700  rtos_a
  10            9728           13823   2.0 MiB     0700  rtos_b
  11           13824           14847   512.0 KiB   0700  appdata
  12           14848           14879   16.0 KiB    0700  misc
  13           14880           14911   16.0 KiB    0700  misc_bak
  14           14912           15167   128.0 KiB   0700  ubootenv
  15           15168           15423   128.0 KiB   0700  ubootenv_bak
  16           15424           19519   2.0 MiB     0700  uboot_a
  17           19520           23615   2.0 MiB     0700  uboot_b
  18           23616           23871   128.0 KiB   0700  atf_a
  19           23872           24127   128.0 KiB   0700  atf_b
  20           24128           26175   1024.0 KiB  0700  optee_a
  21           26176           28223   1024.0 KiB  0700  optee_b
  22           28224           69183   20.0 MiB    0700  kernel_a
  23           69184          110143   20.0 MiB    0700  kernel_b
  24          110144          519743   200.0 MiB   0700  rootfs_a
  25          519744          929343   200.0 MiB   0700  rootfs_b
  26          929344         3026495   1024.0 MiB  0700  userdata

注释1:一个关于emmc 分区spec的网站

 https://uefi.org/specs/UEFI/2.10/05_GUID_Partition_Table_Format.html#

注释2:后来同事发现还有一个展示信息更加丰富的工具,如下

image

 

posted @ 2026-01-28 22:35  midhillzhou  阅读(55)  评论(0)    收藏  举报