os/kernel/binary_manager.c: Add binary_manager_sync_bootparam#7131
os/kernel/binary_manager.c: Add binary_manager_sync_bootparam#7131jylee9613 wants to merge 5 commits intoSamsung:masterfrom
Conversation
…rnel update test to accept command line arguments - Add support for running specific tests: same_version, new_version, invalid, all - Each test now runs independently with proper error handling - Update main function to parse argc/argv and call appropriate test functions
… update tests separately This commit modifies the wifiapp to allow users to run individual binary update tests instead of only running all tests together
Current test code considers about kernel/common/app1 partition, not about app2 partition. This commit has been modified to enable testing even when app2 partition present. Signed-off-by: Jaeyong Lee <jaeyong1.lee@samsung.com>
All useidx and active_idx should be same in bootparam. But sometimes partition indices of each binary are being set differently during factory process, and it causes booting failure. This commit adds `binary_manager_sync_bootparam` to sync all binaries' partition to kernel's active partition. (Because both BPs are corrupted, bootloader restores kernel address.) However, in order to prevent kernel from rollback due to bootloader's restoration, `binary_manager_sync_bootparam` checks the partition which contains the latest version of kernel. [Prerequisite] Partition mixing in bootparam can occur only if binaries exist in both A and B partitions. [example] ``` Current bootparam --------------------------------- kernel | common | app1 | resource A | B | A | B --------------------------------- Updated bootparam (updated by `binary_manager_sync_bootparam`) --------------------------------- kernel | common | app1 | resource A | A | A | A --------------------------------- ``` Signed-off-by: Jaeyong Lee <jaeyong1.lee@samsung.com>
Add testcode to test `binary_manager_sync_bootparam_partitions` Also add configuration of resource binary. Signed-off-by: Jaeyong Lee <jaeyong1.lee@samsung.com>
| #ifdef CONFIG_USE_BP | ||
| /* Check and synchronize bootparam indices at boot time */ | ||
| ret = binary_manager_sync_bootparam_partitions(); | ||
| if (binary_manager_sync_bootparam_partitions() != BINMGR_OK) { |
There was a problem hiding this comment.
| if (binary_manager_sync_bootparam_partitions() != BINMGR_OK) { | |
| if (ret != BINMGR_OK) { |
| ret = binary_manager_check_kernel_update(); | ||
| if (ret == BINMGR_OK) { |
| } | ||
|
|
||
| /* Check resource_active_idx with kernel's active_idx */ | ||
| #ifdef CONFIG_RESOURCE_FS |
There was a problem hiding this comment.
if resource is broken, This function will be not performed
even If resource mount is failed, we need to call this function .
| ret = binary_manager_check_kernel_update(); | ||
| if (ret == BINMGR_OK) { | ||
| /* Update index for inactive partition */ | ||
| bp_data.active_idx ^= 1; |
There was a problem hiding this comment.
How about verify active_idx 0 or 1
| if (bp_data.resource_active_idx != kernel_active_idx) { | ||
| bmdbg("Resource partition mismatch: resource_active_idx (%u) != kernel_active_idx (%u)\n", | ||
| bp_data.resource_active_idx, kernel_active_idx); | ||
| need_update_bp = true; |
There was a problem hiding this comment.
I'm not certain, but when I followed the code flow, it seems there could be a problem like the one below.
I think need_update_bp = true; should move to in line 464 after bp_data.active_idx ^= 1;.
Like below case, bp_data.active_idx will be updated, but other, app idx will be same with updated active_idx. need_update_bp = true; will be not called. And in this case, we don't reboot system.
- Current bootparam
-------------------------------------
kernel | common | app1 | resource
A(old) | B(new) | B(new) | B(new)
-------------------------------------
| } | ||
| return ret; | ||
| } | ||
| printf("Invalid test type: %s\n", argv[1]); |
There was a problem hiding this comment.
argv[1] can be NULL here.
Wrapping with if statement would be safe.
All useidx and active_idx should be same in bootparam.
But sometimes partition indices of each binary are being set differently during factory process, and it causes booting failure.
This commit adds
binary_manager_sync_bootparamto sync all binaries' partition to kernel's active partition.(Because both BPs are corrupted, bootloader restores kernel address.)
However, in order to prevent kernel from rollback due to bootloader's restoration,
binary_manager_sync_bootparamchecks the partition which contains the latest version of kernel.[Prerequisite]
Partition mixing in bootparam can occur only if binaries exist in both A and B partitions.
[example]