mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-04 23:45:26 +00:00
CPLD: Use correct bitstream for updating hardware.
Determine hardware version and use one of two CPLD bitstream files.
This commit is contained in:
parent
73d62367d1
commit
797e63a590
@ -71,8 +71,11 @@ set(USE_FPU no)
|
||||
# Project, sources and paths
|
||||
#
|
||||
|
||||
set(CPLD_SVF_PATH ${HARDWARE_PATH}/portapack_h1/cpld/20150901/output_files/portapack_h1_cpld.svf)
|
||||
set(CPLD_DATA_CPP ${CMAKE_CURRENT_BINARY_DIR}/portapack_cpld_data.cpp)
|
||||
set(CPLD_20150901_SVF_PATH ${HARDWARE_PATH}/portapack_h1/cpld/20150901/output_files/portapack_h1_cpld.svf)
|
||||
set(CPLD_20150901_DATA_CPP ${CMAKE_CURRENT_BINARY_DIR}/portapack_cpld_20150901_data.cpp)
|
||||
|
||||
set(CPLD_20170522_SVF_PATH ${HARDWARE_PATH}/portapack_h1/cpld/20170522/output_files/portapack_h1_cpld.svf)
|
||||
set(CPLD_20170522_DATA_CPP ${CMAKE_CURRENT_BINARY_DIR}/portapack_cpld_20170522_data.cpp)
|
||||
|
||||
set(HACKRF_CPLD_DATA_HPP ${CMAKE_CURRENT_BINARY_DIR}/hackrf_cpld_data.hpp)
|
||||
set(HACKRF_CPLD_DATA_CPP ${CMAKE_CURRENT_BINARY_DIR}/hackrf_cpld_data.cpp)
|
||||
@ -194,7 +197,8 @@ set(CPPSRC
|
||||
${COMMON}/jtag.cpp
|
||||
${COMMON}/jtag_tap.cpp
|
||||
cpld_update.cpp
|
||||
${CPLD_DATA_CPP}
|
||||
${CPLD_20150901_DATA_CPP}
|
||||
${CPLD_20170522_DATA_CPP}
|
||||
${HACKRF_CPLD_DATA_CPP}
|
||||
)
|
||||
|
||||
@ -310,9 +314,15 @@ include(${RULESPATH}/rules.cmake)
|
||||
##############################################################################
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${CPLD_DATA_CPP}
|
||||
COMMAND ${EXTRACT_CPLD_DATA} ${CPLD_SVF_PATH} >${CPLD_DATA_CPP}
|
||||
DEPENDS ${EXTRACT_CPLD_DATA} ${CPLD_SVF_PATH}
|
||||
OUTPUT ${CPLD_20150901_DATA_CPP}
|
||||
COMMAND ${EXTRACT_CPLD_DATA} ${CPLD_20150901_SVF_PATH} rev_20150901 >${CPLD_20150901_DATA_CPP}
|
||||
DEPENDS ${EXTRACT_CPLD_DATA} ${CPLD_20150901_SVF_PATH}
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${CPLD_20170522_DATA_CPP}
|
||||
COMMAND ${EXTRACT_CPLD_DATA} ${CPLD_20170522_SVF_PATH} rev_20170522 >${CPLD_20170522_DATA_CPP}
|
||||
DEPENDS ${EXTRACT_CPLD_DATA} ${CPLD_20170522_SVF_PATH}
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
|
@ -27,10 +27,12 @@
|
||||
#include "jtag_target_gpio.hpp"
|
||||
#include "cpld_max5.hpp"
|
||||
#include "cpld_xilinx.hpp"
|
||||
#include "portapack_cpld_data.hpp"
|
||||
#include "hackrf_cpld_data.hpp"
|
||||
|
||||
bool cpld_update_if_necessary() {
|
||||
bool cpld_update_if_necessary(
|
||||
const std::array<uint16_t, 3328>& block_0,
|
||||
const std::array<uint16_t, 512>& block_1
|
||||
) {
|
||||
jtag::GPIOTarget target {
|
||||
portapack::gpio_cpld_tck,
|
||||
portapack::gpio_cpld_tms,
|
||||
@ -63,17 +65,11 @@ bool cpld_update_if_necessary() {
|
||||
}
|
||||
|
||||
/* Verify CPLD contents against current bitstream. */
|
||||
auto ok = cpld.verify(
|
||||
portapack::cpld::block_0,
|
||||
portapack::cpld::block_1
|
||||
);
|
||||
auto ok = cpld.verify(block_0, block_1);
|
||||
|
||||
/* CPLD verifies incorrectly. Erase and program with current bitstream. */
|
||||
if( !ok ) {
|
||||
ok = cpld.program(
|
||||
portapack::cpld::block_0,
|
||||
portapack::cpld::block_1
|
||||
);
|
||||
ok = cpld.program(block_0, block_1);
|
||||
}
|
||||
|
||||
/* If programming OK, reset CPLD to user mode. Otherwise leave it in
|
||||
|
@ -22,7 +22,13 @@
|
||||
#ifndef __CPLD_UPDATE_H__
|
||||
#define __CPLD_UPDATE_H__
|
||||
|
||||
bool cpld_update_if_necessary();
|
||||
#include <cstdint>
|
||||
#include <array>
|
||||
|
||||
bool cpld_update_if_necessary(
|
||||
const std::array<uint16_t, 3328>& block_0,
|
||||
const std::array<uint16_t, 512>& block_1
|
||||
);
|
||||
|
||||
bool cpld_hackrf_load_sram();
|
||||
bool cpld_hackrf_verify_eeprom();
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "portapack.hpp"
|
||||
#include "portapack_hal.hpp"
|
||||
#include "portapack_dma.hpp"
|
||||
#include "portapack_cpld_data.hpp"
|
||||
#include "portapack_persistent_memory.hpp"
|
||||
|
||||
#include "hackrf_hal.hpp"
|
||||
@ -174,8 +175,14 @@ void init() {
|
||||
clock_manager.set_reference_ppb(persistent_memory::correction_ppb());
|
||||
clock_manager.run_at_full_speed();
|
||||
|
||||
if( !cpld_update_if_necessary() ) {
|
||||
chSysHalt();
|
||||
if( portapack_model() == PortaPackModel::R2_20170522 ) {
|
||||
if( !cpld_update_if_necessary(portapack::cpld::rev_20170522::block_0, portapack::cpld::rev_20170522::block_1) ) {
|
||||
chSysHalt();
|
||||
}
|
||||
} else {
|
||||
if( !cpld_update_if_necessary(portapack::cpld::rev_20150901::block_0, portapack::cpld::rev_20150901::block_1) ) {
|
||||
chSysHalt();
|
||||
}
|
||||
}
|
||||
|
||||
if( !cpld_hackrf_load_sram() ) {
|
||||
|
@ -28,8 +28,15 @@
|
||||
namespace portapack {
|
||||
namespace cpld {
|
||||
|
||||
namespace rev_20150901 {
|
||||
extern const std::array<uint16_t, 3328> block_0;
|
||||
extern const std::array<uint16_t, 512> block_1;
|
||||
} /* namespace rev_20150901 */
|
||||
|
||||
namespace rev_20170522 {
|
||||
extern const std::array<uint16_t, 3328> block_0;
|
||||
extern const std::array<uint16_t, 512> block_1;
|
||||
} /* namespace rev_20170522 */
|
||||
|
||||
} /* namespace cpld */
|
||||
} /* namespace portapack */
|
||||
|
@ -25,11 +25,12 @@
|
||||
|
||||
import sys
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
print('Usage: <command> <Altera MAX V CPLD SVF file path>')
|
||||
if len(sys.argv) != 3:
|
||||
print('Usage: <command> <Altera MAX V CPLD SVF file path> <revision name>')
|
||||
sys.exit(-1)
|
||||
|
||||
f = open(sys.argv[1], 'r')
|
||||
revision_name = sys.argv[2]
|
||||
|
||||
calculate_crc = False
|
||||
|
||||
@ -98,7 +99,8 @@ print("""#include "portapack_cpld_data.hpp"
|
||||
|
||||
namespace portapack {
|
||||
namespace cpld {
|
||||
""")
|
||||
namespace %s {
|
||||
""" % revision_name)
|
||||
|
||||
print('const std::array<uint16_t, %d> block_0 { {' % len(block_0))
|
||||
print_block(block_0)
|
||||
@ -111,9 +113,10 @@ print_block(block_1)
|
||||
|
||||
print("""} };
|
||||
|
||||
} /* namespace %s */
|
||||
} /* namespace cpld */
|
||||
} /* namespace portapack */
|
||||
""")
|
||||
""" % revision_name)
|
||||
|
||||
if calculate_crc:
|
||||
# Apply post-programming modification to make post-programming CRC correct:
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -41,7 +41,7 @@ set_global_assignment -name DEVICE 5M40ZE64C5
|
||||
set_global_assignment -name TOP_LEVEL_ENTITY top
|
||||
set_global_assignment -name ORIGINAL_QUARTUS_VERSION 13.1
|
||||
set_global_assignment -name PROJECT_CREATION_TIME_DATE "21:24:55 APRIL 29, 2014"
|
||||
set_global_assignment -name LAST_QUARTUS_VERSION 14.1.0
|
||||
set_global_assignment -name LAST_QUARTUS_VERSION "16.1.2 Lite Edition"
|
||||
set_global_assignment -name PROJECT_OUTPUT_DIRECTORY output_files
|
||||
set_global_assignment -name MIN_CORE_JUNCTION_TEMP 0
|
||||
set_global_assignment -name MAX_CORE_JUNCTION_TEMP 85
|
||||
|
11651
hardware/portapack_h1/cpld/20170522/output_files/portapack_h1_cpld.svf
Normal file
11651
hardware/portapack_h1/cpld/20170522/output_files/portapack_h1_cpld.svf
Normal file
File diff suppressed because it is too large
Load Diff
@ -41,7 +41,7 @@ set_global_assignment -name DEVICE 5M40ZE64C5
|
||||
set_global_assignment -name TOP_LEVEL_ENTITY top
|
||||
set_global_assignment -name ORIGINAL_QUARTUS_VERSION 13.1
|
||||
set_global_assignment -name PROJECT_CREATION_TIME_DATE "21:24:55 APRIL 29, 2014"
|
||||
set_global_assignment -name LAST_QUARTUS_VERSION 14.1.0
|
||||
set_global_assignment -name LAST_QUARTUS_VERSION "16.1.2 Lite Edition"
|
||||
set_global_assignment -name PROJECT_OUTPUT_DIRECTORY output_files
|
||||
set_global_assignment -name MIN_CORE_JUNCTION_TEMP 0
|
||||
set_global_assignment -name MAX_CORE_JUNCTION_TEMP 85
|
||||
|
Loading…
Reference in New Issue
Block a user