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=c6d91140906b310e78c2fc232d76634c3c1e568a;hb=01e47d52e2b0f57045a8c6ba4091773f6204d7f5;hpb=813da6b78bec159c44ad57d0c7a6f77f2dd09cea diff --git a/post/src/post.c b/post/src/post.c index c6d9114..2902574 100644 --- a/post/src/post.c +++ b/post/src/post.c @@ -277,6 +277,139 @@ post_test_nor return test_passed; } +void +post_hex_to_string +( + uint32_t hex, + uint32_t nibbles, + char *msg +) +{ + int32_t i; + uint8_t nibble; + + for (i = (nibbles-1); i >= 0; i--) + { + nibble = hex & 0xf; + if (nibble <= 0x9) + { + nibble += '0'; + } + else + { + nibble += ('A' - 0xa); + } + + msg[i] = nibble; + hex = hex >> 4; + } + 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 ******************************************************************************/ @@ -294,15 +427,13 @@ main int32_t i; 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)); memset(&init_flags, 0x01, sizeof(platform_init_flags)); -#ifdef _EVMC6670L_ - init_flags.phy = 0; -#endif - /* Initialize the platform */ if (platform_init(&init_flags, &init_config) != Platform_EOK) { @@ -328,41 +459,58 @@ main platform_uart_set_baudrate(POST_UART_BAUDRATE); if (test_id != POST_TEST_PLL_INIT) { - if (post_write_uart(POST_DEVICE) != TRUE) + if (post_write_uart("\r\n\r\n") != TRUE) { post_display_led_error(POST_TEST_UART); /* Never return from this function */ } + + platform_get_info(&info); + + /* Display the board name */ + post_write_uart(info.board_name); + + /* Display the POST version */ post_write_uart(POST_EVM_VERSION_MSG); post_write_uart(post_version); - /*post_write_uart("\r\n\r\nPOST booting from I2C 0x50 ... ");*/ + post_hex_to_string(info.board_rev, 4, msg); + post_write_uart("\r\n\r\nFPGA Version: "); + post_write_uart(msg); + + 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); - msg[2] = ' '; - msg[3] = 0; post_write_uart("\r\n\r\nEFUSE MAC ID is: "); for (i = 0; i < 6; i++) { - msg[0] = (char)(mac_addr[i]>>4); - if (msg[0] < 0xa) - { - msg[0] += '0'; - } - else - { - msg[0] = msg[0] - 0xa + 'A'; - } - msg[1] = (char)(mac_addr[i]&0xf); - if (msg[1] < 0xa) - { - msg[1] += '0'; - } - else - { - msg[1] = msg[1] - 0xa + 'A'; - } + post_hex_to_string(info.emac.efuse_mac_address[i], 2, msg); + msg[2] = ' '; + msg[3] = 0; 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); + post_write_uart("\r\n\r\nPLL Reset Type Status Register: 0x"); + post_write_uart(msg); } /* Display test in progress UART/LED status or init error */ @@ -382,15 +530,6 @@ main post_display_status(POST_TEST_COMPLETE, TRUE); - /* Read the PLL Reset Type Status register and display on UART */ - reset_type = PLL_CTRL_REG_RSTYPE; - for (i = 7; i >= 0; i--) - { - msg[i] = (char)(reset_type & 0xf) + '0'; - reset_type = reset_type >> 4; - } - msg[8] = 0; - post_write_uart("\r\n\r\nPLL Reset Type Status Register: 0x"); - post_write_uart(msg); + post_write_serial_no(); }