Skip to content

[rescue] Avoid large rodata initializer for dfu_ctx_t#30169

Merged
cfrantz merged 1 commit into
lowRISC:earlgrey_1.0.0from
sasdf:mgTfbbdc497
May 21, 2026
Merged

[rescue] Avoid large rodata initializer for dfu_ctx_t#30169
cfrantz merged 1 commit into
lowRISC:earlgrey_1.0.0from
sasdf:mgTfbbdc497

Conversation

@sasdf

@sasdf sasdf commented May 21, 2026

Copy link
Copy Markdown
Contributor

The dfu_ctx_t struct has a large buffer allocated for rescue transfers in rescue_state_t.

Using a designated initializer for this struct produces a large, mostly zero-filled initializer in rodata, consuming approximately 2.5KB of ROM_EXT flash space.

// Data buffer to hold xmodem upload data.
uint8_t data[2048];
} rescue_state_t;

To reclaim this space, this change replaces the designated initializer with manual field-by-field initialization, eliminating the bloated rodata payload.

The `dfu_ctx_t` struct has a large buffer allocated for rescue
transfers. Using a designated initializer for this struct
produces a large, mostly zero-filled initializer in `rodata`,
consuming approximately 2.5K of ROM_EXT flash space.

To reclaim this space, this change replaces the designated
initializer with manual field-by-field initialization, eliminating
the bloated `rodata` payload.

Change-Id: Ifbbdc4977104cc980677af2b8ca61507d592f1a3
Signed-off-by: Yi-Hsuan Deng <yhdeng@google.com>
@sasdf sasdf changed the title [rescue,usb] Avoid large rodata initializer for dfu_ctx_t [rescue] Avoid large rodata initializer for dfu_ctx_t May 21, 2026
@sasdf sasdf requested a review from cfrantz May 21, 2026 14:26
@sasdf sasdf marked this pull request as ready for review May 21, 2026 14:26
@sasdf sasdf requested a review from a team as a code owner May 21, 2026 14:26
@sasdf sasdf requested review from alees24 and removed request for a team May 21, 2026 14:26

@cfrantz cfrantz left a comment

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.

Great find... especially since I've complained about this in the past and I think I'm responsible for this one.

@cfrantz cfrantz merged commit c4e221b into lowRISC:earlgrey_1.0.0 May 21, 2026
35 checks passed
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.

2 participants