分享

am335x uboot, kernel 编译

 slimfeng 2019-06-18
  • 一、设置环境变量

    //  写在家目录下面的 .bashrc 里面
    export KERNEL_PATH=~/aplex/kernel3.2.0         // kernel 路径
    export UBOOT_PATH=~/aplex/uboot2011.09      // u-boot 路劲
    export ROOTFS_PATH=~/aplex/filesystem
    export TOOLFS_PATH=~/aplex/tools
    export ARCH=arm                                                     // 设置平台类型
    export CROSS_COMPILE=arm-linux-gnueabihf-       // 设置交叉编译器前缀
    export PATH=$PATH:~/aplex/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux/bin         // 配置交叉编译器加入环境变量
    export APLEX_PATH=~/image
  • 二、 u-boot 编译

    cd  $UBOOT_PATH
    make O=out  ok335x
    //  编译完成之后你会在 out 目录下找到   MLO 以及 u-boot.img,  将这两个文件放在 等下制作好的 SD 卡boot 分区下
  • 三、 kernel 编译

    cd $KERNEL_PATH
    make aplex_defconfig
    make uImage -j4
    // 编译完成之后会在  arch/arm/boot/ 下面生成 uImage 文件, 等下也将这个文件放在 SD 卡 boot 分区下
  • 四、文件系统生成

    cd  $ROOTFS_PATH
    mkubiimg.sh
    //  mkubiimg.sh 是生成 ubi 文件系统的脚本
    //  工具的安装请参考 : http://www.cnblogs.com/chenfulin5/p/7975633.html
    //  ubi 文件系统的制作请参考: http://www.cnblogs.com/chenfulin5/p/8024016.html
    mkubiimg.sh 脚本如下: 
    sudo mkfs.ubifs  -q -r rootfs_v2 -m 2048 -e 126976 -c 4040 -o  ubifs.img -F      #制做 rootfs_v2 目录下面的文件系统为 ubifs.img
    echo mkfs.ubifs over!
    sudo ubinize -o ubi.img -m 2048 -p 128KiB ubinize.cfg             # 压缩 ubifs.img 为 ubi.img
    echo ubinize over!

    sync

    cp ubi.img $APLEX_PATH -rf    # 将ubi.img 拷贝到 ~/image 下面
    echo make file system ok !
  • 五、SD 的制作

    将 SD 卡插入电脑, 如下操作
![](http://images2017.cnblogs.com/blog/991711/201801/991711-20180115174107084-7846262.png)
    sudo fdisk  /dev/sdc   # sdc 是 SD卡的节点
    Command (m for help): d         # 删除分区
    Selected partition 1                    # 删除第一个分区
    Command (m for help): n       # 添加分区
    Partition type:
       p   primary (0 primary, 0 extended, 4 free)
       e   extended
    Select (default p): p         # 主分区
    Partition number (1-4, default 1): 1         # 第一个分区
    First sector (2048-15126527, default 2048): 
    Using default value 2048
    Last sector, +sectors or +size{K,M,G} (2048-15126527, default 15126527): 
    Using default value 15126527

    Command (m for help): t      # 改变分区格式
    Selected partition 1
    Hex code (type L to list codes): e         # 选择FAT16格式
    Changed system type of partition 1 to e (W95 FAT16 (LBA))

    Command (m for help): a     # 设置为 boot 分区
    Partition number (1-4): 1
    
    Command (m for help): p    # 显示

    Disk /dev/sdc: 7744 MB, 7744782336 bytes
    32 heads, 12 sectors/track, 39392 cylinders, total 15126528 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x5fb59036

       Device Boot      Start         End      Blocks   Id  System
    /dev/sdc1   *        2048    15126527     7562240    e  W95 FAT16 (LBA)
    Command (m for help): w                # 保存
    mkfs.vfat -n "boot"  -F 16 /dev/sdc1
  • 六、最后将上述文件放到 /dev/sdc1

    sudo mount  /dev/sdc1  /mnt
    cp  u-boot.img MLO  uImage  ubi.img   /mnt -rf
    sync
    sudo umount /mnt

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多