Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not proceed activating the firmware if hpm_finish_upload fails #158

Closed
augustofg opened this issue Jul 17, 2023 · 0 comments · Fixed by #159
Closed

Do not proceed activating the firmware if hpm_finish_upload fails #158

augustofg opened this issue Jul 17, 2023 · 0 comments · Fixed by #159
Assignees

Comments

@augustofg
Copy link
Member

After 65ccb1f, the firmware activation step writes the bootloader magic word even if the hpm_finish_upload function fails. We should create a variable to indicate that the hpm_finish_upload function executed without any error before proceeding writing the bootloader magic word. This variable should be initialised in such a way that only if a successful execution of hpm_finish_upload will allow ipmc_hpm_finish_upload and bootloader_hpm_activate_firmware to execute without errors. This variable should be reseted when calling hpm_prepare_comp.

Relevant source excerpts:

uint8_t hpm_finish_upload(uint32_t image_size, enum memory_area area)
{
/* Check if the last page was already programmed */
if(ipmc_page_byte_index != 0) {
/* Program the complete page in the Flash */
program_page( ipmc_page_addr, ipmc_page, sizeof(ipmc_page), area);
ipmc_image_size += ipmc_page_byte_index;
ipmc_page_byte_index = 0;
ipmc_page_addr = 0;
}
if (ipmc_image_size != image_size) {
/* HPM CC: Number of bytes received does not match the size provided in the "Finish firmware upload" request */
return 0x81;
}
return IPMI_CC_OK;
}

uint8_t ipmc_hpm_activate_firmware(void)
{
fw_info fw_update_header;
memset(&fw_update_header, 0xFF, sizeof(fw_update_header));
/*
* Write firmware update record to inform the bootloader that a
* new firmware is available.
*
* TODO: Write actual firmware ID
*/
fw_update_header.magic = 0xAAAAAAAA;
fw_update_header.fw_type = 1; // Update application
fw_update_header.version[0] = 1;
fw_update_header.version[1] = 4;
fw_update_header.version[2] = 1;
program_page((uint32_t)fw_header - (uint32_t)update_start_addr, (uint32_t*)&fw_update_header, sizeof(fw_update_header), FW_UPDATE_FLASH);
/*
* Schedule a reset to 500ms from now
*/
sys_schedule_reset(500);
return IPMI_CC_OK;
}

uint8_t bootloader_hpm_activate_firmware(void)
{
sys_schedule_reset(500);
return IPMI_CC_OK;
}

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

Successfully merging a pull request may close this issue.

2 participants