Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions mflash/mflash.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,31 @@ int write_chunks(mflash* mfl, u_int32_t addr, u_int32_t len, u_int8_t* data)
block_data[i + prefix_pad_size],
verify_buffer[i]));

// Print 4 dwords (16 bytes) starting from the dword before the error
u_int32_t error_offset = addr + i;
u_int32_t start_dword_offset = (error_offset & ~0x3) - 4; // Align to dword, go back 1 dword
if ((int32_t)start_dword_offset < 0 || start_dword_offset < addr) {
start_dword_offset = addr;
}

u_int32_t bytes_to_print = 16; // 4 dwords
u_int32_t start_idx = start_dword_offset - addr;

printf("Address range: 0x%08x - 0x%08x\n", start_dword_offset, start_dword_offset + bytes_to_print - 1);
printf("expected (4 dwords): ");
for (uint32_t j = start_idx; j < start_idx + bytes_to_print && j < data_size; j++)
{
printf("%02x ", block_data[j + prefix_pad_size]);
}
printf("\n");
printf("actual (4 dwords): ");
for (uint32_t j = start_idx; j < start_idx + bytes_to_print && j < data_size; j++)
{
printf("%02x ", verify_buffer[j]);
}
printf("\n");
fflush(stdout);

if (retries_counter >= retries_num) {
return MFE_VERIFY_ERROR;
} else {
Expand Down
19 changes: 19 additions & 0 deletions mflash/mflash_new_gw.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,25 @@ int new_gw_int_spi_get_status_data(mflash* mfl, u_int8_t op_type, u_int32_t* sta
rc = new_gw_exec_cmd_get(mfl, gw_cmd, &flash_data, 1, (u_int32_t*)NULL, "Read id");
CHECK_RC(rc);
DPRINTF(("new_gw_int_spi_get_status_data: op=%02x status=%08x\n", op_type, flash_data));

if (op_type == SFC_RDSR)
{
u_int32_t written_flash_cmd_without_busy = gw_cmd;

// this changes are applied to the flash gw right before writing it, so need to add before comapring. no need to
// set the busy as it will be unset when we read the flash data.
written_flash_cmd_without_busy = MERGE(written_flash_cmd_without_busy, 1, 31, 1); // lock
written_flash_cmd_without_busy =
MERGE(written_flash_cmd_without_busy, (u_int32_t)mfl->curr_bank, mfl->gw_chip_select_bit_offset, 1);

if (written_flash_cmd_without_busy == flash_data)
{
printf("============================================================================\n");
printf("new_gw_int_spi_get_status_data: flash_data is the same as flash gw cmd!\n");
printf("============================================================================\n");
}
}

*status = (flash_data >> 8 * (4 - bytes_num));
DPRINTF(("new_gw_int_spi_get_status_data: after shift status=%08x\n", *status));
return MFE_OK;
Expand Down