Telink TLSR8232 BLE SDK Developer Handbook
AN-19112700-E1
139
Ver.1.0.0
Slave OTA Service Data Attribute (The handle value can be pre-appointed by Slave
and Master, or obtained via “read_by_type”.)
5) After the Atrribute Handle value is obtained, OTA Master may need to obtain version
number of current Slave Flash firmware, and compare it with the version number of
local stored new firmware. This step is determined by user.
6) To enable OTA upgrade, OTA Master will send an OTA_start command to inform
Slave to enter OTA mode.
7) After the OTA_start command is received, Slave enters OTA mode and waits for OTA
data to be sent from Master.
8) Master reads the firmware stored in the Flash area starting from 0x20000, and
continuously sends OTA data to Slave until the whole firmware is sent.
9) After the OTA data are received, Slave stores the data into the area starting from
ota_program_offset.
10) After the OTA data are sent, Master will check if all data are correctly received by
Slave (invoke related BLE function in bottom layer to judge whether Link Layer data
are all correctly acked).
11) After Master confirms all OTA data are correctly received by Slave, it will send an
OTA_END command.
12) After Slave receives the OTA_END command, offset address 8 based on the new
firmware starting address (i.e. ota_program8
) is written with “0x4b”, and
offset address 8 based on the old firmware starting address is written with “0x00”.
This indicates Slave will execute the firmware from the new area after the next
booting.
13) Slave reboots, and the new firmware will take effect.
14) During the whole OTA upgrade process, Slave will continuously check whether
there’s packet error, packet loss or timeout (A timer is started when OTA starts).
Once packet error, packet loss or timeout is detected, Slave will determine the OTA
process fails. Then Slave reboots, and executes the old firmware.
The OTA related operations on Slave side described above have been realized in 5316
BLE SDK and can be used by user directly. On Master side, extra firmware design is
needed and it will be introduced later.
6.1.3 Modify Firmware Size and Boot Address
The API “bls_ota_setFirmwareSizeAndOffset” supports two functions: modifying
maximum firmware size and booting address in the OTA design. Herein booting address
means the adderss except 0 to store New_firmware, so it should be 0x10000 or 0x20000
or 0x40000.
In SDK, by default, the default maximum firmware size is 128kB, and the booting address
is 0x20000.
void
bls_ota_setFirmwareSizeAndOffset
(
int
firmware_size_k,
u32
boot_addr);
“firmware_size_k” must be 4kB aligned, i.e. it must be integral multiples of 4kB. For
example, for 97kB size, the “firmware_size_k” must be set as 100kB.