int main(void) { void *rw_hash; hardware_init(); debug_printf("%s started\n", is_ro_mode() ? "RO" : "RW"); /* the RO partition protection is not enabled : do it */ if (!flash_physical_is_permanently_protected()) flash_physical_permanent_protect(); /* * calculate the hash of the RW partition * * Also pre-cache it so we can answer Discover Identity VDM * fast enough (in less than 30ms). */ rw_hash = flash_hash_rw(); /* Verify RW firmware and use it if valid */ if (is_ro_mode() && check_rw_valid(rw_hash)) jump_to_rw(); /* background loop for PD events */ pd_task(); debug_printf("EXIT!\n"); /* we should never reach that point */ system_reset(0); return 0; }
int main(void) { hardware_init(); debug_printf("Power supply started ... %s\n", is_ro_mode() ? "RO" : "RW"); /* Verify RW firmware and use it if valid */ if (is_ro_mode() && check_rw_valid()) jump_to_rw(); /* background loop for PD events */ pd_task(); debug_printf("background loop exited !\n"); /* we should never reach that point */ cpu_reset(); return 0; }
uint32_t *board_get_info(void) { if (rw_flash_changed) { /* re-calculate RW hash */ rw_hash = flash_hash_rw(); rw_flash_changed = 0; } /* copy first 20 bytes of RW hash */ memcpy(info_data, rw_hash, 5 * sizeof(uint32_t)); /* copy other info into data msg */ info_data[5] = VDO_INFO(CONFIG_USB_PD_HW_DEV_ID_BOARD_MAJOR, CONFIG_USB_PD_HW_DEV_ID_BOARD_MINOR, ver_get_numcommits(), !is_ro_mode()); return info_data; }