diff --git a/ble/vu.key b/ble/ble.key similarity index 100% rename from ble/vu.key rename to ble/ble.key diff --git a/ble/ble_flashing.sh b/ble/ble_flashing.sh index 09a118c396..0508e721d8 100644 --- a/ble/ble_flashing.sh +++ b/ble/ble_flashing.sh @@ -20,20 +20,70 @@ PARTTION="$current_directory/partition-table.bin" OTA_DATA_INITIAL="$current_directory/ota_data_initial.bin" NETWORK_ADAPTER="$current_directory/network_adapter.bin" BOOTLOADER="$current_directory/bootloader.bin" +KEY_FILE="$current_directory/ble.key" OPTIONS="--before default_reset --after hard_reset --chip esp32s3 write_flash" -# Search for .key files only in the specified directory (not in subdirectories) -KEY_FILE=$(find "$current_directory" -maxdepth 1 -type f -name "*.key") -# Check if any .key files were found -if [ -n "$KEY_FILE" ]; then - $ESPTOOL -p $SERIAL_PORT -b $FLASH_BAUD $OPTIONS --flash_mode $FLASH_MODE --flash_size $FLASH_SIZE --flash_freq $FLASH_FREQ 0x0 $BOOTLOADER 0x8000 $PARTTION 0x9000 $KEY_FILE 0xd000 $OTA_DATA_INITIAL 0x10000 $NETWORK_ADAPTER +# BLE restart loader +ble_restart_loader() { + ble_restart_loader="00000148#FD00" + cansend can0 $ble_restart_loader + result=$? + # Check the result + if [ $result -eq 0 ]; then + echo "ble restart loader successfully." + return 0 + else + echo "Error: ble restart loader failed with exit code $result." + return -1 + fi +} + +# BLE restart app +ble_restart_app() { + # BLE restart app + ble_restart_app="00000148#FD01" + cansend can0 $ble_restart_app + result=$? + # Check the result + if [ $result -eq 0 ]; then + echo "ble restart app successfully." + return 0 + else + echo "Error: ble restart app failed with exit code $result." + return -1 + fi +} + +ble_flashing() { + $ESPTOOL -p $SERIAL_PORT -b $FLASH_BAUD $OPTIONS --flash_mode $FLASH_MODE --flash_size $FLASH_SIZE --flash_freq $FLASH_FREQ 0x0 $BOOTLOADER 0x8000 $PARTTION 0x9000 $KEY_FILE 0xd000 $OTA_DATA_INITIAL 0x10000 $NETWORK_ADAPTER # Check the exit status of the esptool.py command if [ $? -eq 0 ]; then echo "Flash completed successfully." + return 0 else echo "Flash failed." + return -1 fi -else - echo "No .key files found in the specified directory." -fi \ No newline at end of file +} + +__main__() { + ble_restart_loader + if [ $? -ne 0 ]; then + return -1 + fi + sleep 1 + + ble_flashing + if [ $? -ne 0 ]; then + return -1 + fi + + sleep 1 + ble_restart_app + if [ $? -ne 0 ]; then + return -1 + fi +} + +__main__ \ No newline at end of file diff --git a/ble/cp_to_imx.sh b/ble/cp_to_imx.sh index 97023b6e32..7c268aa0d1 100755 --- a/ble/cp_to_imx.sh +++ b/ble/cp_to_imx.sh @@ -1,7 +1,6 @@ #!/bin/bash scp ble_flashing.sh root@192.168.7.1:/home/root/ble_fw/ble_self_hosted/. -scp tri.bin root@192.168.7.1:/home/root/ble_fw/ble_self_hosted/. -scp vu.key root@192.168.7.1:/home/root/ble_fw/ble_self_hosted/. +scp ble.key root@192.168.7.1:/home/root/ble_fw/ble_self_hosted/. scp build/bootloader/bootloader.bin root@192.168.7.1:/home/root/ble_fw/ble_self_hosted/. scp build/partition_table/partition-table.bin root@192.168.7.1:/home/root/ble_fw/ble_self_hosted/. scp build/ota_data_initial.bin root@192.168.7.1:/home/root/ble_fw/ble_self_hosted/. diff --git a/ble/tri.bin b/ble/tri.bin deleted file mode 100644 index 89d7447c68..0000000000 Binary files a/ble/tri.bin and /dev/null differ