Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: azonenberg/starshipraider
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 343bd83fdea4
Choose a base ref
...
head repository: azonenberg/starshipraider
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 87d75b807be3
Choose a head ref
  • 2 commits
  • 9 files changed
  • 1 contributor

Commits on Jul 4, 2020

  1. Copy the full SHA
    32bf9fb View commit details
  2. Copy the full SHA
    87d75b8 View commit details
3 changes: 3 additions & 0 deletions firmware/MEAD/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.o
*.elf
*.bin
16 changes: 16 additions & 0 deletions firmware/MEAD/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CFLAGS=-g -mcpu=cortex-m0 -DSTM32F031 -Os
CXXFLAGS=$(CFLAGS) --std=c++17 -fno-exceptions -fno-rtti -g --specs=nano.specs \
-I../stm32-cpp/devices/inc/ \
-I../stm32-cpp/src/
CC=arm-none-eabi-gcc
CXX=arm-none-eabi-g++
all:
$(CXX) *.cpp -c $(CXXFLAGS)
$(CC) ../stm32-cpp/src/cpu/*.S -c $(CFLAGS)
$(CXX) ../stm32-cpp/src/newlib-stubs/*.cpp -c $(CXXFLAGS)
$(CXX) ../stm32-cpp/src/peripheral/*.cpp -c $(CXXFLAGS)
# $(CXX) ../stm32-cpp/src/util/*.cpp -c $(CXXFLAGS)
$(CXX) ../stm32-cpp/devices/src/stm32f031.cpp -c $(CXXFLAGS)
$(CXX) $(CXXFLAGS) *.o -Wl,-T ../stm32-cpp/devices/link/stm32f031.ld -o firmware.elf
arm-none-eabi-objcopy -O binary --only-section=.text --only-section=.data firmware.elf firmware.bin
./imagesize.sh
32 changes: 32 additions & 0 deletions firmware/MEAD/imagesize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

LINE=`ls -lh firmware.bin | cut -d ' ' -f 5`
echo "Flash memory usage: $LINE";

STACKSTART=$(arm-none-eabi-objdump -t firmware.elf | grep __end | cut -d ' ' -f 1);
STACKEND=$(arm-none-eabi-objdump -t firmware.elf | grep __stack | cut -d ' ' -f 1);
DSTACKSTART=$(echo "obase=10;ibase=16;${STACKSTART^^}" | bc);
DSTACKEND=$(echo "obase=10;ibase=16;${STACKEND^^}" | bc);
STACKSIZE=$(expr $DSTACKEND - $DSTACKSTART);
#STACKKB=$(expr $STACKSIZE / 1024);
echo "Stack size: $STACKSIZE bytes";

DATASTART=$(arm-none-eabi-objdump -t firmware.elf | grep __data_start | cut -d ' ' -f 1);
DATAEND=$(arm-none-eabi-objdump -t firmware.elf | grep __data_end | cut -d ' ' -f 1);
DDATASTART=$(echo "obase=10;ibase=16;${DATASTART^^}" | bc);
DDATAEND=$(echo "obase=10;ibase=16;${DATAEND^^}" | bc);
DATASIZE=$(expr $DDATAEND - $DDATASTART);
DATAKB=$(expr $DATASIZE / 1024);
echo "Global data size: $DATASIZE bytes";

BSSSTART=$(arm-none-eabi-objdump -t firmware.elf | grep __bss_start | cut -d ' ' -f 1);
BSSEND=$(arm-none-eabi-objdump -t firmware.elf | grep __bss_end | cut -d ' ' -f 1);
DBSSSTART=$(echo "obase=10;ibase=16;${BSSSTART^^}" | bc);
DBSSEND=$(echo "obase=10;ibase=16;${BSSEND^^}" | bc);
BSSSIZE=$(expr $DBSSEND - $DBSSSTART);
BSSKB=$(expr $BSSSIZE / 1024);
echo "Global BSS size: $BSSSIZE bytes";

GLOBALSIZE=$(expr $DATASIZE + $BSSSIZE);
GLOBALKB=$(expr $GLOBALSIZE / 1024);
echo "Total global size: $GLOBALSIZE bytes";
104 changes: 104 additions & 0 deletions firmware/MEAD/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/***********************************************************************************************************************
* *
* STARSHIPRAIDER v0.1 *
* *
* Copyright (c) 2020 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

#include <stm32fxxx.h>
#include <peripheral/UART.h>
#include <peripheral/GPIO.h>
#include <peripheral/SPI.h>
/*
#include "SCPIParser.h"
#include "LTC2664.h"
#include "ADL5205.h"
*/

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Entry point

//UART stuff
UART* g_uart;

//When possible, long-lived stuff here should be declared static.
//This puts them in .bss instead of stack, and enables better accounting of memory usage
//on the (heavily limited) STM32F031 on the characterization board.
int main()
{
//Initialize the PLL
//CPU clock = AHB clock = APB clock = 48 MHz
RCCHelper::InitializePLLFromInternalOscillator(2, 12, 1, 1);

//Initialize the UART
static GPIOPin uart_tx(&GPIOA, 9, GPIOPin::MODE_PERIPHERAL, 1);
static GPIOPin uart_rx(&GPIOA, 10, GPIOPin::MODE_PERIPHERAL, 1);
static UART uart(&USART1, &USART1, 417);
g_uart = &uart;

//Enable RXNE interrupt vector (IRQ27)
//TODO: better contants here
volatile uint32_t* NVIC_ISER0 = (volatile uint32_t*)(0xe000e100);
*NVIC_ISER0 = 0x8000000;


//Set up SPI bus at 12 MHz (APB/4)
static GPIOPin spi_sck( &GPIOB, 3, GPIOPin::MODE_PERIPHERAL, 0);
static GPIOPin spi_miso(&GPIOB, 4, GPIOPin::MODE_PERIPHERAL, 0);
static GPIOPin spi_mosi(&GPIOB, 5, GPIOPin::MODE_PERIPHERAL, 0);
static SPI spi(&SPI1, true, 4);

//Set up timer


//Set up LCD
/*
g_uart->Printf("Turning on LCD\n");
static GPIOPin lcd_cs(&GPIOA, 0, GPIOPin::MODE_OUTPUT);
static GPIOPin lcd_rst(&GPIOA, 2, GPIOPin::MODE_OUTPUT);
static GPIOPin lcd_ctl_data(&GPIOA, 3, GPIOPin::MODE_OUTPUT);
lcd_cs.Set(1);
*/

/*
//Reset LCD
lcd_rst.Set(0);
for(int i=0; i<50; i++)
lcd_rst.Set(0);
for(int i=0; i<50; i++)
lcd_rst.Set(1);
//Set everything on
lcd_cs.Set(0);
spi.BlockingWrite(0xa4);
spi.WaitForWrites();
lcd_cs.Set(1);
*/
//Wait forever
while(1)
{}

return 0;
}
Loading