diff --git a/.gitignore b/.gitignore index 6405fed..5909629 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,6 @@ .DS_Store FactoryTest/build/* +Sample/build/* *.bak diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..100f609 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,16 @@ +{ + "configurations": [ + { + "name": "Mac", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [], + "compilerPath": "/usr/bin/clang", + "cStandard": "c17", + "cppStandard": "c++14", + "intelliSenseMode": "macos-clang-arm64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 98fd0d9..efff2b8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -10,5 +10,6 @@ "string_view": "cpp", "unordered_map": "cpp", "vector": "cpp" - } + }, + "C_Cpp.errorSquiggles": "disabled" } \ No newline at end of file diff --git a/11_write_factorytest.sh b/11_write_factorytest.sh new file mode 100755 index 0000000..b037c20 --- /dev/null +++ b/11_write_factorytest.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +source ./lib.sh + +# Get esptool command +BUILD_TOOL=$(lib_get_esptool_command) +# BUILD_TOOLの文字列の長さが20以上の場合は、終了する +if [ ${#BUILD_TOOL} -ge 20 ]; then + echo $BUILD_TOOL + echo "===" + echo "Please execute the script again." + echo "(上記のメッセージを確認したあと) もう一度実行してください。" + echo "===" + exit 1 +fi + +# Find port - Cross-platform detection +PORT=$(lib_detect_esptool_port) + +# Check if PORT is set, otherwise prompt user +if [ -z "$PORT" ]; then + lib_no_esp_device_message_and_exit +fi + +echo "Using port: $PORT" + +# Define the paths to the firmware files +BUILD_PATH="FactoryTest/build/esp32.esp32.m5stack_stickc_plus2" +BOOTLOADER_PATH="$BUILD_PATH/FactoryTest.ino.bootloader.bin" +PARTITIONS_PATH="$BUILD_PATH/FactoryTest.ino.partitions.bin" +FIRMWARE_PATH="$BUILD_PATH/FactoryTest.ino.bin" + +# Check if all required files exist +if [ ! -f "$BOOTLOADER_PATH" ]; then + echo "Bootloader file not found at $BOOTLOADER_PATH" + exit 1 +fi +if [ ! -f "$PARTITIONS_PATH" ]; then + echo "Partitions file not found at $PARTITIONS_PATH" + exit 1 +fi +if [ ! -f "$FIRMWARE_PATH" ]; then + echo "Firmware file not found at $FIRMWARE_PATH" + exit 1 +fi + +echo "Flashing complete ESP32 firmware..." +echo "Bootloader: $BOOTLOADER_PATH" +echo "Partitions: $PARTITIONS_PATH" +echo "Main firmware: $FIRMWARE_PATH" + +# Upload the complete firmware using esptool.py +$BUILD_TOOL --chip esp32 --port "$PORT" --baud 460800 write-flash -z \ + 0x1000 "$BOOTLOADER_PATH" \ + 0x8000 "$PARTITIONS_PATH" \ + 0x10000 "$FIRMWARE_PATH" && echo "Flashing completed." \ No newline at end of file diff --git a/11_write_factorytest_by_esptool.sh b/11_write_factorytest_by_esptool.sh deleted file mode 100755 index 1177bed..0000000 --- a/11_write_factorytest_by_esptool.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash - -source ./lib.sh - -# Get esptool command -BUILD_TOOL=$(lib_get_esptool_command) -# BUILD_TOOLの文字列の長さが20以上の場合は、終了する -if [ ${#BUILD_TOOL} -ge 20 ]; then - echo $BUILD_TOOL - echo "===" - echo "Please execute the script again." - echo "(上記のメッセージを確認したあと) もう一度実行してください。" - echo "===" - exit 1 -fi - -# Find port - Cross-platform detection -PORT=$(lib_detect_esptool_port) - -# Check if PORT is set, otherwise prompt user -if [ -z "$PORT" ]; then - lib_no_esp_device_message_and_exit -fi - -echo "Using port: $PORT" - -# Define the paths to the firmware files -BUILD_PATH="FactoryTest/build/esp32.esp32.m5stack_stickc_plus2" -BOOTLOADER_PATH="$BUILD_PATH/FactoryTest.ino.bootloader.bin" -PARTITIONS_PATH="$BUILD_PATH/FactoryTest.ino.partitions.bin" -FIRMWARE_PATH="$BUILD_PATH/FactoryTest.ino.bin" - -# Check if all required files exist -if [ ! -f "$BOOTLOADER_PATH" ]; then - echo "Bootloader file not found at $BOOTLOADER_PATH" - exit 1 -fi -if [ ! -f "$PARTITIONS_PATH" ]; then - echo "Partitions file not found at $PARTITIONS_PATH" - exit 1 -fi -if [ ! -f "$FIRMWARE_PATH" ]; then - echo "Firmware file not found at $FIRMWARE_PATH" - exit 1 -fi - -echo "Flashing complete ESP32 firmware..." -echo "Bootloader: $BOOTLOADER_PATH" -echo "Partitions: $PARTITIONS_PATH" -echo "Main firmware: $FIRMWARE_PATH" - -# Upload the complete firmware using esptool.py -$BUILD_TOOL --chip esp32 --port "$PORT" --baud 460800 write-flash -z \ - 0x1000 "$BOOTLOADER_PATH" \ - 0x8000 "$PARTITIONS_PATH" \ - 0x10000 "$FIRMWARE_PATH" - -echo "Flashing completed." \ No newline at end of file diff --git a/22_write_byhash.sh b/22_write_byhash.sh new file mode 100755 index 0000000..872eee7 --- /dev/null +++ b/22_write_byhash.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +source ./lib.sh + +# Get esptool command +BUILD_TOOL=$(lib_get_esptool_command) + +# Find port - Cross-platform detection +PORT=$(lib_detect_esptool_port) + +if [ -z "$PORT" ]; then + lib_no_esp_device_message_and_exit +fi + +echo "Using port: $PORT" + +# Define the paths to the firmware files +BUILD_PATH="." +BOOTLOADER_PATH="$BUILD_PATH/byhash.bootloader.bin" +PARTITIONS_PATH="$BUILD_PATH/byhash.partitions.bin" +FIRMWARE_PATH="$BUILD_PATH/byhash.bin" + +# Check if all required files exist +if [ ! -f "$BOOTLOADER_PATH" ]; then + echo "Bootloader file not found at $BOOTLOADER_PATH" + exit 1 +fi +if [ ! -f "$PARTITIONS_PATH" ]; then + echo "Partitions file not found at $PARTITIONS_PATH" + exit 1 +fi +if [ ! -f "$FIRMWARE_PATH" ]; then + echo "Firmware file not found at $FIRMWARE_PATH" + exit 1 +fi + +echo "Flashing complete ESP32 firmware..." +echo "Bootloader: $BOOTLOADER_PATH" +echo "Partitions: $PARTITIONS_PATH" +echo "Main firmware: $FIRMWARE_PATH" + +# Upload the complete firmware using esptool.py +$BUILD_TOOL --chip esp32 --port "$PORT" --baud 460800 write_flash -z \ + 0x1000 "$BOOTLOADER_PATH" \ + 0x8000 "$PARTITIONS_PATH" \ + 0x10000 "$FIRMWARE_PATH" && echo "Flashing completed." \ No newline at end of file diff --git a/22_write_byhash_esptool.sh b/22_write_byhash_esptool.sh deleted file mode 100755 index e76e3c1..0000000 --- a/22_write_byhash_esptool.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -source ./lib.sh - -# Get esptool command -BUILD_TOOL=$(lib_get_esptool_command) - -# Find port - Cross-platform detection -PORT=$(lib_detect_esptool_port) - -if [ -z "$PORT" ]; then - lib_no_esp_device_message_and_exit -fi - -echo "Using port: $PORT" - -# Define the paths to the firmware files -BUILD_PATH="." -BOOTLOADER_PATH="$BUILD_PATH/byhash.bootloader.bin" -PARTITIONS_PATH="$BUILD_PATH/byhash.partitions.bin" -FIRMWARE_PATH="$BUILD_PATH/byhash.bin" - -# Check if all required files exist -if [ ! -f "$BOOTLOADER_PATH" ]; then - echo "Bootloader file not found at $BOOTLOADER_PATH" - exit 1 -fi -if [ ! -f "$PARTITIONS_PATH" ]; then - echo "Partitions file not found at $PARTITIONS_PATH" - exit 1 -fi -if [ ! -f "$FIRMWARE_PATH" ]; then - echo "Firmware file not found at $FIRMWARE_PATH" - exit 1 -fi - -echo "Flashing complete ESP32 firmware..." -echo "Bootloader: $BOOTLOADER_PATH" -echo "Partitions: $PARTITIONS_PATH" -echo "Main firmware: $FIRMWARE_PATH" - -# Upload the complete firmware using esptool.py -$BUILD_TOOL --chip esp32 --port "$PORT" --baud 460800 write_flash -z \ - 0x1000 "$BOOTLOADER_PATH" \ - 0x8000 "$PARTITIONS_PATH" \ - 0x10000 "$FIRMWARE_PATH" - -echo "Flashing completed." \ No newline at end of file diff --git a/33_write_latest.sh b/33_write_latest.sh new file mode 100755 index 0000000..7559a07 --- /dev/null +++ b/33_write_latest.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +source ./lib.sh + +# Get esptool command +BUILD_TOOL=$(lib_get_esptool_command) + +# Find port - Cross-platform detection +PORT=$(lib_detect_esptool_port) + +# Check if PORT is set, otherwise prompt user +if [ -z "$PORT" ]; then + lib_no_esp_device_message_and_exit +fi + +echo "Using port: $PORT" + +# Define the paths to the firmware files +BUILD_PATH="." +BOOTLOADER_PATH="$BUILD_PATH/latest.bootloader.bin" +PARTITIONS_PATH="$BUILD_PATH/latest.partitions.bin" +FIRMWARE_PATH="$BUILD_PATH/latest.bin" + +# Check if all required files exist +if [ ! -f "$BOOTLOADER_PATH" ]; then + echo "Bootloader file not found at $BOOTLOADER_PATH" + exit 1 +fi +if [ ! -f "$PARTITIONS_PATH" ]; then + echo "Partitions file not found at $PARTITIONS_PATH" + exit 1 +fi +if [ ! -f "$FIRMWARE_PATH" ]; then + echo "Firmware file not found at $FIRMWARE_PATH" + exit 1 +fi + +echo "Flashing complete ESP32 firmware..." +echo "Bootloader: $BOOTLOADER_PATH" +echo "Partitions: $PARTITIONS_PATH" +echo "Main firmware: $FIRMWARE_PATH" + +# Upload the complete firmware using esptool.py +$BUILD_TOOL --chip esp32 --port "$PORT" --baud 460800 write_flash -z \ + 0x1000 "$BOOTLOADER_PATH" \ + 0x8000 "$PARTITIONS_PATH" \ + 0x10000 "$FIRMWARE_PATH" && echo "Flashing completed." \ No newline at end of file diff --git a/33_write_latest_esptool.sh b/33_write_latest_esptool.sh deleted file mode 100755 index 12c3d59..0000000 --- a/33_write_latest_esptool.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -source ./lib.sh - -# Get esptool command -BUILD_TOOL=$(lib_get_esptool_command) - -# Find port - Cross-platform detection -PORT=$(lib_detect_esptool_port) - -# Check if PORT is set, otherwise prompt user -if [ -z "$PORT" ]; then - lib_no_esp_device_message_and_exit -fi - -echo "Using port: $PORT" - -# Define the paths to the firmware files -BUILD_PATH="." -BOOTLOADER_PATH="$BUILD_PATH/latest.bootloader.bin" -PARTITIONS_PATH="$BUILD_PATH/latest.partitions.bin" -FIRMWARE_PATH="$BUILD_PATH/latest.bin" - -# Check if all required files exist -if [ ! -f "$BOOTLOADER_PATH" ]; then - echo "Bootloader file not found at $BOOTLOADER_PATH" - exit 1 -fi -if [ ! -f "$PARTITIONS_PATH" ]; then - echo "Partitions file not found at $PARTITIONS_PATH" - exit 1 -fi -if [ ! -f "$FIRMWARE_PATH" ]; then - echo "Firmware file not found at $FIRMWARE_PATH" - exit 1 -fi - -echo "Flashing complete ESP32 firmware..." -echo "Bootloader: $BOOTLOADER_PATH" -echo "Partitions: $PARTITIONS_PATH" -echo "Main firmware: $FIRMWARE_PATH" - -# Upload the complete firmware using esptool.py -$BUILD_TOOL --chip esp32 --port "$PORT" --baud 460800 write_flash -z \ - 0x1000 "$BOOTLOADER_PATH" \ - 0x8000 "$PARTITIONS_PATH" \ - 0x10000 "$FIRMWARE_PATH" - -echo "Flashing completed." \ No newline at end of file diff --git a/53_compile_sample.sh b/53_compile_sample.sh new file mode 100755 index 0000000..7397052 --- /dev/null +++ b/53_compile_sample.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +# arduino-cli compile -help +arduino-cli compile -b esp32:esp32:m5stack_stickc_plus2 -v -e Sample + diff --git a/54_write_sample.sh b/54_write_sample.sh new file mode 100755 index 0000000..147eaac --- /dev/null +++ b/54_write_sample.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +source ./lib.sh + +# Get esptool command +BUILD_TOOL=$(lib_get_esptool_command) +# BUILD_TOOLの文字列の長さが20以上の場合は、終了する +if [ ${#BUILD_TOOL} -ge 20 ]; then + echo $BUILD_TOOL + echo "===" + echo "Please execute the script again." + echo "(上記のメッセージを確認したあと) もう一度実行してください。" + echo "===" + exit 1 +fi + +# Find port - Cross-platform detection +PORT=$(lib_detect_esptool_port) + +# Check if PORT is set, otherwise prompt user +if [ -z "$PORT" ]; then + lib_no_esp_device_message_and_exit +fi + +echo "Using port: $PORT" + +# Define the paths to the firmware files +BUILD_PATH="Sample/build/esp32.esp32.m5stack_stickc_plus2" +BOOTLOADER_PATH="$BUILD_PATH/Sample.ino.bootloader.bin" +PARTITIONS_PATH="$BUILD_PATH/Sample.ino.partitions.bin" +FIRMWARE_PATH="$BUILD_PATH/Sample.ino.bin" + +# Check if all required files exist +if [ ! -f "$BOOTLOADER_PATH" ]; then + echo "Bootloader file not found at $BOOTLOADER_PATH" + exit 1 +fi +if [ ! -f "$PARTITIONS_PATH" ]; then + echo "Partitions file not found at $PARTITIONS_PATH" + exit 1 +fi +if [ ! -f "$FIRMWARE_PATH" ]; then + echo "Firmware file not found at $FIRMWARE_PATH" + exit 1 +fi + +echo "Flashing complete Sample firmware..." +echo "Bootloader: $BOOTLOADER_PATH" +echo "Partitions: $PARTITIONS_PATH" +echo "Main firmware: $FIRMWARE_PATH" + +# Upload the complete firmware using esptool.py +$BUILD_TOOL --chip esp32 --port "$PORT" --baud 460800 write-flash -z \ + 0x1000 "$BOOTLOADER_PATH" \ + 0x8000 "$PARTITIONS_PATH" \ + 0x10000 "$FIRMWARE_PATH" + +echo "Flashing completed." + +# Open serial monitor +read -p "シリアルモニタを開きますか?(y/n): " yn +if [ $yn = "y" ]; then + echo "終了するときはCtrl+Cを押してください。" + arduino-cli monitor -p "$PORT" --config 115200 +fi + diff --git a/94_upload_factorytest.sh b/94_upload_factorytest.sh deleted file mode 100755 index f121116..0000000 --- a/94_upload_factorytest.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -echo "Finding serial ports..." -## get serial port via board list, choose lines including "USB", and pick up 1st word -serials=`arduino-cli board list | grep USB | awk '{print $1}'` - -# echo ${serials} -if [ -z "${serials}" ]; then - echo "No device connected." - echo "デバイスを接続しているのに認識しないときは、ドライバを入れてください。" - echo "https://ftdichip.com/drivers/vcp-drivers/ → Click here to download の hereをおす。ZIP解凍して実行。" - exit -fi - -## if multiple ports found, try uploading to all ports. -seriallist=($serials) - -## print the list -# echo ${seriallist[@]} - -for ser in ${seriallist[@]} ; do - echo ${ser} -# arduino-cli upload --fqbn esp32:esp32:m5stick-c -p ${ser} -v FactoryTest - arduino-cli upload --fqbn esp32:esp32:m5stack_stickc_plus2 -p ${ser} -v FactoryTest -done - - -if [[ "${#seriallist[@]}" -eq 1 ]]; then - arduino-cli monitor -p ${seriallist[0]} --config 115200 -fi - diff --git a/94_write_factorytest.sh b/94_write_factorytest.sh new file mode 100755 index 0000000..aa0f20f --- /dev/null +++ b/94_write_factorytest.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +source ./lib.sh + +# Get esptool command +BUILD_TOOL=$(lib_get_esptool_command) +# BUILD_TOOLの文字列の長さが20以上の場合は、終了する +if [ ${#BUILD_TOOL} -ge 20 ]; then + echo $BUILD_TOOL + echo "===" + echo "Please execute the script again." + echo "(上記のメッセージを確認したあと) もう一度実行してください。" + echo "===" + exit 1 +fi + +# Find port - Cross-platform detection +PORT=$(lib_detect_esptool_port) + +# Check if PORT is set, otherwise prompt user +if [ -z "$PORT" ]; then + lib_no_esp_device_message_and_exit +fi + +echo "Using port: $PORT" + +# Define the paths to the firmware files +BUILD_PATH="FactoryTest/build/esp32.esp32.m5stack_stickc_plus2" +BOOTLOADER_PATH="$BUILD_PATH/FactoryTest.ino.bootloader.bin" +PARTITIONS_PATH="$BUILD_PATH/FactoryTest.ino.partitions.bin" +FIRMWARE_PATH="$BUILD_PATH/FactoryTest.ino.bin" + +# Check if all required files exist +if [ ! -f "$BOOTLOADER_PATH" ]; then + echo "Bootloader file not found at $BOOTLOADER_PATH" + exit 1 +fi +if [ ! -f "$PARTITIONS_PATH" ]; then + echo "Partitions file not found at $PARTITIONS_PATH" + exit 1 +fi +if [ ! -f "$FIRMWARE_PATH" ]; then + echo "Firmware file not found at $FIRMWARE_PATH" + exit 1 +fi + +echo "Flashing complete FactoryTest firmware..." +echo "Bootloader: $BOOTLOADER_PATH" +echo "Partitions: $PARTITIONS_PATH" +echo "Main firmware: $FIRMWARE_PATH" + +# Upload the complete firmware using esptool.py +$BUILD_TOOL --chip esp32 --port "$PORT" --baud 460800 write-flash -z \ + 0x1000 "$BOOTLOADER_PATH" \ + 0x8000 "$PARTITIONS_PATH" \ + 0x10000 "$FIRMWARE_PATH" + +echo "Flashing completed." + +# Open serial monitor +read -p "シリアルモニタを開きますか?(y/n): " yn +if [ $yn = "y" ]; then + echo "終了するときはCtrl+Cを押してください。" + arduino-cli monitor -p "$PORT" --config 115200 +fi + diff --git a/99_latest_setup.sh b/99_latest_setup.sh new file mode 100755 index 0000000..1800e08 --- /dev/null +++ b/99_latest_setup.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +echo "---------------------------------------------------" +echo " m5latest.sh の MYUID と LOGIN を書き換えます。" +echo "---------------------------------------------------" +echo " MYUID と LOGIN は、https://lattr.istlab.info/dashboard に書かれています。" +read -p " MYUID を入力してください : " myuid +read -p " LOGIN を入力してください : " login + +cp m5latest.sh m5latest.sh.bak +# sedコマンドで書き換え +sed -i.bak "s/MYUID=\"[0-9]*\"/MYUID=\"${myuid}\"/" m5latest.sh +sed -i.bak "s/LOGIN=\"[0-9a-zA-Z]*\"/LOGIN=\"${login}\"/" m5latest.sh +echo " m5latest.sh の MYUID と LOGIN を書き換えました。" +echo "------------------------------" +echo " バックアップファイル m5latest.sh.bak を作成しました。" +echo "------------------------------" +echo " 確認のため、m5latest.sh の 20行目付近を表示します。" +echo "" +head -n 21 m5latest.sh | tail -n 6 +echo "" diff --git a/99_m5latest_setup.sh b/99_m5latest_setup.sh deleted file mode 100755 index 1800e08..0000000 --- a/99_m5latest_setup.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -echo "---------------------------------------------------" -echo " m5latest.sh の MYUID と LOGIN を書き換えます。" -echo "---------------------------------------------------" -echo " MYUID と LOGIN は、https://lattr.istlab.info/dashboard に書かれています。" -read -p " MYUID を入力してください : " myuid -read -p " LOGIN を入力してください : " login - -cp m5latest.sh m5latest.sh.bak -# sedコマンドで書き換え -sed -i.bak "s/MYUID=\"[0-9]*\"/MYUID=\"${myuid}\"/" m5latest.sh -sed -i.bak "s/LOGIN=\"[0-9a-zA-Z]*\"/LOGIN=\"${login}\"/" m5latest.sh -echo " m5latest.sh の MYUID と LOGIN を書き換えました。" -echo "------------------------------" -echo " バックアップファイル m5latest.sh.bak を作成しました。" -echo "------------------------------" -echo " 確認のため、m5latest.sh の 20行目付近を表示します。" -echo "" -head -n 21 m5latest.sh | tail -n 6 -echo "" diff --git a/Sample/Sample.ino b/Sample/Sample.ino new file mode 100644 index 0000000..28c5f39 --- /dev/null +++ b/Sample/Sample.ino @@ -0,0 +1,21 @@ +#include + +void setup() { + auto cfg = M5.config(); + cfg.serial_baudrate = 115200; + M5.begin(cfg); + M5.Display.setRotation(3); + M5.Display.setFont(&fonts::lgfxJapanGothic_16); + M5.Display.println("SampleProject"); + M5.Display.setTextScroll(true); + M5.Display.setBrightness(255); +} + +void loop() { + M5.update(); + Serial.println("SampleProjectのプログラムです。"); + M5.delay(2000); +} +// 書き込み方法: https://scrapbox.io/iot-programming/Build_on_Server を参照してください。 + +