How-to manual Installing a toolchain for Cortex-M3/STM32 on Ubuntu
How-to manual Installing a toolchain for Cortex-M3/STM32 on Ubuntu
How-to manual Installing a toolchain for Cortex-M3/STM32 on Ubuntu
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
The makefile will use library “ST<str<strong>on</strong>g>M3</str<strong>on</strong>g>2F10x_StdPeriph_Lib_V3.6.1”. Code optimizati<strong>on</strong> is turned off<br />
<str<strong>on</strong>g>to</str<strong>on</strong>g> make debugging produce the expected results. File is c<strong>on</strong>figured <str<strong>on</strong>g>for</str<strong>on</strong>g> a “ST<str<strong>on</strong>g>M3</str<strong>on</strong>g>2 Medium density<br />
device” cause the MCU “ST<str<strong>on</strong>g>M3</str<strong>on</strong>g>2F103RBT6” bel<strong>on</strong>gs <str<strong>on</strong>g>to</str<strong>on</strong>g> this device class, change "ST<str<strong>on</strong>g>M3</str<strong>on</strong>g>2F10X_MD"<br />
<str<strong>on</strong>g>to</str<strong>on</strong>g> another setting if another microc<strong>on</strong>troller bel<strong>on</strong>ging <str<strong>on</strong>g>to</str<strong>on</strong>g> a different class is used. An explanati<strong>on</strong> of<br />
this define can be found in file:<br />
/libs/ST<str<strong>on</strong>g>M3</str<strong>on</strong>g>2F10x_StdPeriph_Lib_V3.6.1/Libraries/CMSIS/Device/ST/ST<str<strong>on</strong>g>M3</str<strong>on</strong>g>2F10x/Include/stm32f10x.h<br />
inside your current project direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry.<br />
5.2.2.2 Libs Makefile<br />
When building the ST<str<strong>on</strong>g>M3</str<strong>on</strong>g>2 library as a static library, changes <str<strong>on</strong>g>to</str<strong>on</strong>g> the applicati<strong>on</strong> do not induce a<br />
complete re-compile of the library and this speeds up the build process. Create another Makefile<br />
named “Makefile” in the libs direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry with the following c<strong>on</strong>tents by use of a text edi<str<strong>on</strong>g>to</str<strong>on</strong>g>r:<br />
include ../Makefile.comm<strong>on</strong><br />
LIBS+=libstm32.a<br />
CFLAGS+=-c<br />
all: libs<br />
libs: $(LIBS)<br />
libstm32.a:<br />
@echo -n "Building $@ ..."<br />
@cd $(STMLIB)/CMSIS/Device/ST/ST<str<strong>on</strong>g>M3</str<strong>on</strong>g>2F10x/Source/Templates && \<br />
$(CC) $(CFLAGS) \<br />
system_stm32f10x.c<br />
@cd $(STMLIB)/ST<str<strong>on</strong>g>M3</str<strong>on</strong>g>2F10x_StdPeriph_Driver/src && \<br />
$(CC) $(CFLAGS) \<br />
-D"assert_param(expr)=((void)0)" \<br />
-I../../CMSIS/Include \<br />
-I../../CMSIS/Device/ST/ST<str<strong>on</strong>g>M3</str<strong>on</strong>g>2F10x/Include \<br />
-I../inc \<br />
*.c<br />
@cd $(STMLIB)/ST<str<strong>on</strong>g>M3</str<strong>on</strong>g>2_USB-FS-Device_Driver/src && \<br />
$(CC) $(CFLAGS) \<br />
-D"assert_param(expr)=((void)0)" \<br />
-I../../CMSIS/Include \<br />
-I../../CMSIS/Device/ST/ST<str<strong>on</strong>g>M3</str<strong>on</strong>g>2F10x/Include \<br />
-I../inc \<br />
*.c<br />
@$(AR) cr $(LIBDIR)/$@ \<br />
$(STMLIB)/CMSIS/Device/ST/ST<str<strong>on</strong>g>M3</str<strong>on</strong>g>2F10x/Source/Templates/system_stm32f10x.o \<br />
$(STMLIB)/ST<str<strong>on</strong>g>M3</str<strong>on</strong>g>2F10x_StdPeriph_Driver/src/*.o \<br />
$(STMLIB)/ST<str<strong>on</strong>g>M3</str<strong>on</strong>g>2_USB-FS-Device_Driver/src/*.o<br />
@echo "d<strong>on</strong>e."<br />
.PHONY: libs clean<br />
clean:<br />
Makefile<br />
rm -f $(STMLIB)/CMSIS/Device/ST/ST<str<strong>on</strong>g>M3</str<strong>on</strong>g>2F10x/Source/Templates/system_stm32f10x.o<br />
rm -f $(STMLIB)/ST<str<strong>on</strong>g>M3</str<strong>on</strong>g>2F10x_StdPeriph_Driver/src/*.o<br />
rm -f $(STMLIB)/ST<str<strong>on</strong>g>M3</str<strong>on</strong>g>2_USB-FS-Device_Driver/src/*.o<br />
rm -f $(LIBS)<br />
To test that everything is OK, execute following commands from the “libs” direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry:<br />
make clean<br />
make<br />
Now you should see the ST<str<strong>on</strong>g>M3</str<strong>on</strong>g>2 library get compiled, and a new file called “libstm32.a” appear in the<br />
current projects “libs” direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry. If not, be sure that your cross compiler is installed properly.<br />
Page 19 of 38