我下载官网的MSP430的USB开发包 MSP430USBDevelopersPackage_5_20_07_01.zip,解压后到解压目录下
MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC
准备使用msp430-elf-gcc 编译这个工程
简单修改Makefile中的第4行

原本是
REDHAT_GCC =
改为:
REDHAT_GCC = /home/jjinl/gcc_set/msp430-gcc
用于指定msp430 gcc路径
改动Makefile的第17行:

添加了 -L $(SUPPORT_FILE_DIRECTORY) 不然会报错如下:

接着再次进行make时候会报重定义,报错如下
make /home/jjinl/gcc_set/msp430-gcc/bin/msp430-elf-gcc -I /home/jjinl/gcc_set/msp430-gcc/include -I ./../../../.. -I ./../../../../driverlib/MSP430F5xx_6xx -I ./../../../../examples/CDC_virtualCOMport/C0_SimpleSend -I ./../../../../examples/CDC_virtualCOMport/C0_SimpleSend/USB_config -I ./../../../../USB_API -D__MSP430F5529__ -DDEPRECATED -mmcu=msp430f5529 -O3 -Os -g -fdata-sections -w -L /home/jjinl/gcc_set/msp430-gcc/include -T ./../../../../USB_API/msp430USB.ld -T /home/jjinl/gcc_set/msp430-gcc/include/msp430f5529.ld -Wl,--gc-sections ../system_pre_init.c ../hal.c ../main.c ../USB_config/UsbIsr.c ../USB_config/descriptors.c ../USB_app/usbConstructs.c ../USB_app/usbEventHandling.c ../../../../USB_API/USB_PHDC_API/UsbPHDC.c ../../../../USB_API/USB_HID_API/UsbHid.c ../../../../USB_API/USB_HID_API/UsbHidReq.c ../../../../USB_API/USB_CDC_API/UsbCdc.c ../../../../USB_API/USB_Common/usb.c ../../../../USB_API/USB_Common/usbdma.c ../../../../USB_API/USB_MSC_API/UsbMscScsi.c ../../../../USB_API/USB_MSC_API/UsbMscStateMachine.c ../../../../USB_API/USB_MSC_API/UsbMscReq.c ../../../../driverlib/MSP430F5xx_6xx/dac12_a.c ../../../../driverlib/MSP430F5xx_6xx/usci_b_spi.c ../../../../driverlib/MSP430F5xx_6xx/usci_b_i2c.c ../../../../driverlib/MSP430F5xx_6xx/ctsd16.c ../../../../driverlib/MSP430F5xx_6xx/rtc_a.c ../../../../driverlib/MSP430F5xx_6xx/tec.c ../../../../driverlib/MSP430F5xx_6xx/ucs.c ../../../../driverlib/MSP430F5xx_6xx/ldopwr.c ../../../../driverlib/MSP430F5xx_6xx/battbak.c ../../../../driverlib/MSP430F5xx_6xx/sd24_b.c ../../../../driverlib/MSP430F5xx_6xx/gpio.c ../../../../driverlib/MSP430F5xx_6xx/dma.c ../../../../driverlib/MSP430F5xx_6xx/wdt_a.c ../../../../driverlib/MSP430F5xx_6xx/adc10_a.c ../../../../driverlib/MSP430F5xx_6xx/pmm.c ../../../../driverlib/MSP430F5xx_6xx/usci_a_uart.c ../../../../driverlib/MSP430F5xx_6xx/comp_b.c ../../../../driverlib/MSP430F5xx_6xx/sysctl.c ../../../../driverlib/MSP430F5xx_6xx/mpy32.c ../../../../driverlib/MSP430F5xx_6xx/flashctl.c ../../../../driverlib/MSP430F5xx_6xx/oa.c ../../../../driverlib/MSP430F5xx_6xx/lcd_b.c ../../../../driverlib/MSP430F5xx_6xx/tlv.c ../../../../driverlib/MSP430F5xx_6xx/eusci_a_uart.c ../../../../driverlib/MSP430F5xx_6xx/aes.c ../../../../driverlib/MSP430F5xx_6xx/timer_a.c ../../../../driverlib/MSP430F5xx_6xx/rtc_c.c ../../../../driverlib/MSP430F5xx_6xx/timer_b.c ../../../../driverlib/MSP430F5xx_6xx/ram.c ../../../../driverlib/MSP430F5xx_6xx/eusci_b_i2c.c ../../../../driverlib/MSP430F5xx_6xx/ref.c ../../../../driverlib/MSP430F5xx_6xx/timer_d.c ../../../../driverlib/MSP430F5xx_6xx/pmap.c ../../../../driverlib/MSP430F5xx_6xx/eusci_b_spi.c ../../../../driverlib/MSP430F5xx_6xx/adc12_a.c ../../../../driverlib/MSP430F5xx_6xx/rtc_b.c ../../../../driverlib/MSP430F5xx_6xx/eusci_a_spi.c ../../../../driverlib/MSP430F5xx_6xx/usci_a_spi.c ../../../../driverlib/MSP430F5xx_6xx/sfr.c ../../../../driverlib/MSP430F5xx_6xx/crc.c -o C0_SimpleSend.out /home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/ccmmI6UN.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:107: multiple definition of `CdcReadCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:107: first defined here /home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/ccmmI6UN.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:94: multiple definition of `CdcWriteCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:94: first defined here /home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/cc7ugCZa.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:107: multiple definition of `CdcReadCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:107: first defined here /home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/cc7ugCZa.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:94: multiple definition of `CdcWriteCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:94: first defined here /home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/ccrOYl9x.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:107: multiple definition of `CdcReadCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:107: first defined here /home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/ccrOYl9x.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:94: multiple definition of `CdcWriteCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:94: first defined here /home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/ccR2FhpV.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:107: multiple definition of `CdcReadCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:107: first defined here /home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/ccR2FhpV.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:94: multiple definition of `CdcWriteCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:94: first defined here /home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/cchKoC7q.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/../../../../USB_API/USB_CDC_API/../USB_CDC_API/UsbCdc.h:94: multiple definition of `CdcWriteCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:94: first defined here /home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/cchKoC7q.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/../../../../USB_API/USB_CDC_API/../USB_CDC_API/UsbCdc.h:107: multiple definition of `CdcReadCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:107: first defined here /home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/ccBjRddP.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/../../../../USB_API/USB_Common/../USB_CDC_API/UsbCdc.h:107: multiple definition of `CdcReadCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:107: first defined here /home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/ccBjRddP.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/../../../../USB_API/USB_Common/../USB_CDC_API/UsbCdc.h:94: multiple definition of `CdcWriteCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:94: first defined here collect2: error: ld returned 1 exit status Makefile:79: recipe for target 'C0_SimpleSend' failed make: *** [C0_SimpleSend] Error 1
我仔细看了,原因是在 MSP430_USB_Software/MSP430_USB_API/USB_API/USB_CDC_API/UsbCdc.h这个文件中,在头文件中定义两个结构体变量,多处包含头文件后,会导致重复定义
/*
* ======== UsbCdc.h ========
*/
#ifndef _UsbCdc_H_
#define _UsbCdc_H_
#ifdef __cplusplus
extern "C"
{
#endif
/*----------------------------------------------------------------------------
* The following function names and macro names are deprecated. These were
* updated to new names to follow OneMCU naming convention.
+---------------------------------------------------------------------------*/
#ifndef DEPRECATED
#define kUSBCDC_sendStarted USBCDC_SEND_STARTED
#define kUSBCDC_sendComplete USBCDC_SEND_COMPLETE
#define kUSBCDC_intfBusyError USBCDC_INTERFACE_BUSY_ERROR
#define kUSBCDC_receiveStarted USBCDC_RECEIVE_STARTED
#define kUSBCDC_receiveCompleted USBCDC_RECEIVE_COMPLETED
#define kUSBCDC_receiveInProgress USBCDC_RECEIVE_IN_PROGRESS
#define kUSBCDC_generalError USBCDC_GENERAL_ERROR
#define kUSBCDC_busNotAvailable USBCDC_BUS_NOT_AVAILABLE
#define kUSBCDC_waitingForSend USBCDC_WAITING_FOR_SEND
#define kUSBCDC_waitingForReceive USBCDC_WAITING_FOR_RECEIVE
#define kUSBCDC_dataWaiting USBCDC_DATA_WAITING
#define kUSB_allCdcEvents USBCDC_ALL_CDC_EVENTS
#define kUSBCDC_noDataWaiting USBCDC_NO_DATA_WAITING
#define USBCDC_intfStatus USBCDC_getInterfaceStatus
#define USBCDC_bytesInUSBBuffer USBCDC_getBytesInUSBBuffer
#endif
#define USBCDC_SEND_STARTED 0x01
#define USBCDC_SEND_COMPLETE 0x02
#define USBCDC_INTERFACE_BUSY_ERROR 0x03
#define USBCDC_RECEIVE_STARTED 0x04
#define USBCDC_RECEIVE_COMPLETED 0x05
#define USBCDC_RECEIVE_IN_PROGRESS 0x06
#define USBCDC_GENERAL_ERROR 0x07
#define USBCDC_BUS_NOT_AVAILABLE 0x08
//returned by USBCDC_rejectData() if no data pending
#define USBCDC_NO_DATA_WAITING 0X01
#define USBCDC_WAITING_FOR_SEND 0x01
#define USBCDC_WAITING_FOR_RECEIVE 0x02
#define USBCDC_DATA_WAITING 0x04
#define USBCDC_BUS_NOT_AVAILABLE 0x08
#define USBCDC_ALL_CDC_EVENTS 0xFF
#ifdef _CDC_
struct _CdcWrite {
uint16_t nCdcBytesToSend; //holds counter of bytes to be sent
uint16_t nCdcBytesToSendLeft; //holds counter how many bytes is still to be sent
const uint8_t* pUsbBufferToSend; //holds the buffer with data to be sent
uint8_t bCurrentBufferXY; //is 0 if current buffer to write data is X, or 1 if current buffer is Y
uint8_t bZeroPacketSent; //= FALSE;
uint8_t last_ByteSend;
} CdcWriteCtrl[CDC_NUM_INTERFACES];
struct _CdcRead {
uint8_t *pUserBuffer; //holds the current position of user's receiving buffer. If NULL- no receiving
//operation started
uint8_t *pCurrentEpPos; //current positon to read of received data from curent EP
uint16_t nBytesToReceive; //holds how many bytes was requested by receiveData() to receive
uint16_t nBytesToReceiveLeft; //holds how many bytes is still requested by receiveData() to receive
uint8_t * pCT1; //holds current EPBCTxx register
uint8_t * pCT2; //holds next EPBCTxx register
uint8_t * pEP2; //holds addr of the next EP buffer
uint8_t nBytesInEp; //how many received bytes still available in current EP
uint8_t bCurrentBufferXY; //indicates which buffer is used by host to transmit data via OUT endpoint3
} CdcReadCtrl[CDC_NUM_INTERFACES];
#endif
这个问题怎么解决,直接修改标准头文件, 还是USB库故意这样做??