mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-08-12 10:53:42 +00:00
7ea3eec016
* Initial commit and pr for HackRF Pro (praline) arch-port to mayhem-firmware. Please see https://github.com/portapack-mayhem/mayhem-firmware/issues/2957. Added flash specifics for -DBOARD=PRALINE. This firmware only builds with toolchain v9.2.1 if hackrf codebase has -B arm in firmware/hackrf_usb/CMakeLists.txt. * Updated CMakeLists.txt per coordination with @HtoToo. For -DBOARD=PRALINE FLASH_MB_SIZE and FLASH_MB_LIMIT_SIZE are now 4. Removed praline specific variable for FLASH limits. * Updated chibios-portapack's board.cpp to support initialization of the HachRF-Pro (praline) FPGA. Added append_fpga_bitstream.py tool to ensure that praline_fgpa.bin bitstream can be appended to -DBOARD=PRALINE produced firmware. In order to ensure successful execution of append_fpga_bitstream.py to append the fpga bitstream we should expect that the bistsream will be located at 0x180000 in flash. This requires that FLASH_MB_LIMIT_SIZE must be 1.5, and FLASH_BYTES_LIMIT_SIZE must be 1535 * 1024. If we want to allow more or less space for the base firmware image sans the fpga bitstream the location of the bistream must be moved to a location other than 0x180000. * Updated location of praline_fpga.bin bitstream to 0x380000 to allow more room for firmware. Firmware now has 3.5MB, or 2MB more available than before as coordinated with @HTotoo. * Expanded #ifndef PRALINE to include og and r9 gpio and pin setup as coordinated with @HTotoo. * Added note for PRALINE FLASH_MB_LIMIT_SIZE and FLASH_BYTES_LIMIT_SIZE to explain why we are using the 3.5 and 3584 values respectively as coordinated with @HTotoo. * Next round of modifications derived heavily, if not entirely from work done by @banandana at https://github.com/Banandana/mayhem-firmware. This commit should power on the HackRF Pro (praline) display, power on the fpga, and enable gpio, and provide debug utilties. There is still a lot of work to be done to fully enable the new praline board with this build and firmware architectural porting effort. However, hackrf-one boards do not seem to be adversely impacted by the #ifdef PRALINE statements, and CMakeLists updates, as far as I have been able to test. * Ran format-code.sh. Updates for this commit are only due to formatting. Tested builds and they seem to work as exptected. * Addressed fixes in firmware/application and firmware/baseband. Stream now flows to capture and looking glass. Issues were related to thread management. Issues were originally addressed by @banandana. * Ran format-code.sh to allow for consistency with autoamted clang checks. * Update hackrf ref repo to mayhem-portapack-hackrf next from https://github.com/portapack-mayhem/hackrf * Addressed format edits necessary to pass clang-format check. * Starting addressing Si5351 Clocks for radio sampling. These updates correctly set the Si5351 clock at start up. There appears to be an issue during runtime when testing with RX Test Init, Capture and Looking glass. * Updated clock_manager.cpp to restore correct function introduced by @banandana when testing with Rx Test Init. * Switched to using decimation for setting the sample rate without changing the Si5351 clock. This assumes that for the praline board Si5351 CLK0 runs at fixed 8 MHz (constant) and the FPGA decimates to get the desired sample rate. For example, for a 1 MHz sample rate -> Si5351 outputs 8 MHz, FPGA decimates by 8. There is still more work needed here, and potential verification that this is the correct way to operate with this new archteitecture. * After deliberating on hackrf_usb hackrf_core.c and radio.c, and reviewing firmware/application/hw/si5351.cpp the original approach of using the aproach detailed in hackrf_core.c sample_rate_frac_set() lines 580-582, via the implementation in firmware/application/hw/si5351.cpp seems like the best place to continue testing efforts. * Tested at ~2.4GHz (2.3 - 2.5) with lookgin glass and was able to receive signals. Added a Signal Path debug app to test gains, and readio mode (receive/transmit). * Added two debug apps for the RFFC507x. Status View and Tuning View. This helped debug some of the potential issues with tuning. * update submodule * format code * Small touch up merging latest next and ensuring build for HackRF One. * Fix ui addition of max2831 debug display. * Reverted edits to re: firmware/baseband/sd_over_usb/scsi.c and firmware/application/portapack.cpp. Source now builds, had to pull latest hackrf submodule. * Skipped detect hardware for praline board to avoid backscreen in HackRF Pro praline board. * Added UI debug display for max2831 like the rffc507x. Added Filter Band display and Mixer status to Signal Path Status debug display. * Added ability to set Q: INV, or Q:NOR in Signal Path Status Debug view for testing. Also added display entries for the FGPA Ctrl register fir debugging. * Added System Diagnostics which allows testing sample rate, q-inv, and dc blk * Corrected LP - GPIO4[8], and GPIO4[9] issue which was preventing RF Amp, and LPF from chaning state. HackRF Pro (praline) now correctly changes state of LPF and RF Amp as expected. * Corrected LP - GPIO4[8], and GPIO4[9] issue which was preventing RF Amp, and LPF from chaning state. HackRF Pro (praline) now correctly changes state of LPF and RF Amp as expected. * Added consistency for testing. * Added ui to debug whether rffc5072 is locking correctly. Also addressed rf_amp fixed in on state, such that it may now be able to be toggled in HackRF Pro praline setups. * Updated format to support automated tests. * format code * Updated rffc5072 status view in ui_debug to help with debugging. Made updated recommendtions for merge from PR comments. Made updates to ensure resetx isn't reconfigured for output in rffc507x.cpp. * Ran ./format-code.sh * Added reference comment that addresses debugging in PRALINE to detail that when the capture app was requesting 15 MHz, it matched 15100000 which resulted in the 8.5M setting. To get the actual 15M setting (22.6 MHz bandwidth), I had to force a request at least 22 MHz while debugging. * Debugging tunning ENX and frequency locking in low band. * Addressed pin differences between HackRF One and HackRF Pro (praline), resolved ENX configuration. * Cirrected pins, and debugging tuning for low band. High band now goes past 2.7GHz into 3.3 GHz. * Updated ui_debug to track ENX updates and support tracing which calls may be changing ENX. * Removed clkin reference in ui_debug.cpp to allow space for more information about CLK0, CLK1, CLK4, and CLK5. * Removed clkin reference in ui_debug.cpp to allow space for more information about CLK0, CLK1, CLK4, and CLK5. * Ran format-code.sh * Updated rffc507xx.cpp, and ensured hackrf submodule at f1dcd554. --------- Co-authored-by: gullradriel <gullradriel@users.noreply.github.com>
228 lines
7.8 KiB
C++
228 lines
7.8 KiB
C++
/*
|
|
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
|
* Copyright (C) 2016 Furrtek
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
// Color bitmaps generated with:
|
|
// Gimp image > indexed colors (16), then "xxd -i *.bmp"
|
|
|
|
// Note about available RAM:
|
|
// Check what ends up in the BSS section by looking at the map files !
|
|
// Use constexpr where possible or make sure const are in .cpp files, not headers !
|
|
|
|
// Note about messages:
|
|
// There can only be one message handler for one kind of message at once
|
|
// If an attempt is made to register a second handler, there's a chDbgPanic "MsgDblReg"
|
|
|
|
// Note about matched filters: see proc_sonde.hpp
|
|
|
|
// TEST: Goertzel tone detect
|
|
// TEST: Menuview refresh, seems to blink a lot
|
|
// TEST: Check AFSK transmit end, skips last bits ?
|
|
// TEST: Imperial in whipcalc
|
|
|
|
// BUG: Console lock-up if first string to be printed starts with escape character ?
|
|
// BUG: (Workaround ok) CPLD-related rx ok, tx bad, see portapack.cpp lines 214+ to disable CPLD overlay
|
|
// BUG: SCANNER Lock on frequency, if frequency jump, still locked on first one
|
|
// BUG: SCANNER Multiple slices
|
|
// GLITCH: The about view scroller sometimes misses lines because of a race condition between the display scrolling and drawing the line
|
|
// GLITCH: Start of tx using ReplayThread plays a small bit of previous transmission (content of 1 buffer ?)
|
|
// See fifo.reset_in() ?
|
|
|
|
// FIXED: Update button in signal gen doesn't work for shape change
|
|
// BUG: Signal gen noise shape doesn't work
|
|
// TODO: Continue acars receiver. See matched filter, probably doesn't shift the spectrum correctly
|
|
// TODO: Add larger description text field in frequency load, under menuview
|
|
// TODO: Allow apps to select a preferred FREQMAN file
|
|
// TODO: Make play button larger in Replay
|
|
// TODO: Add default headphones volume setting in Audio settings
|
|
// TODO: Put LNA and VGA controls in Soundboard
|
|
// TODO: Make CTCSS display only when squelch is opened
|
|
// TODO: DCS decoder
|
|
// TODO: Increase resolution of audio FFT view ? Currently 48k/(256/2) (375Hz) because of the use of real values (half of FFT output)
|
|
// TODO: Move Touchtunes remote to Custom remote
|
|
// TODO: Use escapes \x1B to set colors in text, it works !
|
|
// TODO: Open files in File Manager
|
|
// TODO: Ask for filename after record
|
|
// TODO: Super simple text file viewer
|
|
// TODO: Clean up ReplayThread
|
|
// TODO: Cap Wav viewer position
|
|
// TODO: Adapt wav viewer position step
|
|
// TODO: Use unit_auto_scale
|
|
// TODO: Remove make_bistream from encoders.cpp, too complex, stinks. bitstream_append should be enough.
|
|
// TODO: Continue work on proc_afskrx_corr, see python script (it works !)
|
|
// TODO: De bruijn sequence scanner for encoders
|
|
// TODO: FILEMAN Move files
|
|
// TODO: Use separate thread for scanning in EPAR TX
|
|
// TODO: Make freqman refresh simpler (use previous black rectangle method)
|
|
// TODO: Merge AFSK and TONES procs ?
|
|
// TODO: NFM RX mode: nav.pop on squelch
|
|
// TODO: MORSE use prosigns
|
|
// TODO: MORSE live keying mode
|
|
// TODO: Use to_string_short_freq wherever possible
|
|
// TODO: SCANNER Waveform widget as FFT view ?
|
|
// TODO: Optimize (and group ?) CTCSS tone gen code
|
|
/*
|
|
Continuous (Fox-oring)
|
|
12s transmit, 48s space (Sprint 1/5th)
|
|
60s transmit, 240s space (Classic 1/5 min)
|
|
60s transmit, 360s space (Classic 1/7 min)
|
|
*/
|
|
// TODO: FreqMan: Remove and rename categories
|
|
// TODO: Mousejack ?
|
|
// TODO: Move frequencykeypad from ui_receiver to ui_widget (used everywhere)
|
|
// TODO: ADS-B draw trajectory + GPS coordinates + scale, and playback
|
|
// TODO: RDS multiple groups (sequence)
|
|
// TODO: Use ModalMessageView confirmation for TX ?
|
|
// TODO: Use msgpack for settings, lists... on sd card
|
|
|
|
// Multimon-style stuff:
|
|
// TODO: DMR detector
|
|
// TODO: GSM channel detector
|
|
// TODO: Setup: Play dead by default ? Enable/disable ?
|
|
|
|
// Old or low-priority stuff:
|
|
// TODO: Bodet :)
|
|
// TODO: Analog TV tx with camcorder font character generator
|
|
// TODO: Scan for OOK TX
|
|
// TODO: Check more OOK encoders
|
|
// BUG (fixed ?): No audio in about when shown second time
|
|
// TODO: Show MD5 mismatches for modules not found, etc...
|
|
// BUG: Description doesn't show up first time going to system>module info (UI drawn on top)
|
|
// TODO: Two players tic-tac-toe
|
|
// TODO: Analog TV pong game
|
|
|
|
#include "ch.h"
|
|
|
|
#include "portapack.hpp"
|
|
#include "portapack_shared_memory.hpp"
|
|
#include "config_mode.hpp"
|
|
|
|
#include "message_queue.hpp"
|
|
|
|
#include "ui.hpp"
|
|
#include "ui_widget.hpp"
|
|
#include "ui_painter.hpp"
|
|
#include "ui_navigation.hpp"
|
|
|
|
#include "irq_lcd_frame.hpp"
|
|
#include "irq_controls.hpp"
|
|
#include "irq_rtc.hpp"
|
|
|
|
#include "event_m0.hpp"
|
|
|
|
#include "core_control.hpp"
|
|
#include "spi_image.hpp"
|
|
|
|
#include "debug.hpp"
|
|
#include "led.hpp"
|
|
|
|
#include "gcc.hpp"
|
|
|
|
#include "sd_card.hpp"
|
|
|
|
#include <string.h>
|
|
#include "i2cdevmanager.hpp"
|
|
|
|
#include "rffc507x.hpp" /* c/m, avoiding initial short ON Ant_DC_Bias pulse, from cold reset */
|
|
rffc507x::RFFC507x first_if;
|
|
ui::SystemView* system_view_ptr;
|
|
|
|
static uint32_t random_seed_state = 123456789;
|
|
extern "C" int rand(void) {
|
|
random_seed_state ^= random_seed_state << 13;
|
|
random_seed_state ^= random_seed_state >> 17;
|
|
random_seed_state ^= random_seed_state << 5;
|
|
return (int)(random_seed_state & 0x7FFFFFFF);
|
|
}
|
|
extern "C" void srand(unsigned int seed) {
|
|
if (seed == 0) {
|
|
random_seed_state = 123456789;
|
|
} else {
|
|
random_seed_state = seed;
|
|
}
|
|
}
|
|
|
|
static void event_loop() {
|
|
static ui::Context context;
|
|
static ui::SystemView system_view{
|
|
context,
|
|
portapack::display.screen_rect()};
|
|
|
|
system_view_ptr = &system_view;
|
|
|
|
EventDispatcher event_dispatcher{&system_view, context};
|
|
static MessageHandlerRegistration message_handler_display_sleep{
|
|
Message::ID::DisplaySleep,
|
|
[&event_dispatcher](const Message* const) {
|
|
event_dispatcher.set_display_sleep(true);
|
|
}};
|
|
portapack::setEventDispatcherToUSBSerial(&event_dispatcher);
|
|
i2cdev::I2CDevManager::setEventDispatcher(&event_dispatcher);
|
|
system_view.get_navigation_view()->handle_autostart();
|
|
event_dispatcher.run();
|
|
}
|
|
|
|
int main(void) {
|
|
#ifndef PRALINE // Do not perform quick set up of GP01_RFF507X = 1 for PRALINE
|
|
first_if.init(); /* To avoid initial short Ant_DC_Bias pulse ,we need quick set up GP01_RFF507X =1 */
|
|
#endif
|
|
|
|
if (config_mode_should_enter()) {
|
|
config_mode_clear();
|
|
config_mode_run();
|
|
}
|
|
|
|
config_mode_set();
|
|
|
|
switch (portapack::init()) {
|
|
case portapack::init_status_t::INIT_HACKRF_CPLD_FAILED:
|
|
portapack::init_error = "HACKRF CPLD FAILED";
|
|
[[fallthrough]];
|
|
|
|
case portapack::init_status_t::INIT_SUCCESS:
|
|
|
|
config_mode_clear();
|
|
|
|
lcd_frame_sync_configure();
|
|
rtc_interrupt_enable();
|
|
|
|
Theme::SetTheme((Theme::ThemeId)portapack::persistent_memory::ui_theme_id());
|
|
|
|
event_loop();
|
|
|
|
sdcDisconnect(&SDCD1);
|
|
sdcStop(&SDCD1);
|
|
|
|
portapack::shutdown();
|
|
break;
|
|
|
|
case portapack::init_status_t::INIT_NO_PORTAPACK:
|
|
case portapack::init_status_t::INIT_PORTAPACK_CPLD_FAILED:
|
|
config_mode_clear();
|
|
break;
|
|
}
|
|
|
|
m4_init(portapack::spi_flash::image_tag_hackrf, portapack::memory::map::m4_code_hackrf, true);
|
|
m0_halt();
|
|
|
|
return 0;
|
|
}
|