Beispiel #1
0
std::string getBoardBinaryFile(const char *prefix, cl_device_id device) {
  // First check if <prefix>.aocx exists. Use it if it does.
  std::string file_name = std::string(prefix) + ".aocx";
  if(fileExists(file_name.c_str())) {
    return file_name;
  }

  // Now get the name of the board. For Altera SDK for OpenCL boards,
  // the name of the device is presented as:
  //  <board name> : ...
  std::string device_name = getDeviceName(device);

  // Now search for the " :" in the device name.
  size_t end = device_name.find(" :");
  if(end != std::string::npos) {
    std::string board_name(device_name, 0, end);

    // Look for a AOCX with the name <prefix>_<board_name>_<version>.aocx.
    file_name = std::string(prefix) + "_" + board_name + "_" + VERSION_STR + ".aocx";
    if(fileExists(file_name.c_str())) {
      return file_name;
    }
  }

  // At this point just use <prefix>.aocx. This file doesn't exist
  // and this should trigger an error later.
  return std::string(prefix) + ".aocx";
}
/* Program the board ID fuses if not already done */
test_return_t program_board_id(void)
{
    const char* const indent = menu_get_indent();

    char chip_str[64];
    char chip_str_full[64];
    char chip_rev_str[64];
    char board_str[64];
    char board_rev_str[64];

    fsl_board_id_t board_id = get_board_id();

    chip_name(chip_str, board_id.B.CHIP_TYPE_ID, false);
    chip_name(chip_str_full, board_id.B.CHIP_TYPE_ID, true);
    chip_revision(chip_rev_str, board_id.B.CHIP_REV_MAJOR, board_id.B.CHIP_REV_MINOR);
    board_name(board_str, board_id.B.BOARD_TYPE_ID);
    board_revision(board_rev_str, board_id.B.BOARD_REV);

    uint32_t fw_board_type = BOARD_TYPE;
    uint32_t fw_board_rev = BOARD_REVISION;

    /* Special case for MX6SDL/DQ SMART_DEVICE/SABRE_AI REV_B boards.
     * Allow user to choose to program the board as a REV_C or a REV_BX board */
    if ((CHIP_TYPE == CHIP_TYPE_MX6SDL || CHIP_TYPE == CHIP_TYPE_MX6DQ) &&
        (BOARD_TYPE == BOARD_TYPE_SABRE_AI || BOARD_TYPE == BOARD_TYPE_SMART_DEVICE) &&
         BOARD_REVISION == BOARD_REVISION_B)
    {
        printf("%sThis binary will work for REV_D, REV_C, REV_BX, and REV_B boards.\n", indent);
        printf("%sWould you like to use the REV_D board ID for this board?\n", indent);
        if (is_input_char('y', indent)) {
            printf("%sUsing REV_D board ID instead of REV_B board ID.\n\n", indent);
            fw_board_rev = BOARD_REVISION_D;
        }
        else {
            printf("%sWould you like to use the REV_C board ID for this board?\n", indent);
            if (is_input_char('y', indent)) {
                printf("%sUsing REV_C board ID instead of REV_B board ID.\n\n", indent);
                fw_board_rev = BOARD_REVISION_C;
            }
            else if(BOARD_TYPE == BOARD_TYPE_SABRE_AI){
                printf("%sWould you like to use the REV_BX board ID for this board?\n", indent);
                if (is_input_char('y', indent)) {
                    printf("%sUsing REV_BX board ID instead of REV_B board ID.\n\n", indent);
                    fw_board_rev = BOARD_REVISION_BX;
                }
            }
        }
    }

    /* Special case for MX6SL EVB/EVK boards.
     * Allow user to choose to program the board as a EVK_EPDC or EVK_SPDC board */
    if (CHIP_TYPE == CHIP_TYPE_MX6SL)
    {
        printf("%sThis binary will work for both EVB and EVK boards.\n", indent);
        printf("%sWould you like to use the EVK board ID for this board?\n", indent);
        if (is_input_char('y', indent))
        {
            printf("%sUsing BOARD_TYPE_EVK board ID instead of BOARD_TYPE_EVB board ID.\n\n", indent);
            printf("%sUsing BOARD_REVISION_A board ID instead of BOARD_REVISION_B board ID.\n\n", indent);
            fw_board_type = BOARD_TYPE_EVK;
            fw_board_rev = BOARD_REVISION_A;
        }
    }

    if (board_id.B.BOARD_TYPE_ID == 0 || board_id.B.BOARD_REV == 0)
    {
        // Board is not programmed
        printf("%sNo Board ID found in the fuses.\n", indent);
        board_id.B.BOARD_TYPE_ID = fw_board_type;
        board_id.B.BOARD_REV = fw_board_rev;

        printf("%sThis OBDS binary will program Board ID to 0x%08X as detailed below:\n", indent, board_id.U);
        show_board_id(board_id, indent);

        printf_color(g_TextAttributeBold, g_TextColorRed, "%sContinue with irreversible operation to program Board ID?\n", indent);
        if (!is_input_char('y', indent))
        {
            /* Do not program the suggested value to Board ID fuse bank */
            printf("%sNOT programming board ID to fuses.\n", indent);

            return TEST_BYPASSED;
        }

        // DO THE PROGRAMMING
        test_return_t err = program_board_id_fuses(board_id.B.BOARD_TYPE_ID, board_id.B.BOARD_REV, indent);
        if (err == TEST_PASSED)
        {
            printf("%sFuses programmed successfully.\n\n", indent);
            show_board_id(get_board_id(), indent);
        }

        return err;
    }
    else if ((board_id.B.BOARD_TYPE_ID == BOARD_TYPE_SABRE_AI || board_id.B.BOARD_REV == BOARD_REVISION_B) &&
             (fw_board_rev == BOARD_REVISION_BX) )
    {
        // SABRE AI Board is programmed as REV_B , but we need it to be REV_BX
        printf("\n%sSABRE AI Rev. B board ID found in the fuses.\n", indent);
        board_id.B.BOARD_TYPE_ID = fw_board_type;
        board_id.B.BOARD_REV = fw_board_rev;

        printf("%sThis OBDS binary will program Board ID to 0x%08X as detailed below:\n", indent, board_id.U);
        show_board_id(board_id, indent);
        printf("\n");
        printf_color(g_TextAttributeBold, g_TextColorRed, "%sContinue with irreversible operation to program Board ID?\n", indent);
        if (!is_input_char('y', indent))
        {
            /* Do not program the suggested value to Board ID fuse bank */
            printf("%sNOT programming board ID to fuses.\n", indent);

            return TEST_BYPASSED;
        }

        // DO THE PROGRAMMING
        test_return_t err = program_board_id_fuses(board_id.B.BOARD_TYPE_ID, board_id.B.BOARD_REV, indent);
        if (err == TEST_PASSED)
        {
            printf("%sFuses programmed successfully.\n\n", indent);
            show_board_id(get_board_id(), indent);
        }

        return err;
    }
    else if ( board_id.B.CHIP_TYPE_ID  != CHIP_TYPE     ||
              board_id.B.BOARD_TYPE_ID != fw_board_type ||
              board_id.B.BOARD_REV     != fw_board_rev  )
    {
        // Software is not compiled for this board
        printf("\n%sSoftware is not compiled for this board.\n", indent);

        chip_name(chip_str, CHIP_TYPE, false);
        board_name(board_str, fw_board_type);
        board_revision(board_rev_str, fw_board_rev);
        printf("%sSoftware for %s %s %s.\n", indent, chip_str, board_str, board_rev_str);

        chip_name(chip_str, board_id.B.CHIP_TYPE_ID, false);
        board_name(board_str, board_id.B.BOARD_TYPE_ID);
        board_revision(board_rev_str, board_id.B.BOARD_REV);
        printf("%sBoard is %s %s %s.\n", indent, chip_str, board_str, board_rev_str);

        return TEST_FAILED;
    }
    else if ( board_id.B.CHIP_TYPE_ID  == CHIP_TYPE     &&
              board_id.B.BOARD_TYPE_ID == fw_board_type &&
              board_id.B.BOARD_REV     == fw_board_rev  )
    {
        // Board ID fuses are already correct
        printf("\n%sBoard ID fuses are already programmed.\n\n", indent);
        show_board_id(board_id, indent);

        return TEST_PASSED;
    }
    else
    {
        // Unhandled cases
        printf("\n%sUnknown failure.\n\n", indent);
        show_board_id(board_id, indent);

        return TEST_FAILED;
    }
}