Skip to content

Commit

Permalink
ble flashing script restart loader and return flashing status
Browse files Browse the repository at this point in the history
  • Loading branch information
vult0306 committed Jan 29, 2024
1 parent 77c7b25 commit ca27c96
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 10 deletions.
File renamed without changes.
66 changes: 58 additions & 8 deletions ble/ble_flashing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

__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__
3 changes: 1 addition & 2 deletions ble/cp_to_imx.sh
Original file line number Diff line number Diff line change
@@ -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/.
Expand Down
Binary file removed ble/tri.bin
Binary file not shown.

0 comments on commit ca27c96

Please sign in to comment.