Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: Improve debug configuration #1051

Merged
merged 2 commits into from
Jun 19, 2022
Merged

Conversation

StarGate01
Copy link
Contributor

@StarGate01 StarGate01 commented Mar 25, 2022

This PR has been broken out of #1050.

CMakeLists.txt Outdated Show resolved Hide resolved
src/CMakeLists.txt Outdated Show resolved Hide resolved
src/CMakeLists.txt Outdated Show resolved Hide resolved
POST_BUILD
COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME} ${DFU_MCUBOOT_RECOVERYLOADER_FILE_NAME}
COMMENT "post build (DFU) steps for ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}"
)
endif()


# FLASH
if (USE_JLINK)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff looks a bit odd, I only corrected the indentation here as well.

doc/buildAndProgram.md Outdated Show resolved Hide resolved
@StarGate01
Copy link
Contributor Author

I rebased this PR on the latest development version, and removed any hardware target configuration options. These will be moved to #1050 .

Copy link
Contributor

@Riksu9000 Riksu9000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bin to hex change is blocking this currently, since there's concern that it may break compatibility with some companion apps. #256 also has this same change, so we'll reconsider that first.

src/CMakeLists.txt Outdated Show resolved Hide resolved
@Riksu9000
Copy link
Contributor

The bin to hex change is blocking this currently, since there's concern that it may break compatibility with some companion apps. #256 also has this same change, so we'll reconsider that first.

The objcopy command is invoked by the CMake script as well, such that both the bin as well as the hex version are created. The binary file is exactly the same as before. Or are there concerns of tools depending on the inner workings of the CMake compilation chain?

Maybe something about the DFU. I'm not entirely sure. Someone else will need to take a closer look at it.

@StarGate01
Copy link
Contributor Author

The image creating tool tools/mcuboot/imgtool.py accepts both bin as well as hex files to create a DFU package.

@JF002
Copy link
Collaborator

JF002 commented May 14, 2022

I unfortunately do not have much time to think about those changes right now. I'm currently working on improving the memory usage and monitoring, and I do not have much brain bandwidth for other things :)

This PR is not easy to read as it serves multiples goals (change the debug configuration behavior, switch from bin to hex, change indentation,...).

As I am the one who wrote the original script, I decided to use .bin file because that's what I'm used to use... I'm in full control of where the data will be flashed in memory and that fine for me. I know other people prefer the hex file because they don't have to worry about the offset in memory. I don't think one is better than the other, they are just different.

Now, other than this practical aspect, do we have other valid reasons to change how the files (firmwares, DFUs, mcuboot images) are generated?
Also, we need to pay attention to not break any companion app. I'm not sure all of them rely on the NRF library to parse the DFU file. I think at least Amazfish reads the .bin file directly for the OTA functionality.

This PR also changes the behavior of the Debug configuration by settings new variables. Not every developer will need them. Also, they are already defined in sdk_config.h. I'm wondering if these duplicate declarations/definitions won't be confusing...

@StarGate01
Copy link
Contributor Author

StarGate01 commented May 14, 2022

@JF002 Thanks for your feedback. I see that there are valid concerns about third party tools. How about I revert the process of the DFU generation back to its original state, but add a objcopy statement (unrelated to the DFU creation) to generate a hex file from the bin file in addition?

My main motivation to generate hex files is that the toolchain I use (J-Link / nrfjprog) can only process hex files. OpenOCD is somehow unstable on my system, and lacks some debugging functionality.

@StarGate01
Copy link
Contributor Author

StarGate01 commented May 17, 2022

The hex format change as well as the linker fix included in this PR are the same as in #256, since my P8 fork is based on the fork by @ildar . This is also noted in the commit messages.

Copy link
Collaborator

@JF002 JF002 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StarGate01 I've finally taken the time to check a few things : the .bin and .hex files are correctly generated, and the DFU file still contains a .bin file. So I guess my concerns were unfounded. Sorry about that!

src/CMakeLists.txt Show resolved Hide resolved
@JF002
Copy link
Collaborator

JF002 commented Jun 1, 2022

@Riksu9000 @StarGate01 Which PR should we merge? This one or #256?

@StarGate01
Copy link
Contributor Author

This PR should include all changes from #256, since I forked from @ildar orgininally.

@Riksu9000
Copy link
Contributor

@JF002 I would merge #256 first, but it doesn't make a big difference in the end.

@JF002
Copy link
Collaborator

JF002 commented Jun 6, 2022

I've just merged #265 #256 ;-)
But I guess the remaining changes in this PR still make sense? If yes, I'll merge it too !

@NeroBurner
Copy link
Contributor

@JF002 I think you mean #256 instead of #265

@JF002
Copy link
Collaborator

JF002 commented Jun 6, 2022

@JF002 I think you mean #256 instead of #265

Yep, my fingers slipped! I've just fixed my comment!

Enable debug output for InfiniTime, Nimble and the NRF SDK
via SEGGER RTT on debug builds.
@StarGate01 StarGate01 changed the title CMake: Fix linker scripts and formats, improve debug configuration CMake: Improve debug configuration Jun 6, 2022
@StarGate01
Copy link
Contributor Author

StarGate01 commented Jun 6, 2022

I rebased this PR, it now contains only the debug config enhancements as well as the fixes for the indentation. All good to merge afaik, the two obsolete commits were the same as in #256 .

Copy link
Contributor

@NeroBurner NeroBurner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not using on device debugging, so I can't comment on that.

But the changes are simple and seem to be sound

@Riksu9000 Riksu9000 requested a review from JF002 June 12, 2022 07:38
Copy link
Collaborator

@Avamander Avamander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks better than before, I think.

@JF002 JF002 added this to the 1.10.0 milestone Jun 19, 2022
@JF002
Copy link
Collaborator

JF002 commented Jun 19, 2022

Thanks for this PR, @StarGate01 ! Looks good to me :-)

By the way, as you've touched the flash commands in the CMake file, may I ask your opinion about #801 ? It removes those custom targets as I think they are not generic/portable enough. I haven't dared to merge it as I'm afraid to confuse some developers who might use them.

@JF002 JF002 merged commit 91c69d3 into InfiniTimeOrg:develop Jun 19, 2022
@StarGate01 StarGate01 deleted the cmake-fixes branch June 25, 2022 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants