board/ctrl: add BOARDCTL_SWITCH_BOOT switch boot system support

BOARDIOC_SWITCH_BOOT is required to communicate the boot partition from
userspace (OTA subsystem) to board. It can be used to change the system
boot behavior. So it's useful for A/B boot or even single boot case.

For the board support A/B boot case:
1. Download the new image from the sever
2. Write the new image to the alternative partition
3. Call BOARDCTL_SWITCH_BOOT to the alternative system

For single boot partition case:
1. Download the new image from the sever
2. Call BOARDCTL_SWITCH_BOOT and reboot to a small system
3. Write the new image to the main partition in the small system
4. Call BOARDCTL_SWITCH_BOOT again to the main system

Change-Id: Ifebb495784ecf06842946a249bec64f75dce894f
Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>
This commit is contained in:
liuhaitao
2021-07-20 22:12:28 +08:00
parent c4e5410fa5
commit 14cc2d09d2
4 changed files with 49 additions and 1 deletions
+10
View File
@@ -3389,6 +3389,16 @@ config BOARDCTL_UNIQUEKEY_SIZE
Provides the size of the memory buffer that must be provided by the
caller of board_uniquekey() in which to receive the board unique KEY.
config BOARDCTL_SWITCH_BOOT
bool "Enable switch boot system support"
default n
---help---
BOARDIOC_SWITCH_BOOT is required to communicate the boot partition
from userspace (OTA subsystem) to board for A/B boot or single boot
case. It can be used to change the system boot behavior. For instance,
once a firmware updated successfully, this boardctl can be used to
modify FLASH bank selection.
config BOARDCTL_MKRD
bool "Enable application space creation of RAM disks"
default n
+16
View File
@@ -436,6 +436,22 @@ int boardctl(unsigned int cmd, uintptr_t arg)
break;
#endif
#ifdef CONFIG_BOARDCTL_SWITCH_BOOT
/* CMD: BOARDIOC_SWITCH_BOOT
* DESCRIPTION: Used to change the system boot behavior. Switch to
* the updated or specified boot system.
* ARG: Boot system updated or specified
* DEPENDENCIES: Board logic must provide the board_switch_boot()
* interface.
*/
case BOARDIOC_SWITCH_BOOT:
{
ret = board_switch_boot((FAR const char *)arg);
}
break;
#endif
#ifdef CONFIG_BOARDCTL_MKRD
/* CMD: BOARDIOC_MKRD
* DESCRIPTION: Create a RAM disk