README: Include notes on reuse

This is just one way of doing it, but it shows the basic steps
This commit is contained in:
Karl Palsson
2014-03-23 12:41:19 +00:00
parent abf774c0f4
commit 49760aa021

68
README
View File

@@ -19,7 +19,7 @@ Usage
-----
The makefiles are generally useable for your own projects with
only minimal changes for the libopencm3 install path (See Installation)
only minimal changes for the libopencm3 install path (See Reuse)
For flashing the 'miniblink' example (after you built libopencm3 and the
examples by typing 'make' at the top-level directory) onto the Olimex
@@ -43,3 +43,69 @@ You can also flash manually like this:
Replace the "jtagkey-tiny.cfg" with whatever JTAG device you are using, and/or
replace "stm32f1x.cfg" with your respective config file. Replace "foobar.hex"
with the file name of the image you want to flash.
Reuse
-----
If you want to use libopencm3 in your own project, this examples repository
shows the general way. (If there's interest, we can make a stub template
repository)
##### Create an empty repository
$ mkdir mycoolrobot && cd mycoolrobot && git init .
##### Add libopencm3 as a submodule
$ git submodule add https://github.com/libopencm3/libopencm3
##### Grab a copy of the basic rules
These urls grab the latest from the libopencm3-examples repository
$ wget \
https://raw.githubusercontent.com/libopencm3/libopencm3-examples/master/examples/Makefile.rules \
-O libopencm3.rules.mk
##### Grab a copy of your target Makefile
in this case, for STM32L1
$ wget \
https://raw.githubusercontent.com/libopencm3/libopencm3-examples/master/examples/stm32/l1/Makefile.include \
-O libopencm3.target.mk
##### Edit paths in libopencm3.target.mk
Edit the _last_ line of libopencm3.target.mk and change the include to read
include ../libopencm3.rules.mk (the amount of .. depends on where you put your
project in the next step..
##### beg/borrow/steal an example project
For sanity's sake, use the same target as the makefile you grabbed up above)
$ cp -a \
somewhere/libopencm3-examples/examples/stm32/l1/stm32ldiscovery/miniblink \
myproject
Add the path to OPENCM3_DIR, and modify the path to makefile include
```
$ diff -u
---
2014-01-24 21:10:52.687477831 +0000
+++ Makefile 2014-03-23 12:27:57.696088076 +0000
@@ -19,7 +19,8 @@
BINARY = miniblink
+OPENCM3_DIR=../libopencm3
LDSCRIPT = $(OPENCM3_DIR)/lib/stm32/l1/stm32l15xxb.ld
-include ../../Makefile.include
+include ../libopencm3.target.mk
```
You're done :)
You need to run "make" inside the libopencm3 directory once to build the
library, then you can just run make/make clean in your project directory as
often as you like.