resolved conflicts and merged jboone:firmware_cmake

This commit is contained in:
Michael Ossmann
2014-11-04 17:53:42 -07:00
25 changed files with 549 additions and 485 deletions

2
.gitignore vendored
View File

@ -64,3 +64,5 @@ firmware/cpld/**/*.xrpt
firmware/cpld/**/*.xsl
firmware/cpld/**/*.xst
firmware/cpld/**/*.xwbt
firmware/**/build

View File

@ -1,5 +1,3 @@
# Hey Emacs, this is a -*- makefile -*-
#
# Copyright 2012 Jared Boone <jared@sharebrained.com>
#
# This file is part of HackRF.
@ -20,16 +18,19 @@
# Boston, MA 02110-1301, USA.
#
BINARY = sgpio-rx
# Top directory CMake project for HackRF firmware
SRC = $(BINARY).c \
../common/hackrf_core.c \
../common/tuning.c \
../common/rf_path.c \
../common/sgpio.c \
../common/si5351c.c \
../common/max2837.c \
../common/max5864.c \
../common/rffc5071.c
cmake_minimum_required(VERSION 2.8.9)
set(CMAKE_TOOLCHAIN_FILE toolchain-arm-cortex-m.cmake)
include ../common/Makefile_inc.mk
project (hackrf_firmware_all)
add_subdirectory(blinky)
add_subdirectory(mixertx)
add_subdirectory(sgpio)
add_subdirectory(sgpio-rx)
add_subdirectory(simpletx)
add_subdirectory(startup)
add_subdirectory(startup_systick)
add_subdirectory(startup_systick_perfo)
add_subdirectory(hackrf_usb)

View File

@ -1,54 +0,0 @@
# Hey Emacs, this is a -*- makefile -*-
#
# Copyright 2012 Jared Boone <jared@sharebrained.com>
#
# This file is part of HackRF.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
TARGETS = blinky \
mixertx \
sgpio \
sgpio-rx \
simpletx \
startup \
startup_systick \
startup_systick_perfo \
hackrf_usb
all: build
build: examples
examples:
$(Q)for i in $(TARGETS); do \
if [ -d $$i ]; then \
printf " BUILD $$i\n"; \
$(MAKE) -C $$i || exit $?; \
fi; \
done
clean:
$(Q)for i in $(addprefix lib/,$(TARGETS)) \
$(TARGETS); do \
if [ -d $$i ]; then \
printf " CLEAN $$i\n"; \
$(MAKE) -C $$i clean || exit $?; \
fi; \
done
.PHONY: build examples

View File

@ -25,10 +25,13 @@ $ make
To build and install a standard firmware image for HackRF One:
$ cd hackrf_usb
$ make -e BOARD=HACKRF_ONE
$ hackrf_spiflash -w hackrf_usb_rom_to_ram.bin
$ mkdir build
$ cd build
$ cmake .. -DBOARD=HACKRF_ONE
$ make
$ hackrf_spiflash -w hackrf_usb.bin
If you have a Jawbreaker, use BOARD=JAWBREAKER instead.
If you have a Jawbreaker, use -DBOARD=JAWBREAKER instead.
For loading firmware into RAM with DFU you will also need:
@ -43,7 +46,10 @@ With dfu-util and dfu-suffix (from the dfu-util package) installed and with the
HackRF operating in DFU mode, you can build firmware for RAM and load it with:
$ cd hackrf_usb
$ make -e BOARD=HACKRF_ONE RUN_FROM=RAM program
$ mkdir build
$ cd build
$ cmake .. -DRUN_FROM=RAM
$ make program
Alternatively you can load a .dfu file from a release package with:

View File

@ -1,5 +1,3 @@
# Hey Emacs, this is a -*- makefile -*-
#
# Copyright 2012 Michael Ossmann <mike@ossmann.com>
# Copyright 2012 Jared Boone <jared@sharebrained.com>
#
@ -21,13 +19,15 @@
# Boston, MA 02110-1301, USA.
#
BINARY = spiflash
cmake_minimum_required(VERSION 2.8.9)
set(CMAKE_TOOLCHAIN_FILE ../toolchain-arm-cortex-m.cmake)
SRC = $(BINARY).c \
../common/hackrf_core.c \
../common/sgpio.c \
../common/si5351c.c \
../common/max2837.c \
../common/w25q80bv.c
project(blinky)
include ../common/Makefile_inc.mk
include(../hackrf-common.cmake)
set(SRC_M4
blinky.c
)
DeclareTargets()

View File

@ -1,238 +0,0 @@
# Hey Emacs, this is a -*- makefile -*-
#
# Copyright 2009 Uwe Hermann <uwe@hermann-uwe.de>
# Copyright 2010 Piotr Esden-Tempski <piotr@esden.net>
# Copyright 2012 Michael Ossmann <mike@ossmann.com>
# Copyright 2012 Benjamin Vernoux <titanmkd@gmail.com>
# Copyright 2012 Jared Boone <jared@sharebrained.com>
#
# This file is part of HackRF.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
# derived primarily from Makefiles in libopencm3
BOARD ?= HACKRF_ONE
RUN_FROM ?= SPIFI
ifeq ($(BOARD),HACKRF_ONE)
MCU_PARTNO=LPC4320
else
MCU_PARTNO=LPC4330
endif
HACKRF_OPTS = -D$(BOARD) -DLPC43XX -D$(MCU_PARTNO)
# comment to disable RF transmission
HACKRF_OPTS += -DTX_ENABLE
# automatic git version when working out of git
VERSION_STRING ?= -D'VERSION_STRING="git-$(shell git log -n 1 --format=%h)"'
HACKRF_OPTS += $(VERSION_STRING)
PATH_HACKRF ?= ../..
PATH_HACKRF_FIRMWARE = $(PATH_HACKRF)/firmware
PATH_HACKRF_FIRMWARE_COMMON = $(PATH_HACKRF_FIRMWARE)/common
LIBOPENCM3 ?= $(PATH_HACKRF_FIRMWARE)/libopencm3
VPATH += $(PATH_HACKRF_FIRMWARE_COMMON)/xapp058
VPATH += $(PATH_HACKRF_FIRMWARE_COMMON)
SRC_M4_C ?= $(SRC)
SRC_M0_C ?= $(PATH_HACKRF_FIRMWARE_COMMON)/m0_sleep.c
BUILD_DIR = build
OBJDIR_M4 = $(BUILD_DIR)/m4
OBJDIR_M0 = $(BUILD_DIR)/m0
OBJ_M4_C = $(patsubst %.c, $(OBJDIR_M4)/%.o, $(notdir $(SRC_M4_C)))
OBJ_M4_S = $(patsubst %.s, $(OBJDIR_M4)/%.o, $(notdir $(SRC_M4_S)))
OBJ_M0_C = $(patsubst %.c, $(OBJDIR_M0)/%.o, $(notdir $(SRC_M0_C)))
OBJ_M0_S = $(patsubst %.s, $(OBJDIR_M0)/%.o, $(notdir $(SRC_M0_S)))
LDSCRIPT_M4 += -T$(PATH_HACKRF_FIRMWARE_COMMON)/$(MCU_PARTNO)_M4_memory.ld
ifeq ($(RUN_FROM),RAM)
LDSCRIPT_M4 += -Tlibopencm3_lpc43xx.ld
else
LDSCRIPT_M4 += -Tlibopencm3_lpc43xx_rom_to_ram.ld
endif
LDSCRIPT_M4 += -T$(PATH_HACKRF_FIRMWARE_COMMON)/LPC43xx_M4_M0_image_from_text.ld
LDSCRIPT_M0 += -T$(PATH_HACKRF_FIRMWARE_COMMON)/LPC43xx_M0_memory.ld
LDSCRIPT_M0 += -Tlibopencm3_lpc43xx_m0.ld
PREFIX ?= arm-none-eabi
CC = $(PREFIX)-gcc
LD = $(PREFIX)-gcc
OBJCOPY = $(PREFIX)-objcopy
OBJDUMP = $(PREFIX)-objdump
GDB = $(PREFIX)-gdb
TOOLCHAIN_DIR := $(shell dirname `which $(CC)`)/../$(PREFIX)
CFLAGS_COMMON += -std=gnu99 -Os -g3 -Wall -Wextra -I$(LIBOPENCM3)/include -I$(PATH_HACKRF_FIRMWARE_COMMON) \
$(HACKRF_OPTS) -fno-common -mthumb -MD
LDFLAGS_COMMON += -mthumb \
-L$(PATH_HACKRF_FIRMWARE_COMMON) \
-L$(LIBOPENCM3)/lib -L$(LIBOPENCM3)/lib/lpc43xx \
-nostartfiles \
-Wl,--gc-sections \
-lc -lnosys
CFLAGS_M0 += -mcpu=cortex-m0 -DLPC43XX_M0
LDFLAGS_M0 += -mcpu=cortex-m0 -DLPC43XX_M0
LDFLAGS_M0 += $(LDSCRIPT_M0)
LDFLAGS_M0 += --specs=nano.specs
LDFLAGS_M0 += -Xlinker -Map=$(OBJDIR_M0)/m0.map
LDFLAGS_M0 += -lopencm3_lpc43xx_m0
CFLAGS_M4 += -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -DLPC43XX_M4
LDFLAGS_M4 += -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -DLPC43XX_M4
LDFLAGS_M4 += -L$(TOOLCHAIN_DIR)/lib/armv7e-m/fpu
LDFLAGS_M4 += $(LDSCRIPT_M4)
LDFLAGS_M4 += -Xlinker -Map=$(OBJDIR_M4)/m4.map
LDFLAGS_M4 += -lopencm3_lpc43xx -lm
# Be silent per default, but 'make V=1' will show all compiler calls.
ifneq ($(V),1)
Q := @
NULL := 2>/dev/null
else
LDFLAGS_COMMON += -Wl,--print-gc-sections
endif
.SUFFIXES: .elf .bin .hex .srec .list .images
.SECONDEXPANSION:
.SECONDARY:
all: images
images: $(BINARY).images
flash: $(BINARY).flash
program: $(BINARY).dfu
$(Q)dfu-util --device 1fc9:000c --alt 0 --download $(BINARY).dfu
$(BINARY).images: $(BINARY).bin $(BINARY).hex $(BINARY).srec $(BINARY).list
@#echo "*** $* images generated ***"
$(BINARY).dfu: $(BINARY).bin
$(Q)rm -f _tmp.dfu _header.bin
$(Q)cp $(BINARY).bin _tmp.dfu
$(Q)dfu-suffix --vid=0x1fc9 --pid=0x000c --did=0x0 -s 0 -a _tmp.dfu
$(Q)python -c "import os.path; import struct; print('0000000: da ff ' + ' '.join(map(lambda s: '%02x' % ord(s), struct.pack('<H', os.path.getsize('$(BINARY).bin') / 512 + 1))) + ' ff ff ff ff')" | xxd -g1 -r > _header.bin
$(Q)cat _header.bin _tmp.dfu >$(BINARY).dfu
$(Q)rm -f _tmp.dfu _header.bin
$(BINARY).bin: $(BINARY).elf
@#printf " OBJCOPY $(*).bin\n"
$(Q)$(OBJCOPY) -Obinary $(BINARY).elf $(BINARY).bin
$(OBJDIR_M0)/m0.bin: $(OBJDIR_M0)/m0.elf
@#printf " OBJCOPY $(*).bin\n"
$(Q)$(OBJCOPY) -Obinary $(OBJDIR_M0)/m0.elf $(OBJDIR_M0)/m0.bin
#$(OBJDIR_M0)/m0.o: $(OBJDIR_M0)/m0.bin
# $(Q)$(OBJCOPY) -I binary -B arm -O elf32-littlearm $(OBJDIR_M0)/m0.bin $(OBJDIR_M0)/m0.o
$(BINARY).hex: $(BINARY).elf
@#printf " OBJCOPY $(BINARY).hex\n"
$(Q)$(OBJCOPY) -Oihex $(BINARY).elf $(BINARY).hex
$(BINARY).srec: $(BINARY).elf
@#printf " OBJCOPY $(BINARY).srec\n"
$(Q)$(OBJCOPY) -Osrec $(BINARY).elf $(BINARY).srec
$(BINARY).list: $(BINARY).elf
@#printf " OBJDUMP $(BINARY).list\n"
$(Q)$(OBJDUMP) -S $(BINARY).elf > $(BINARY).list
$(BINARY).elf: obj_m4
@#printf " LD $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(LD) -o $(BINARY).elf $(OBJ_M4_C) $(OBJ_M4_S) $(OBJDIR_M4)/m0_bin.o $(LDFLAGS_COMMON) $(LDFLAGS_M4)
$(OBJDIR_M0)/m0.elf: obj_m0
@#printf " LD $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(LD) -o $(OBJDIR_M0)/m0.elf $(OBJ_M0_C) $(OBJ_M0_S) $(LDFLAGS_COMMON) $(LDFLAGS_M0)
obj_m4: $(OBJ_M4_C) $(OBJ_M4_S) $(OBJDIR_M4)/m0_bin.o
obj_m0: $(OBJ_M0_C) $(OBJ_M0_S)
$(OBJDIR_M4)/%.o: %.c | $(OBJDIR_M4)
@printf " CC $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(CC) $(CFLAGS_COMMON) $(CFLAGS_M4) -o $@ -c $<
$(OBJDIR_M4)/%.o: %.s | $(OBJDIR_M4)
@printf " CC $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(CC) $(CFLAGS_COMMON) $(CFLAGS_M4) -o $@ -c $<
$(OBJDIR_M4)/m0_bin.o: m0_bin.s $(OBJDIR_M0)/m0.bin | $(OBJDIR_M4)
@printf " CC $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(CC) $(CFLAGS_COMMON) $(CFLAGS_M4) -o $@ -c $<
$(OBJDIR_M0)/%.o: %.c | $(OBJDIR_M0)
@printf " CC $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(CC) $(CFLAGS_COMMON) $(CFLAGS_M0) -o $@ -c $<
$(OBJDIR_M0)/%.o: %.s | $(OBJDIR_M0)
@printf " CC $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(CC) $(CFLAGS_COMMON) $(CFLAGS_M0) -o $@ -c $<
$(OBJDIR_M4):
$(Q)mkdir -p $@
$(OBJDIR_M0):
$(Q)mkdir -p $@
clean:
$(Q)rm -f *.o
$(Q)rm -f *.d
$(Q)rm -f *.elf
$(Q)rm -f *.bin
$(Q)rm -f *.dfu
$(Q)rm -f _tmp.dfu _header.bin
$(Q)rm -f *.hex
$(Q)rm -f *.srec
$(Q)rm -f *.list
$(Q)rm -f *.map
$(Q)rm -f *.lst
$(Q)rm -f $(PATH_HACKRF_FIRMWARE)/hackrf_usb/*.o
$(Q)rm -f $(PATH_HACKRF_FIRMWARE)/hackrf_usb/*.d
$(Q)rm -f $(PATH_HACKRF_FIRMWARE)/hackrf_usb/*.lst
$(Q)rm -f $(PATH_HACKRF_FIRMWARE_COMMON)/*.o
$(Q)rm -f $(PATH_HACKRF_FIRMWARE_COMMON)/*.d
$(Q)rm -f $(PATH_HACKRF_FIRMWARE_COMMON)/*.lst
$(Q)rm -f $(PATH_HACKRF_FIRMWARE_COMMON)/xapp058/*.o
$(Q)rm -f $(PATH_HACKRF_FIRMWARE_COMMON)/xapp058/*.d
$(Q)rm -f $(OBJDIR_M4)/*.o
$(Q)rm -f $(OBJDIR_M4)/*.d
$(Q)rm -f $(OBJDIR_M4)/*.elf
$(Q)rm -f $(OBJDIR_M4)/*.bin
$(Q)rm -f $(OBJDIR_M4)/*.map
$(Q)rm -f $(OBJDIR_M0)/*.o
$(Q)rm -f $(OBJDIR_M0)/*.d
$(Q)rm -f $(OBJDIR_M0)/*.elf
$(Q)rm -f $(OBJDIR_M0)/*.bin
$(Q)rm -f $(OBJDIR_M0)/*.map
$(Q)rm -rf $(BUILD_DIR)
.PHONY: images clean
-include $(OBJ_M4_C:.o=.d)
-include $(OBJ_M0_C:.o=.d)

View File

@ -20,4 +20,4 @@
.data
.section .m0_bin, "ax"
.incbin "build/m0/m0.bin"
.incbin "${PROJECT_NAME}_m0.bin"

View File

@ -0,0 +1,178 @@
# Copyright 2009 Uwe Hermann <uwe@hermann-uwe.de>
# Copyright 2010 Piotr Esden-Tempski <piotr@esden.net>
# Copyright 2012 Michael Ossmann <mike@ossmann.com>
# Copyright 2012 Benjamin Vernoux <titanmkd@gmail.com>
# Copyright 2012 Jared Boone <jared@sharebrained.com>
#
# This file is part of HackRF.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
# derived primarily from Makefiles in libopencm3
enable_language(C CXX ASM)
SET(PATH_HACKRF ../..)
SET(PATH_HACKRF_FIRMWARE ${PATH_HACKRF}/firmware)
SET(PATH_HACKRF_FIRMWARE_COMMON ${PATH_HACKRF_FIRMWARE}/common)
SET(LIBOPENCM3 ${PATH_HACKRF_FIRMWARE}/libopencm3)
execute_process(
COMMAND git log -n 1 --format=%h
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE GIT_VERSION_FOUND
ERROR_QUIET
OUTPUT_VARIABLE GIT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (GIT_VERSION_FOUND)
set(VERSION "unknown")
else (GIT_VERSION_FOUND)
set(VERSION ${GIT_VERSION})
endif (GIT_VERSION_FOUND)
if(NOT DEFINED BOARD)
set(BOARD HACKRF_ONE)
endif()
if(NOT DEFINED RUN_FROM)
set(RUN_FROM SPIFI)
endif()
if(BOARD STREQUAL "HACKRF_ONE")
set(MCU_PARTNO LPC4320)
else()
set(MCU_PARTNO LPC4330)
endif()
if(NOT DEFINED SRC_M0)
set(SRC_M0 "${PATH_HACKRF_FIRMWARE_COMMON}/m0_sleep.c")
endif()
SET(HACKRF_OPTS "-D${BOARD} -DLPC43XX -D${MCU_PARTNO} -DTX_ENABLE -D'VERSION_STRING=\"git-${VERSION}\"' -DRUN_FROM=${RUN_FROM}")
SET(LDSCRIPT_M4 "-T${PATH_HACKRF_FIRMWARE_COMMON}/${MCU_PARTNO}_M4_memory.ld")
if( RUN_FROM STREQUAL "RAM")
SET(LDSCRIPT_M4 "${LDSCRIPT_M4} -Tlibopencm3_lpc43xx.ld")
else()
SET(LDSCRIPT_M4 "${LDSCRIPT_M4} -Tlibopencm3_lpc43xx_rom_to_ram.ld")
endif()
SET(LDSCRIPT_M4 "${LDSCRIPT_M4} -T${PATH_HACKRF_FIRMWARE_COMMON}/LPC43xx_M4_M0_image_from_text.ld")
SET(LDSCRIPT_M0 "-T${PATH_HACKRF_FIRMWARE_COMMON}/LPC43xx_M0_memory.ld -Tlibopencm3_lpc43xx_m0.ld")
SET(CFLAGS_COMMON "-Os -g3 -Wall -Wextra ${HACKRF_OPTS} ${COMMON_FLAGS} -fno-common -MD")
SET(LDFLAGS_COMMON "-nostartfiles -Wl,--gc-sections")
if(V STREQUAL "1")
SET(LDFLAGS_COMMON "${LDFLAGS_COMMON} -Wl,--print-gc-sections")
endif()
SET(CPUFLAGS_M0 "-mthumb -mcpu=cortex-m0 -mfloat-abi=soft")
SET(CFLAGS_M0 "-std=gnu99 ${CFLAGS_COMMON} ${CPUFLAGS_M0} -DLPC43XX_M0")
SET(CXXFLAGS_M0 "-std=gnu++0x ${CFLAGS_COMMON} ${CPUFLAGS_M0} -DLPC43XX_M0")
SET(LDFLAGS_M0 "${LDFLAGS_COMMON} ${CPUFLAGS_M0} ${LDSCRIPT_M0} -Xlinker -Map=m0.map --specs=nano.specs")
SET(CPUFLAGS_M4 "-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16")
SET(CFLAGS_M4 "-std=gnu99 ${CFLAGS_COMMON} ${CPUFLAGS_M4} -DLPC43XX_M4")
SET(CXXFLAGS_M4 "-std=gnu++0x ${CFLAGS_COMMON} ${CPUFLAGS_M4} -DLPC43XX_M4")
SET(LDFLAGS_M4 "${LDFLAGS_COMMON} ${CPUFLAGS_M4} ${LDSCRIPT_M4} -Xlinker -Map=m4.map")
set(BUILD_SHARED_LIBS OFF)
include_directories("${LIBOPENCM3}/include/")
include_directories("${PATH_HACKRF_FIRMWARE_COMMON}")
macro(DeclareTargets)
configure_file(
${PATH_HACKRF_FIRMWARE_COMMON}/m0_bin.s.cmake
m0_bin.s
)
link_directories(
"${PATH_HACKRF_FIRMWARE_COMMON}"
"${LIBOPENCM3}/lib"
"${LIBOPENCM3}/lib/lpc43xx"
"${CMAKE_INSTALL_PREFIX}/lib/armv7e-m/fpu"
)
add_executable(${PROJECT_NAME}_m0.elf ${SRC_M0})
target_link_libraries(
${PROJECT_NAME}_m0.elf
c
nosys
opencm3_lpc43xx_m0
)
set_target_properties(${PROJECT_NAME}_m0.elf PROPERTIES COMPILE_FLAGS "${CFLAGS_M0}")
set_target_properties(${PROJECT_NAME}_m0.elf PROPERTIES LINK_FLAGS "${LDFLAGS_M0}")
add_custom_target(
${PROJECT_NAME}_m0.bin
DEPENDS ${PROJECT_NAME}_m0.elf
COMMAND ${CMAKE_OBJCOPY} -Obinary ${PROJECT_NAME}_m0.elf ${PROJECT_NAME}_m0.bin
)
add_executable(${PROJECT_NAME}.elf
${SRC_M4}
${PATH_HACKRF_FIRMWARE_COMMON}/hackrf_core.c
${PATH_HACKRF_FIRMWARE_COMMON}/sgpio.c
${PATH_HACKRF_FIRMWARE_COMMON}/rf_path.c
${PATH_HACKRF_FIRMWARE_COMMON}/si5351c.c
${PATH_HACKRF_FIRMWARE_COMMON}/max2837.c
${PATH_HACKRF_FIRMWARE_COMMON}/max5864.c
${PATH_HACKRF_FIRMWARE_COMMON}/rffc5071.c
m0_bin.s
)
add_dependencies(${PROJECT_NAME}.elf ${PROJECT_NAME}_m0.bin)
target_link_libraries(
${PROJECT_NAME}.elf
c
nosys
opencm3_lpc43xx
m
)
set_target_properties(${PROJECT_NAME}.elf PROPERTIES COMPILE_FLAGS "${CFLAGS_M4}")
set_target_properties(${PROJECT_NAME}.elf PROPERTIES LINK_FLAGS "${LDFLAGS_M4}")
add_custom_target(
${PROJECT_NAME}.bin
DEPENDS ${PROJECT_NAME}.elf
COMMAND ${CMAKE_OBJCOPY} -Obinary ${PROJECT_NAME}.elf ${PROJECT_NAME}.bin
)
add_custom_target(
${PROJECT_NAME}.dfu ALL
DEPENDS ${PROJECT_NAME}.bin
COMMAND rm -f _tmp.dfu _header.bin
COMMAND cp ${PROJECT_NAME}.bin _tmp.dfu
COMMAND dfu-suffix --vid=0x1fc9 --pid=0x000c --did=0x0 -s 0 -a _tmp.dfu
COMMAND python -c \"import os.path\; import struct\; print\('0000000: da ff ' + ' '.join\(map\(lambda s: '%02x' % ord\(s\), struct.pack\('<H', os.path.getsize\('${PROJECT_NAME}.bin'\) / 512 + 1\)\)\) + ' ff ff ff ff'\)\" | xxd -g1 -r > _header.bin
COMMAND cat _header.bin _tmp.dfu >${PROJECT_NAME}.dfu
COMMAND rm -f _tmp.dfu _header.bin
)
add_custom_target(
${PROJECT_NAME}-program
DEPENDS ${PROJECT_NAME}.dfu
COMMAND dfu-util --device 1fc9:000c --alt 0 --download ${PROJECT_NAME}.dfu
)
endmacro()

View File

@ -0,0 +1,55 @@
# Copyright 2012 Jared Boone <jared@sharebrained.com>
#
# This file is part of HackRF.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
cmake_minimum_required(VERSION 2.8.9)
set(CMAKE_TOOLCHAIN_FILE ../toolchain-arm-cortex-m.cmake)
project(hackrf_usb)
include(../hackrf-common.cmake)
set(SRC_M4
hackrf_usb.c
"${PATH_HACKRF_FIRMWARE_COMMON}/tuning.c"
"${PATH_HACKRF_FIRMWARE_COMMON}/streaming.c"
sgpio_isr.c
usb_bulk_buffer.c
"${PATH_HACKRF_FIRMWARE_COMMON}/usb.c"
"${PATH_HACKRF_FIRMWARE_COMMON}/usb_request.c"
"${PATH_HACKRF_FIRMWARE_COMMON}/usb_standard_request.c"
usb_descriptor.c
usb_device.c
usb_endpoint.c
usb_api_board_info.c
usb_api_cpld.c
usb_api_register.c
usb_api_spiflash.c
usb_api_transceiver.c
"${PATH_HACKRF_FIRMWARE_COMMON}/usb_queue.c"
"${PATH_HACKRF_FIRMWARE_COMMON}/fault_handler.c"
"${PATH_HACKRF_FIRMWARE_COMMON}/w25q80bv.c"
"${PATH_HACKRF_FIRMWARE_COMMON}/cpld_jtag.c"
"${PATH_HACKRF_FIRMWARE_COMMON}/xapp058/lenval.c"
"${PATH_HACKRF_FIRMWARE_COMMON}/xapp058/micro.c"
"${PATH_HACKRF_FIRMWARE_COMMON}/xapp058/ports.c"
"${PATH_HACKRF_FIRMWARE_COMMON}/rom_iap.c"
)
DeclareTargets()

View File

@ -1,61 +0,0 @@
# Hey Emacs, this is a -*- makefile -*-
#
# Copyright 2012 Jared Boone <jared@sharebrained.com>
#
# This file is part of HackRF.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
ifeq ($(RUN_FROM),RAM)
BINARY = hackrf_usb_ram
else
BINARY = hackrf_usb_rom_to_ram
endif
SRC_M4_C = hackrf_usb.c \
../common/rf_path.c \
../common/tuning.c \
../common/streaming.c \
sgpio_isr.c \
usb_bulk_buffer.c \
../common/usb.c \
../common/usb_request.c \
../common/usb_standard_request.c \
usb_descriptor.c \
usb_device.c \
usb_endpoint.c \
usb_api_board_info.c \
usb_api_cpld.c \
usb_api_register.c \
usb_api_spiflash.c \
usb_api_transceiver.c \
../common/usb_queue.c \
../common/fault_handler.c \
../common/hackrf_core.c \
../common/sgpio.c \
../common/si5351c.c \
../common/max2837.c \
../common/max5864.c \
../common/rffc5071.c \
../common/w25q80bv.c \
../common/cpld_jtag.c \
../common/xapp058/lenval.c \
../common/xapp058/micro.c \
../common/xapp058/ports.c \
../common/rom_iap.c
include ../common/Makefile_inc.mk

View File

@ -0,0 +1,32 @@
# Copyright 2014 Jared Boone <jared@sharebrained.com>
#
# This file is part of HackRF.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
cmake_minimum_required(VERSION 2.8.9)
set(CMAKE_TOOLCHAIN_FILE ../toolchain-arm-cortex-m.cmake)
project(mixertx)
include(../hackrf-common.cmake)
set(SRC_M4
mixertx.c
)
DeclareTargets()

View File

@ -1,14 +0,0 @@
# Hey Emacs, this is a -*- makefile -*-
BINARY = mixertx
SRC = $(BINARY).c \
../common/hackrf_core.c \
../common/rf_path.c \
../common/sgpio.c \
../common/si5351c.c \
../common/max2837.c \
../common/max5864.c \
../common/rffc5071.c
include ../common/Makefile_inc.mk

View File

@ -1,5 +1,3 @@
# Hey Emacs, this is a -*- makefile -*-
#
# Copyright 2012 Jared Boone <jared@sharebrained.com>
#
# This file is part of HackRF.
@ -20,15 +18,16 @@
# Boston, MA 02110-1301, USA.
#
BINARY = sgpio_test
cmake_minimum_required(VERSION 2.8.9)
set(CMAKE_TOOLCHAIN_FILE ../toolchain-arm-cortex-m.cmake)
SRC = $(BINARY).c \
../common/hackrf_core.c \
../common/rf_path.c \
../common/sgpio.c \
../common/si5351c.c \
../common/max2837.c \
../common/max5864.c \
../common/rffc5071.c
project(sgpio-rx)
include ../common/Makefile_inc.mk
include(../hackrf-common.cmake)
set(SRC_M4
sgpio-rx.c
${PATH_HACKRF_FIRMWARE_COMMON}/tuning.c
)
DeclareTargets()

View File

@ -0,0 +1,32 @@
# Copyright 2012 Jared Boone <jared@sharebrained.com>
#
# This file is part of HackRF.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
cmake_minimum_required(VERSION 2.8.9)
set(CMAKE_TOOLCHAIN_FILE ../toolchain-arm-cortex-m.cmake)
project(sgpio_test)
include(../hackrf-common.cmake)
set(SRC_M4
sgpio_test.c
)
DeclareTargets()

View File

@ -1,5 +1,3 @@
# Hey Emacs, this is a -*- makefile -*-
#
# Copyright 2012 Jared Boone <jared@sharebrained.com>
# Copyright 2012 Benjamin Vernoux <titanmkd@gmail.com>
#
@ -21,12 +19,15 @@
# Boston, MA 02110-1301, USA.
#
BINARY = sgpio_passthrough
cmake_minimum_required(VERSION 2.8.9)
set(CMAKE_TOOLCHAIN_FILE ../toolchain-arm-cortex-m.cmake)
SRC = $(BINARY).c \
../common/hackrf_core.c \
../common/sgpio.c \
../common/si5351c.c \
../common/max2837.c
project(sgpio_passthrough)
include ../common/Makefile_inc.mk
include(../hackrf-common.cmake)
set(SRC_M4
sgpio_passthrough.c
)
DeclareTargets()

View File

@ -0,0 +1,32 @@
# Copyright 2014 Jared Boone <jared@sharebrained.com>
#
# This file is part of HackRF.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
cmake_minimum_required(VERSION 2.8.9)
set(CMAKE_TOOLCHAIN_FILE ../toolchain-arm-cortex-m.cmake)
project(simpletx)
include(../hackrf-common.cmake)
set(SRC_M4
simpletx.c
)
DeclareTargets()

View File

@ -1,14 +0,0 @@
# Hey Emacs, this is a -*- makefile -*-
BINARY = simpletx
SRC = $(BINARY).c \
../common/hackrf_core.c \
../common/rf_path.c \
../common/sgpio.c \
../common/si5351c.c \
../common/max2837.c \
../common/max5864.c \
../common/rffc5071.c
include ../common/Makefile_inc.mk

View File

@ -1,5 +1,3 @@
# Hey Emacs, this is a -*- makefile -*-
#
# Copyright 2012 Michael Ossmann <mike@ossmann.com>
# Copyright 2012 Jared Boone <jared@sharebrained.com>
#
@ -21,15 +19,16 @@
# Boston, MA 02110-1301, USA.
#
BINARY = blinky
cmake_minimum_required(VERSION 2.8.9)
set(CMAKE_TOOLCHAIN_FILE ../toolchain-arm-cortex-m.cmake)
SRC = $(BINARY).c \
../common/hackrf_core.c \
../common/sgpio.c \
../common/rf_path.c \
../common/si5351c.c \
../common/max2837.c \
../common/max5864.c \
../common/rffc5071.c
project(spiflash)
include ../common/Makefile_inc.mk
include(../hackrf-common.cmake)
set(SRC_M4
spiflash.c
"${PATH_HACKRF_FIRMWARE_COMMON}/w25q80bv.c"
)
DeclareTargets()

View File

@ -0,0 +1,32 @@
# Copyright 2014 Jared Boone <jared@sharebrained.com>
#
# This file is part of HackRF.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
cmake_minimum_required(VERSION 2.8.9)
set(CMAKE_TOOLCHAIN_FILE ../toolchain-arm-cortex-m.cmake)
project(startup)
include(../hackrf-common.cmake)
set(SRC_M4
startup.c
)
DeclareTargets()

View File

@ -1,14 +0,0 @@
# Hey Emacs, this is a -*- makefile -*-
BINARY = startup
SRC = $(BINARY).c \
../common/hackrf_core.c \
../common/rf_path.c \
../common/sgpio.c \
../common/si5351c.c \
../common/max2837.c \
../common/max5864.c \
../common/rffc5071.c
include ../common/Makefile_inc.mk

View File

@ -0,0 +1,32 @@
# Copyright 2014 Jared Boone <jared@sharebrained.com>
#
# This file is part of HackRF.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
cmake_minimum_required(VERSION 2.8.9)
set(CMAKE_TOOLCHAIN_FILE ../toolchain-arm-cortex-m.cmake)
project(startup_systick)
include(../hackrf-common.cmake)
set(SRC_M4
startup_systick.c
)
DeclareTargets()

View File

@ -1,14 +0,0 @@
# Hey Emacs, this is a -*- makefile -*-
BINARY = startup_systick
SRC = $(BINARY).c \
../common/hackrf_core.c \
../common/rf_path.c \
../common/sgpio.c \
../common/si5351c.c \
../common/max2837.c \
../common/max5864.c \
../common/rffc5071.c
include ../common/Makefile_inc.mk

View File

@ -0,0 +1,33 @@
# Copyright 2014 Jared Boone <jared@sharebrained.com>
#
# This file is part of HackRF.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
cmake_minimum_required(VERSION 2.8.9)
set(CMAKE_TOOLCHAIN_FILE ../toolchain-arm-cortex-m.cmake)
project(startup_systick_perfo_SPIFI)
include(../hackrf-common.cmake)
set(SRC_M4
startup_systick.c
perf_mips.c
)
DeclareTargets()

View File

@ -1,15 +0,0 @@
# Hey Emacs, this is a -*- makefile -*-
BINARY = startup_systick_perfo_SPIFI
SRC = startup_systick.c \
perf_mips.c \
../common/hackrf_core.c \
../common/rf_path.c \
../common/sgpio.c \
../common/si5351c.c \
../common/max2837.c \
../common/max5864.c \
../common/rffc5071.c
include ../common/Makefile_inc.mk

View File

@ -0,0 +1,54 @@
# Copyright 2014 Jared Boone <jared@sharebrained.com>
#
# This file is part of HackRF.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR arm)
include(CMakeForceCompiler)
CMAKE_FORCE_C_COMPILER(arm-none-eabi-gcc GNU)
CMAKE_FORCE_CXX_COMPILER(arm-none-eabi-g++ GNU)
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-file-name=libc.a
OUTPUT_VARIABLE CMAKE_INSTALL_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
get_filename_component(CMAKE_INSTALL_PREFIX
"${CMAKE_INSTALL_PREFIX}" PATH
)
get_filename_component(CMAKE_INSTALL_PREFIX
"${CMAKE_INSTALL_PREFIX}/.." REALPATH
)
set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE FILEPATH
"Install path prefix, prepended onto install directories.")
message(STATUS "Cross-compiling with the gcc-arm-embedded toolchain")
message(STATUS "Toolchain prefix: ${CMAKE_INSTALL_PREFIX}")
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
#set(CMAKE_LD ${CMAKE_INSTALL_PREFIX}/bin/ld CACHE INTERNAL "ld tool")
set(CMAKE_OBJCOPY ${CMAKE_INSTALL_PREFIX}/bin/objcopy CACHE INTERNAL "objcopy tool")
set(CMAKE_FIND_ROOT_PATH ${CMAKE_INSTALL_PREFIX})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)