Skip to content

Conversation

multiplemonomials
Copy link
Collaborator

Summary of changes

I picked up an Infineon PSoC 62 dev kit a while back, and finally got around to trying it with Mbed. Getting it working was a little bit of an adventure (as some new features had to be added to support multicore CPUs), but I have building, flashing, and debugging working now!

Made the following changes:

  • Fixed the "external wifi firmware" resource code. This code was under Target_CYPRESS but wanted to use the block device code, which is a no-go in the new CMake build system (code in mbed core can't use BlockDevice). In fact, ARM never actually added this code to the CMake build system! I updated this code to be its own library and then linked it in to the correct places where it wants to provide the default block device.
  • Added upload method config for MBED, PYOCD, and OPENOCD.
  • Added support to PYOCD and OPENOCD for selecting the core index (as this is the first dual-core device we have seen where the core we want is not core 0)
  • Added support to OPENOCD for customizing the reset sequence, as this chip needs a custom reset sequence
  • Switched to using monitor program instead of load with OpenOCD, as the former works with this target while the latter does not.
  • Fix loading hex files with OpenOCD not working, as OpenOCD would add the offset passed on the command line to the offset in the hex file, leading to your hex file being loaded at double the intended start address.
  • Made MCU_PSOC62_CM4 and MCU_PSOC64_CM4 their own target families to better reflect how the devices are organized
  • Removed OpenOCD_SCRIPT_DIR entirely. I added this a long time ago, before I realized that you could just pass OpenOCD scripts by relative path. This variable made it hard to switch the version of OpenOCD in use, because you had to set both OpenOCD and OpenOCD_SCRIPT_DIR on the command line, so removing it improves usability by a lot.
  • Reworked mbed_adjust_upload_debug_commands(). This function, I found out, had a significant issue, which is that the way it used cache variables made it impossible to modify MBED_UPLOAD_LAUNCH_COMMANDS after the first time CMake was run! Looking at it, it seemed a lot simpler to make this function into a getter that doesn't modify the global variable, as it's only used in two places.

Note that I did not run the test suite yet as there still seem to be a few issues to fix there. But I will do that next.

Impact of changes

  • PYOCD and OPENOCD upload methods now support debugging cores other than core 0
  • OpenOCD should work a little bit better and be more configurable
  • CY8CPROTO_062S3_4343W now compiles!
  • We now support flashing and debugging Cypress PSoC 62 targets

Migration actions required

Documentation

Updated the doc site with the new upload method variables!


Pull request type

[] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[X] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[] Covered by existing mbed-os tests (Greentea or Unittest)
[X] Tests / results supplied as part of this PR

I have verified that I can flash and debug using VS Code and the command line (sadly not CLion as it doesn't allow the same level of customization of the GDB init sequence...). Also verified that the wifi firmware does boot (though the wifi tests are still hardfaulting, need to investigate why in a subsequent PR).


if(MBED_IS_STANDALONE)

# Always print output on test failure
list(APPEND CMAKE_CTEST_ARGUMENTS --output-on-failure)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This should be a big quality of life improvement :)

# Mbed OS upload method configuration file for target ARDUINO_GIGA_CM7.
# To change any of these parameters from their default values, set them in your build script between where you
# include app.cmake and where you add mbed os as a subdirectory.
# include mbed_toolchain_setup and where you add mbed os as a subdirectory.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was bothering me that all these files still mentioned the old app.cmake name, so I batch updated them.

Comment on lines -191 to -197

# Give chance to adjust MBED_UPLOAD_LAUNCH_COMMANDS or MBED_UPLOAD_RESTART_COMMANDS
# for debug launch
if(COMMAND mbed_adjust_upload_debug_commands)
mbed_adjust_upload_debug_commands(${target})
endif()

Copy link

Choose a reason for hiding this comment

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

Suggest keeping invoking mbed_adjust_upload_debug_commands if it is defined. Nuvoton has one bootloader example, which needs to modify MBED_UPLOAD_LAUNCH_COMMANDS via mbed_adjust_upload_debug_commands.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah yeah, I think I see what you are trying to do (load the merged hex file instead of the regular one). There is an easier way to do that, by just calling the gen_upload_target() function directly https://github.com/zhiyong-ft/mcuboot/blob/6723e39d45af70b6e75f7defc556a8587d509bf8/boot/mbed/mcuboot_imgtool.cmake#L153

Also, how come Nuvoton has its own mcuboot example? We have a Mbed OS MCU-Boot example here: https://github.com/mbed-ce/mbed-mcuboot-bootloader . I would really love if we could merge these two repos together and you could add the Nuvoton board configurations to the mbed_app.json in our repo.

And yeah regarding this change, I really would like to get rid of this function as it causes a lot of issues with trying to change the debug commands after a project is configured the first time, which is an unacceptable level of confusion for users in my opinion.

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.

2 participants