bbb 供电_用bbb配置u boot

bbb 供电

Here I am going to be using the latest version of Linux Kernel along with U-BOOT. Kindly follow through each step to successfully compile a verified U-BOOT and BBB Kernel.

在这里,我将使用最新版本的Linux内核以及U-BOOT。 请按照每个步骤操作,以成功编译经过验证的U-BOOT和BBB内核。

Make sure to use a Virtual Machine that has at least 30 GB of space available. While following the tutorial, kindly make a note of where you are executing the mentioned commands.

确保使用至少有30 GB可用空间的虚拟机。 在学习本教程的同时,请记下您在何处执行上述命令。

步骤1:配置目录结构和环境变量 (Step 1: Configuring the Directory Structure and Environment Variables)

Let us assume that this is the directory structure you are following for your home directory.

让我们假设这是您要在主目录中使用的目录结构。

root@kali:~# ls ~new_kernel   work  u-boot

Issue nano ~/.bashrc and copy the following Environmental variables in them. This will make things easier from here on.

发出nano ~/.bashrc并在其中复制以下环境变量。 从现在开始,这将使事情变得容易。

export CROSS_COMPILE=arm-linux-gnueabi-export ARCH=armexport UBOOT=/root/u-bootexport UOUT=$UBOOT/b/am335x_evm_defconfigexport KERNEL=/root/new_kernelexport OKERNEL=$KERNEL/arch/arm/bootexport WORK=/root/workexport PATH=$PATH:$UBOOT/tools

子步骤1:解决依赖性 (Sub-step 1: Resolving the dependencies)

Let’s also resolve any dependency issue that might occur while compiling u-boot or kernel to make things smoother. Issue the following command to resolve all the dependencies

让我们还解决在编译u-boot或内核以使事情更平滑时可能发生的任何依赖关系问题。 发出以下命令来解决所有依赖性

# apt-get install gcc-arm-linux-gnueabi binutils-arm-linux-gnueabi gcc-arm-linux-gnueabihf lzop libssl-dev bc bison flex device-tree-compiler

These are the basic dependencies that are needed, I may be forgetting something here, but if you come across an error, just google how to install them.

这些是需要的基本依赖关系,我可能在这里忘记了一些东西,但是如果您遇到错误,请通过谷歌搜索安装方法。

步骤2:让我们编译U-BOOT (Step 2: Let’s compile the U-BOOT)

  1. Download the latest U-BOOT Source code.

    下载最新的U-BOOT源代码。
# cd $UBOOT# git clone https://github.com/u-boot/u-boot.git .

2. Compile the U-BOOT for BBB

2.编译用于BBB的U-BOOT

# make am335x_evm_defconfig O=b/am335x_evm_defconfig# make all O=b/am335x_evm_defconfig

3. Compile the tools,

3.编译工具,

We will need the mkimage utility that comes with u-boot later to create a Kernel image and also a signed image.

稍后,我们将需要u-boot附带的mkimage实用程序来创建内核映像和签名映像。

# make sandbox_defconfig tools-only

Now we have everything we need we need from U-BOOT, you can navigate to b/am335x_boneblack_vboot/ to check if there is a u-boot-dtb.img file. Also, navigate to tools/ and confirm that there is an executable mkimage.

现在,我们有了U-BOOT所需的一切,您可以导航至b/am335x_boneblack_vboot/来检查是否存在u-boot-dtb.img文件。 另外,导航至tools/并确认存在可执行文件mkimage

# cd b/am335x_evm_defconfig/# ls -l | grep "u-boot-dtb.img"-rw-r--r--  1 root root  499141 Apr 27 07:03 u-boot-dtb.img# cd tools# ls -l | grep "mkimage"-rwxr-xr-x 1 root root 308224 Apr 27 07:06 mkimage-rw-r--r-- 1 root root  19186 Apr 27 06:43 mkimage.c-rw-r--r-- 1 root root    965 Apr 27 06:43 mkimage.h-rw-r--r-- 1 root root  23080 Apr 27 07:06 mkimage.o

If you don’t have these, there is something wrong, and you should correctly follow the steps mentioned above before proceeding.

如果没有这些,可能是有问题,在继续操作之前,应正确执行上述步骤。

步骤3:编译Linux内核 (Step 3: Compiling the Linux Kernel)

  1. Download the latest Linux Kernel

    下载最新的Linux内核
# cd $KERNEL# git clone https://github.com/meghaviparikh/linux.git .

2. Compile the Linux Kernel for BBB

2.编译用于BBB的Linux内核

Here, I have used -j 4 to speed up things. This simply means that allocate 4 computational cores to compiling the kernel. Depending upon your machine, edit the value of -j to speed up the process.

在这里,我使用-j 4来加快速度。 这仅意味着分配4个计算内核来编译内核。 根据您的计算机,编辑-j的值以加快该过程。

# make bb.org_defconfig# make uImage dtbs LOADADDR=80008000 -j 4

Navigate to $OKERNEL and make sure you have Image and dts/am335x-boneblack.dtb files

导航至$OKERNEL并确保您具有Imagedts/am335x-boneblack.dtb文件

# cd $OKERNEL# ls -l | grep "Image"-rwxr-xr-x   1 root root 21022800 Apr 27 07:20 Image-rw-r--r--   1 root root  9692832 Apr 27 07:25 uImage-rwxr-xr-x   1 root root  9692768 Apr 27 07:20 zImage# ls -l dts/ | grep "am335x-boneblack.dtb"-rw-r--r-- 1 root root  60180 Apr 27 07:18 am335x-boneblack.dtb

If you have these, kindly proceed ahead. If you don’t have these files, there is a chance that you might have done something wrong.

如果有这些,请继续。 如果没有这些文件,则可能是您做错了什么。

步骤4:准备工作目录 (Step 4: Preparing the Work Directory)

Navigate to the Working directory.

导航到工作目录。

# cd $WORK

Now create a file named sign.its and put the following contents in the file.

现在创建一个名为sign.its的文件,并将以下内容放入文件中。

# nano sign.its/dts-v1/;/ {description = "Beaglebone black";#address-cells = <1>;images {kernel@1 {data = /incbin/("Image.lzo");type = "kernel";arch = "arm";os = "linux";compression = "lzo";load = <0x80008000>;entry = <0x80008000>;hash@1 {algo = "sha1";};};fdt@1 {description = "beaglebone-black";data = /incbin/("am335x-boneblack.dtb");type = "flat_dt";arch = "arm";compression = "none";hash@1 {algo = "sha1";};};};configurations {default = "conf@1";conf@1 {kernel = "kernel@1";fdt = "fdt@1";signature@1 {algo = "sha1,rsa2048";key-name-hint = "dev";sign-images = "fdt", "kernel";};};};};

步骤5:创建密钥对 (Step 5: Creating the key-pair)

# cd $WORK# mkdir keys# openssl genrsa -F4 -out keys/dev.key 2048# openssl req -batch -new -x509 -key keys/dev.key -out keys/dev.crt

The dev.key is the private key here, so don’t share it with anyone.

dev.key是此处的私钥,因此请勿与任何人共享。

步骤6:签署核心 (Step 6: Signing the Kernel)

This step depends on the success of the previous steps. If the previous steps are not completed, kindly complete them, and then proceed.

此步骤取决于先前步骤的成功。 如果上述步骤未完成,请完成这些步骤,然后继续。

# ln -s $OKERNEL/dts/am335x-boneblack.dtb# ln -s $OKERNEL/Image# ln -s $UOUT/u-boot-dtb.img# cp $UOUT/arch/arm/dts/am335x-boneblack.dtb am335x-boneblack-pubkey.dtb# lzop Image# $UOUT/tools/mkimage -f sign.its -K am335x-boneblack-pubkey.dtb -k keys -r image.fit

If you see the output something like this, you are on the right track!

如果您看到类似这样的输出,那么您就走对了!

FIT description: Beaglebone blackCreated:         Mon Apr 27 07:32:06 2020Image 0 (kernel@1)Description:  unavailableCreated:      Mon Apr 27 07:32:06 2020Type:         Kernel ImageCompression:  lzo compressedData Size:    12468420 Bytes = 12176.19 KiB = 11.89 MiBArchitecture: ARMOS:           LinuxLoad Address: 0x80008000Entry Point:  0x80008000Hash algo:    sha1Hash value:   10e931a06395a5ff60b5b92bce7e2b901c009adeImage 1 (fdt@1)Description:  beaglebone-blackCreated:      Mon Apr 27 07:32:06 2020Type:         Flat Device TreeCompression:  uncompressedData Size:    60180 Bytes = 58.77 KiB = 0.06 MiBArchitecture: ARMHash algo:    sha1Hash value:   c5ad10fe4f60bf7acb9262d58bbf5ec2fa0eb0b6Default Configuration: 'conf@1'Configuration 0 (conf@1)Description:  unavailableKernel:       kernel@1FDT:          fdt@1Sign algo:    sha1,rsa2048:dev

Here you can confirm the Integrity of the hash using:

在这里,您可以使用以下命令确认哈希的完整性:

# $UOUT/tools/fit_check_sign -f image.fit -k am335x-boneblack-pubkey.dtb

If you see something like this, everything is perfect till now! And you may proceed ahead.

如果您看到这样的内容,那么到目前为止一切都非常完美! 您可能会继续前进。

Loading Flat Device Tree## Loading ramdisk from FIT Image at 7f8e78955000 ...Using 'conf@1' configurationVerifying Hash Integrity ...sha1,rsa2048:dev+OK

步骤7:将公钥放入U-Boot的映像中 (Step 7: Put the public key in U-Boot’s image)

# cd $UBOOT# make O=b/am335x_boneblack_vboot EXT_DTB=${WORK}/am335x-boneblack-pubkey.dtb

步骤8:将U-Boot和内核放入开发板 (Step 8: Put U-Boot and the kernel onto the board)

Now, you are ready to install U-BOOT and Kernel on the board so partition your sd card into two volumes. The first volume should contain a minimum of 50 MB. I used the Windows Disk Mgmt to Partition them to make things easy.

现在,您可以在板上安装U-BOOT和内核了,因此将SD卡分成两个卷。 第一个卷至少应包含50 MB。 我使用Windows磁盘管理对它们进行分区以使事情变得容易。

When you insert your SD card, you should see something like this:

插入SD卡时,您应该会看到以下内容:

# lsblkNAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTsda      8:0    0   80G  0 disk|-sda1   8:1    0   78G  0 part /|-sda2   8:2    0    1K  0 part`-sda5   8:5    0    2G  0 part [SWAP]sdb      8:16   0 15.2G  0 disk├─sdb1   8:17   0   50M  0 part└─sdb2   8:18   0 15.1G  0 part

Here sdb is your sd card. sdb1 and sdb2 are the partitions where we are going to install U-BOOT and KERNEL, respectively.

sdb是您的SD卡。 sdb1sdb2分别是我们将要安装U-BOOTKERNEL的分区。

Open your ~/.bashrc file and paste the following values below the Environment Variables we created in step 1.

打开~/.bashrc文件,并将以下值粘贴到我们在步骤1中创建的环境变量下面。

export UDEV=/dev/sdb1export KDEV=/dev/sdb2

Keep in mind that the smaller partition should come first as in pointed by, and the larger one is pointed by KDEV.

请记住,较小的分区应首先由指示,而较大的分区应由KDEV

Reload the profile:

重新加载配置文件:

source ~/.bashrc

Now, Issue the following commands to write the images created onto the SDCARD.

现在,发出以下命令将创建的图像写入SDCARD。

# sudo mount $UDEV /mnt/tmp && sudo cp $UOUT/u-boot-dtb.img /mnt/tmp/u-boot.img  && sudo cp $UOUT/MLO /mnt/tmp/MLO && sleep 1 && sudo umount $UDEV# sudo mount $KDEV /mnt/tmp && sudo cp $WORK/image.fit /mnt/tmp/boot/image.fit && sleep 1 && sudo umount $KDEV

Congratulations, the SD card with verified U-BOOT is ready!

恭喜,已验证U-BOOT的SD卡已准备就绪!

翻译自: https://medium.com/@meghaviparikh/configuring-u-boot-with-bbb-10fa4ec6c840

bbb 供电

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值