Write all baseband binaries into tagged image file.

This commit is contained in:
Jared Boone 2016-06-30 16:45:41 -07:00
parent 946d45b31c
commit 01833ccb83
3 changed files with 85 additions and 18 deletions

View File

@ -27,6 +27,7 @@ set(CHIBIOS_PORTAPACK ${PROJECT_SOURCE_DIR}/chibios-portapack)
set(HACKRF_FIRMWARE_FILENAME hackrf_one_usb_ram.dfu)
set(HACKRF_FIRMWARE_IMAGE ${PROJECT_SOURCE_DIR}/${HACKRF_FIRMWARE_FILENAME})
set(MAKE_SPI_IMAGE ${PROJECT_SOURCE_DIR}/tools/make_spi_image.py)
set(MAKE_IMAGE_CHUNK ${PROJECT_SOURCE_DIR}/tools/make_image_chunk.py)
add_subdirectory(application)
add_subdirectory(baseband)

View File

@ -249,7 +249,9 @@ include_directories(. ${INCDIR})
set(BASEBAND_IMAGES)
macro(DeclareTargets)
macro(DeclareTargets chunk_tag name)
project("baseband_${name}")
include(${RULESPATH}/rules.cmake)
add_executable(${PROJECT_NAME}.elf $<TARGET_OBJECTS:baseband> ${MODE_CPPSRC} ${LDSCRIPT})
add_definitions(${DEFS})
@ -263,72 +265,70 @@ macro(DeclareTargets)
DEPENDS ${PROJECT_NAME}.elf
)
set(BASEBAND_IMAGES ${BASEBAND_IMAGES} ${PROJECT_NAME}.bin)
add_custom_target(
${PROJECT_NAME}.img
COMMAND ${MAKE_IMAGE_CHUNK} ${PROJECT_NAME}.bin ${chunk_tag} ${PROJECT_NAME}.img
DEPENDS ${PROJECT_NAME}.bin
)
set(BASEBAND_IMAGES ${BASEBAND_IMAGES} ${PROJECT_NAME}.img)
endmacro()
### AIS
project(baseband_ais)
set(MODE_CPPSRC
proc_ais.cpp
)
DeclareTargets()
DeclareTargets(PAIS ais)
### AM Audio
project(baseband_am_audio)
set(MODE_CPPSRC
proc_am_audio.cpp
)
DeclareTargets()
DeclareTargets(PAMA am_audio)
### Capture
project(baseband_capture)
set(MODE_CPPSRC
proc_capture.cpp
)
DeclareTargets()
DeclareTargets(PCAP capture)
### ERT
project(baseband_ert)
set(MODE_CPPSRC
proc_ert.cpp
)
DeclareTargets()
DeclareTargets(PERT ert)
### NFM Audio
project(baseband_nfm_audio)
set(MODE_CPPSRC
proc_nfm_audio.cpp
)
DeclareTargets()
DeclareTargets(PNFM nfm_audio)
### TPMS
project(baseband_tpms)
set(MODE_CPPSRC
proc_tpms.cpp
)
DeclareTargets()
DeclareTargets(PTPM tpms)
### WFM Audio
project(baseband_wfm_audio)
set(MODE_CPPSRC
proc_wfm_audio.cpp
)
DeclareTargets()
DeclareTargets(PWFM wfm_audio)
### Wideband Spectrum
project(baseband_wideband_spectrum)
set(MODE_CPPSRC
proc_wideband_spectrum.cpp
)
DeclareTargets()
DeclareTargets(PSPE wideband_spectrum)
#######################################################################

View File

@ -0,0 +1,66 @@
#!/usr/bin/env python
#
# Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
#
# This file is part of PortaPack.
#
# 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.
#
import sys
import struct
usage_message = """
PortaPack image chunk writer
Usage: <command> <input_binary> <four-characer tag> <output_tagged_binary>
"""
def read_image(path):
f = open(path, 'rb')
data = f.read()
f.close()
return data
def write_image(data, path):
f = open(path, 'wb')
f.write(data)
f.close()
if len(sys.argv) != 4:
print(usage_message)
sys.exit(-1)
input_image = read_image(sys.argv[1])
tag = sys.argv[2].encode()
output_path = sys.argv[3]
if len(tag) != 4:
print(usage_message)
sys.exit(-2)
input_image_max_length = 32768
if len(input_image) > input_image_max_length:
raise RuntimeError('image size of %d exceeds device size of %d bytes' % (len(input_image), input_image_max_length))
if (len(input_image) & 3) != 0:
raise RuntimeError('image size of %d is not multiple of four' % (len(input_image,)))
output_image = bytearray()
output_image += struct.pack('<4sI', tag, len(input_image))
output_image += input_image
write_image(output_image, output_path)