mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
Change M4 loader to use image tags.
Also finish moving HackRF binary to tagged image region.
This commit is contained in:
parent
0e62876578
commit
97ba19af24
@ -36,7 +36,7 @@ add_subdirectory(bootstrap)
|
||||
|
||||
add_custom_target(
|
||||
${PROJECT_NAME}.bin
|
||||
COMMAND ${MAKE_SPI_IMAGE} ${bootstrap_BINARY_DIR}/bootstrap.bin ${HACKRF_FIRMWARE_IMAGE} ${baseband_BINARY_DIR}/baseband.img ${application_BINARY_DIR}/application.bin ${PROJECT_NAME}.bin
|
||||
COMMAND ${MAKE_SPI_IMAGE} ${bootstrap_BINARY_DIR}/bootstrap.bin ${baseband_BINARY_DIR}/baseband.img ${application_BINARY_DIR}/application.bin ${PROJECT_NAME}.bin
|
||||
DEPENDS bootstrap.bin baseband.img application.bin
|
||||
)
|
||||
|
||||
|
@ -286,7 +286,7 @@ void AISRecentEntryDetailView::set_entry(const AISRecentEntry& entry) {
|
||||
}
|
||||
|
||||
AISAppView::AISAppView(NavigationView&) {
|
||||
baseband::run_image(portapack::spi_flash::baseband);
|
||||
baseband::run_image(portapack::spi_flash::image_tag_ais);
|
||||
|
||||
add_children({ {
|
||||
&label_channel,
|
||||
|
@ -79,8 +79,6 @@ NBFMOptionsView::NBFMOptionsView(
|
||||
AnalogAudioView::AnalogAudioView(
|
||||
NavigationView& nav
|
||||
) {
|
||||
baseband::run_image(portapack::spi_flash::baseband);
|
||||
|
||||
add_children({ {
|
||||
&rssi,
|
||||
&channel,
|
||||
@ -273,6 +271,18 @@ void AnalogAudioView::update_modulation(const ReceiverModel::Mode modulation) {
|
||||
audio::output::mute();
|
||||
record_view.stop();
|
||||
|
||||
portapack::spi_flash::image_tag_t image_tag;
|
||||
switch(modulation) {
|
||||
case ReceiverModel::Mode::AMAudio: image_tag = portapack::spi_flash::image_tag_am_audio; break;
|
||||
case ReceiverModel::Mode::NarrowbandFMAudio: image_tag = portapack::spi_flash::image_tag_nfm_audio; break;
|
||||
case ReceiverModel::Mode::WidebandFMAudio: image_tag = portapack::spi_flash::image_tag_wfm_audio; break;
|
||||
case ReceiverModel::Mode::SpectrumAnalysis: image_tag = portapack::spi_flash::image_tag_wideband_spectrum; break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
baseband::run_image(image_tag);
|
||||
|
||||
const auto is_wideband_spectrum_mode = (modulation == ReceiverModel::Mode::SpectrumAnalysis);
|
||||
receiver_model.set_baseband_configuration({
|
||||
.mode = toUType(modulation),
|
||||
|
@ -90,8 +90,8 @@ void stop() {
|
||||
send_message(&message);
|
||||
}
|
||||
|
||||
void run_image(const portapack::spi_flash::region_t image_region) {
|
||||
m4_init(image_region, portapack::memory::map::m4_code);
|
||||
void run_image(const portapack::spi_flash::image_tag_t image_tag) {
|
||||
m4_init(image_tag, portapack::memory::map::m4_code);
|
||||
|
||||
creg::m4txevent::enable();
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ struct WFMConfig {
|
||||
void start(BasebandConfiguration configuration);
|
||||
void stop();
|
||||
|
||||
void run_image(const portapack::spi_flash::region_t image_region);
|
||||
void run_image(const portapack::spi_flash::image_tag_t image_tag);
|
||||
void shutdown();
|
||||
|
||||
void spectrum_streaming_start();
|
||||
|
@ -32,7 +32,7 @@ using namespace portapack;
|
||||
namespace ui {
|
||||
|
||||
CaptureAppView::CaptureAppView(NavigationView& nav) {
|
||||
baseband::run_image(portapack::spi_flash::baseband);
|
||||
baseband::run_image(portapack::spi_flash::image_tag_capture);
|
||||
|
||||
add_children({ {
|
||||
&rssi,
|
||||
|
@ -38,17 +38,27 @@ using namespace lpc43xx;
|
||||
* I suppose I could force M4MEMMAP to an invalid memory reason which would
|
||||
* cause an exception and effectively halt the M4. But that feels gross.
|
||||
*/
|
||||
void m4_init(const portapack::spi_flash::region_t from, const portapack::memory::region_t to) {
|
||||
/* Initialize M4 code RAM */
|
||||
std::memcpy(reinterpret_cast<void*>(to.base()), from.base(), from.size);
|
||||
void m4_init(const portapack::spi_flash::image_tag_t image_tag, const portapack::memory::region_t to) {
|
||||
const portapack::spi_flash::chunk_t* chunk = reinterpret_cast<const portapack::spi_flash::chunk_t*>(portapack::spi_flash::images.base());
|
||||
while(chunk->tag) {
|
||||
if( chunk->tag == image_tag ) {
|
||||
/* Initialize M4 code RAM */
|
||||
std::memcpy(reinterpret_cast<void*>(to.base()), &chunk->data[0], chunk->length);
|
||||
|
||||
/* M4 core is assumed to be sleeping with interrupts off, so we can mess
|
||||
* with its address space and RAM without concern.
|
||||
*/
|
||||
LPC_CREG->M4MEMMAP = to.base();
|
||||
/* M4 core is assumed to be sleeping with interrupts off, so we can mess
|
||||
* with its address space and RAM without concern.
|
||||
*/
|
||||
LPC_CREG->M4MEMMAP = to.base();
|
||||
|
||||
/* Reset M4 core */
|
||||
LPC_RGU->RESET_CTRL[0] = (1 << 13);
|
||||
/* Reset M4 core */
|
||||
LPC_RGU->RESET_CTRL[0] = (1 << 13);
|
||||
|
||||
return;
|
||||
}
|
||||
chunk = chunk->next();
|
||||
}
|
||||
|
||||
chDbgPanic("NoImg");
|
||||
}
|
||||
|
||||
void m4_request_shutdown() {
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "memory_map.hpp"
|
||||
#include "spi_image.hpp"
|
||||
|
||||
void m4_init(const portapack::spi_flash::region_t from, const portapack::memory::region_t to);
|
||||
void m4_init(const portapack::spi_flash::image_tag_t image_tag, const portapack::memory::region_t to);
|
||||
void m4_request_shutdown();
|
||||
|
||||
void m0_halt();
|
||||
|
@ -121,7 +121,7 @@ void RecentEntriesView<ERTRecentEntries>::draw(
|
||||
}
|
||||
|
||||
ERTAppView::ERTAppView(NavigationView&) {
|
||||
baseband::run_image(portapack::spi_flash::baseband);
|
||||
baseband::run_image(portapack::spi_flash::image_tag_ert);
|
||||
|
||||
add_children({ {
|
||||
&recent_entries_view,
|
||||
|
@ -91,7 +91,7 @@ int main(void) {
|
||||
sdcStop(&SDCD1);
|
||||
|
||||
portapack::shutdown();
|
||||
m4_init(portapack::spi_flash::hackrf, portapack::memory::map::m4_code_hackrf);
|
||||
m4_init(portapack::spi_flash::image_tag_hackrf, portapack::memory::map::m4_code_hackrf);
|
||||
m0_halt();
|
||||
|
||||
return 0;
|
||||
|
@ -164,7 +164,7 @@ void RecentEntriesView<TPMSRecentEntries>::draw(
|
||||
}
|
||||
|
||||
TPMSAppView::TPMSAppView(NavigationView&) {
|
||||
baseband::run_image(portapack::spi_flash::baseband);
|
||||
baseband::run_image(portapack::spi_flash::image_tag_tpms);
|
||||
|
||||
add_children({ {
|
||||
&rssi,
|
||||
|
@ -96,14 +96,9 @@ constexpr region_t bootstrap {
|
||||
.size = 0x10000,
|
||||
};
|
||||
|
||||
constexpr region_t hackrf {
|
||||
constexpr region_t images {
|
||||
.offset = 0x10000,
|
||||
.size = 0x8000,
|
||||
};
|
||||
|
||||
constexpr region_t baseband {
|
||||
.offset = 0x20000,
|
||||
.size = 0x8000,
|
||||
.size = 0x30000,
|
||||
};
|
||||
|
||||
constexpr region_t application {
|
||||
|
@ -26,7 +26,7 @@ import sys
|
||||
usage_message = """
|
||||
PortaPack SPI flash image generator
|
||||
|
||||
Usage: <command> <bootstrap_path> <hackrf_path> <baseband_path> <application_path> <output_path>
|
||||
Usage: <command> <bootstrap_path> <baseband_path> <application_path> <output_path>
|
||||
Where paths refer to the .bin files for each component project.
|
||||
"""
|
||||
|
||||
@ -36,25 +36,19 @@ def read_image(path):
|
||||
f.close()
|
||||
return data
|
||||
|
||||
def read_image_from_dfu(path):
|
||||
data = read_image(path)
|
||||
# Strip DFU header from file to get binary image.
|
||||
return data[16:]
|
||||
|
||||
def write_image(data, path):
|
||||
f = open(path, 'wb')
|
||||
f.write(data)
|
||||
f.close()
|
||||
|
||||
if len(sys.argv) != 6:
|
||||
if len(sys.argv) != 5:
|
||||
print(usage_message)
|
||||
sys.exit(-1)
|
||||
|
||||
bootstrap_image = read_image(sys.argv[1])
|
||||
hackrf_image = read_image_from_dfu(sys.argv[2])
|
||||
baseband_image = read_image(sys.argv[3])
|
||||
application_image = read_image(sys.argv[4])
|
||||
output_path = sys.argv[5]
|
||||
baseband_image = read_image(sys.argv[2])
|
||||
application_image = read_image(sys.argv[3])
|
||||
output_path = sys.argv[4]
|
||||
|
||||
spi_size = 1048576
|
||||
|
||||
@ -64,15 +58,10 @@ images = (
|
||||
'data': bootstrap_image,
|
||||
'size': 0x10000,
|
||||
},
|
||||
{
|
||||
'name': 'hackrf',
|
||||
'data': hackrf_image,
|
||||
'size': 0x10000,
|
||||
},
|
||||
{
|
||||
'name': 'baseband',
|
||||
'data': baseband_image,
|
||||
'size': 0x20000,
|
||||
'size': 0x30000,
|
||||
},
|
||||
{
|
||||
'name': 'application',
|
||||
|
Loading…
Reference in New Issue
Block a user