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:
parent
de83b50dec
commit
92b4a3a288
17
uartboot.c
17
uartboot.c
|
@ -86,6 +86,7 @@ void
|
||||||
uart_boot(uint32_t *jump_entry_point)
|
uart_boot(uint32_t *jump_entry_point)
|
||||||
{
|
{
|
||||||
#if defined(FLASH_TYPE_NAND)
|
#if defined(FLASH_TYPE_NAND)
|
||||||
|
int wrote_copies = 0;
|
||||||
int prog_ok = 0;
|
int prog_ok = 0;
|
||||||
int block_num;
|
int block_num;
|
||||||
struct nand_image_descriptor_t im_desc;
|
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,
|
NOR_WriteBytes(nor_get_flashbase(), uart_ack_header.size,
|
||||||
(uint32_t) uart_ack_header.recv_buffer);
|
(uint32_t) uart_ack_header.recv_buffer);
|
||||||
#elif defined(FLASH_TYPE_NAND)
|
#elif defined(FLASH_TYPE_NAND)
|
||||||
|
wrote_copies = 0;
|
||||||
for (block_num = START_UBL_BLOCK_NUM; block_num <= END_UBL_BLOCK_NUM; block_num++) {
|
for (block_num = START_UBL_BLOCK_NUM; block_num <= END_UBL_BLOCK_NUM; block_num++) {
|
||||||
im_desc.magic = uart_ack_header.magic;
|
im_desc.magic = uart_ack_header.magic;
|
||||||
im_desc.block_num = block_num;
|
im_desc.block_num = block_num;
|
||||||
im_desc.entry_point = uart_ack_header.entry_point;
|
im_desc.entry_point = uart_ack_header.entry_point;
|
||||||
im_desc.load_address = 0; /* Load address not used by RBL */
|
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;
|
prog_ok = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!prog_ok)
|
if (!prog_ok)
|
||||||
goto uartboot_error;
|
goto uartboot_error;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Indicate that UBL flashing was successfull. */
|
/* 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("DONE");
|
||||||
|
|
||||||
host_msg("SENDAPP");
|
host_msg("SENDAPP");
|
||||||
|
@ -193,6 +200,7 @@ uart_boot(uint32_t *jump_entry_point)
|
||||||
#elif defined(FLASH_TYPE_NAND)
|
#elif defined(FLASH_TYPE_NAND)
|
||||||
/* Write multiple copy of U-Boot (depending on the defines in NAND.h) */
|
/* Write multiple copy of U-Boot (depending on the defines in NAND.h) */
|
||||||
prog_ok = 0;
|
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) {
|
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.magic = uart_ack_header.magic;
|
||||||
im_desc.block_num = block_num;
|
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. */
|
/* Assuming load address is identical to entry point. */
|
||||||
im_desc.load_address = uart_ack_header.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;
|
prog_ok = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!prog_ok)
|
if (!prog_ok)
|
||||||
goto uartboot_error;
|
goto uartboot_error;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Indicate that APP flashing was successfull. */
|
/* Indicate that APP flashing was successfull. */
|
||||||
|
uart_send_str("INFO: APPs written: ");
|
||||||
|
uart_send_hexnum(wrote_copies, 1);
|
||||||
|
uart_send_lf();
|
||||||
host_msg("DONE");
|
host_msg("DONE");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue