STのUSBLibがFreeRtosに移行して、ビルドまではできました。
結構改造したので、メモしましょう。
FwLibのバージョン番号はV2.0.3
USBLibのバージョン番号はV2.2.1
Makefileを下記に示します
# Project name
PROJECT_NAME=RTOSDemo
RTOS_SOURCE_DIR=../../../Source
DEMO_COMMON_DIR=../../Common/Minimal
DEMO_INCLUDE_DIR=../../Common/include
ST_LIB_DIR=../../Common/drivers/ST/STM32F10xFWLib/v2_0_3
ST_USB_LIB_DIR=../../Common/drivers/ST/USBLib/library
ST_USBCODE_DIR=./STCode/usblib
CC=arm-none-eabi-gcc
OBJCOPY=arm-none-eabi-objcopy
OBJDUMP=arm-none-eabi-size
NM = arm-none-eabi-nm
LDSCRIPT=stm32_flash.ld
# should use --gc-sections but the debugger does not seem to be able to cope with the option.
LINKER_FLAGS=-nostartfiles -Xlinker -o$(PROJECT_NAME).axf -Xlinker -M -Xlinker -Map=$(PROJECT_NAME).map -Xlinker --no-gc-sections
DEBUG=-ggdb
OPTIM=-O0
CFLAGS=$(DEBUG) \
$(OPTIM) \
-T$(LDSCRIPT) \
-I . \
-I ./STCode \
-I $(RTOS_SOURCE_DIR)/include \
-I $(RTOS_SOURCE_DIR)/portable/GCC/ARM_CM3 \
-I $(DEMO_INCLUDE_DIR) \
-I $(ST_LIB_DIR)/inc \
-I $(ST_USB_LIB_DIR)/inc \
-I $(ST_USBCODE_DIR) \
-D GCC_ARMCM3 \
-D inline= \
-D PACK_STRUCT_END=__attribute\(\(packed\)\) \
-D ALIGN_STRUCT_END=__attribute\(\(aligned\(4\)\)\) \
-mthumb \
-mcpu=cortex-m3 \
-ffunction-sections \
-fdata-sections
SOURCE= main.c \
timertest.c \
printf.c \
stm32f10x_it.c \
./ParTest/ParTest.c \
./STCode/lcd_mb694.c \
./serial/serial.c \
$(ST_LIB_DIR)/src/stm32f10x_lib.c \
$(ST_LIB_DIR)/src/stm32f10x_rcc.c \
$(ST_LIB_DIR)/src/stm32f10x_gpio.c \
$(ST_LIB_DIR)/src/stm32f10x_spi.c \
$(ST_LIB_DIR)/src/stm32f10x_systick.c \
$(ST_LIB_DIR)/src/stm32f10x_tim.c \
$(ST_LIB_DIR)/src/stm32f10x_usart.c \
$(ST_LIB_DIR)/src/stm32f10x_nvic.c \
$(ST_LIB_DIR)/src/stm32f10x_fsmc.c \
$(ST_LIB_DIR)/src/stm32f10x_flash.c \
$(ST_USB_LIB_DIR)/src/usb_init.c \
$(ST_USB_LIB_DIR)/src/usb_regs.c \
$(ST_USB_LIB_DIR)/src/usb_mem.c \
$(ST_USB_LIB_DIR)/src/usb_int.c \
$(ST_USB_LIB_DIR)/src/usb_core.c \
$(ST_USBCODE_DIR)/usb_istr.c \
$(ST_USBCODE_DIR)/usb_desc.c \
$(ST_USBCODE_DIR)/usb_pwr.c \
$(ST_USBCODE_DIR)/usb_endp.c \
$(ST_USBCODE_DIR)/usb_prop.c \
$(ST_USBCODE_DIR)/hw_config.c \
$(DEMO_COMMON_DIR)/blocktim.c \
$(DEMO_COMMON_DIR)/death.c \
$(DEMO_COMMON_DIR)/flash.c \
$(DEMO_COMMON_DIR)/integer.c \
$(DEMO_COMMON_DIR)/PollQ.c \
$(DEMO_COMMON_DIR)/semtest.c \
$(RTOS_SOURCE_DIR)/list.c \
$(RTOS_SOURCE_DIR)/queue.c \
$(RTOS_SOURCE_DIR)/tasks.c \
$(RTOS_SOURCE_DIR)/portable/GCC/ARM_CM3/port.c \
$(RTOS_SOURCE_DIR)/portable/MemMang/heap_2.c
LIBS=
OBJS = $(SOURCE:.c=.o)
all: $(PROJECT_NAME).bin $(PROJECT_NAME).hex
$(PROJECT_NAME).bin : $(PROJECT_NAME).axf
$(OBJCOPY) $(PROJECT_NAME).axf -O binary $(PROJECT_NAME).bin
$(PROJECT_NAME).hex : $(PROJECT_NAME).axf
$(OBJCOPY) $(PROJECT_NAME).axf -O ihex $(PROJECT_NAME).hex
$(PROJECT_NAME).axf : $(OBJS) crt0_STM32x.o Makefile
$(CC) $(CFLAGS) $(OBJS) crt0_STM32x.o cortexm3_macro.s $(LIBS) $(LINKER_FLAGS)
$(OBJS) : %.o : %.c Makefile FreeRTOSConfig.h
$(CC) -c $(CFLAGS) $< -o $@ crt0_STM32x.o : crt0_STM32x.c Makefile $(CC) -c $(CFLAGS) -O1 crt0_STM32x.c -o crt0_STM32x.o clean : rm $(OBJS) rm crt0_STM32x.o rm $(PROJECT_NAME).axf rm $(PROJECT_NAME).hex log : $(PROJECT_NAME).axf $(NM) -n $(PROJECT_NAME).axf > $(PROJECT_NAME)SymbolTable.txt
$(OBJDUMP) $(PROJECT_NAME).axf > $(PROJECT_NAME)MemoryListing.txt
コピーしたファイルは下記のとおり
../
usblib/
| hw_config.h
| platform_config.h
| usb_conf.h
| usb_desc.h
| usb_istr.h
| usb_prop.h
| usb_pwr.h
| hw_config.c
| usb_desc.c
| usb_endp.c
| usb_istr.c
| usb_prop.c
| usb_pwr.c
次はstm32f10x_conf.h に一行を追加します
#define _FLASH
最後はmain.cに必要なヘッドファイルを追加します
#include "usb_lib.h"
#include "usb_desc.h"
#include "usb_pwr.h"
#include "hw_config.h"
実機に確認しましたが、USB認識でもできません。
PIDとVIDをきちんと書きましたが、何で動かないの?
謎ですね...
0 件のコメント:
コメントを投稿