uartboot: Count how many copies were written

We want to know how many copies of UBL/APP have been written.
It is necessary to know that we have written multiple copies
to avoid two bitflips rendering the device unusable.

dvnixload debug1:    Reading: [INFO: UBLs written: 0x5]
dvnixload debug1:    Reading: [INFO: APPs written: 0x4]

Related: SYS#438
This commit is contained in:
Holger Hans Peter Freyther 2014-11-20 18:42:13 +01:00
parent de83b50dec
commit 92b4a3a288
1 changed files with 15 additions and 2 deletions

View File

@ -86,6 +86,7 @@ void
uart_boot(uint32_t *jump_entry_point)
{
#if defined(FLASH_TYPE_NAND)
int wrote_copies = 0;
int prog_ok = 0;
int block_num;
struct nand_image_descriptor_t im_desc;
@ -130,20 +131,26 @@ uart_boot(uint32_t *jump_entry_point)
NOR_WriteBytes(nor_get_flashbase(), uart_ack_header.size,
(uint32_t) uart_ack_header.recv_buffer);
#elif defined(FLASH_TYPE_NAND)
wrote_copies = 0;
for (block_num = START_UBL_BLOCK_NUM; block_num <= END_UBL_BLOCK_NUM; block_num++) {
im_desc.magic = uart_ack_header.magic;
im_desc.block_num = block_num;
im_desc.entry_point = uart_ack_header.entry_point;
im_desc.load_address = 0; /* Load address not used by RBL */
if (nand_write_prog(&im_desc, uart_ack_header.recv_buffer, uart_ack_header.size) == E_PASS)
if (nand_write_prog(&im_desc, uart_ack_header.recv_buffer, uart_ack_header.size) == E_PASS) {
wrote_copies += 1;
prog_ok = 1;
}
}
if (!prog_ok)
goto uartboot_error;
#endif
/* Indicate that UBL flashing was successfull. */
uart_send_str("INFO: UBLs written: ");
uart_send_hexnum(wrote_copies, 1);
uart_send_lf();
host_msg("DONE");
host_msg("SENDAPP");
@ -193,6 +200,7 @@ uart_boot(uint32_t *jump_entry_point)
#elif defined(FLASH_TYPE_NAND)
/* Write multiple copy of U-Boot (depending on the defines in NAND.h) */
prog_ok = 0;
wrote_copies = 0;
for (block_num = START_UBOOT_BLOCK_NUM; (block_num+MAX_BLOCK_PER_UBOOT-1) <= END_UBOOT_BLOCK_NUM; block_num += MAX_BLOCK_PER_UBOOT) {
im_desc.magic = uart_ack_header.magic;
im_desc.block_num = block_num;
@ -201,14 +209,19 @@ uart_boot(uint32_t *jump_entry_point)
/* Assuming load address is identical to entry point. */
im_desc.load_address = uart_ack_header.entry_point;
if (nand_write_prog(&im_desc, uart_ack_header.recv_buffer, uart_ack_header.size) == E_PASS)
if (nand_write_prog(&im_desc, uart_ack_header.recv_buffer, uart_ack_header.size) == E_PASS) {
wrote_copies += 1;
prog_ok = 1;
}
}
if (!prog_ok)
goto uartboot_error;
#endif
/* Indicate that APP flashing was successfull. */
uart_send_str("INFO: APPs written: ");
uart_send_hexnum(wrote_copies, 1);
uart_send_lf();
host_msg("DONE");
break;