diff --git a/01_install_cli.sh b/01_install_cli.sh index 796a9b7..4eef263 100755 --- a/01_install_cli.sh +++ b/01_install_cli.sh @@ -19,18 +19,10 @@ # download m5scp2_exp (by miura) if [ -d "m5scp2_exp" ]; then echo "m5scp2_exp folder exists." + cd m5scp2_exp + git pull + ls -al + cd .. else git clone https://git.istlab.info/git/miura250/m5scp2_exp.git fi - -cd m5scp2_exp -git pull -ls -al -./setup.sh - -if [ ! -d "build" ]; then - echo "cd m5scp2_exp" - echo "./compile.sh" - echo "FactoryTest2025 の初回コンパイルをします。数分固まったようにみえます。" - ./compile.sh -fi diff --git a/10_upload_by_hash.sh b/10_upload_by_hash.sh new file mode 100755 index 0000000..fdb38d9 --- /dev/null +++ b/10_upload_by_hash.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +if [ -z "$1" ]; then + echo "Usage: $0 " + + read -p "Enter the hash: " hash + if [ -z "$hash" ]; then + echo "No hash entered." + exit 1 + fi +else + hash=$1 +fi + +# ダウンロードURL +URL="https://lattr.istlab.info/inobin/dl/${hash}" + +RESPONCE_CODE=$(curl -s -o byhash.bin -w "%{http_code}" $URL) +if [ $RESPONCE_CODE -ne 200 ]; then + echo "Error: $RESPONCE_CODE" + exit 1 +fi + +curl -o byhash.partitions.bin -s ${URL}/partitions +curl -o byhash.bootloader.bin -s ${URL}/bootloader +echo "Downloaded ${hash} as [byhash.bin], [byhash.partitions.bin], [byhash.bootloader.bin]" + +# もし、hashがp1ではじまっていたら、注意喚起する +if [[ $hash =~ ^p1 ]]; then + echo "注:Plus2(黄色)ではなく、Plus(オレンジ色)用のプログラムです。" + board="plus" +else + board="plus2" +fi + +# 書き込みを行う +serials=`arduino-cli board list | grep USB | awk '{print $1}'` +seriallist=($serials) + +if [ -z "${serials}" ]; then + echo "デバイスがみつかりませんでした。" + sleep 2 + echo "デバイスを接続しているのに認識しないときは、ドライバを入れてください。" + sleep 2 + echo "https://ftdichip.com/drivers/vcp-drivers/ → Click here to download + の hereをおす。ZIP解凍して実行。" + exit +fi +for ser in ${seriallist[@]} ; do + echo ${ser} + arduino-cli upload --fqbn esp32:esp32:m5stack_stickc_${board} -p ${ser} --input-file byhash.bin +done + +# 接続デバイスが1つのみの場合、シリアルモニタを開くか確認 +if [[ "${#seriallist[@]}" -eq 1 ]]; then + read -p "シリアルモニタを開きますか?(y/n): " yn + if [ $yn = "y" ]; then + echo "終了するときはCtrl+Cを押してください。" + arduino-cli monitor -p ${seriallist[0]} --config 115200 + fi +fi + +