Browse Source

Add compiling option for sdcard image.

Atlas Luo 4 months ago
parent
commit
c964463b88
2 changed files with 43 additions and 2 deletions
  1. 8 0
      igh_ethercat/README.md
  2. 35 2
      igh_ethercat/igh_ethercat.sh

+ 8 - 0
igh_ethercat/README.md

@@ -20,6 +20,12 @@ README.md       本文件
 ./igh_ethercat.sh
 ```
 
+或添加`img`参数同时编译sdcard.img:
+
+```bash
+./igh_ethercat.sh img
+```
+
 #### 说明
 
 该脚本会检测SDK所使用的 linux 内核版本是否为 rt-ethercat-release 且是否已经编译过,若确认在该分支上且编译过,则会拉取指定版本的 IgH EtherCAT 主站代码,进行主站以及Demo程序的编译。
@@ -28,6 +34,8 @@ README.md       本文件
 
 IgH EtherCAT主站启动脚本以及Demo程序会在主站编译完成后编译并安装到 work/buildroot_initramfs_sysroot/root 路径,即打包后的镜像的 /root 路径下。
 
+添加`img`参数同时编译sdcard.img时,脚本会同时检测 work/buildroot_rootfs 是否存在,否则会提示先执行`make buildroot_rootfs -j$(nproc)`。成功完毕脚本后,IgH EtherCAT主站启动脚本以及Demo程序会在主站编译完成后编译并安装到 work/buildroot_rootfs/target/root 路径下,并打包至sdcard.img中。
+
 ### 启动脚本
 
 EtherCAT 主站的使用需要绑定对应网口的 MAC 地址号,此 MAC 地址需要在 U-boot 命令行模式下通过命令获取:

+ 35 - 2
igh_ethercat/igh_ethercat.sh

@@ -3,11 +3,30 @@
 current_path=$(pwd)
 work_path=${current_path}/../../work
 buildroot_initramfs_sysroot_path=${work_path}/buildroot_initramfs_sysroot
+buildroot_rootfs_path=${work_path}/buildroot_rootfs
 linux_path=${work_path}/linux
 kernel_release_file=${linux_path}/include/config/kernel.release
 install_mod_path=${work_path}/module_install_path
 toolchains_path=${work_path}/buildroot_initramfs/host/bin
 
+sdcard_img=0
+
+# Determine if compile 'sdcard.img' and check if the root filesystem is compiled.
+if [ "$#" -eq 0 ]; then
+    echo "Compile 'image.fit' only."
+    echo "If you need to compile 'sdcard.img', usage: '$0 img'"
+elif [ "$1" = "img" ]; then
+    if [ -d "${buildroot_rootfs_path}" ]; then
+      echo "Compile both 'image.fit' and 'sdcard.img'"
+      sdcard_img=1
+    else
+      echo "Could not add application to sdcard image, please run 'make buildroot_rootfs -j$(nproc)' first."
+      exit 1 
+    fi
+else
+    echo "The argument is not 'img'"
+fi
+
 cd ../../linux
 linux_branch=$(git rev-parse --abbrev-ref HEAD)
 
@@ -16,7 +35,7 @@ if [ "$linux_branch" == "rt-ethercat-release" ]; then
     git pull
     cd ../
     make clean
-    make
+    make -j$(nproc)
 else
     echo "The Linux source code is not on the 'rt-ethercat-release' branch. Exiting."
     cd ${current_path}
@@ -148,6 +167,11 @@ CC=${CC} make
 
 cp ectest_PV  ${buildroot_initramfs_sysroot_path}/root
 
+if [ $sdcard_img -eq 1 ]; then
+    echo "Copy application to '${buildroot_rootfs_path}/target/root'."
+    cp ectest_PV ${buildroot_rootfs_path}/target/root
+fi
+
 echo ""
 echo "==============================Generating 'start_ethercat_master.sh'=============================="
 
@@ -178,11 +202,20 @@ EOF
 
 chmod +x start_ethercat_master.sh
 
+if [ $sdcard_img -eq 1 ]; then
+    echo "Copy script to '${buildroot_rootfs_path}/target/root'."
+    cp start_ethercat_master.sh  ${buildroot_rootfs_path}/target/root
+fi
+
 echo ""
 echo "==============================Re-compiling SDK=============================="
 
 cd ${current_path}/../../
 
-make
+make -j$(nproc)
+
+if [ $sdcard_img -eq 1 ]; then
+    make img
+fi
 
 cd ${current_path}