Navigation Menu

Skip to content

Commit

Permalink
Thanks to Martin Capitanio and the linux code at http://capitanio.org…
Browse files Browse the repository at this point in the history
…/mlink/index.html

Was able to take my new stm32 value line discovery and load a simple program into sram and run it.

So far all it does is blink the green and blue leds.
  • Loading branch information
dwelch67 committed Mar 9, 2011
1 parent 1e612c8 commit 4b00cb1
Show file tree
Hide file tree
Showing 10 changed files with 1,398 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Makefile
@@ -0,0 +1,32 @@

ARMGNU = arm-none-linux-gnueabi

ARCH = -mcpu=cortex-m3
#ARCH =
AOPS = --warn --fatal-warnings -mthumb $(ARCH)
COPS = -Wall -Werror -O2 -nostdlib -nostartfiles -ffreestanding -mthumb $(ARCH)


all : blinker.bin

clean :
rm -f *.o
rm -f *.elf
rm -f *.list
rm -f *.bin

blinker.elf : blinker.o vectors.o memmap
$(ARMGNU)-ld -T memmap vectors.o blinker.o -o blinker.elf
$(ARMGNU)-objdump -D blinker.elf > blinker.list

blinker.o : blinker.c
$(ARMGNU)-gcc $(COPS) -c blinker.c -o blinker.o

vectors.o : vectors.s
$(ARMGNU)-as $(AOPS) vectors.s -o vectors.o


blinker.bin : blinker.elf
$(ARMGNU)-objcopy blinker.elf -O binary blinker.bin


34 changes: 34 additions & 0 deletions blinker.c
@@ -0,0 +1,34 @@

void PUT32 ( unsigned int, unsigned int );
unsigned int GET32 ( unsigned int );

#define GPIOCBASE 0x40011000

int notmain ( void )
{

volatile unsigned int ra;
unsigned int rb;
unsigned int rc;

//Blue LED on PORT C bit 8
//Green LED on PORT C bit 9

//output push-pull b0001
ra=GET32(GPIOCBASE+0x04);
ra&=(~(0xF<<16));
ra|=0x1<<16;
PUT32(GPIOCBASE+0x04,ra);

rb=GET32(GPIOCBASE+0x0C);
rc=rb|(3<<8);
rb&=(~(3<<8));
while(1)
{
PUT32(GPIOCBASE+0x0C,rb);
for(ra=0;ra<1000000;ra++) continue;
PUT32(GPIOCBASE+0x0C,rc);
for(ra=0;ra<1000000;ra++) continue;
}
return(0);
}
11 changes: 11 additions & 0 deletions memmap
@@ -0,0 +1,11 @@

MEMORY
{
ram : ORIGIN = 0x20000000, LENGTH = 0x10000
}

SECTIONS
{
.text : { *(.text*) } > ram
}

Binary file added stlink-access-test-04.tgz
Binary file not shown.
3 changes: 3 additions & 0 deletions stlink-access-test/AUTHORS
@@ -0,0 +1,3 @@
Martin Capitanio <m@capitanio.org>
Spencer Oliver <spen@spen-soft.co.uk>
Lementec Fabien <fabien.lementec@gmail.com>
27 changes: 27 additions & 0 deletions stlink-access-test/LICENSE
@@ -0,0 +1,27 @@
Copyright (c) 2011 The "Capt'ns Missing Link" Authors. 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 Martin Capitanio nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"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 COPYRIGHT
OWNER OR CONTRIBUTORS BE 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.
5 changes: 5 additions & 0 deletions stlink-access-test/README
@@ -0,0 +1,5 @@
cd build
make

edit Makefile
make run
27 changes: 27 additions & 0 deletions stlink-access-test/build/Makefile
@@ -0,0 +1,27 @@
PRG := stlink-access-test
DEV := /dev/sg2

all: $(PRG)

LIBS := \
-lsgutils2

OBJS += \
stlink-access-test.o

$(PRG): $(OBJS)
@echo 'Invoking: GCC C Linker'
gcc -o$(PRG) $(OBJS) $(LIBS)

%.o: ../src/%.c
@echo 'Building file: $<'
gcc -O0 -g3 -Wall -c -fmessage-length=0 -std=gnu99 -MMD -MP \
-MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)"\
-o"$@" "$<"

clean:
@rm -vf *.d *.o $(PRG)

run: all
cp $(PRG) /tmp/
sudo /tmp/$(PRG) $(DEV)

0 comments on commit 4b00cb1

Please sign in to comment.