I want to port an application from a non Xiao NRF52840 dev board that uses FreeRTOS via an Adafruit runtime implementation ( not mbed RTOS)
I’m looking for a couple things.
- the “official” bootloader/SoftDevice hex file for the Xiao BLE (not Sense if that matters)
- pointer to the bootloader source used to build the above, if available to get a better understanding of what is going on.
My issue:
When FreeRTOS starts, it starts the first task/thread via an “SVC 0” instruction call. The RTOS code sets up a stack much like is done with
a normal branch to a subroutine, saves registers, sets return PC, LR, etc… then executes the “SVC 0”. The difference is the LR is set to 0xFFFF FFFD (EXEC_RETURN).
The SVC handler should run and then should properly decode that stack content. The handler should take the return address from the premade stack, not via the actual LR which is 0XFFFFFFD (EXEC_RETURN : Exception Return Mechanism - an overview | ScienceDirect Topics).
As I understand it at execution time the address of the interrupt vector table
can be found at address 0x2000 0000. The SVC_Handler address should
then be at this base address + 0x2c.
I have two Bootloader/SoftDevice binaries that I’m uploading:
- Refereced at the wiki: Getting Started with XIAO BLE (Sense) - Seeed Wiki
This version seems to be calling the SVC_Handler in bootloader address space.
The vector table address is 0xF4000, thus the handler at the address found in 0xF402c is called. This runs some looping code (trying to determine the SCV number perhaps???) and ends up returning to the actual LR address, 0xFFFFFFC, not the one from within the stack.
- Another version taken from the Nordic site
S140 - nordicsemi.com (version 7.3.0)
This version seems to be calling the SVC_Handler in SoftDevice address space. The vector table address is 0x1000, thus the handler address found in 0x102c is called.
This runs a few instructions, but (no looping), ends up returning to an
address taken from the built stack, not the actual LR content, entering the first task as expected.
So, I can use the Nordic version, but it does not appear to have a bootloader, thus we loose the double reset button taking us to DFU mode and who knows what else.
I would like to understand why the Seeed version is not handling the SVC 0 as expected.