X-Git-Url: https://git.ti.com/gitweb?p=keystone-rtos%2Fmcsdk-tools.git;a=blobdiff_plain;f=post%2Fsrc%2Fpost.c;h=2902574a9e300f90fe1b792bdcd07d7a0c7b9b53;hp=f69e87c886f9b218902d4159fb4a5f7595da610d;hb=01e47d52e2b0f57045a8c6ba4091773f6204d7f5;hpb=076ca095c68f326e39ed57b661a1e3ea948e4dc9 diff --git a/post/src/post.c b/post/src/post.c index f69e87c..2902574 100644 --- a/post/src/post.c +++ b/post/src/post.c @@ -306,6 +306,110 @@ post_hex_to_string msg[nibbles] = 0; } +Bool +post_serial_num_isvalid +( + char c +) +{ + if ( + ((c >= '0') && (c <= '9')) || + ((c >= 'a') && (c <= 'z')) || + ((c >= 'A') && (c <= 'Z')) + ) + { + return TRUE; + } + else + { + return FALSE; + } +} + +/****************************************************************************** + * Function: post_write_serial_no + ******************************************************************************/ +void +post_write_serial_no +( + void +) +{ + uint32_t i, j; + uint8_t msg[20], msg2[2]; + PLATFORM_DEVICE_info *p_device; + + /* Check if user key in the passcode "ti" to enter board serial number */ + if (platform_uart_read(msg, POST_UART_READ_TIMEOUT) != Platform_EOK) + { + return; + } + if (msg[0] != 't') + { + return; + } + + if (platform_uart_read(msg, POST_UART_READ_TIMEOUT) != Platform_EOK) + { + return; + } + if (msg[0] != 'i') + { + return; + } + + /* Passcode verified, prompt the user to enter serial number */ + p_device = platform_device_open(PLATFORM_DEVID_EEPROM50, 0); + if (p_device == NULL) + { + return; + } + + post_write_uart("\r\n\r\nPlease enter the 10 digit serial number for this board, and then press ENTER key:\r\n\r\n"); + + i = 0; + msg2[1] = 0; + while (TRUE) + { + if (platform_uart_read(&msg[i], POST_UART_READ_TIMEOUT) != Platform_EOK) + { + platform_device_close(p_device->handle); + post_write_uart("\r\n\r\nSerial number input time out!"); + return; + } + + if (msg[i] == '\r') + { + break; + } + if ((i < POST_MAX_SN_SIZE) && post_serial_num_isvalid(msg[i])) + { + msg2[0] = msg[i]; + post_write_uart((char *)msg2); + i++; + } + } + + if (i < POST_MAX_SN_SIZE) + { + for (j = i; j < POST_MAX_SN_SIZE; j++) + { + msg[j] = 0xff; + } + } + + if(platform_device_write(p_device->handle, POST_SERIAL_NUM_ADDR, msg, 16) == Platform_EOK) + { + post_write_uart("\r\n\r\nSerial number programmed to EEPROM successfully! "); + } + else + { + post_write_uart("\r\n\r\nFailed to program the serial number to EEPROM!"); + } + platform_device_close(p_device->handle); + +} + /****************************************************************************** * Function: main function for POST ******************************************************************************/ @@ -324,6 +428,7 @@ main char msg[9]; uint8_t mac_addr[6]; platform_info info; + uint32_t sa_enable; /* Turn on all the platform initialize flags */ memset(&init_config, 0, sizeof(platform_init_config)); @@ -372,7 +477,11 @@ main post_write_uart("\r\n\r\nFPGA Version: "); post_write_uart(msg); - /*post_write_uart("\r\n\r\nPOST booting from I2C 0x50 ... ");*/ + if (info.serial_nbr[0] != 0) + { + post_write_uart("\r\n\r\nBoard Serial Number: "); + post_write_uart(info.serial_nbr); + } /* Display the EFUSE MAC address */ platform_get_macaddr(PLATFORM_MAC_TYPE_EFUSE, mac_addr); @@ -385,6 +494,18 @@ main post_write_uart(msg); } + sa_enable = *(volatile uint32_t *)0x20c0000; + sa_enable &= 0x1; + + if (sa_enable) + { + post_write_uart("\r\n\r\nSA is enabled on this board."); + } + else + { + post_write_uart("\r\n\r\nSA is disabled on this board."); + } + /* Read the PLL Reset Type Status register and display on UART */ reset_type = PLL_CTRL_REG_RSTYPE; post_hex_to_string(reset_type, 8, msg); @@ -408,5 +529,7 @@ main post_display_status(POST_TEST_NAND, test_passed); post_display_status(POST_TEST_COMPLETE, TRUE); + + post_write_serial_no(); }