Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PetalinuxのビルドからSDカードを焼くまでの効率化

Posted at

はじめに

SoC開発において、FPGAに変更が加わるたびに論理合成/配置配線の結果をBootファイルなどと統合してSDカードに焼く必要が出てくることがあります。その手間を最小限にするスクリプトを書きました。

前提条件

  • Ubuntu 22.04.2 LTS
  • Vivado v2024.1 (64-bit)
  • PetaLinuxツール v2024.1

あらかじめpetalinux-createでプロジェクトを作成、petalinux-configでハードウェアコンフィギュレーション(.xsa)をインポートしているものとします。

スクリプト

以下のスクリプト(rebuild.sh)をプロジェクトディレクトリに置き実行します。
一部Superuserにならないといけないところでは、expectを使い自動化しています。
rootのパスワードはxxxxxxxx、userはaaaaaaaaとしています。
SDカードのマウント場所や/dev/sdxは適宜確認してください。

rebuild.sh
#!/bin/bash

echo "Start rebuilding!"

petalinux-build
petalinux-package --boot --u-boot --force
cd images/linux
rm -rf ramdisk*
dd bs=64 skip=1 if=rootfs.cpio.gz.u-boot of=ramdisk.cpio.gz
gunzip ramdisk.cpio.gz
mkdir ramdisk && cd ramdisk
cpio -i -F ../ramdisk.cpio
cd ..

path=\".*#\"

expect -c "
set timeout 20
spawn su
expect \"Password:\"
send \"xxxxxxxx\r\"
expect -re ${path}
send \"mount /dev/sdb1 /media/aaaaaaaa/boot\r\"
expect -re ${path}
send \"mount /dev/sdb2 /media/aaaaaaaa/root\r\"
expect -re ${path}
send \"cp -rf ramdisk/lib/modules /media/aaaaaaaa/root/lib/\r\"
expect -re ${path}
send \"cp -rf BOOT.BIN boot.scr image.ub /media/aaaaaaaa/boot/\r\"
expect -re ${path}
send \"umount /dev/sdb1\r\"
expect -re ${path}
send \"umount /dev/sdb2\r\"
expect -re ${path}
"
echo ""

exit 0

関連

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?