2023-05-08 09:40 PM
I am following this video link showing step by step to create OTA app.
https://www.youtube.com/watch?v=mRzZOa3jmuM.
I am successfully to create the custom application, download the OTA loader app at 0x08000000, and the custom's app at 0x08007000. The problem I am facing is whenever I sent some data to OTA Reboot characteristic, the custom app is just reset, then go back to the custom app. It didn't enter the OTA loader app. Am I missing something like the erase current app function? I also notice in my custom app, once the ST BLE tool box or ST BLE Sensor app connects to my device, it didn't show the OTA reboot option like when I tried the BLE_p2pServer_ota.
Solved! Go to Solution.
2023-05-11 02:38 AM
Thank you Axel.
I found the bug. My copied and pasted code mistake so I used the Notification characteristic for the Reboot Mode characteristic which is the problem I will never got the command sent in from ST ToolBox BLE app.
2023-05-09 02:10 AM - edited 2023-11-20 06:00 AM
So I found this info,
When my device is up, it has the option "OTA Reboot Request" when I use ST Ble Toolbox,
I write Hex "000702" but nothing is happening
My code has
case CUSTOM_STM_BOOT_REQUEST_EVT:
*(uint32_t*)(SRAM1_BASE) = *(uint32_t*)pNotification->DataTransfered.pPayload;
NVIC_SystemReset();
break;
Do I understand the logic is OTA loader will use the information from SRAM1_BASE (which is define at 0x20000000UL, to erase my 2 sector starting at 0x08007000?
#define SRAM_BASE (0x20000000UL)/*!< SRAM(up to 256 KB) base address */
#define SRAM1_BASE SRAM_BASE /*!< SRAM1(up to 192 KB) base address */
If I used the programmer, and manually erased 2 sectors starting from 0x08007000, after the power cycle, my device always comes up with STM_OTA which is the OTA loader application was loaded at 0x08000000.
Please suggest where should I need to double check or my errors.
2023-05-11 02:33 AM - edited 2023-11-20 06:00 AM
Hello @Jtron.1 ,
Please not that I am not an expert of BLE or OTA, but from my own experience I could give you some advises.
First of all, may I have for information about your configuration?
What MCU are you using, running on an EVAL board ? What binary OTA application do you flash ? It is the last release ?
For the following I am assuming that your are running an custom BLE application.
Here is the general idea of procedure for OTA application:
In custom_app.c:
...
case CUSTOM_STM_OTA_REBOOT_REQUEST_WRITE_EVT:
/* USER CODE BEGIN CUSTOM_STM_OTA_REBOOT_REQUEST_WRITE_EVT */
APP_DBG_MSG("\r\n\r** OTA Reboot event!\n");
/* Write reboot reason at 0x20000000 (SRAM1):
* Boot Mode: 0x00-> User Application (0x08007000), 0x01-> OTA application (0x08000000)
* Sector index: 0x07 (7 sectors is the first to be program)
* Number of sector to be erase (4K granulation): Filesize/4K + 1
* Total: 3bytes (octets).
* */
*(uint32_t *)SRAM1_BASE = *(uint32_t*)pNotification->DataTransfered.pPayload;
NVIC_SystemReset();
while(1);
/* USER CODE END CUSTOM_STM_OTA_REBOOT_REQUEST_WRITE_EVT */
break;
...
In /Core/Src/system_stm32wbxx.c
...
#define USER_VECT_TAB_ADDRESS
#if defined(USER_VECT_TAB_ADDRESS)
/*!< Uncomment this line for user vector table remap in Sram else user remap
will be done in Flash. */
/* #define VECT_TAB_SRAM */
#if defined(VECT_TAB_SRAM)
#define VECT_TAB_BASE_ADDRESS SRAM1_BASE /*!< Vector Table base address field.
This value must be a multiple of 0x200. */
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
This value must be a multiple of 0x200. */
#else
#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
This value must be a multiple of 0x200. */
#define VECT_TAB_OFFSET 0x00007000U /*!< Vector Table base offset field.
This value must be a multiple of 0x200. */
#endif /* VECT_TAB_SRAM */
#endif /* USER_VECT_TAB_ADDRESS */
...
.ota_region 0x08007140:
{
KEEP(*(TAG_OTA_START))
. = ALIGN(4);
} >FLASH
...
.ota_region_end :
{
. = ALIGN(4);
KEEP(*(TAG_OTA_END))
. = ALIGN(4);
} >FLASH
...
/**
* These are the two tags used to manage a power failure during OTA
* The MagicKeywordAdress shall be mapped @0x140 from start of the binary image
* The MagicKeywordvalue is checked in the ble_ota application
*/
PLACE_IN_SECTION("TAG_OTA_END") const uint32_t MagicKeywordValue = 0x94448A29 ;
PLACE_IN_SECTION("TAG_OTA_START") const uint32_t MagicKeywordAddress = (uint32_t)&MagicKeywordValue;
You may see the OTA procedure describe in this figure
AN5247 may be usefull for you.
BeST Regards,
Axel L.
2023-05-11 02:38 AM
Thank you Axel.
I found the bug. My copied and pasted code mistake so I used the Notification characteristic for the Reboot Mode characteristic which is the problem I will never got the command sent in from ST ToolBox BLE app.
2023-05-11 02:42 AM
Glad that you resolve your problem.
May you flag this question as answer, this can help other people.
BeST Regards,
Axel L.
2023-05-11 02:55 AM
Axel,
May I ask you couple questions regarding the ST BLE toolbox or Sensor app?
Is this proprietary from ST? Or there are any App Note that share the information.
Is the feature depending on the specific UUID it receives?
In my custom template app, I have 1 service: 2 characters: write and notification. Doesn't matter what UUID I assigned but when I used FULL 128 bits, my write characteristic always show the same UUID as the notification characteristic.
If I changed them back to reduce, I then see 2 different UUID (2 bytes) for each of characteristics.
Do you know why?
Or do you know any App Note to elaborate the UUIDs?
2023-05-11 03:24 AM
Sure, if I can help,
From what I experience:
2023-05-11 03:30 AM
Thank you Axel,
That is my problem. I generate 128 bit of UUID for my own, I used it for Service, Write, and Notification characteristics but ST BLE tool box pickup and use the same UUID for Write and Notification. I don't understand this.
2023-05-11 03:34 AM
Please pay attention that you need to generate a custom UUID for you #Service1 then generate customs UUIDs for you characteristic #CharA, and #CharB.
As a result of the previous example, you will have a custom service #Service1 that contain two characteristics: #CharA and #CharB.
2023-05-11 03:40 AM
Thank you so much for your help. I might not clear in my previously post.
I generated for example EEAABB01-0000-0000.., I used for Service 1 then I just change EEAABB02- 0000-0000.., and EEAABB02-0000-0000.., for CharA and CharB respectively.
Still the ST BLE toolbox app pick only EEAABB02-0000-0000.., to show on the app for both Char.