Bring up the M0 & blink TX LED

This commit is contained in:
Mike Walters
2020-01-15 02:09:10 +00:00
parent 058276d010
commit 3e2ca4e6c3
4 changed files with 52 additions and 0 deletions

View File

@ -34,3 +34,4 @@ MEMORY
} }
usb_bulk_buffer = ORIGIN(ram_usb); usb_bulk_buffer = ORIGIN(ram_usb);
PROVIDE(__ram_m0_start__ = ORIGIN(ram_m0));

View File

@ -63,6 +63,8 @@ set(SRC_M4
"${PATH_HACKRF_FIRMWARE_COMMON}/operacake.c" "${PATH_HACKRF_FIRMWARE_COMMON}/operacake.c"
) )
set(SRC_M0 sgpio_m0.c)
if(BOARD STREQUAL "HACKRF_ONE") if(BOARD STREQUAL "HACKRF_ONE")
SET(SRC_M4 SET(SRC_M4
${SRC_M4} ${SRC_M4}

View File

@ -22,7 +22,9 @@
#include <stddef.h> #include <stddef.h>
#include <libopencm3/lpc43xx/ipc.h>
#include <libopencm3/lpc43xx/m4/nvic.h> #include <libopencm3/lpc43xx/m4/nvic.h>
#include <libopencm3/lpc43xx/rgu.h>
#include <streaming.h> #include <streaming.h>
@ -50,6 +52,10 @@
#include "hackrf-ui.h" #include "hackrf-ui.h"
extern uint32_t __m0_start__;
extern uint32_t __m0_end__;
extern uint32_t __ram_m0_start__;
static usb_request_handler_fn vendor_request_handler[] = { static usb_request_handler_fn vendor_request_handler[] = {
NULL, NULL,
usb_vendor_request_set_transceiver_mode, usb_vendor_request_set_transceiver_mode,
@ -176,6 +182,16 @@ static bool cpld_jtag_sram_load(jtag_t* const jtag) {
return success; return success;
} }
static void m0_rom_to_ram() {
uint32_t *dest = &__ram_m0_start__;
uint32_t *src = &__m0_start__;
while (src < &__m0_end__) {
*dest = *src;
dest++;
src++;
}
}
int main(void) { int main(void) {
bool operacake_allow_gpio; bool operacake_allow_gpio;
pin_setup(); pin_setup();
@ -188,6 +204,10 @@ int main(void) {
#endif #endif
cpu_clock_init(); cpu_clock_init();
/* Wake the M0 */
m0_rom_to_ram();
ipc_start_m0((uint32_t)&__ram_m0_start__);
if( !cpld_jtag_sram_load(&jtag_cpld) ) { if( !cpld_jtag_sram_load(&jtag_cpld) ) {
halt_and_flash(6000000); halt_and_flash(6000000);
} }

View File

@ -0,0 +1,29 @@
/*
* Copyright 2020 Mike Walters <mike@flomp.net>
*
* 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.
*/
#include "gpio_lpc.h"
int main() {
while(1) {
*(uint8_t*)0x400f4048 ^= 1;
for (volatile int i = 0; i < 10000000; i++) {}
}
}