environment:
ubuntu 13.10
stm32f103zet6
1. STM 32 GCC Installation
stm32 belongs to the arm cortex-m series thumb instruction set, so arm-none-eabi is enough for arm. First, download
Download address: https://launchpad .NET /gcc-arm-embedded/+download
Download gcc-arm-none-eabi-version-linux.tar.bz2
Unzip to a directory you know will produce a gcc-arm-none-eabi folder
Add the compiler to your environment: sudo gedit ~/.bashrc
Add to the last line: Because I have added the Raspberry Pi compiler before, it is actually like this:
export PATH=$PATH:/your_pi_gcc_dir/tools-master/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin/:/your_stm_gcc_dir/gcc-arm-none-eabi-4_8-2013q4/bin
The two compiler environments are separated by a colon;
Test after logout : arm-none-eabi-gcc -v
You can check the version of the compiler, which means it is OK.
2. Establishment of Engineering Environment
Create a new project folder and its directory:
mkdir stm_project
cd stm_project
mkdir libs
mkdir src
mkdir inc
Download and install the official library:
The registers of stm32 are not as few as those of 51 avr and other microcontrollers. You can just write the library and memorize the registers by yourself. Therefore, ST company provides their official library. In order to avoid reinventing the wheel, we directly use their library. The library version is STM32_USB-FS-Device_Lib_V4.0.0. This library has more USB support. If you want to download it, go to the st official website and search for stm32f10x.
Download link: http://download.csdn.net/detail/canyue102/6778837
Here are the places that need to be modified. According to the chip model, select the corresponding RAM FLASH size
MEMORY {
//Adust LENGTH to RAMsize of target MCU:
//STM32F103RBT --> 20K
//RAM (RWX) : ORIGIN = 0x20000000 , LENGTH = 20K
//STM32F103RET --> 64K
//STM32F103ZET --> 64K
RAM (RWX) : ORIGIN = 0x20000000 , LENGTH = 64K
EXTSRAM (RWX) : ORIGIN = 0x68000000 , LENGTH = 0
//Adust LENGTH to (FLASHsize - FeePROMsize) of target MCU:
//STM32F103RBT --> 126K
FLASH (RX) : ORIGIN = 0x08000000 , LENGTH = 126K
//STM32F103RET --> 508K
//FLASH (RX) : ORIGIN = 0x08000000 , LENGTH = 508K
//STM32F103ZET --> 508K
FLASH (RX) : ORIGIN = 0x08000000 , LENGTH = 508K
//Adust ORIGIN to (0x08000000 + (FLASHsize-FeePROMsize)) of target MCU
//and adust LENGTH to FeePROMsize allocated:
//STM32F103RBT --> 0x08000000+126K, 2K
EEMUL (RWX) : ORIGIN = 0x08000000+126K, LENGTH = 2K
//STM32F103RET --> 0x08000000+508K, 4K
//EEMUL (RWX) : ORIGIN = 0x08000000+508K, LENGTH = 4K
}
Create a new Makefile in the project root directory:
# general Makefile
include Makefile.common
LDFLAGS=$(COMMONFLAGS) -fno-exceptions -ffunction-sections -fdata-sections -L$(LIBDIR) -nostartfiles -Wl,--gc-sections,-Tlinker.ld
LDLIBS+=-lm
LDLIBS+=-lstm32
STARTUP=startup.c
all: libs src
$(CC) -o $(PROGRAM).elf $(LDFLAGS) \
-Wl,--whole-archive \
src/app.a \
-Wl,--no-whole-archive \
$(LDLIBS)
$(OBJCOPY) -O ihex $(PROGRAM).elf $(PROGRAM).hex
$(OBJCOPY) -O binary $(PROGRAM).elf $(PROGRAM).bin
#Extract info contained in ELF to readable text-files:
arm-none-eabi-readelf -a $(PROGRAM).elf > $(PROGRAM). info_elf
arm-none-eabi-size -d -B -t $(PROGRAM).elf > $(PROGRAM).info_size
arm-none-eabi-objdump -S $(PROGRAM).elf > $(PROGRAM).info_code
arm-none-eabi-nm -td -S --size-sort -s $(PROGRAM).elf > $(PROGRAM).info_symbol
.PHONY: libs src clean tshow
libs:
$(MAKE) -C libs $@
src:
$(MAKE) -C src $@
clean:
$(MAKE) -C src $@
$(MAKE) -C libs $@
rm -f $(PROGRAM).elf $(PROGRAM).hex $(PROGRAM).bin $(PROGRAM).info_elf $(PROGRAM).info_size
rm -f $(PROGRAM).info_code
rm -f $(PROGRAM).info_symbol
tshow:
@echo "################################### ################################################ ################"
@echo "################ optimize settings: $(InfoTextLib), $(InfoTextSrc)"
@echo "################################################# ################################################## ###"
It's almost done, add the test source code in src
Mainly startup.c and main.c, I won't explain them here, you can view the pdf or go to my resource download
http://download.csdn.net/detail/canyue102/6778885
Then enter the main directory of the project and download make.
make clean
make OptLIB=0 OptSRC=0 all tshow
Then, it's done. For more information about burning programs to stm32 under ubuntu, please see the next blog
Previous article:Establishing stm32 development environment under ubuntu: burning program openocd+openjtag
Next article:STM32CubeMX Tutorial Series
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Ranking of installed capacity of smart driving suppliers from January to September 2024: Rise of independent manufacturers and strong growth of LiDAR market
- Industry first! Xiaopeng announces P7 car chip crowdfunding is completed: upgraded to Snapdragon 8295, fluency doubled
- P22-009_Butterfly E3106 Cord Board Solution
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- SHT31 Review Summary
- The differential voltage measured by the oscilloscope when the RS485 bus is idle is ±3.7V, and the periodic waveform with a frequency of 50hz
- What are the functions of magnetic beads and capacitors? How to choose the impedance of magnetic beads and the size of capacitors?
- Why would the filter added to the final stage cavity be burned?
- 【Beetle ESP32-C3】GNSS test
- Arteli AT32 uses GPIO to simulate HDMI CEC case
- Analyze the cause of tms320c6455 burning
- Beacon navigation sound positioning and recognition - microphone array
- How to make a boost circuit so that the output is equal to the input voltage?
- An experienced person explains Shannon's theorem, Nyquist's theorem, coding and modulation