-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add stress test firmware to support Facedancer stress test
- Loading branch information
Showing
9 changed files
with
836 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Prerequisites | ||
*.d | ||
|
||
# astyle generated | ||
*.*.orig | ||
|
||
# Object files | ||
*.o | ||
*.ko | ||
*.obj | ||
*.elf | ||
*.bin | ||
*.lst | ||
|
||
# Linker output | ||
*.ilk | ||
*.map | ||
*.exp | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Libraries | ||
*.lib | ||
*.a | ||
*.la | ||
*.lo | ||
|
||
# Shared objects (inc. Windows DLLs) | ||
*.dll | ||
*.so | ||
*.so.* | ||
*.dylib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
*.i*86 | ||
*.x86_64 | ||
*.hex | ||
|
||
# Debug files | ||
*.dSYM/ | ||
*.su | ||
*.idb | ||
*.pdb | ||
|
||
# Kernel Module Compile Results | ||
*.mod* | ||
*.cmd | ||
.tmp_versions/ | ||
modules.order | ||
Module.symvers | ||
Mkfile.old | ||
dkms.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
project(test_firmware_usb_stress_test LANGUAGES C) | ||
set(CMAKE_EXECUTABLE_SUFFIX_C ".elf") | ||
|
||
add_executable(${PROJECT_NAME}) | ||
|
||
target_sources(${PROJECT_NAME} PUBLIC | ||
${CMAKE_CURRENT_LIST_DIR}/User/main.c | ||
) | ||
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/User) | ||
|
||
##### Define program options | ||
|
||
#### wch-ch56x-lib options | ||
|
||
target_compile_definitions(wch-ch56x-lib-scheduled INTERFACE POOL_BLOCK_SIZE=512 POOL_BLOCK_NUM=40 INTERRUPT_QUEUE_SIZE=20) | ||
|
||
#### logging options | ||
|
||
# set(LOG_OUTPUT "printf") | ||
# set(LOG_LEVEL 1) | ||
# set(LOG_FILTER_IDS "1") | ||
|
||
if (DEFINED LOG_OUTPUT) | ||
if (${LOG_OUTPUT} STREQUAL "buffer") | ||
target_compile_definitions(${PROJECT_NAME} PRIVATE LOG_TYPE_BUFFER=1) | ||
endif() | ||
if (${LOG_OUTPUT} STREQUAL "serdes") | ||
target_compile_definitions(${PROJECT_NAME} PRIVATE LOG_TYPE_SERDES=1) | ||
endif() | ||
if (${LOG_OUTPUT} STREQUAL "printf") | ||
target_compile_definitions(${PROJECT_NAME} PRIVATE LOG_TYPE_PRINTF=1) | ||
endif() | ||
endif() | ||
|
||
if (DEFINED LOG_LEVEL) | ||
target_compile_definitions(${PROJECT_NAME} PRIVATE LOG_LEVEL=${LOG_LEVEL}) | ||
endif() | ||
|
||
if (DEFINED LOG_FILTER_IDS) | ||
target_compile_definitions(${PROJECT_NAME} PRIVATE LOG_FILTER_IDS=${LOG_FILTER_IDS}) | ||
endif() | ||
|
||
if (DEFINED STATIC_ANALYSIS) | ||
target_compile_options(${PROJECT_NAME} PRIVATE -fanalyzer) | ||
endif() | ||
|
||
##### Compilation and linkage options | ||
|
||
target_compile_options(${PROJECT_NAME} PRIVATE | ||
-Werror -Warray-bounds=2 -Wno-comment -pedantic -Wall -Wno-error=unused-parameter | ||
-Wbad-function-cast -Wredundant-decls -Wmissing-prototypes -Wchar-subscripts -Wshadow -Wundef -Wwrite-strings -Wunused -Wuninitialized -Wpointer-arith -Winline -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wmissing-declarations -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wtype-limits -Wcast-align -Wswitch-enum | ||
-Wextra -Wclobbered -Wcast-function-type -Wimplicit-fallthrough=3 -Wmissing-parameter-type -Wold-style-declaration -Woverride-init -Wshift-negative-value -Wunused-but-set-parameter | ||
) | ||
|
||
if (DEFINED EXTRACFLAGS) | ||
target_compile_options(${PROJECT_NAME} PRIVATE | ||
-Wunused-parameter -Wno-error=unused-parameter | ||
-Wsign-compare -Wno-error=sign-compare | ||
-Wconversion -Wno-error=conversion -Wno-error=sign-conversion -Wno-error=float-conversion | ||
) | ||
endif() | ||
|
||
if (${RISCV_GCC_TOOLCHAIN_PREFIX} STREQUAL "riscv-none-embed-gcc") | ||
message("Using riscv-none-embed-gcc") | ||
target_compile_options(${PROJECT_NAME} PRIVATE -march=rv32imac) | ||
elseif(${RISCV_GCC_TOOLCHAIN_PREFIX} STREQUAL "riscv-none-elf-gcc") | ||
message("Using riscv-none-elf-gcc") | ||
target_compile_options(${PROJECT_NAME} PRIVATE -march=rv32imac_zicsr) | ||
else() | ||
message("Toolchain not found") | ||
endif() | ||
|
||
target_compile_options(${PROJECT_NAME} PRIVATE -std=gnu99 -MMD -MP -mno-strict-align -mabi=ilp32 -msmall-data-limit=8 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections) | ||
target_compile_options(${PROJECT_NAME} PRIVATE $<$<CONFIG:Debug>:-Og> $<$<CONFIG:Release>:-Oz>) | ||
target_link_options(${PROJECT_NAME} PRIVATE -T "${CMAKE_CURRENT_LIST_DIR}/.ld" -nostartfiles LINKER:--gc-sections LINKER:--print-memory-usage -Wl,-Map,${PROJECT_NAME}.map --specs=nano.specs --specs=nosys.specs) | ||
target_link_libraries(${PROJECT_NAME} wch-ch56x-lib-scheduled) | ||
|
||
##### Generate additional targets | ||
|
||
add_custom_target(${PROJECT_NAME}.bin ALL DEPENDS ${PROJECT_NAME}.elf) | ||
add_custom_target(${PROJECT_NAME}.hex ALL DEPENDS ${PROJECT_NAME}.elf) | ||
add_custom_target(${PROJECT_NAME}.lst ALL DEPENDS ${PROJECT_NAME}.elf) | ||
|
||
add_custom_command(TARGET ${PROJECT_NAME}.bin | ||
COMMAND ${CMAKE_OBJCOPY} -O binary ${PROJECT_NAME}.elf | ||
${PROJECT_NAME}.bin) | ||
|
||
add_custom_command(TARGET ${PROJECT_NAME}.hex | ||
COMMAND ${CMAKE_OBJCOPY} -O ihex ${PROJECT_NAME}.elf | ||
${PROJECT_NAME}.hex) | ||
|
||
add_custom_command(TARGET ${PROJECT_NAME}.lst | ||
COMMAND ${CMAKE_OBJDUMP} --source --all-headers --demangle --line-numbers --wide ${PROJECT_NAME}.elf > ${PROJECT_NAME}.lst) | ||
|
||
##### Export generated files | ||
|
||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.bin DESTINATION ${CMAKE_SOURCE_DIR}/out/${PROJECT_NAME}) | ||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.hex DESTINATION ${CMAKE_SOURCE_DIR}/out/${PROJECT_NAME}) | ||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.elf DESTINATION ${CMAKE_SOURCE_DIR}/out/${PROJECT_NAME}) | ||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.lst DESTINATION ${CMAKE_SOURCE_DIR}/out/${PROJECT_NAME}) | ||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.map DESTINATION ${CMAKE_SOURCE_DIR}/out/${PROJECT_NAME}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/********************************** (C) COPYRIGHT ******************************* | ||
Copyright (c) 2023 Quarkslab | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*******************************************************************************/ | ||
|
||
#ifndef DEFINITIONS_H | ||
#define DEFINITIONS_H | ||
|
||
#define ENDP_1_15_MAX_PACKET_SIZE 1024 | ||
/* Global define */ | ||
// DEF_ENDP_OUT_BURST_LEVEL / DEF_ENDP_IN_BURST_LEVEL maximum burst size 16 | ||
// defined by the USB3 specification Warning USB3 endpoint bulk with 8 or 16 | ||
// burst can be problematic on some PC | ||
#define DEF_ENDP_OUT_BURST_LEVEL 4 | ||
#define DEF_ENDP_IN_BURST_LEVEL (DEF_ENDP_OUT_BURST_LEVEL) | ||
#define DEF_ENDP_MAX_SIZE (DEF_ENDP1_OUT_BURST_LEVEL * 1024) | ||
|
||
#define MAX_TRANSFER_LENGTH 768 | ||
|
||
#endif |
Oops, something went wrong.