Fix T92: kernel modules are build for all kernel headers

general.cpp now compiles on stretch
debian/compat bumped from 7 to 9
This commit is contained in:
Markus Rosenstihl 2018-03-26 15:21:11 +02:00
parent 3f878d9746
commit a05667a7c7
4 changed files with 77 additions and 42 deletions

2
debian/compat vendored
View File

@ -1 +1 @@
7 9

View File

@ -21,31 +21,58 @@ add_custom_command(OUTPUT ${SPC_HEADERS}
# If the "linux" folder exists the driver will be build. # If the "linux" folder exists the driver will be build.
# Alternatively you can set the SPC_SOURCE environment variable to the micx_drv folder # Alternatively you can set the SPC_SOURCE environment variable to the micx_drv folder
if(DEFINED ENV{SPC_SOURCE}) message("\nIf you have signed the NDA from Spectrum and got a kernel driver tarball (i.e. drvsrc_all_V*.tgz), put it in:\n\n\t" ${CMAKE_CURRENT_SOURCE_DIR} "\n\nto get a kernel module built\n")
message(STATUS "SPC_SOURCE environment variable set" $ENV{SPC_SOURCE}) file(GLOB MILIST "drvsrc_all_V*.tgz" )
# sort and select last (alphabetic order) tarball driver
list(SORT MILIST )
list(GET MILIST -1 MITGZ )
message(STATUS ${MITGZ})
if(EXISTS ${MITGZ})
message(STATUS "Using spectrum driver source tarball: " ${MITGZ})
add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/linux/src_all/micx_drv
COMMAND tar xfvz ${MITGZ}
COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/linux/src_all/micx_drv/makefile.kernel26 ${CMAKE_CURRENT_SOURCE_DIR}/linux/src_all/micx_drv/Makefile
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Unpacking Spectrum driver tarball"
VERBATIM)
set(SPC_SRC "${CMAKE_CURRENT_SOURCE_DIR}/linux/src_all/micx_drv")
add_custom_target(spc_smp ALL DEPENDS linux/src_all/micx_drv)
elseif(DEFINED ENV{SPC_SOURCE})
message(STATUS "SPC_SOURCE environment variable set:" $ENV{SPC_SOURCE})
set(SPC_SRC $ENV{SPC_SOURCE}) set(SPC_SRC $ENV{SPC_SOURCE})
else() else()
set(SPC_SRC ${CMAKE_CURRENT_SOURCE_DIR}/linux/src_all/micx_drv) set(SPC_SRC "${CMAKE_CURRENT_SOURCE_DIR}/linux/src_all/micx_drv")
message(WARNING "Spectrum driver source path not defined in envirnoment variable SPC_SOURCE, using default:" ${SPC_SOURCE}) message(WARNING "Spectrum driver source path not defined in envirnoment variable SPC_SOURCE, using default:" ${SPC_SRC})
endif() endif()
set(DRIVER_FILE ${SPC_SRC}/spc_smp.ko )
set(KERNEL_DIR "/lib/modules/${CMAKE_SYSTEM_VERSION}/build" )
set(DRIVER_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
file(GLOB KERNEL_VERSIONS_DIR RELATIVE "/lib/modules" "/lib/modules/*/build")
foreach(KERNEL_DIR ${KERNEL_VERSIONS_DIR})
string(REPLACE "/build" "" KERNEL_VERSION ${KERNEL_DIR})
message(STATUS "Compiling spc_smp.ko for kernel: " ${KERNEL_VERSION})
set(DRIVER_FILE ${KERNEL_VERSION}/spc_smp.ko )
set(KBUILD_CMD ${CMAKE_MAKE_PROGRAM} set(KBUILD_CMD ${CMAKE_MAKE_PROGRAM}
-C ${KERNEL_DIR} -C "/lib/modules/${KERNEL_DIR}"
M=${SPC_SRC} modules) M=${SPC_SRC} modules)
add_custom_command(OUTPUT ${DRIVER_FILE} add_custom_command(OUTPUT ${DRIVER_FILE}
COMMAND ${KBUILD_CMD} COMMAND ${KBUILD_CMD}
COMMENT "Building spc_smp.ko" COMMAND mkdir -p ${DRIVER_DIRECTORY}/${KERNEL_VERSION}
COMMAND mv -fv ${SPC_SRC}/spc_smp.ko ${DRIVER_DIRECTORY}/${KERNEL_VERSION}/spc_smp.ko
COMMENT "Building spc_smp.ko for kernel version: " ${KERNEL_VERSION}
WORKING_DIRECTORY ${SPC_SRC} WORKING_DIRECTORY ${SPC_SRC}
VERBATIM) VERBATIM)
if(EXISTS ${SPC_SRC}) if(EXISTS ${SPC_SRC})
add_custom_target (micx_drv ALL DEPENDS ${DRIVER_FILE} ) add_custom_target (micx_drv_${KERNEL_VERSION} ALL DEPENDS ${DRIVER_FILE} )
install(FILES ${DRIVER_FILE} DESTINATION /lib/modules/${CMAKE_SYSTEM_VERSION}/kernel/damaris) install(FILES ${DRIVER_FILE} DESTINATION /lib/modules/${KERNEL_VERSION}/kernel/damaris)
else() else()
message(WARNING "Spectrum MI40xx kernel driver not found " ${SPC_SRC} " unpack and configure it (i.e. set SPC_SOURCE variable") message(WARNING "Spectrum MI40xx kernel driver not found " ${SPC_SRC} " unpack and configure it (i.e. set SPC_SOURCE variable)")
endif() endif()
endforeach(KERNEL_DIR)
add_library(Spectrum_MI40xxSeries STATIC Spectrum-MI40xxSeries.cpp GatedData.cpp ${SPC_HEADERS}) add_library(Spectrum_MI40xxSeries STATIC Spectrum-MI40xxSeries.cpp GatedData.cpp ${SPC_HEADERS})
add_executable(hw_test_ext hw_test_extclock.cpp GatedData.cpp ${SPC_HEADERS}) add_executable(hw_test_ext hw_test_extclock.cpp GatedData.cpp ${SPC_HEADERS})

View File

@ -1,21 +1,29 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
set(DRIVER_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
file(GLOB KERNEL_VERSIONS_DIR RELATIVE "/lib/modules" "/lib/modules/*/build")
foreach(KERNEL_DIR ${KERNEL_VERSIONS_DIR})
string(REPLACE "/build" "" KERNEL_VERSION ${KERNEL_DIR})
message(STATUS "Compiling pulseblaster.ko for kernel: " ${KERNEL_VERSION})
# Creating pulseblaster kernel module # Creating pulseblaster kernel module
set(DRIVER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/pulseblaster.ko ) set(DRIVER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${KERNEL_VERSION}/pulseblaster.ko )
set(KERNEL_DIR "/lib/modules/${CMAKE_SYSTEM_VERSION}/build" )
set(KBUILD_CMD ${CMAKE_MAKE_PROGRAM} set(KBUILD_CMD ${CMAKE_MAKE_PROGRAM}
-C ${KERNEL_DIR} -C "/lib/modules/${KERNEL_DIR}"
M=${CMAKE_CURRENT_SOURCE_DIR} modules) M=${CMAKE_CURRENT_SOURCE_DIR} modules)
add_custom_command(OUTPUT ${DRIVER_FILE} add_custom_command(OUTPUT ${DRIVER_FILE}
COMMAND ${KBUILD_CMD} COMMAND ${KBUILD_CMD}
# COMMAND cp -f ${DRIVER_FILE} ${DRIVER_BIN_FILE} COMMAND mkdir -p ${KERNEL_VERSION}
COMMENT "Building pulseblaster.ko" COMMAND mv -fv pulseblaster.ko ${DRIVER_FILE}
COMMENT "Building pulseblaster.ko for kernel version: " ${KERNEL_VERSION}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM) VERBATIM)
add_custom_target(pulseblaster_drv ALL DEPENDS ${DRIVER_FILE} ) add_custom_target(pulseblaster_driver_${KERNEL_VERSION} ALL DEPENDS ${DRIVER_FILE} )
install(FILES ${DRIVER_FILE} DESTINATION /lib/modules/${CMAKE_SYSTEM_VERSION}/kernel/damaris) install(FILES ${DRIVER_FILE} DESTINATION /lib/modules/${KERNEL_VERSION}/kernel/damaris)
endforeach(KERNEL_DIR)
#include_directories(..) #include_directories(..)
add_library(SpinCore-PulseBlaster SpinCore-PulseBlaster.cpp) add_library(SpinCore-PulseBlaster SpinCore-PulseBlaster.cpp)
add_library(PulseBlasterProgram PulseBlasterProgram.cpp) add_library(PulseBlasterProgram PulseBlasterProgram.cpp)

View File

@ -98,19 +98,19 @@ public:
ttlout trigger; ttlout trigger;
trigger.id = g_key_file_get_integer(cfg_file, "ADC", "id", &error); trigger.id = g_key_file_get_integer(cfg_file, "ADC", "id", &error);
if (error) if (error)
g_error(error->message); g_error("%s",error->message);
error = NULL; error = NULL;
trigger.ttls = (channel_array) (1 << g_key_file_get_integer(cfg_file, "ADC", "trigger_line", &error)); trigger.ttls = (channel_array) (1 << g_key_file_get_integer(cfg_file, "ADC", "trigger_line", &error));
if (error) if (error)
g_error(error->message); g_error("%s",error->message);
error = NULL; error = NULL;
int ext_reference_clock = (int) g_key_file_get_double(cfg_file, "ADC", "refclock", &error); // 50 MHz from PB24 SP17; defaults to 100MHz (PB24 SP 2) int ext_reference_clock = (int) g_key_file_get_double(cfg_file, "ADC", "refclock", &error); // 50 MHz from PB24 SP17; defaults to 100MHz (PB24 SP 2)
if (error) if (error)
g_error(error->message); g_error("%s",error->message);
error = NULL; error = NULL;
double impedance = g_key_file_get_double(cfg_file, "ADC", "impedance", &error); // Ohm ( or 50 Ohm) double impedance = g_key_file_get_double(cfg_file, "ADC", "impedance", &error); // Ohm ( or 50 Ohm)
if (error) if (error)
g_error(error->message); g_error("%s",error->message);
error = NULL; error = NULL;
my_adc = new SpectrumMI40xxSeries(trigger, (float) impedance, ext_reference_clock); my_adc = new SpectrumMI40xxSeries(trigger, (float) impedance, ext_reference_clock);
@ -118,15 +118,15 @@ public:
/* configure PulseBlaster */ /* configure PulseBlaster */
int pb_id = g_key_file_get_integer(cfg_file, "PB", "id", &error); int pb_id = g_key_file_get_integer(cfg_file, "PB", "id", &error);
if (error) if (error)
g_error(error->message); g_error("%s",error->message);
error = NULL; error = NULL;
double pb_refclock = g_key_file_get_double(cfg_file, "PB", "refclock", &error); double pb_refclock = g_key_file_get_double(cfg_file, "PB", "refclock", &error);
if (error) if (error)
g_error(error->message); g_error("%s",error->message);
error = NULL; error = NULL;
int pb_sync_bit = g_key_file_get_integer(cfg_file, "PB", "sync_line", &error); int pb_sync_bit = g_key_file_get_integer(cfg_file, "PB", "sync_line", &error);
if (error) if (error)
g_error(error->message); g_error("%s",error->message);
error = NULL; error = NULL;
int pb_sync = 0; int pb_sync = 0;
if (pb_sync_bit != 128) { if (pb_sync_bit != 128) {
@ -141,13 +141,13 @@ public:
/* configure PTS */ /* configure PTS */
int pts_id = g_key_file_get_integer(cfg_file, "PTS", "id", &error); int pts_id = g_key_file_get_integer(cfg_file, "PTS", "id", &error);
if (error) if (error)
g_error(error->message); g_error("%s",error->message);
error = NULL; error = NULL;
my_pts = new PTS_latched(pts_id); my_pts = new PTS_latched(pts_id);
// PTS 500 has 0.36 or 0.72 above 200MHz ; PTS 310 has 0.225 degrees/step // PTS 500 has 0.36 or 0.72 above 200MHz ; PTS 310 has 0.225 degrees/step
my_pts->phase_step = (float) g_key_file_get_double(cfg_file, "PTS", "phase_stepsize", &error); my_pts->phase_step = (float) g_key_file_get_double(cfg_file, "PTS", "phase_stepsize", &error);
if (error) if (error)
g_error(error->message); g_error("%s",error->message);
error = NULL; error = NULL;
// publish devices // publish devices