File tree Expand file tree Collapse file tree 9 files changed +30
-29
lines changed Expand file tree Collapse file tree 9 files changed +30
-29
lines changed Original file line number Diff line number Diff line change @@ -396,7 +396,7 @@ to a verilator simulation model to be simulated on a PC.
396
396
```
397
397
mkdir sw/build
398
398
pushd sw/build
399
- cmake ../
399
+ cmake ..
400
400
make
401
401
popd
402
402
```
Original file line number Diff line number Diff line change 1
- cmake_minimum_required (VERSION 3.10 )
2
- project (demo_system_sw )
1
+ cmake_minimum_required (VERSION 3.12 )
2
+
3
+ if (NOT DEFINED CMAKE_TOOLCHAIN_FILE )
4
+ set (CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR} /gcc_toolchain.cmake" )
5
+ endif ()
6
+
7
+ project (demo_system_sw LANGUAGES C ASM )
8
+
9
+ if (CMAKE_BUILD_TYPE STREQUAL "" )
10
+ get_property (helpstring CACHE CMAKE_BUILD_TYPE PROPERTY HELPSTRING )
11
+ set (CMAKE_BUILD_TYPE "Debug" CACHE STRING "${helpstring} " FORCE )
12
+ endif ()
3
13
4
14
option (SIM_CTRL_OUTPUT
5
15
"Send string output to simulator control rather than UART" )
@@ -8,19 +18,6 @@ if(SIM_CTRL_OUTPUT)
8
18
add_compile_definitions (SIM_CTRL_OUTPUT )
9
19
endif ()
10
20
11
- set (COMMON_DIR "${CMAKE_CURRENT_LIST_DIR} /common" )
12
- set (LINKER_SCRIPT "${COMMON_DIR} /link.ld" )
13
- set (CMAKE_C_COMPILER riscv32-unknown-elf-gcc )
14
- set (CMAKE_EXE_LINKER_FLAGS "-nostartfiles -T${LINKER_SCRIPT} " )
15
- set (CMAKE_C_FLAGS "-march=rv32imc -mabi=ilp32 -static -mcmodel=medany -Wall -g \
16
- -fvisibility=hidden -ffreestanding" )
17
-
18
21
add_subdirectory (common )
19
-
20
- function (add_prog prog_name srcs )
21
- add_executable (${prog_name} ${srcs} $< TARGET_OBJECTS:common> )
22
- target_include_directories (${prog_name} PRIVATE $< TARGET_PROPERTY:common,INCLUDE_DIRECTORIES> )
23
- endfunction ()
24
-
25
22
add_subdirectory (demo )
26
23
add_subdirectory (blank )
Original file line number Diff line number Diff line change 1
1
add_executable (blank blank.S )
2
- set_property (SOURCE blank.S PROPERTY LANGUAGE C )
3
2
4
3
add_custom_command (
5
4
TARGET blank POST_BUILD
6
- COMMAND riscv32-unknown-elf-objcopy -O binary "$<TARGET_FILE:blank>" "$<TARGET_FILE:blank>.bin"
5
+ COMMAND ${CMAKE_OBJCOPY} -O binary "$<TARGET_FILE:blank>" "$<TARGET_FILE:blank>.bin"
7
6
COMMAND srec_cat "$<TARGET_FILE:blank>.bin" -binary -offset 0x0000 -byte-swap 4 -o "$<TARGET_FILE:blank>.vmem" -vmem
8
7
VERBATIM )
Original file line number Diff line number Diff line change 1
1
add_library (common OBJECT demo_system.c uart.c timer.c gpio.c pwm.c spi.c crt0.S )
2
- set_property (SOURCE crt0.S PROPERTY LANGUAGE C )
3
- target_include_directories (common PUBLIC "${CMAKE_CURRENT_LIST_DIR} " )
2
+ target_include_directories (common INTERFACE "${CMAKE_CURRENT_SOURCE_DIR} " )
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../vendor/newae/simpleseri
6
6
include_directories (${CMAKE_CURRENT_SOURCE_DIR} /../../common )
7
7
8
8
9
- add_prog (basic-passwdcheck ${CMAKE_CURRENT_SOURCE_DIR} /../../../vendor/newae/basic-passwdcheck/basic-passwdcheck.c )
9
+ add_executable (basic-passwdcheck ${CMAKE_CURRENT_SOURCE_DIR} /../../../vendor/newae/basic-passwdcheck/basic-passwdcheck.c )
10
10
11
- target_link_libraries (basic-passwdcheck simpleserial )
11
+ target_link_libraries (basic-passwdcheck common simpleserial )
12
12
Original file line number Diff line number Diff line change 1
- add_prog (demo main.c )
1
+ add_executable (demo main.c )
2
+ target_link_libraries (demo common )
Original file line number Diff line number Diff line change @@ -6,12 +6,10 @@ ${CMAKE_CURRENT_SOURCE_DIR}/../../../vendor/display_drivers/core/lucida_console_
6
6
${CMAKE_CURRENT_SOURCE_DIR} /../../../vendor/display_drivers/st7735/lcd_st7735.c
7
7
)
8
8
9
- string (APPEND CMAKE_C_FLAGS " -O2" )
10
-
11
9
# add_executable(lcd_st7735 main.c)
12
- add_prog (lcd_st7735 " main.c; lcd.c; fractal_fixed.c; fractal_float.c; fractal_palette.c" )
10
+ add_executable (lcd_st7735 main.c lcd.c fractal_fixed.c fractal_float.c fractal_palette.c )
13
11
14
12
# pull in core dependencies and additional i2c hardware support
15
- target_link_libraries (lcd_st7735 lcd_st7735_lib )
13
+ target_link_libraries (lcd_st7735 common lcd_st7735_lib )
16
14
17
15
target_include_directories (lcd_st7735 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} /../../../vendor/display_drivers )
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ ${CMAKE_CURRENT_SOURCE_DIR}/../../../vendor/newae/crypto/aes-independant.c
16
16
${CMAKE_CURRENT_SOURCE_DIR} /../../../vendor/newae/crypto/tiny-AES128-C/aes.c
17
17
)
18
18
19
- add_prog (simpleserial-aes ${CMAKE_CURRENT_SOURCE_DIR} /../../../vendor/newae/simpleserial-aes/simpleserial-aes.c )
19
+ add_executable (simpleserial-aes ${CMAKE_CURRENT_SOURCE_DIR} /../../../vendor/newae/simpleserial-aes/simpleserial-aes.c )
20
20
21
- target_link_libraries (simpleserial-aes simpleserial tiny-AES128 )
21
+ target_link_libraries (simpleserial-aes common simpleserial tiny-AES128 )
22
22
Original file line number Diff line number Diff line change
1
+ set (LINKER_SCRIPT "${CMAKE_CURRENT_LIST_DIR} /common/link.ld" )
2
+ set (CMAKE_SYSTEM_NAME Generic )
3
+ set (CMAKE_C_COMPILER riscv32-unknown-elf-gcc )
4
+ set (CMAKE_C_FLAGS_INIT
5
+ "-march=rv32imc -mabi=ilp32 -mcmodel=medany -Wall -fvisibility=hidden -ffreestanding" )
6
+ set (CMAKE_ASM_FLAGS_INIT "-march=rv32imc" )
7
+ set (CMAKE_EXE_LINKER_FLAGS_INIT "-nostartfiles -T \" ${LINKER_SCRIPT} \" " )
You can’t perform that action at this time.
0 commit comments