DISTORTEC / distortos

object-oriented C++ RTOS for microcontrollers
https://distortos.org/
Mozilla Public License 2.0
430 stars 66 forks source link

Can't find '.hex' file in the ’output‘ directory? How to burn the program to the chip? #61

Closed YaoweiFan closed 4 months ago

YaoweiFan commented 3 years ago

I have followed the article -- Configuring and building a distortos-based project to build my project. The content of 'CMakeLists.txt' file is as follows:

cmake_minimum_required(VERSION 3.7)
project(my-project)

add_subdirectory(distortos)

add_executable(my-project EXCLUDE_FROM_ALL
        src/main.cpp
        src/OperationCountingType.cpp
        src/PrioritizedTestCase.cpp
        src/priorityTestPhases.cpp
        src/SequenceAsserter.cpp
        src/TestCaseCommon.cpp
        src/TestCase.cpp
        src/TestCaseGroup.cpp
        src/testCases.cpp
        src/waitForNextTick.cpp
        src/wasteTime.cpp)

target_include_directories(my-project
    PRIVATE
        ${PROJECT_SOURCE_DIR}/distortos/test
)

target_link_libraries(my-project PRIVATE
    distortos::distortos)
distortosTargetLinkerScripts(my-project $ENV{DISTORTOS_LINKER_SCRIPT})

include(distortos/test/architecture/distortosTest-sources.cmake)
include(distortos/test/CallOnce/distortosTest-sources.cmake)
include(distortos/test/ConditionVariable/distortosTest-sources.cmake)
include(distortos/test/Mutex/distortosTest-sources.cmake)
include(distortos/test/Queue/distortosTest-sources.cmake)
include(distortos/test/Semaphore/distortosTest-sources.cmake)
include(distortos/test/Signals/distortosTest-sources.cmake)
include(distortos/test/SoftwareTimer/distortosTest-sources.cmake)
include(distortos/test/Thread/distortosTest-sources.cmake)

distortosBin(my-project my-project.bin)
distortosDmp(my-project my-project.dmp)
distortosHex(my-project my-project.hex)
distortosLss(my-project my-project.lss)
distortosMap(my-project my-project.map)
distortosSize(my-project)

I successfully build this project. The output of command 'ninja' is:

$ ninja
[150/150] Linking CXX static library distortos/libdistortos.a

My problem is why I can't find '.hex' file in my ’output‘ directory? How can I burn the program to the chip? I am a newbie in this area. Could you give me some advice to quickly get familiar with it? Thank you very much.

FreddieChopin commented 3 years ago

You copied way too much from the test project. It may be better to check these files as a good starting points for a "real" project (as opposed to the test application used for development):

https://github.com/DISTORTEC/distortosTemplateSubfolder/blob/master/CMakeLists.txt (a bare minimum of what is needed) https://github.com/DISTORTEC/STM32F7-ETH-LAN8720A-lwIP-MQTT/blob/master/CMakeLists.txt https://github.com/DISTORTEC/STM32F7-USB-host-ME906-lwIP-MQTT/blob/master/CMakeLists.txt

The main problem in the file you posted is here:

add_executable(my-project EXCLUDE_FROM_ALL

The executable is excluded from "all" ("all" target is built when you don't specify any specific target - as in your case). If you would run ninja my-project instead of just ninja, then CMake would try to build this executable, along with the *.hex file.

But even if you would remove that EXCLUDE_FROM_ALL, it may still not build, because you include sources of the test application (all the include(distortos/test/... lines and also all the *.cpp files you copied from the test app), so there may be some issues in the sources.

Generally the test application is not the best example of how to use distortos in a real project. If the examples I posted above are also not helpful, let me know, post what you have and I'll help you with any issues you may face (;