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: 7a0c15b1d530
Choose a base ref
...
head repository: azonenberg/starshipraider
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 103378d6fd9f
Choose a head ref
  • 1 commit
  • 10 files changed
  • 1 contributor

Commits on Apr 18, 2020

  1. Copy the full SHA
    103378d View commit details
3 changes: 3 additions & 0 deletions firmware/BLONDEL/afe-characterization/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.o
*.elf
*.bin
10 changes: 10 additions & 0 deletions firmware/BLONDEL/afe-characterization/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CFLAGS=-g -mcpu=cortex-m0
CXXFLAGS=$(CFLAGS) --std=c++17 -fno-exceptions -fno-rtti -g
CC=arm-none-eabi-gcc
CXX=arm-none-eabi-g++
all:
$(CC) *.S -c $(CFLAGS)
$(CXX) *.cpp -c $(CXXFLAGS)
$(CXX) $(CXXFLAGS) *.o -Wl,-T stm32f031.ld -o firmware.elf
arm-none-eabi-objcopy -O binary --only-section=.text --only-section=.data firmware.elf firmware.bin
./imagesize.sh
20 changes: 20 additions & 0 deletions firmware/BLONDEL/afe-characterization/cpu.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.globl DisableInterrupts
DisableInterrupts:
cpsid i
bx lr

.globl EnableInterrupts
EnableInterrupts:
cpsie i
bx lr

.globl EnterCriticalSection
EnterCriticalSection:
mrs r0, primask
cpsid i
bx lr

.globl LeaveCriticalSection
LeaveCriticalSection:
msr primask, r0
bx lr
28 changes: 28 additions & 0 deletions firmware/BLONDEL/afe-characterization/imagesize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

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";

GLOBALSTART=$(arm-none-eabi-objdump -t firmware.elf | grep __data_start | cut -d ' ' -f 1);
GLOBALEND=$(arm-none-eabi-objdump -t firmware.elf | grep __bss_end__ | cut -d ' ' -f 1);
DGLOBALSTART=$(echo "obase=10;ibase=16;${GLOBALSTART^^}" | bc);
DGLOBALEND=$(echo "obase=10;ibase=16;${GLOBALEND^^}" | bc);
GLOBALSIZE=$(expr $DGLOBALEND - $DGLOBALSTART);
GLOBALKB=$(expr $GLOBALSIZE / 1024);
echo "Global size: $GLOBALSIZE bytes";

HEAPSTART=$(arm-none-eabi-objdump -t firmware.elf | grep __heap_start | cut -d ' ' -f 1);
HEAPEND=$(arm-none-eabi-objdump -t firmware.elf | grep __end | cut -d ' ' -f 1);
DHEAPSTART=$(echo "obase=10;ibase=16;${HEAPSTART^^}" | bc);
DHEAPEND=$(echo "obase=10;ibase=16;${HEAPEND^^}" | bc);
HEAPSIZE=$(expr $DHEAPEND - $DHEAPSTART);
HEAPKB=$(expr $HEAPSIZE / 1024);
echo "Heap size: $HEAPSIZE bytes";
52 changes: 52 additions & 0 deletions firmware/BLONDEL/afe-characterization/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/***********************************************************************************************************************
* *
* 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 <stdint.h>
#include "stm32f031.h"

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

int main()
{
//Enable GPIOB
RCC.AHBENR |= RCC_AHB_GPIOB;

//Set PB7 (LED0) on
GPIOB.MODER = (GPIOB.MODER & 0xffff3fff) | 0x4000;
GPIOB.ODR = GPIOB.ODR | 0x80;

return 0;
}

extern "C" void _exit()
{
while(true)
{}
}
65 changes: 65 additions & 0 deletions firmware/BLONDEL/afe-characterization/stm32f031.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/***********************************************************************************************************************
* *
* 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 <stdint.h>
#include "stm32f031.h"

volatile gpio_t GPIOA __attribute__((section(".gpioa")));
volatile gpio_t GPIOB __attribute__((section(".gpiob")));
volatile gpio_t GPIOC __attribute__((section(".gpioc")));
/*
volatile gpio_t GPIOD __attribute__((section(".gpiod")));
volatile gpio_t GPIOE __attribute__((section(".gpioe")));
volatile gpio_t GPIOF __attribute__((section(".gpiof")));
volatile gpio_t GPIOG __attribute__((section(".gpiog")));
volatile gpio_t GPIOH __attribute__((section(".gpioh")));
volatile gpio_t GPIOI __attribute__((section(".gpioi")));
volatile gpio_t GPIOJ __attribute__((section(".gpioj")));
volatile gpio_t GPIOK __attribute__((section(".gpiok")));
*/
volatile rcc_t RCC __attribute__((section(".rcc")));
/*
volatile flash_t FLASH __attribute__((section(".flash")));
volatile spi_t SPI1 __attribute__((section(".spi1")));
volatile spi_t SPI4 __attribute__((section(".spi4")));
volatile spi_t SPI5 __attribute__((section(".spi5")));
volatile spi_t SPI6 __attribute__((section(".spi6")));
volatile usart_t USART1 __attribute__((section(".usart1")));
volatile usart_t USART2 __attribute__((section(".usart2")));
volatile usart_t USART3 __attribute__((section(".usart3")));
volatile usart_t UART4 __attribute__((section(".uart4")));
volatile usart_t UART5 __attribute__((section(".uart5")));
volatile usart_t USART6 __attribute__((section(".usart6")));
*/

extern "C" void atexit()
{
}
81 changes: 81 additions & 0 deletions firmware/BLONDEL/afe-characterization/stm32f031.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/***********************************************************************************************************************
* *
* 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. *
* *
***********************************************************************************************************************/

#ifndef stm32f031_h
#define stm32f031_h

typedef struct
{
uint32_t MODER;
uint32_t OTYPER;
uint32_t OSPEEDR;
uint32_t PUPDR;
uint32_t IDR;
uint32_t ODR;
uint32_t BSRR;
uint32_t LCKR;
uint32_t AFRL;
uint32_t AFRH;
} gpio_t;

extern volatile gpio_t GPIOA;
extern volatile gpio_t GPIOB;
extern volatile gpio_t GPIOC;

enum rcc_ahb
{
RCC_AHB_GPIOA = 0x020000,
RCC_AHB_GPIOB = 0x040000,
RCC_AHB_GPIOC = 0x080000,
RCC_AHB_GPIOD = 0x100000,
RCC_AHB_GPIOE = 0x200000,
RCC_AHB_GPIOF = 0x400000
};

typedef struct
{
uint32_t CR;
uint32_t CFGR;
uint32_t CIR;
uint32_t APB2RSTR;
uint32_t APB1RSTR;
uint32_t AHBENR;
uint32_t APB2ENR;
uint32_t APB1ENR;
uint32_t BDCR;
uint32_t CSR;
uint32_t AHBRSTR;
uint32_t CFGR2;
uint32_t CFGR3;
uint32_t CR2;
} rcc_t;

extern volatile rcc_t RCC;

#endif
89 changes: 89 additions & 0 deletions firmware/BLONDEL/afe-characterization/stm32f031.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
MEMORY
{
FLASH(RX): ORIGIN = 0x08000000, LENGTH = 32K
SRAM(RW): ORIGIN = 0x20000000, LENGTH = 4K

/* SFRs */
AHB2(RW): ORIGIN = 0x48000000, LENGTH = 384K
AHB1(RW): ORIGIN = 0x40020000, LENGTH = 384K
APB2(RW): ORIGIN = 0x40010000, LENGTH = 32K
APB1(RW): ORIGIN = 0x40000000, LENGTH = 32K
}

SECTIONS
{
/* Code comes right after the vector tables */
.text :
{
*(.vector)
*(.text.*)
*(.rodata)
*(.ctors)
. = ALIGN(4);
__ctor_start = .;
*(.init_array)
__ctor_end = .;
__dtor_start = .;
*(.fini_array)
__dtor_end = .;
} > FLASH

/* Initialized data needs special handling because it lives in two places */
.data :
{
__data_romstart = LOADADDR(.data);
__data_start = .;
*(.data)
__data_end = .;
} > SRAM AT> FLASH

/* BSS is pretty straightforward */
.bss :
{
__bss_start__ = .;
*(.bss)
__bss_end__ = .;

__heap_start = .;
. = ALIGN(4);
. += 0x400;

__end = .;
. = ORIGIN(SRAM) + LENGTH(SRAM) - 4;
__stack = .;

} > SRAM

/* SFRs */
.sfr_ahb1 :
{
. += 1024; /* DMA not implemented */
. += 3072; /* Reserved */
. = ALIGN(1024);
*(.rcc)
} > AHB1

.sfr_ahb2 :
{
. = ALIGN(1024);
*(.gpioa)
. = ALIGN(1024);
*(.gpiob)
. = ALIGN(1024);
*(.gpioc)
} > AHB2

.sfr_apb1 :
{
. += 1024; /* TIM2 not yet implemented */
/*
. = ALIGN(1024);
*(.usart2)
*/
} > APB1

.sfr_apb2 :
{
. += 1024; /* TIM1 not yet implemented */
} > APB2
}
Loading