Remove bare metal compilation framework in preparation for new Zephyr build files

parent 5d1c5eef
################################################################################
###
### @file CMakeLists.txt
###
### @project
###
### @brief Top level CMake file
###
################################################################################
###
################################################################################
###
### @copyright Copyright (c) 2018-2020, Evan Lojewski
### @cond
###
### All rights reserved.
###
### Redistribution and use in source and binary forms, with or without
### modification, are permitted provided that the following conditions are met:
### 1. Redistributions of source code must retain the above copyright notice,
### this list of conditions and the following disclaimer.
### 2. Redistributions in binary form must reproduce the above copyright notice,
### this list of conditions and the following disclaimer in the documentation
### and/or other materials provided with the distribution.
### 3. Neither the name of the copyright holder nor the
### names of its contributors may be used to endorse or promote products
### derived from this software without specific prior written permission.
###
################################################################################
###
### THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
### AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
### IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
### ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
### LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
### CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
### SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
### INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
### CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
### ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
### POSSIBILITY OF SUCH DAMAGE.
### @endcond
################################################################################
enable_testing()
include(GoogleTest)
SET(FPGA_BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bootrom/fpga/release"
CACHE PATH
"Path to the FPGA build folder from the litex-boards repo: <litex-boards-repo>/litex_boards/targets/build/versa_ecp5")
FIND_PROGRAM(CMAKE_C_COMPILER
NAMES flint_clang clang
REQUIRED)
FIND_PROGRAM(CMAKE_CXX_COMPILER
NAMES flint_clang++ clang++
REQUIRED)
FIND_PROGRAM(CMAKE_ASM_COMPILER
NAMES clang
REQUIRED)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")
include(cmake/version.cmake)
cmake_minimum_required(VERSION 3.5.1)
project(firmware VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
include(bootrom/cmake/clang-format.cmake)
include(bootrom/cmake/clang-analyzer.cmake)
include(bootrom/cmake/clang-tidy.cmake)
include(bootrom/cmake/config.cmake)
add_subdirectory(bootrom/utils)
# add_subdirectory(bootrom/tests)
# # Default include for all subprojects
include_directories(${FPGA_BUILD_DIR}/software/include)
include_directories(bootrom/include)
add_definitions("-D__microwatt__")
add_subdirectory(bootrom/libbase)
ppc64le_add_executable(${PROJECT_NAME}
utility.c utility.h
isr.c
main.c
fsi.c fsi.h
opencores_i2c.c opencores_i2c.h
aquila.h
ipmi_bt.h
micron_n25q_flash.h
tercel_spi.h
)
ppc64le_linker_script(${PROJECT_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/linker.ld")
target_link_libraries(${PROJECT_NAME} PRIVATE libbase)
target_compile_definitions(${PROJECT_NAME} PRIVATE "-DNO_FLINT") # Disable linting
format_target_sources(${PROJECT_NAME})
enable_clang_tidy(${PROJECT_NAME})
#!/bin/sh
################################################################################
###
### @file build.sh
###
### @project bootrom
###
### @brief Top level build script.
###
################################################################################
###
################################################################################
###
### @copyright Copyright (c) 2020, Evan Lojewski
### @cond
###
### All rights reserved.
###
### Redistribution and use in source and binary forms, with or without
### modification, are permitted provided that the following conditions are met:
### 1. Redistributions of source code must retain the above copyright notice,
### this list of conditions and the following disclaimer.
### 2. Redistributions in binary form must reproduce the above copyright notice,
### this list of conditions and the following disclaimer in the documentation
### and/or other materials provided with the distribution.
### 3. Neither the name of the copyright holder nor the
### names of its contributors may be used to endorse or promote products
### derived from this software without specific prior written permission.
###
################################################################################
###
### THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
### AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
### IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
### ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
### LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
### CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
### SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
### INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
### CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
### ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
### POSSIBILITY OF SUCH DAMAGE.
### @endcond
################################################################################
GENERATOR=
BUILD_DIR=build
ARGS="$@"
if [ ! -x "$CMAKE" ]
then
CMAKE=`which cmake3`
if [ ! -x "$CMAKE" ]
then
CMAKE=`which cmake`
if [ ! -x "$CMAKE" ]
then
echo "ERROR: Unable to locate cmake."
exit -1
fi
fi
fi
if [ ! -x "$CPACK" ]
then
CPACK=`which cpack3`
if [ ! -x "$CPACK" ]
then
CPACK=`which cpack`
if [ ! -x "$CPACK" ]
then
echo "ERROR: Unable to locate cpack."
exit -1
fi
fi
fi
NINJA=`which ninja-build`
if [ -x "$NINJA" ]
then
GENERATOR=-GNinja
else
NINJA=`which ninja`
if [ -x "$NINJA" ]
then
GENERATOR=-GNinja
else
echo "WARNING: Unable to locate ninja."
fi
fi
echo "Using cmake: $CMAKE $GENERATOR"
set -e
# Clean out the build folder.
"$CMAKE" -E remove_directory "$BUILD_DIR"
"$CMAKE" -E make_directory "$BUILD_DIR"
cd "$BUILD_DIR"
# Generate the build system
"$CMAKE" .. $GENERATOR "$@"
# Ensure formatting is correct and perform the build
"$CMAKE" --build . --target check-format
"$CMAKE" --build . --target all
# Run the tests
"$CMAKE" --build . --target test
# Generate release packages.
"$CMAKE" --build . --target package
# Work around an issue with --target package_source that fails due to ('s in the path
"$CPACK" --config ./CPackSourceConfig.cmake
################################################################################
###
### @file source_install.cmake.in
###
### @project
###
### @brief Release Package configurations
###
################################################################################
###
################################################################################
###
### @copyright Copyright (c) 2020, Evan Lojewski
### @cond
###
### All rights reserved.
###
### Redistribution and use in source and binary forms, with or without
### modification, are permitted provided that the following conditions are met:
### 1. Redistributions of source code must retain the above copyright notice,
### this list of conditions and the following disclaimer.
### 2. Redistributions in binary form must reproduce the above copyright notice,
### this list of conditions and the following disclaimer in the documentation
### and/or other materials provided with the distribution.
### 3. Neither the name of the copyright holder nor the
### names of its contributors may be used to endorse or promote products
### derived from this software without specific prior written permission.
###
################################################################################
###
### THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
### AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
### IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
### ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
### LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
### CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
### SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
### INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
### CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
### ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
### POSSIBILITY OF SUCH DAMAGE.
### @endcond
################################################################################
if(CPACK_SOURCE_INSTALLED_DIRECTORIES)
file(INSTALL
DESTINATION
"${CMAKE_INSTALL_PREFIX}/"
TYPE FILE
FILES
"@CMAKE_BINARY_DIR@/changelog"
"@CMAKE_BINARY_DIR@/version"
)
endif()
################################################################################
###
### @file version.cmake
###
### @project bootrom
###
### @brief Version configuration
###
################################################################################
###
################################################################################
###
### @copyright Copyright (c) 2021, Evan Lojewski
### @cond
###
### All rights reserved.
###
### Redistribution and use in source and binary forms, with or without
### modification, are permitted provided that the following conditions are met:
### 1. Redistributions of source code must retain the above copyright notice,
### this list of conditions and the following disclaimer.
### 2. Redistributions in binary form must reproduce the above copyright notice,
### this list of conditions and the following disclaimer in the documentation
### and/or other materials provided with the distribution.
### 3. Neither the name of the copyright holder nor the
### names of its contributors may be used to endorse or promote products
### derived from this software without specific prior written permission.
###
################################################################################
###
### THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
### AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
### IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
### ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
### LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
### CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
### SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
### INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
### CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
### ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
### POSSIBILITY OF SUCH DAMAGE.
### @endcond
################################################################################
SET(VERSION_MAJOR 0)
SET(VERSION_MINOR 1)
SET(VERSION_PATCH )
SET(SEMVER_REGEX "v?(0|[1-9]*)\\.(0|[0-9]*)\\.(0|[0-9]*)")
SET(VERSION_FILE ${CMAKE_SOURCE_DIR}/version)
SET(CHANGELOG_FILE ${CMAKE_SOURCE_DIR}/changelog)
IF(EXISTS ${VERSION_FILE})
# Release package including a version file.
FILE(STRINGS ${VERSION_FILE} lines)
LIST(GET lines 0 FULL_VERSION)
LIST(GET lines 1 VERSION_DATE)
LIST(GET lines 2 VERSION_TIMESTAMP)
STRING(REPLACE "." ";" FULL_VERSION ${FULL_VERSION})
LIST(GET FULL_VERSION 0 VERSION_MAJOR)
LIST(GET FULL_VERSION 1 VERSION_MINOR)
LIST(GET FULL_VERSION 2 VERSION_PATCH)
# Read in changelog
FILE(READ ${CHANGELOG_FILE} CHANGELOG)
ELSE()
# Within a git repository
# Find the previous tag. This should be in the format of "vMajor.Minor.Patch"
# HEAD~1 is used here to ensure release tags build properly.
EXECUTE_PROCESS(COMMAND git describe --abbrev=0 --tags HEAD~1
OUTPUT_VARIABLE PREVIOUS_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE)
STRING(REGEX MATCHALL "${SEMVER_REGEX}" DID_MATCH "${PREVIOUS_TAG}")
SET(PREVIOUS_MAJOR ${CMAKE_MATCH_1})
SET(PREVIOUS_MINOR ${CMAKE_MATCH_2})
SET(PREVIOUS_PATCH ${CMAKE_MATCH_3})
EXECUTE_PROCESS(COMMAND git rev-list --count ${PREVIOUS_TAG}..HEAD
OUTPUT_VARIABLE VERSION_PATCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
EXECUTE_PROCESS(COMMAND git log --pretty=format:%s ${PREVIOUS_TAG}..HEAD
OUTPUT_VARIABLE CHANGELOG
OUTPUT_STRIP_TRAILING_WHITESPACE)
# If we are on the same Major/Minor version, continue increasing the patch version.
IF("${PREVIOUS_MAJOR}.${PREVIOUS_MINOR}" VERSION_EQUAL "${VERSIN_MAJOR}.${VERSION_MINOR}")
MATH(EXPR VERSION_PATCH "${PREVIOUS_PATCH} + ${VERSION_PATCH}")
ELSEIF("${PREVIOUS_MAJOR}.${PREVIOUS_MINOR}" VERSION_GREATER "${VERSIN_MAJOR}.${VERSION_MINOR}")
# We somehow regressed in versioning.
MESSAGE(FATAL_ERROR "Last release ${PREVIOUS_TAG} is newer than current ${VERSION_MAJOR}.${VERSION_MINOR}.x")
ELSE()
# No released versions for this major.minor pair.
ENDIF()
EXECUTE_PROCESS(COMMAND git log -1 --date=short --format=%cd
OUTPUT_VARIABLE VERSION_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE)
EXECUTE_PROCESS(COMMAND git log -1 --date=short --format=%cD
OUTPUT_VARIABLE VERSION_TIMESTAMP
OUTPUT_STRIP_TRAILING_WHITESPACE)
ENDIF()
SET(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
add_compile_options(
-DVERSION_MAJOR=${VERSION_MAJOR}
-DVERSION_MINOR=${VERSION_MINOR}
-DVERSION_PATCH=${VERSION_PATCH}
)
FILE(WRITE ${CMAKE_BINARY_DIR}/version "${VERSION_STRING}\n${VERSION_DATE}\n${VERSION_TIMESTAMP}")
FILE(WRITE ${CMAKE_BINARY_DIR}/changelog ${CHANGELOG})
INSTALL(FILES ${CMAKE_BINARY_DIR}/version DESTINATION .)
INSTALL(FILES ${CMAKE_BINARY_DIR}/changelog DESTINATION .)
INCLUDE generated/output_format.ld
ENTRY(_start)
INCLUDE generated/regions.ld
SECTIONS
{
.text :
{
_ftext = .;
*(.text.crt0) /* _start */
/* Remaing text */
*(.text .stub .text.* .gnu.linkonce.t.*)
_etext = .;
} > main_ram
.rodata ALIGN(8):
{
_frodata = .;
*(.rodata .rodata.* .gnu.linkonce.r.*)
*(.rodata1)
*(.got .got.*)
*(.toc .toc.*)
/* Make sure the file is aligned on disk as well
as in memory; CRC calculation requires that. */
FILL(0);
. = ALIGN(8);
_erodata = .;
} > main_ram
.data ALIGN(8):
{
_fdata = .;
*(.branch_lt)
*(.data .data.* .gnu.linkonce.d.*)
*(.data1)
*(.sdata .sdata.* .gnu.linkonce.s.*)
/* Make sure the file is aligned on disk as well
as in memory; CRC calculation requires that. */
FILL(0);
. = ALIGN(8);
_edata = .;
} > main_ram
.ivt ALIGN(16K) (NOLOAD):
{
_ivt_base = .;
. += 4K;
} > main_ram
.bss ALIGN(8):
{
_fbss = .;
*(.dynsbss)
*(.sbss .sbss.* .gnu.linkonce.sb.*)
*(.scommon)
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(8);
_ebss = .;
_end = .;
} > sram
/DISCARD/ :
{
*(.eh_frame)
*(.comment)
}
}
PROVIDE(_fstack = ORIGIN(sram) + LENGTH(sram) - 8);
/* Ensure needed symbols are at the expected locations */
ASSERT(_exception_entry_size <= 0x80, "_exception_entry must not be larger than 0x80 bytes)")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment