diff options
author | Josh Blum <josh@joshknows.com> | 2010-11-29 11:37:18 -0500 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-12-12 18:23:46 -0800 |
commit | c08da91e832637e3197758f81128682f6fccf1bd (patch) | |
tree | a64580fa299b435db389741c8a31f918300c6f81 /firmware/microblaze | |
parent | 096405b9291d1d3b3ac37d9768232cca43a37db6 (diff) | |
download | uhd-c08da91e832637e3197758f81128682f6fccf1bd.tar.gz uhd-c08da91e832637e3197758f81128682f6fccf1bd.tar.bz2 uhd-c08da91e832637e3197758f81128682f6fccf1bd.zip |
usrp-n: created cmake/zpu build for firmware
Diffstat (limited to 'firmware/microblaze')
-rw-r--r-- | firmware/microblaze/CMakeLists.txt | 120 | ||||
-rw-r--r-- | firmware/microblaze/lib/CMakeLists.txt | 47 | ||||
-rw-r--r-- | firmware/microblaze/lib/hal_io.h | 28 | ||||
-rw-r--r-- | firmware/microblaze/lib/hal_uart.c | 2 | ||||
-rw-r--r-- | firmware/microblaze/lib/mdelay.c | 3 | ||||
-rw-r--r-- | firmware/microblaze/usrp2/CMakeLists.txt | 35 | ||||
-rw-r--r-- | firmware/microblaze/usrp2p/CMakeLists.txt | 48 |
7 files changed, 267 insertions, 16 deletions
diff --git a/firmware/microblaze/CMakeLists.txt b/firmware/microblaze/CMakeLists.txt new file mode 100644 index 000000000..dd56f3579 --- /dev/null +++ b/firmware/microblaze/CMakeLists.txt @@ -0,0 +1,120 @@ +# +# Copyright 2010 Ettus Research LLC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +######################################################################## +# setup project and compiler +######################################################################## +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +SET(CMAKE_C_COMPILER zpu-elf-gcc) +SET(CMAKE_C_COMPILER_WORKS TRUE) +SET(CMAKE_C_COMPILER_FORCED TRUE) +PROJECT(USRP_NXXX_FW C) + +######################################################################## +# lwIP header include dirs +######################################################################## +SET(LWIPDIR ${CMAKE_SOURCE_DIR}/lwip/lwip-1.3.1) + +INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/lwip + ${CMAKE_SOURCE_DIR}/lwip_port + ${LWIPDIR}/src/include + ${LWIPDIR}/src/include/ipv4 +) + +######################################################################## +# misc flags for the gcc compiler +######################################################################## +SET(CMAKE_C_FLAGS -abel) #always needed compile time and link time +#ADD_DEFINITIONS(-mxl-soft-div -msoft-float -mxl-soft-mul -mxl-barrel-shift) +ADD_DEFINITIONS(-Os --std=gnu99 -Wall -Werror-implicit-function-declaration) + +MACRO(ADD_LINKER_FLAGS flags) + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flags}") +ENDMACRO(ADD_LINKER_FLAGS) + +ADD_LINKER_FLAGS("-Wl,-defsym -Wl,_STACK_SIZE=3072") +ADD_LINKER_FLAGS("-Wl,--relax -Wl,--gc-sections") + +######################################################################## +# define for the hal io (FIXME move?) +######################################################################## +#ADD_DEFINITIONS(-DHAL_IO_USES_DBOARD_PINS) +ADD_DEFINITIONS(-DHAL_IO_USES_UART) + +######################################################################## +# common cflags and ldflags +######################################################################## +INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/../../host/lib/usrp + ${CMAKE_SOURCE_DIR}/lib +) + +######################################################################## +# setup programs for output files +######################################################################## +FIND_PROGRAM(LINKER zpu-elf-ld) +FIND_PROGRAM(OBJCOPY zpu-elf-objcopy) +FIND_PROGRAM(OBJDUMP zpu-elf-objdump) +FIND_PROGRAM(HEXDUMP hexdump) + +######################################################################## +# helper functions to build output formats +######################################################################## +MACRO(GEN_OUTPUTS target) + GET_FILENAME_COMPONENT(name ${target} NAME_WE) + #command to create a map from elf + ADD_CUSTOM_COMMAND( + OUTPUT ${name}.map DEPENDS ${target} + COMMAND ${LINKER} + ARGS -Map ${name}.map ${target} + ) + #command to create a bin from elf + ADD_CUSTOM_COMMAND( + OUTPUT ${name}.bin DEPENDS ${target} + COMMAND ${OBJCOPY} + ARGS -O binary ${target} ${name}.bin + ) + #command to create a ihx from elf + ADD_CUSTOM_COMMAND( + OUTPUT ${name}.ihx DEPENDS ${target} + COMMAND ${OBJCOPY} + ARGS -O ihex ${target} ${name}.ihx + ) + #command to create a dump from elf + ADD_CUSTOM_COMMAND( + OUTPUT ${name}.dump DEPENDS ${target} + COMMAND ${OBJDUMP} + ARGS -DSC ${target} > ${name}.dump + ) + #command to create a rom from bin + ADD_CUSTOM_COMMAND( + OUTPUT ${name}.rom DEPENDS ${name}.bin + COMMAND ${HEXDUMP} + ARGS -v -e'1/1 \"%.2X\\n\"' ${name}.bin > ${name}.rom + ) + #add a top level target for output files + ADD_CUSTOM_TARGET( + ${name}_outputs ALL DEPENDS ${name}.map ${name}.bin ${name}.ihx ${name}.dump ${name}.rom + ) +ENDMACRO(GEN_OUTPUTS) + +######################################################################## +# Add the subdirectories +######################################################################## +ADD_SUBDIRECTORY(usrp2) +ADD_SUBDIRECTORY(usrp2p) diff --git a/firmware/microblaze/lib/CMakeLists.txt b/firmware/microblaze/lib/CMakeLists.txt new file mode 100644 index 000000000..193d63cfa --- /dev/null +++ b/firmware/microblaze/lib/CMakeLists.txt @@ -0,0 +1,47 @@ +# +# Copyright 2010 Ettus Research LLC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +######################################################################## +SET(COMMON_SRCS + ${CMAKE_SOURCE_DIR}/lib/u2_init.c + ${CMAKE_SOURCE_DIR}/lib/abort.c + ${CMAKE_SOURCE_DIR}/lib/ad9510.c + ${CMAKE_SOURCE_DIR}/lib/clocks.c + ${CMAKE_SOURCE_DIR}/lib/eeprom.c + ${CMAKE_SOURCE_DIR}/lib/eth_addrs.c + ${CMAKE_SOURCE_DIR}/lib/eth_mac.c + ${CMAKE_SOURCE_DIR}/lib/_exit.c + ${CMAKE_SOURCE_DIR}/lib/exit.c + ${CMAKE_SOURCE_DIR}/lib/hal_io.c + ${CMAKE_SOURCE_DIR}/lib/hal_uart.c + ${CMAKE_SOURCE_DIR}/lib/i2c.c + ${CMAKE_SOURCE_DIR}/lib/mdelay.c + ${CMAKE_SOURCE_DIR}/lib/memcpy_wa.c + ${CMAKE_SOURCE_DIR}/lib/memset_wa.c + ${CMAKE_SOURCE_DIR}/lib/nonstdio.c + ${CMAKE_SOURCE_DIR}/lib/pic.c + ${CMAKE_SOURCE_DIR}/lib/pkt_ctrl.c + ${CMAKE_SOURCE_DIR}/lib/print_addrs.c + ${CMAKE_SOURCE_DIR}/lib/print_rmon_regs.c + ${CMAKE_SOURCE_DIR}/lib/print_buffer.c + ${CMAKE_SOURCE_DIR}/lib/printf.c + ${CMAKE_SOURCE_DIR}/lib/ihex.c + ${CMAKE_SOURCE_DIR}/lib/spi.c + ${CMAKE_SOURCE_DIR}/lib/net_common.c + ${CMAKE_SOURCE_DIR}/lib/arp_cache.c + ${CMAKE_SOURCE_DIR}/lib/banal.c +) diff --git a/firmware/microblaze/lib/hal_io.h b/firmware/microblaze/lib/hal_io.h index 950f8d591..ff87a3494 100644 --- a/firmware/microblaze/lib/hal_io.h +++ b/firmware/microblaze/lib/hal_io.h @@ -72,10 +72,10 @@ hal_disable_ints(void) { int result, t0; - asm volatile("mfs %0, rmsr \n\ - andni %1, %0, 0x2 \n\ - mts rmsr, %1" - : "=r" (result), "=r" (t0)); + //asm volatile("mfs %0, rmsr \n\ +// andni %1, %0, 0x2 \n\ +// mts rmsr, %1" +// : "=r" (result), "=r" (t0)); return result; } @@ -88,10 +88,10 @@ hal_enable_ints(void) { int result, t0; - asm volatile("mfs %0, rmsr \n\ - ori %1, %0, 0x2 \n\ - mts rmsr, %1" - : "=r" (result), "=r" (t0)); +// asm volatile("mfs %0, rmsr \n\ +// ori %1, %0, 0x2 \n\ +// mts rmsr, %1" +// : "=r" (result), "=r" (t0)); return result; } @@ -103,12 +103,12 @@ static inline void hal_restore_ints(int prev_state) { int t0, t1; - asm volatile("andi %0, %2, 0x2 \n\ - mfs %1, rmsr \n\ - andni %1, %1, 0x2 \n\ - or %1, %1, %0 \n\ - mts rmsr, %1" - : "=r" (t0), "=r"(t1) : "r" (prev_state)); +// asm volatile("andi %0, %2, 0x2 \n\ +// mfs %1, rmsr \n\ +// andni %1, %1, 0x2 \n\ +// or %1, %1, %0 \n\ +// mts rmsr, %1" +// : "=r" (t0), "=r"(t1) : "r" (prev_state)); } #endif /* INCLUDED_HAL_IO_H */ diff --git a/firmware/microblaze/lib/hal_uart.c b/firmware/microblaze/lib/hal_uart.c index 7836240fe..f0921f4f0 100644 --- a/firmware/microblaze/lib/hal_uart.c +++ b/firmware/microblaze/lib/hal_uart.c @@ -113,7 +113,7 @@ hal_uart_getc_timeout(hal_uart_name_t u) int hal_uart_rx_flush(hal_uart_name_t u) { - char x; + char x = 0; while(uart_regs[u].rxlevel) x = uart_regs[u].rxchar; return x; } diff --git a/firmware/microblaze/lib/mdelay.c b/firmware/microblaze/lib/mdelay.c index c8c119b1a..958acf3f5 100644 --- a/firmware/microblaze/lib/mdelay.c +++ b/firmware/microblaze/lib/mdelay.c @@ -30,7 +30,7 @@ inline static void delay_1ms(int loop_count) { - int i; +/* int i; for (i = 0; i < loop_count; i++){ asm volatile ("or r0, r0, r0\n\ or r0, r0, r0\n\ @@ -40,6 +40,7 @@ delay_1ms(int loop_count) or r0, r0, r0\n\ or r0, r0, r0\n"); } +*/ } // delay about ms milliseconds diff --git a/firmware/microblaze/usrp2/CMakeLists.txt b/firmware/microblaze/usrp2/CMakeLists.txt new file mode 100644 index 000000000..cdd09e02a --- /dev/null +++ b/firmware/microblaze/usrp2/CMakeLists.txt @@ -0,0 +1,35 @@ +# +# Copyright 2010 Ettus Research LLC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +######################################################################## +INCLUDE(${CMAKE_SOURCE_DIR}/lib/CMakeLists.txt) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) + +ADD_LIBRARY(libusrp2fw STATIC + ${COMMON_SRCS} + sd.c + ethernet.c + udp_fw_update.c +) + +######################################################################## +ADD_LINKER_FLAGS("-Wl,-defsym -Wl,_TEXT_START_ADDR=0x0050") + +ADD_EXECUTABLE(usrp2_txrx_uhd.elf ${CMAKE_SOURCE_DIR}/apps/txrx_uhd.c) +TARGET_LINK_LIBRARIES(usrp2_txrx_uhd.elf libusrp2fw) +GEN_OUTPUTS(usrp2_txrx_uhd.elf) + diff --git a/firmware/microblaze/usrp2p/CMakeLists.txt b/firmware/microblaze/usrp2p/CMakeLists.txt new file mode 100644 index 000000000..825c3ab9e --- /dev/null +++ b/firmware/microblaze/usrp2p/CMakeLists.txt @@ -0,0 +1,48 @@ +# +# Copyright 2010 Ettus Research LLC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +######################################################################## +INCLUDE(${CMAKE_SOURCE_DIR}/lib/CMakeLists.txt) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) + +ADD_DEFINITIONS(-DUSRP2P) + +ADD_LIBRARY(libusrp2pfw STATIC + ${COMMON_SRCS} + spif.c + spi_flash.c + spi_flash_read.c + bootloader_utils.c + ethernet.c + xilinx_s3_icap.c + udp_fw_update.c +) + +######################################################################## +ADD_LINKER_FLAGS("-Wl,-defsym -Wl,_TEXT_START_ADDR=0x8050") + +ADD_EXECUTABLE(usrp2p_txrx_uhd.elf ${CMAKE_SOURCE_DIR}/apps/txrx_uhd.c) +TARGET_LINK_LIBRARIES(usrp2p_txrx_uhd.elf libusrp2pfw) +GEN_OUTPUTS(usrp2p_txrx_uhd.elf) + +ADD_EXECUTABLE(usrp2p_blinkenlights.elf ${CMAKE_SOURCE_DIR}/apps/blinkenlights.c) +TARGET_LINK_LIBRARIES(usrp2p_blinkenlights.elf libusrp2pfw) +GEN_OUTPUTS(usrp2p_blinkenlights.elf) + +ADD_EXECUTABLE(usrp2p_uart_flash_loader.elf ${CMAKE_SOURCE_DIR}/apps/uart_flash_loader.c) +TARGET_LINK_LIBRARIES(usrp2p_uart_flash_loader.elf libusrp2pfw) +GEN_OUTPUTS(usrp2p_uart_flash_loader.elf) |