最近在捣鼓LimeSDR
,如果只使用USB
供电的话,默认USB
固件只向系统声明了400MA
的电流。
明显当设备全功率运行的话,是不够设备使用的,全功率大约是3W
以上的样子,因此,我们需要调整USB
固件,向系统多申请些电流。
USB 3.0
可以提供900MA
的电流。
下面是如何编译LimeSDR
的USB
固件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
$ cd ~ $ wget https://www.mobibrw.com/wp-content/uploads/2018/02/FX3_SDK_Linux_v1.3.3.tar.gz $ tar -zxvf FX3_SDK_Linux_v1.3.3.tar.gz $ tar -zxvf ARM_GCC.tar.gz $ tar -zxvf fx3_firmware_linux.tar.gz $ tar -zxvf eclipse_x64.tar.gz $ export PATH=~/arm-2013.11/bin:$PATH $ export FX3_INSTALL_PATH=~/cyfx3sdk $ export ARMGCC_INSTALL_PATH=~/arm-2013.11 $ export ARMGCC_VERSION=4.8.1 #编译镜像打包工具 $ cd ~/cyfx3sdk/util/elf2img $ gcc elf2img.c -o elf2img -Wall $ cd ~ $ git clone https://github.com/myriadrf/LimeSDR-USB_FX3.git $ ./eclipse/ezUsbSuite |
参照下面的步骤导入工程(但是要注意的是,用ezUsbSuite
开发,目前在不修改工程的情况下,只能在Windows
下开发,原因是模板设置的时候,部分路径没有配置正确)
对于ubuntu
系统,并且需要使用命令行编译的情况,需要手工生成如下几个文件( 这几个文件根据Debug
目录下的配置文件修改来的)
1 2 3 4 5 6 7 8 9 10 11 12 13 |
$ cd LimeSDR-USB_FX3 $ mkdir Release $ cd Release $ touch makefile $ touch objects.mk $ touch sources.mk $ touch subdir.mk |
编译配置文件的内容如下:
makefile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
################################################################################ # Automatically-generated file. Do not edit! ################################################################################ RM := rm -rf # All of the sources participating in the build are defined here -include sources.mk -include subdir.mk -include objects.mk ifneq ($(MAKECMDGOALS),clean) ifneq ($(strip $(ASM_DEPS)),) -include $(ASM_DEPS) endif ifneq ($(strip $(S_UPPER_DEPS)),) -include $(S_UPPER_DEPS) endif ifneq ($(strip $(C_DEPS)),) -include $(C_DEPS) endif endif -include ../makefile.defs # Add inputs and outputs from these tool invocations to the build variables SECONDARY_LIST += \ LimeSDR-USB_FX3.lst \ SECONDARY_SIZE += \ LimeSDR-USB_FX3.siz \ # All Target all: LimeSDR-USB_FX3.elf secondary-outputs # Tool invocations LimeSDR-USB_FX3.elf: $(OBJS) $(USER_OBJS) @echo 'Building target: $@' @echo 'Invoking: ARM Sourcery Windows GCC C Linker' arm-none-eabi-gcc $(OBJS) $(USER_OBJS) $(LIBS) -T"$(FX3_INSTALL_PATH)/firmware/common/fx3.ld" -nostartfiles -Wl,-Map,LimeSDR-USB_FX3.map -Wl,-d -Wl,--no-wchar-size-warning -Wl,--entry,CyU3PFirmwareEntry "$(FX3_INSTALL_PATH)/firmware/u3p_firmware/lib/fx3_release/cyfxapi.a" "$(FX3_INSTALL_PATH)/firmware/u3p_firmware/lib/fx3_release/cyu3lpp.a" "$(FX3_INSTALL_PATH)/firmware/u3p_firmware/lib/fx3_release/cyu3threadx.a" "$(ARMGCC_INSTALL_PATH)/arm-none-eabi/lib/libc.a" "$(ARMGCC_INSTALL_PATH)/lib/gcc/arm-none-eabi/4.8.1/libgcc.a" -mcpu=arm926ej-s -mthumb-interwork -o"LimeSDR-USB_FX3.elf" @echo 'Finished building target: $@' @echo ' ' $(MAKE) --no-print-directory post-build LimeSDR-USB_FX3.lst: LimeSDR-USB_FX3.elf @echo 'Invoking: ARM Sourcery Windows GNU Create Listing' arm-none-eabi-objdump -h -S LimeSDR-USB_FX3.elf > "LimeSDR-USB_FX3.lst" @echo 'Finished building: $@' @echo ' ' LimeSDR-USB_FX3.siz: LimeSDR-USB_FX3.elf @echo 'Invoking: ARM Sourcery Windows GNU Print Size' arm-none-eabi-size --format=berkeley LimeSDR-USB_FX3.elf @echo 'Finished building: $@' @echo ' ' # Other Targets clean: -$(RM) $(EXECUTABLES)$(OBJS)$(SECONDARY_LIST)$(SECONDARY_SIZE)$(ASM_DEPS)$(S_UPPER_DEPS)$(C_DEPS) LimeSDR-USB_FX3.elf -@echo ' ' post-build: -@echo 'Converting ELF to image (.img) format' -"$(FX3_INSTALL_PATH)/util/elf2img/elf2img" -i LimeSDR-USB_FX3.elf -o LimeSDR-USB_FX3.img -@echo ' ' secondary-outputs: $(SECONDARY_LIST) $(SECONDARY_SIZE) .PHONY: all clean dependents .SECONDARY: post-build -include ../makefile.targets |
objects.mk
1 2 3 4 5 6 7 |
################################################################################ # Automatically-generated file. Do not edit! ################################################################################ USER_OBJS := LIBS := |
sources.mk
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
################################################################################ # Automatically-generated file. Do not edit! ################################################################################ ELF_SRCS := OBJ_SRCS := ASM_SRCS := C_SRCS := S_UPPER_SRCS := O_SRCS := EXECUTABLES := OBJS := SECONDARY_LIST := SECONDARY_SIZE := ASM_DEPS := S_UPPER_DEPS := C_DEPS := # Every subdirectory with source files must be described here SUBDIRS := \ . \ |
subdir.mk
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
################################################################################ # Automatically-generated file. Do not edit! ################################################################################ # Add inputs and outputs from these tool invocations to the build variables C_SRCS += \ ../main.c \ ../rtos_threadx.c \ ../spi_flash_lib.c \ ../usb_descriptors.c S_UPPER_SRCS += \ ../cyfx_gcc_startup.S OBJS += \ ./cyfx_gcc_startup.o \ ./main.o \ ./rtos_threadx.o \ ./spi_flash_lib.o \ ./usb_descriptors.o S_UPPER_DEPS += \ ./cyfx_gcc_startup.d C_DEPS += \ ./main.d \ ./rtos_threadx.d \ ./spi_flash_lib.d \ ./usb_descriptors.d # Each subdirectory must supply rules for building sources it contributes %.o: ../%.S @echo 'Building file: $<' @echo 'Invoking: ARM Sourcery Windows GCC Assembler' arm-none-eabi-gcc -x assembler-with-cpp -I"$(FX3_INSTALL_PATH)/firmware/u3p_firmware/inc" -Wall -Wa,-adhlns="$@.lst" -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -mcpu=arm926ej-s -mthumb-interwork -o "$@" "$<" @echo 'Finished building: $<' @echo ' ' %.o: ../%.c @echo 'Building file: $<' @echo 'Invoking: ARM Sourcery Windows GCC C Compiler' arm-none-eabi-gcc -D__CYU3P_TX__=1 -I"$(FX3_INSTALL_PATH)/firmware/u3p_firmware/inc" -I"..\." -Os -Wall -Wa,-adhlns="$@.lst" -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -mcpu=arm926ej-s -mthumb-interwork -o "$@" "$<" @echo 'Finished building: $<' @echo ' ' |
上面的文件生成后,在同一个Shell
中执行
1 2 3 4 5 |
#编译之前确保 FX3_INSTALL_PATH,ARMGCC_INSTALL_PATH等几个环境变量已经正确定义 $ make clean $ make |
即可在Release
目录下生成LimeSDR-USB_FX3.img
,这个就是需要的刷机镜像。
参照ubuntu 16.04修复固件刷新失败的LimeSDR-USB V1.4,或者
1 |
$ LimeUtil --fw="LimeSDR-USB_FX3.img" |
刷新固件即可。
至于电源控制部分的代码,调整usb_descriptors.c
里面的Max power
部分的数字即可:
1 2 3 4 5 6 7 8 9 10 11 12 |
/* Standard super speed configuration descriptor */ const uint8_t CyFxUSBSSConfigDscr[] __attribute__ ((aligned (32))) = { /* Configuration descriptor */ 0x09, /* Descriptor size */ CY_U3P_USB_CONFIG_DESCR, /* Configuration descriptor type */ 0x46,0x00, /* Length of this descriptor and all sub descriptors */ 0x01, /* Number of interfaces */ 0x01, /* Configuration number */ 0x00, /* COnfiguration string index */ 0x80, /* Config characteristics - Bus powered */ 0x32, /* Max power consumption of device (in 8mA unit) : 400mA */ |
刷新完成后,使用
1 2 3 |
#注意,ubuntu 16.04版本的lsusb -v ,命令显示的 MaxPower 参数是不正确的 $ usb-devices |
查看设备供电情况。
如果固件代码无法成功下载,可以本站下载一份拷贝。