ubuntu下stm32f407环境(正点原子)

2024-04-13 14:32

本文主要是介绍ubuntu下stm32f407环境(正点原子),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1.交叉编译


sudo apt install binutils-arm-none-eabi
sudo apt install gcc-arm-none-eabi
sudo apt install gdb-arm-none-eabi

如果没有gdb-arm-none-eabi 请看https://zhuanlan.zhihu.com/p/134031693

2.安装stlink

1.安装libusb


sudo apt-get install libusb-dev
git clone https://github.com/texane/stlink.git 
cd stlink/ 
mkdir build 
cmake ..
make && sudo make install 

安装完成后


xz@xiaqiu:~/study/stm32/stlink/build$ lsusb
Bus 001 Device 002: ID 8087:8001 Intel Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 006: ID 04f2:b502 Chicony Electronics Co., Ltd Integrated Camera
Bus 002 Device 005: ID 8087:07dc Intel Corp. 
Bus 002 Device 008: ID 0483:3748 STMicroelectronics ST-LINK/V2
Bus 002 Device 010: ID 18f8:0f99 [Maxxter] Optical gaming mouse
Bus 002 Device 012: ID 1c4f:0002 SiGma Micro Keyboard TRACER Gamma Ivory
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
xz@xiaqiu:~/study/stm32/stlink/build$ 

配置选项
makefile.common


TOP = $(shell pwd)
PROGRAM = stm32f4_out
LIBDIR = $(TOP)/lib
TypeOfMCU=STM32F407xxTC=arm-none-eabi
CC=$(TC)-gcc
LD=$(TC)-ld -v
OBJCOPY=$(TC)-objcopy
AR=$(TC)-ar
GDB=$(TC)-gdb
INCLUDE=-I$(TOP)/includeCOMMONFLAGS=-g -mcpu=cortex-m3 -mthumb
COMMONFLAGSlib=$(COMMONFLAGS)CFLAGS+=$(COMMONFLAGS) -Wall -Werror $(INCLUDE)
CFLAGS+=-D $(TypeOfMCU)
CFLAGS+=-D VECT_TAB_FLASHCFLAGSlib+=$(COMMONFLAGSlib) -Wall -Werror $(INCLUDE)
CFLAGSlib+=-D $(TypeOfMCU)
CFLAGSlib+=-D VECT_TAB_FLASH

标准例程-寄存器版本 - 实验1跑马灯实验

https://gitee.com/mrxiao_com/ubuntu-stm32_1


xz@xiaqiu:~/study/stm32/ubuntu-stm32_1$ tree -L 3
.
├── build
├── hardware
│   ├── led
│   │   ├── led.c
│   │   ├── led.h
│   │   └── led.o
│   ├── libstm32.a
│   ├── makefile
│   └── system
│       ├── delay
│       └── sys
├── lib
│   ├── libapp.a
│   └── libstm32.a
├── makefile
├── makefile.common
├── STM32F407VGTx_FLASH.ld
├── stm32f4_out.bin
├── stm32f4_out.elf
├── stm32f4_out.hex
├── stm32f4_out.info_code
├── stm32f4_out.info_elf
├── stm32f4_out.info_size
├── stm32f4_out.info_symbol
├── tags
└── user├── libapp.a├── main.c├── main.o├── makefile├── startup_stm32f40_41xxx.o└── startup_stm32f40_41xxx.s8 directories, 24 files
xz@xiaqiu:~/study/stm32/ubuntu-stm32_1$ 

上层 makefile
ubuntu-stm32_1/makefile


# general Makefileinclude makefile.common
LDFLAGS=$(COMMONFLAGS) -fno-exceptions -ffunction-sections -fdata-sections -L$(LIBDIR) -nostartfiles -Wl,--gc-sections,-TSTM32F407VGTx_FLASH.ld
LDLIBS+=-lstm32
LDLIBS+=-lappall: user  hardware$(CC) -g -o $(PROGRAM).elf $(LDFLAGS) \-Wl,--whole-archive \user/libapp.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_elfarm-none-eabi-size -d -B -t $(PROGRAM).elf > $(PROGRAM).info_sizearm-none-eabi-objdump -S $(PROGRAM).elf > $(PROGRAM).info_codearm-none-eabi-nm -t d -S --size-sort -s $(PROGRAM).elf > $(PROGRAM).info_symbolhardware:ECHO$(MAKE) -C $@
user:ECHO$(MAKE) -C $@
ECHO:@echo $@
.PHONY: clean# 总控的makefile使用$(MAKE)这个宏调用,子目录下的makefile
# 这里的意思是先进入-C之后的目录中然后执行该目录下的makefileclean:hardware_clean user_cleanrm $(PROGRAM).* 
hardware_clean:@cd hardware && make clean
user_clean:@cd user && make clean

ubuntu-stm32_1/user/makefile


include ../makefile.commonCFLAGSlib+=-c
USER = $(shell pwd)src += ./*.c
src += ./*.s
obj = ./*.o 
.PHONY :objlibapp.a : $(obj)$(AR) cr $@ \$^if [ -e libapp.a ]; then cp -f libapp.a ../lib; fi$(obj):$(CC)  $(CFLAGSlib) \-I../include \-I../hardware/system/delay \-I../hardware/system/sys \-I../hardware/led \$(src).PHONY :clean
clean :rm libapp.a  $(obj)

ubuntu-stm32_1/hardware/makefile


# libs Makefile
include ../makefile.common
CFLAGSlib+=-cSTM32LIB = $(shell pwd)obj1 = $(STM32LIB)/system/sys/*.o
obj2 = $(STM32LIB)/system/delay/*.o
obj3 = $(STM32LIB)/led/*.o
inc1 = $(STM32LIB)/led
inc2 = $(STM32LIB)/system/delay
inc3 = $(STM32LIB)/system/syslibstm32.a: $(obj3) $(obj2) $(obj1)echo "comlile stm32lib.a"$(AR) cr $(STM32LIB)/$@ $^echo "make stm32lib success"if [ -e libstm32.a ]; then cp -f libstm32.a ../lib; fi$(obj1) :echo "comlile obj1"cd $(STM32LIB)/system/sys && \$(CC) $(CFLAGSlib) \-I$(inc1) -I$(inc2) -I$(inc3) \*.c$(obj2) :echo "comlile obj2"cd $(STM32LIB)/system/delay && \$(CC) $(CFLAGSlib) \-I$(inc1) -I$(inc2) -I$(inc3) \-I../../../../include \*.c$(obj3) :echo "comlile obj3"cd $(STM32LIB)/led && \$(CC) $(CFLAGSlib) \-I$(inc1) -I$(inc2) -I$(inc3) \-I../../../../include \*.c.PHONY: clean 
clean:rm -f $(STM32LIB)/libstm32.a $(obj1) $(obj2) $(obj3)

编译


xz@xiaqiu:~/study/stm32/ubuntu-stm32_1$ make clean
make[1]: 进入目录“/home/xz/study/stm32/ubuntu-stm32_1/hardware”
rm -f /home/xz/study/stm32/ubuntu-stm32_1/hardware/libstm32.a /home/xz/study/stm32/ubuntu-stm32_1/hardware/system/sys/*.o /home/xz/study/stm32/ubuntu-stm32_1/hardware/system/delay/*.o /home/xz/study/stm32/ubuntu-stm32_1/hardware/led/*.o
make[1]: 离开目录“/home/xz/study/stm32/ubuntu-stm32_1/hardware”
make[1]: 进入目录“/home/xz/study/stm32/ubuntu-stm32_1/user”
rm libapp.a  ./*.o 
make[1]: 离开目录“/home/xz/study/stm32/ubuntu-stm32_1/user”
rm stm32f4_out.* 
xz@xiaqiu:~/study/stm32/ubuntu-stm32_1$ make
ECHO
make -C user
make[1]: 进入目录“/home/xz/study/stm32/ubuntu-stm32_1/user”
arm-none-eabi-gcc  -g -mcpu=cortex-m3 -mthumb -Wall -Werror -I/home/xz/study/stm32/ubuntu-stm32_1/user/include -D STM32F407xx -D VECT_TAB_FLASH -c \
-I../include \
-I../hardware/system/delay \
-I../hardware/system/sys \
-I../hardware/led \
./*.c ./*.s
arm-none-eabi-ar cr libapp.a \
*.o
if [ -e libapp.a ]; then cp -f libapp.a ../lib; fi
make[1]: 离开目录“/home/xz/study/stm32/ubuntu-stm32_1/user”
make -C hardware
make[1]: 进入目录“/home/xz/study/stm32/ubuntu-stm32_1/hardware”
echo "comlile obj3"
comlile obj3
cd /home/xz/study/stm32/ubuntu-stm32_1/hardware/led && \
arm-none-eabi-gcc -g -mcpu=cortex-m3 -mthumb -Wall -Werror -I/home/xz/study/stm32/ubuntu-stm32_1/hardware/include -D STM32F407xx -D VECT_TAB_FLASH -c \-I/home/xz/study/stm32/ubuntu-stm32_1/hardware/led -I/home/xz/study/stm32/ubuntu-stm32_1/hardware/system/delay -I/home/xz/study/stm32/ubuntu-stm32_1/hardware/system/sys \-I../../../../include \*.c
echo "comlile obj2"
comlile obj2
cd /home/xz/study/stm32/ubuntu-stm32_1/hardware/system/delay && \
arm-none-eabi-gcc -g -mcpu=cortex-m3 -mthumb -Wall -Werror -I/home/xz/study/stm32/ubuntu-stm32_1/hardware/include -D STM32F407xx -D VECT_TAB_FLASH -c \-I/home/xz/study/stm32/ubuntu-stm32_1/hardware/led -I/home/xz/study/stm32/ubuntu-stm32_1/hardware/system/delay -I/home/xz/study/stm32/ubuntu-stm32_1/hardware/system/sys \-I../../../../include \*.c
echo "comlile obj1"
comlile obj1
cd /home/xz/study/stm32/ubuntu-stm32_1/hardware/system/sys && \
arm-none-eabi-gcc -g -mcpu=cortex-m3 -mthumb -Wall -Werror -I/home/xz/study/stm32/ubuntu-stm32_1/hardware/include -D STM32F407xx -D VECT_TAB_FLASH -c \-I/home/xz/study/stm32/ubuntu-stm32_1/hardware/led -I/home/xz/study/stm32/ubuntu-stm32_1/hardware/system/delay -I/home/xz/study/stm32/ubuntu-stm32_1/hardware/system/sys \*.c
echo "comlile stm32lib.a"
comlile stm32lib.a
arm-none-eabi-ar cr /home/xz/study/stm32/ubuntu-stm32_1/hardware/libstm32.a /home/xz/study/stm32/ubuntu-stm32_1/hardware/led/*.o /home/xz/study/stm32/ubuntu-stm32_1/hardware/system/delay/*.o /home/xz/study/stm32/ubuntu-stm32_1/hardware/system/sys/*.o
echo "make stm32lib success"
make stm32lib success
if [ -e libstm32.a ]; then cp -f libstm32.a ../lib; fi
make[1]: 离开目录“/home/xz/study/stm32/ubuntu-stm32_1/hardware”
arm-none-eabi-gcc -g -o stm32f4_out.elf -g -mcpu=cortex-m3 -mthumb -fno-exceptions -ffunction-sections -fdata-sections -L/home/xz/study/stm32/ubuntu-stm32_1/lib -nostartfiles -Wl,--gc-sections,-TSTM32F407VGTx_FLASH.ld \-Wl,--whole-archive \user/libapp.a \-Wl,--no-whole-archive \-lstm32 -lapp
arm-none-eabi-objcopy -O ihex stm32f4_out.elf stm32f4_out.hex
arm-none-eabi-objcopy -O binary stm32f4_out.elf stm32f4_out.bin
#Extract info contained in ELF to readable text-files:
arm-none-eabi-readelf -a stm32f4_out.elf > stm32f4_out.info_elf
arm-none-eabi-size -d -B -t stm32f4_out.elf > stm32f4_out.info_size
arm-none-eabi-objdump -S stm32f4_out.elf > stm32f4_out.info_code
arm-none-eabi-nm -t d -S --size-sort -s stm32f4_out.elf > stm32f4_out.info_symbol
xz@xiaqiu:~/study/stm32/ubuntu-stm32_1$ 
xz@xiaqiu:~/study/stm32/ubuntu-stm32_1$ ls
build     makefile.common         stm32f4_out.hex        stm32f4_out.info_symbol
hardware  STM32F407VGTx_FLASH.ld  stm32f4_out.info_code  tags
lib       stm32f4_out.bin         stm32f4_out.info_elf   user
makefile  stm32f4_out.elf         stm32f4_out.info_size
xz@xiaqiu:~/study/stm32/ubuntu-stm32_1$ 

标准例程-库函数版本 - 实验1跑马灯实验

https://gitee.com/mrxiao_com/ubuntu-stm32_2


xz@xiaqiu:~/study/stm32/ubuntu-stm32_2$ tree -L 3
.
├── build
├── hardware
│   ├── core
│   │   ├── core_cm4.h
│   │   ├── core_cm4_simd.h
│   │   ├── core_cmFunc.h
│   │   ├── core_cmInstr.h
│   │   ├── startup_stm32f40_41xxx.o
│   │   └── startup_stm32f40_41xxx.s
│   ├── fwlib
│   │   ├── inc
│   │   └── src
│   ├── led
│   │   ├── led.c
│   │   ├── led.h
│   │   └── led.o
│   ├── libstm32.a
│   ├── makefile
│   └── system
│       ├── delay
│       ├── sys
│       └── usart
├── lib
│   ├── libapp.a
│   └── libstm32.a
├── makefile
├── makefile.common
├── STM32F407VGTx_FLASH.ld
├── stm32f4_out.bin
├── stm32f4_out.elf
├── stm32f4_out.hex
├── stm32f4_out.info_code
├── stm32f4_out.info_elf
├── stm32f4_out.info_size
├── stm32f4_out.info_symbol
├── tags
└── user├── libapp.a├── main.c├── main.o├── makefile├── readme.md├── stm32f4xx_conf.h├── stm32f4xx.h├── stm32f4xx_it.c├── stm32f4xx_it.h├── stm32f4xx_it.o├── system_stm32f4xx.c├── system_stm32f4xx.h└── system_stm32f4xx.o13 directories, 37 files
xz@xiaqiu:~/study/stm32/ubuntu-stm32_2$ 

ubuntu-stm32_2/makefile


# general Makefileinclude makefile.common
LDFLAGS=$(COMMONFLAGS) -fno-exceptions -ffunction-sections -fdata-sections -L$(LIBDIR) -nostartfiles -Wl,--gc-sections,-TSTM32F407VGTx_FLASH.ld
LDLIBS+=-lstm32
LDLIBS+=-lappall: user  hardware$(CC) -g -o $(PROGRAM).elf $(LDFLAGS) \-Wl,--whole-archive \user/libapp.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_elfarm-none-eabi-size -d -B -t $(PROGRAM).elf > $(PROGRAM).info_sizearm-none-eabi-objdump -S $(PROGRAM).elf > $(PROGRAM).info_codearm-none-eabi-nm -t d -S --size-sort -s $(PROGRAM).elf > $(PROGRAM).info_symbolhardware:ECHO$(MAKE) -C  $@
user:ECHO$(MAKE) -C  $@
ECHO:echo $@
.PHONY: clean# 总控的makefile使用$(MAKE)这个宏调用,子目录下的makefile
# 这里的意思是先进入-C之后的目录中然后执行该目录下的makefileclean:hardware_clean user_cleanrm $(PROGRAM).* 
hardware_clean:@cd hardware && make clean
user_clean:@cd user && make clean

ubuntu-stm32_2/user/makefile


include ../makefile.commonCFLAGSlib+=-c -lc
USER = $(shell pwd)src += ./*.c
obj = ./*.o 
.PHONY :objlibapp.a : $(obj)$(AR) cr $@ \$^if [ -e libapp.a ]; then cp -f libapp.a ../lib; fi$(obj):$(CC)  $(CFLAGSlib) \-I./ \-I../include \-I../hardware/core \-I../hardware/fwlib/inc \-I../hardware/system/delay \-I../hardware/system/sys \-I../hardware/system/usart \-I../hardware/led \$(src).PHONY :clean
clean :rm libapp.a  $(obj)

ubuntu-stm32_2/hardware/makefile


# libs Makefile
include ../makefile.common
CFLAGSlib+=-c -Wall -Wno-unused-but-set-variableSTM32LIB = $(shell pwd)obj1 = $(STM32LIB)/core/*.o
obj2 = $(STM32LIB)/system/delay/*.o
obj3 = $(STM32LIB)/system/sys/*.o
obj4 = $(STM32LIB)/system/usart/*.o
obj5 = $(STM32LIB)/led/*.o
obj6 = $(STM32LIB)/fwlib/src/*.oinc1 = $(STM32LIB)/core
inc2 = $(STM32LIB)/system/delay
inc3 = $(STM32LIB)/system/sys
inc4 = $(STM32LIB)/system/usart
inc5 = $(STM32LIB)/led/
inc6 = $(STM32LIB)/fwlib/inc
inc7 = $(STM32LIB)/../userlibstm32.a: $(obj1) $(obj2) $(obj3) $(obj4) $(obj5) $(obj6)echo "comlile stm32lib.a"$(AR) cr $(STM32LIB)/$@ $^echo "make stm32lib success"if [ -e libstm32.a ]; then cp -f libstm32.a ../lib; fi$(obj1) :echo "comlile obj1"cd $(STM32LIB)/core && \$(CC) $(CFLAGSlib) \-I$(inc1) -I$(inc2) -I$(inc3) -I$(inc4) -I$(inc5) -I$(inc6) -I$(inc7) \*.s$(obj2) :echo "comlile obj2"cd $(STM32LIB)/system/delay && \$(CC) $(CFLAGSlib) \-I$(inc1) -I$(inc2) -I$(inc3) -I$(inc4) -I$(inc5) -I$(inc6) -I$(inc7) \*.c$(obj3) :echo "comlile obj3"cd $(STM32LIB)/system/sys && \$(CC) $(CFLAGSlib) \-I$(inc1) -I$(inc2) -I$(inc3) -I$(inc4) -I$(inc5) -I$(inc6) -I$(inc7) \*.c$(obj4) :echo "comlile obj4"cd $(STM32LIB)/system/usart && \$(CC) $(CFLAGSlib) \-I$(inc1) -I$(inc2) -I$(inc3) -I$(inc4) -I$(inc5) -I$(inc6) -I$(inc7) \*.c$(obj5) :echo "comlile obj5"cd $(STM32LIB)/led && \$(CC) $(CFLAGSlib) \-I$(inc1) -I$(inc2) -I$(inc3) -I$(inc4) -I$(inc5) -I$(inc6) -I$(inc7) \*.c$(obj6) :echo "comlile obj6"cd $(STM32LIB)/fwlib/src && \$(CC) $(CFLAGSlib) \-I$(inc1) -I$(inc2) -I$(inc3) -I$(inc4) -I$(inc5) -I$(inc6) -I$(inc7) \*.c.PHONY: clean 
clean:rm -f $(STM32LIB)/libstm32.a $(obj1) $(obj2) $(obj3) $(obj4) $(obj5) $(obj6)

编译


xz@xiaqiu:~/study/stm32/ubuntu-stm32_2$ make 
echo ECHO
ECHO
make -C  user
make[1]: 进入目录“/home/xz/study/stm32/ubuntu-stm32_2/user”
arm-none-eabi-gcc  -g -mcpu=cortex-m3 -mthumb -Wall -Werror -I/home/xz/study/stm32/ubuntu-stm32_2/user/include -D STM32F407xx  -D VECT_TAB_FLASH -c -lc \
-I./ \
-I../include \
-I../hardware/core \
-I../hardware/fwlib/inc \
-I../hardware/system/delay \
-I../hardware/system/sys \
-I../hardware/system/usart \
-I../hardware/led \
./*.c
arm-none-eabi-ar cr libapp.a \
*.o
if [ -e libapp.a ]; then cp -f libapp.a ../lib; fi
make[1]: 离开目录“/home/xz/study/stm32/ubuntu-stm32_2/user”
make -C  hardware
make[1]: 进入目录“/home/xz/study/stm32/ubuntu-stm32_2/hardware”
echo "comlile obj1"
comlile obj1
cd /home/xz/study/stm32/ubuntu-stm32_2/hardware/core && \
arm-none-eabi-gcc -g -mcpu=cortex-m3 -mthumb -Wall -Werror -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/include -D STM32F407xx  -D VECT_TAB_FLASH -c -Wall -Wno-unused-but-set-variable \-I/home/xz/study/stm32/ubuntu-stm32_2/hardware/core -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/system/delay -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/system/sys -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/system/usart -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/led/ -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/fwlib/inc -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/../user \*.s
echo "comlile obj2"
comlile obj2
cd /home/xz/study/stm32/ubuntu-stm32_2/hardware/system/delay && \
arm-none-eabi-gcc -g -mcpu=cortex-m3 -mthumb -Wall -Werror -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/include -D STM32F407xx  -D VECT_TAB_FLASH -c -Wall -Wno-unused-but-set-variable \-I/home/xz/study/stm32/ubuntu-stm32_2/hardware/core -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/system/delay -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/system/sys -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/system/usart -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/led/ -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/fwlib/inc -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/../user \*.c
echo "comlile obj3"
comlile obj3
cd /home/xz/study/stm32/ubuntu-stm32_2/hardware/system/sys && \
arm-none-eabi-gcc -g -mcpu=cortex-m3 -mthumb -Wall -Werror -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/include -D STM32F407xx  -D VECT_TAB_FLASH -c -Wall -Wno-unused-but-set-variable \-I/home/xz/study/stm32/ubuntu-stm32_2/hardware/core -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/system/delay -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/system/sys -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/system/usart -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/led/ -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/fwlib/inc -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/../user \*.c
echo "comlile obj4"
comlile obj4
cd /home/xz/study/stm32/ubuntu-stm32_2/hardware/system/usart && \
arm-none-eabi-gcc -g -mcpu=cortex-m3 -mthumb -Wall -Werror -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/include -D STM32F407xx  -D VECT_TAB_FLASH -c -Wall -Wno-unused-but-set-variable \-I/home/xz/study/stm32/ubuntu-stm32_2/hardware/core -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/system/delay -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/system/sys -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/system/usart -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/led/ -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/fwlib/inc -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/../user \*.c
echo "comlile obj5"
comlile obj5
cd /home/xz/study/stm32/ubuntu-stm32_2/hardware/led && \
arm-none-eabi-gcc -g -mcpu=cortex-m3 -mthumb -Wall -Werror -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/include -D STM32F407xx  -D VECT_TAB_FLASH -c -Wall -Wno-unused-but-set-variable \-I/home/xz/study/stm32/ubuntu-stm32_2/hardware/core -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/system/delay -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/system/sys -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/system/usart -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/led/ -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/fwlib/inc -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/../user \*.c
echo "comlile obj6"
comlile obj6
cd /home/xz/study/stm32/ubuntu-stm32_2/hardware/fwlib/src && \
arm-none-eabi-gcc -g -mcpu=cortex-m3 -mthumb -Wall -Werror -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/include -D STM32F407xx  -D VECT_TAB_FLASH -c -Wall -Wno-unused-but-set-variable \-I/home/xz/study/stm32/ubuntu-stm32_2/hardware/core -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/system/delay -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/system/sys -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/system/usart -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/led/ -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/fwlib/inc -I/home/xz/study/stm32/ubuntu-stm32_2/hardware/../user \*.c
echo "comlile stm32lib.a"
comlile stm32lib.a
arm-none-eabi-ar cr /home/xz/study/stm32/ubuntu-stm32_2/hardware/libstm32.a /home/xz/study/stm32/ubuntu-stm32_2/hardware/core/*.o /home/xz/study/stm32/ubuntu-stm32_2/hardware/system/delay/*.o /home/xz/study/stm32/ubuntu-stm32_2/hardware/system/sys/*.o /home/xz/study/stm32/ubuntu-stm32_2/hardware/system/usart/*.o /home/xz/study/stm32/ubuntu-stm32_2/hardware/led/*.o /home/xz/study/stm32/ubuntu-stm32_2/hardware/fwlib/src/*.o
echo "make stm32lib success"
make stm32lib success
if [ -e libstm32.a ]; then cp -f libstm32.a ../lib; fi
make[1]: 离开目录“/home/xz/study/stm32/ubuntu-stm32_2/hardware”
arm-none-eabi-gcc -g -o stm32f4_out.elf -g -mcpu=cortex-m3 -mthumb -fno-exceptions -ffunction-sections -fdata-sections -L/home/xz/study/stm32/ubuntu-stm32_2/lib -nostartfiles -Wl,--gc-sections,-TSTM32F407VGTx_FLASH.ld \-Wl,--whole-archive \user/libapp.a \-Wl,--no-whole-archive \-lstm32 -lapp
arm-none-eabi-objcopy -O ihex stm32f4_out.elf stm32f4_out.hex
arm-none-eabi-objcopy -O binary stm32f4_out.elf stm32f4_out.bin
#Extract info contained in ELF to readable text-files:
arm-none-eabi-readelf -a stm32f4_out.elf > stm32f4_out.info_elf
arm-none-eabi-size -d -B -t stm32f4_out.elf > stm32f4_out.info_size
arm-none-eabi-objdump -S stm32f4_out.elf > stm32f4_out.info_code
arm-none-eabi-nm -t d -S --size-sort -s stm32f4_out.elf > stm32f4_out.info_symbol
xz@xiaqiu:~/study/stm32/ubuntu-stm32_2$ 
xz@xiaqiu:~/study/stm32/ubuntu-stm32_2$ ls
build     makefile.common         stm32f4_out.hex        stm32f4_out.info_symbol
hardware  STM32F407VGTx_FLASH.ld  stm32f4_out.info_code  tags
lib       stm32f4_out.bin         stm32f4_out.info_elf   user
makefile  stm32f4_out.elf         stm32f4_out.info_size
xz@xiaqiu:~/study/stm32/ubuntu-stm32_2$ 

标准例程-HAL库版本 - 实验1跑马灯实验

https://gitee.com/mrxiao_com/ubuntu-stm32_3


xz@xiaqiu:~/study/stm32/ubuntu-stm32_3$ tree -L 3
.
├── build
├── hardware
│   ├── core
│   │   ├── cmsis_armcc.h
│   │   ├── cmsis_armclang.h
│   │   ├── cmsis_compiler.h
│   │   ├── cmsis_gcc.h
│   │   ├── cmsis_version.h
│   │   ├── core_cm4.h
│   │   ├── core_cmFunc.h
│   │   ├── core_cmInstr.h
│   │   ├── core_cmSimd.h
│   │   ├── mpu_armv7.h
│   │   ├── startup_stm32f40_41xxx.o
│   │   └── startup_stm32f40_41xxx.s
│   ├── led
│   │   ├── led.c
│   │   ├── led.h
│   │   └── led.o
│   ├── libstm32.a
│   ├── Makefile
│   ├── startup_stm32f407xx.s
│   ├── STM32F4xx_HAL_Driver
│   │   ├── Inc
│   │   └── Src
│   └── system
│       ├── delay
│       ├── sys
│       └── usart
├── include
│   ├── stm32f4xx_hal_conf.h
│   └── stm32f4xx_hal.h
├── lib
│   ├── libapp.a
│   └── libstm32.a
├── makefile
├── makefile.common
├── STM32F407VGTx_FLASH.ld
├── stm32f4_out.bin
├── stm32f4_out.elf
├── stm32f4_out.hex
├── stm32f4_out.info_code
├── stm32f4_out.info_elf
├── stm32f4_out.info_size
├── stm32f4_out.info_symbol
├── tags
└── user├── libapp.a├── main.c├── main.h├── main.o├── makefile├── stm32f407xx.h├── stm32f4xx.h├── stm32f4xx_hal_conf.h├── stm32f4xx_hal_msp.c├── stm32f4xx_hal_msp.o├── stm32f4xx_it.c├── stm32f4xx_it.h├── stm32f4xx_it.o├── system_stm32f4xx.c├── system_stm32f4xx.h└── system_stm32f4xx.o14 directories, 49 files
xz@xiaqiu:~/study/stm32/ubuntu-stm32_3$ 

ubuntu-stm32_3/makefile


# general Makefileinclude makefile.common
LDFLAGS=$(COMMONFLAGS) -fno-exceptions -ffunction-sections -fdata-sections -L$(LIBDIR) -nostartfiles -Wl,--gc-sections,-TSTM32F407VGTx_FLASH.ld
LDLIBS+=-lstm32
LDLIBS+=-lappall: user  hardware$(CC) -g -o $(PROGRAM).elf $(LDFLAGS) \-Wl,--whole-archive \user/libapp.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_elfarm-none-eabi-size -d -B -t $(PROGRAM).elf > $(PROGRAM).info_sizearm-none-eabi-objdump -S $(PROGRAM).elf > $(PROGRAM).info_codearm-none-eabi-nm -t d -S --size-sort -s $(PROGRAM).elf > $(PROGRAM).info_symbolhardware:ECHO$(MAKE) -C  $@
user:ECHO$(MAKE) -C  $@
ECHO:echo $@
.PHONY: clean# 总控的makefile使用$(MAKE)这个宏调用,子目录下的makefile
# 这里的意思是先进入-C之后的目录中然后执行该目录下的makefileclean:hardware_clean user_cleanrm $(PROGRAM).* lib/*
hardware_clean:@cd hardware && make clean
user_clean:@cd user && make clean

ubuntu-stm32_3/user/makefile


include ../makefile.commonCFLAGSlib+=-c
USER = $(shell pwd)src += ./*.c
obj = ./*.o 
.PHONY :objlibapp.a : $(obj)$(AR) cr $@ \$^@if [ -e libapp.a ]; then echo "cp -f libapp.a" && cp -f libapp.a ../lib; fi$(obj):$(CC)  $(CFLAGSlib) \-I./ \-I../include \-I../hardware/STM32F4xx_HAL_Driver/Inc \-I../hardware/core \-I../hardware/system/sys \-I../hardware/system/delay \-I../hardware/system/usart \-I../hardware/led \$(src) 
.PHONY :clean
clean :rm libapp.a  $(obj)

ubuntu-stm32_3/hardware/makefile


# libs Makefile
include ../makefile.common
CFLAGSlib+=-c -Wno-unused-but-set-variableSTM32LIB = $(shell pwd)obj1 = $(STM32LIB)/core/*.o
obj2 = $(STM32LIB)/led/*.o
obj3 = $(STM32LIB)/STM32F4xx_HAL_Driver/Src/*.o
obj4 = $(STM32LIB)/system/sys/*.o
obj5 = $(STM32LIB)/system/usart/*.o
obj6 = $(STM32LIB)/system/delay/*.oinc1 = $(STM32LIB)/core
inc2 = $(STM32LIB)/led
inc3 = $(STM32LIB)/STM32F4xx_HAL_Driver/Inc
inc4 = $(STM32LIB)/system/sys
inc5 = $(STM32LIB)/system/usart
inc6 = $(STM32LIB)/system/delay
inc7 = $(STM32LIB)/../userlibstm32.a: $(obj1) $(obj2) $(obj3) $(obj4) $(obj5) $(obj6)@echo "comlile libstm32.a"@$(AR) cr $(STM32LIB)/$@ $^@echo "make stm32lib success"@if [ -e $(STM32LIB)/libstm32.a ]; then cp -f $(STM32LIB)/libstm32.a ../lib; fi$(obj1) :echo "comlile obj1"cd $(STM32LIB)/core/ && \$(CC) $(CFLAGSlib) \-I$(inc1) -I$(inc2) -I$(inc3) -I$(inc4) -I$(inc5) -I$(inc6) -I$(inc7) \*.s$(obj2) :echo "comlile obj2"cd $(STM32LIB)/led/ && \$(CC) $(CFLAGSlib) \-I$(inc1) -I$(inc2) -I$(inc3) -I$(inc4) -I$(inc5) -I$(inc6) -I$(inc7)\-I../../../../include \*.c$(obj3) :echo "comlile obj3"cd $(STM32LIB)/STM32F4xx_HAL_Driver/Src/ && \$(CC) $(CFLAGSlib) \-I$(inc1) -I$(inc2) -I$(inc3) -I$(inc4) -I$(inc5) -I$(inc6) -I$(inc7)\-I../../../../include \*.c$(obj4) :echo "comlile obj4"cd $(STM32LIB)/system/sys/ && \$(CC) $(CFLAGSlib) \-I$(inc1) -I$(inc2) -I$(inc3) -I$(inc4) -I$(inc5) -I$(inc6) -I$(inc7)\-I../../../../include \*.c$(obj5) :echo "comlile obj5"cd $(STM32LIB)/system/usart/ && \$(CC) $(CFLAGSlib) \-I$(inc1) -I$(inc2) -I$(inc3) -I$(inc4) -I$(inc5) -I$(inc6) -I$(inc7)\-I../../../../include \*.c$(obj6) :echo "comlile obj6"cd $(STM32LIB)/system/delay/ && \$(CC) $(CFLAGSlib) \-I$(inc1) -I$(inc2) -I$(inc3) -I$(inc4) -I$(inc5) -I$(inc6) -I$(inc7)\-I../../../../include \*.c.PHONY: clean 
clean:rm -f $(STM32LIB)/libstm32.a $(obj1) $(obj2) $(obj3) $(obj4) $(obj5) $(obj6)

gdb 调试

连接stlink


xz@xiaqiu:~/study/stm32/ubuntu-stm32_3/hardware$ lsusb
Bus 001 Device 002: ID 8087:8001 Intel Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 004: ID 04f2:b502 Chicony Electronics Co., Ltd Integrated Camera
Bus 002 Device 003: ID 8087:07dc Intel Corp. 
Bus 002 Device 009: ID 0483:3748 STMicroelectronics ST-LINK/V2
Bus 002 Device 007: ID 18f8:0f99 [Maxxter] Optical gaming mouse
Bus 002 Device 008: ID 1c4f:0002 SiGma Micro Keyboard TRACER Gamma Ivory
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
xz@xiaqiu:~/study/stm32/ubuntu-stm32_3/hardware$ 

1运行openocd命令连接stlink


openocd -f interface/stlink-v2.cfg -f target/stm32f4x_stlink.cfg

xz@xiaqiu:~/study/stm32/ubuntu-stm32_3/hardware$ openocd -f interface/stlink-v2.cfg -f target/stm32f4x_stlink.cfg
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, readhttp://openocd.org/doc/doxygen/bugs.html
WARNING: target/stm32f4x_stlink.cfg is deprecated, please switch to target/stm32f4x.cfg
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
none separate
Error: couldn't bind tcl to socket: Address already in use
xz@xiaqiu:~/study/stm32/ubuntu-stm32_3/hardware$ 

端口被占用查看端口


xz@xiaqiu:~/study/stm32/ubuntu-stm32_3/hardware$ sudo netstat -nap
[sudo] xz 的密码: 
激活Internet连接 (服务器和已建立连接的)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      796/cupsd           
tcp        0      0 0.0.0.0:6665            0.0.0.0:*               LISTEN      1211/crtmpserver    
tcp        0      0 0.0.0.0:6666            0.0.0.0:*               LISTEN      1211/crtmpserver    
tcp        0      0 0.0.0.0:9999            0.0.0.0:*               LISTEN      1211/crtmpserver    
tcp        0      0 0.0.0.0:1935            0.0.0.0:*               LISTEN      1211/crtmpserver    
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      1211/crtmpserver    
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      731/systemd-resolve 
... ...
xz@xiaqiu:~/study/stm32/ubuntu-stm32_3/hardware$ sudo pkill crtmpserver 
xz@xiaqiu:~/study/stm32/ubuntu-stm32_3/hardware$ 

pkill 占用进程后重新运行


xz@xiaqiu:~/study/stm32/ubuntu-stm32_3/hardware$ openocd -f interface/stlink-v2.cfg -f target/stm32f4x_stlink.cfg
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, readhttp://openocd.org/doc/doxygen/bugs.html
WARNING: target/stm32f4x_stlink.cfg is deprecated, please switch to target/stm32f4x.cfg
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
none separate
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : clock speed 1800 kHz
Info : STLINK v2 JTAG v35 API v2 SWIM v7 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.237945
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
...

2.新终端输入命令下载程序

输入命令

telnet localhost 4444 

xz@xiaqiu:~/study/stm32/ubuntu-stm32_3/hardware$ telnet localhost 4444 
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
> 
下载程序

reset halt   
flash probe 0    
stm32f4x mass_erase 0
flash write_bank 0 /home/xz/study/stm32/ubuntu-stm32_3/stm32f4_out.elf 0
reset run 

xz@xiaqiu:~/study/stm32/ubuntu-stm32_3/hardware$ telnet localhost 4444 
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
> reset halt   
Unable to match requested speed 2000 kHz, using 1800 kHz
Unable to match requested speed 2000 kHz, using 1800 kHz
adapter speed: 1800 kHz
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08002f80 msp: 0x2001fffc
> flash probe 0    
device id = 0x10076413
flash size = 1024kbytes
flash 'stm32f2x' found at 0x08000000
> stm32f4x mass_erase 0
stm32x mass erase complete
> flash write_bank 0 /home/xz/study/stm32/ubuntu-stm32_3/stm32f4_out.elf 0
target halted due to breakpoint, current mode: Thread 
xPSR: 0x61000000 pc: 0x20000046 msp: 0x2001fffc
wrote 201112 bytes from file /home/xz/study/stm32/ubuntu-stm32_3/stm32f4_out.elf to flash bank 0 at offset 0x00000000 in 2.252120s (87.206 KiB/s)
> reset run 
Unable to match requested speed 2000 kHz, using 1800 kHz
Unable to match requested speed 2000 kHz, using 1800 kHz
adapter speed: 1800 kHz
> 

arm-none-eabi-gdb调试程序


arm-none-eabi-gdb stm32f4_out.elf
target remote localhost:3333
monitor reset  
monitor halt  
load 

xz@xiaqiu:~/study/stm32/ubuntu-stm32_3$ arm-none-eabi-gdb stm32f4_out.elf
GNU gdb (7.10-1ubuntu3+9) 7.10
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-linux-gnu --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from stm32f4_out.elf...done.
(gdb) target remote localhost:3333
Remote debugging using localhost:3333
0x08002f80 in ?? ()
(gdb) monitor reset  
Unable to match requested speed 2000 kHz, using 1800 kHz
Unable to match requested speed 2000 kHz, using 1800 kHz
adapter speed: 1800 kHz
(gdb) monitor halt  
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0x40000003 pc: 00000000 msp: 0x464c4550
(gdb) load
Loading section .isr_vector, size 0x188 lma 0x8000000
Loading section .text, size 0x219c lma 0x8000188
Loading section .rodata, size 0x18 lma 0x8002324
Loading section .ARM, size 0x8 lma 0x800233c
Loading section .data, size 0xc lma 0x8002344
Start address 0x80022d8, load size 9040
Transfer rate: 15 KB/sec, 1808 bytes/write.
(gdb)-

(gdb)-
(gdb)b main
(gdb)c

在这里插入图片描述
在这里插入图片描述

这篇关于ubuntu下stm32f407环境(正点原子)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/900391

相关文章

IntelliJ IDEA 中配置 Spring MVC 环境的详细步骤及问题解决

《IntelliJIDEA中配置SpringMVC环境的详细步骤及问题解决》:本文主要介绍IntelliJIDEA中配置SpringMVC环境的详细步骤及问题解决,本文分步骤结合实例给大... 目录步骤 1:创建 Maven Web 项目步骤 2:添加 Spring MVC 依赖1、保存后执行2、将新的依赖

Python如何自动生成环境依赖包requirements

《Python如何自动生成环境依赖包requirements》:本文主要介绍Python如何自动生成环境依赖包requirements问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑... 目录生成当前 python 环境 安装的所有依赖包1、命令2、常见问题只生成当前 项目 的所有依赖包1、

Redis在windows环境下如何启动

《Redis在windows环境下如何启动》:本文主要介绍Redis在windows环境下如何启动的实现方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录Redis在Windows环境下启动1.在redis的安装目录下2.输入·redis-server.exe

Pytest多环境切换的常见方法介绍

《Pytest多环境切换的常见方法介绍》Pytest作为自动化测试的主力框架,如何实现本地、测试、预发、生产环境的灵活切换,本文总结了通过pytest框架实现自由环境切换的几种方法,大家可以根据需要进... 目录1.pytest-base-url2.hooks函数3.yml和fixture结论你是否也遇到过

浅谈配置MMCV环境,解决报错,版本不匹配问题

《浅谈配置MMCV环境,解决报错,版本不匹配问题》:本文主要介绍浅谈配置MMCV环境,解决报错,版本不匹配问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录配置MMCV环境,解决报错,版本不匹配错误示例正确示例总结配置MMCV环境,解决报错,版本不匹配在col

Ubuntu中远程连接Mysql数据库的详细图文教程

《Ubuntu中远程连接Mysql数据库的详细图文教程》Ubuntu是一个以桌面应用为主的Linux发行版操作系统,这篇文章主要为大家详细介绍了Ubuntu中远程连接Mysql数据库的详细图文教程,有... 目录1、版本2、检查有没有mysql2.1 查询是否安装了Mysql包2.2 查看Mysql版本2.

新特性抢先看! Ubuntu 25.04 Beta 发布:Linux 6.14 内核

《新特性抢先看!Ubuntu25.04Beta发布:Linux6.14内核》Canonical公司近日发布了Ubuntu25.04Beta版,这一版本被赋予了一个活泼的代号——“Plu... Canonical 昨日(3 月 27 日)放出了 Beta 版 Ubuntu 25.04 系统镜像,代号“Pluc

Centos环境下Tomcat虚拟主机配置详细教程

《Centos环境下Tomcat虚拟主机配置详细教程》这篇文章主要讲的是在CentOS系统上,如何一步步配置Tomcat的虚拟主机,内容很简单,从目录准备到配置文件修改,再到重启和测试,手把手带你搞定... 目录1. 准备虚拟主机的目录和内容创建目录添加测试文件2. 修改 Tomcat 的 server.X

VSCode配置Anaconda Python环境的实现

《VSCode配置AnacondaPython环境的实现》VisualStudioCode中可以使用Anaconda环境进行Python开发,本文主要介绍了VSCode配置AnacondaPytho... 目录前言一、安装 Visual Studio Code 和 Anaconda二、创建或激活 conda

Ubuntu中Nginx虚拟主机设置的项目实践

《Ubuntu中Nginx虚拟主机设置的项目实践》通过配置虚拟主机,可以在同一台服务器上运行多个独立的网站,本文主要介绍了Ubuntu中Nginx虚拟主机设置的项目实践,具有一定的参考价值,感兴趣的可... 目录简介安装 Nginx创建虚拟主机1. 创建网站目录2. 创建默认索引文件3. 配置 Nginx4