Skip to content

os/kernel/binary_manager.c: Add binary_manager_sync_bootparam#7131

Open
jylee9613 wants to merge 5 commits intoSamsung:masterfrom
jylee9613:BM_sync_bp
Open

os/kernel/binary_manager.c: Add binary_manager_sync_bootparam#7131
jylee9613 wants to merge 5 commits intoSamsung:masterfrom
jylee9613:BM_sync_bp

Conversation

@jylee9613
Copy link
Copy Markdown
Contributor

@jylee9613 jylee9613 commented Jan 22, 2026

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
---------------------------------

abhinav-s235 and others added 3 commits January 15, 2026 13:36
…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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (binary_manager_sync_bootparam_partitions() != BINMGR_OK) {
if (ret != BINMGR_OK) {

Comment on lines +461 to +462
ret = binary_manager_check_kernel_update();
if (ret == BINMGR_OK) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to check crc?

}

/* Check resource_active_idx with kernel's active_idx */
#ifdef CONFIG_RESOURCE_FS
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argv[1] can be NULL here.
Wrapping with if statement would be safe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants