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

Added support for kinetis MK20DX256 chip #1797

Merged
merged 2 commits into from Apr 12, 2024

Conversation

vedranMv
Copy link
Contributor

Detailed description

This PR adds support for a MK20DX256 chip in kinetis.c. It specifies flash region, both RAM segments and FlexNVM. It doesn't, however, add support for FlexRAM that this chip features. That support seems to lack from all other kinetis targets too, I guess due to the complication that this region can be configured both as RAM and EEPROM.

One of the comments made on the branch was to use defines instead of addresses directly, which doesn't seem to be common practice in kinetis.c. So for now I added the values directly as function arguments. If that's still desired, I can make a change :)

Your checklist for this pull request

  • I've read the Code of Conduct
  • I've read the guidelines for contributing to this repository
  • It builds for hardware native (see Building the firmware) - Linker fails with ROM overflowing (arm-none-eabi-gcc (15:10.3-2021.07-4) 10.3.1 20210621, but building main branch fails with the same error). This PR increases ROM consumption by 0.03%.
  • It builds as BMDA (see Building the BMDA)
  • I've tested it to the best of my ability
  • My commit messages provide a useful short description of what the commits do

The following was tested on Tiva ICDI platform, with GDB 8.3.1:

  • load firmware to a MK20 target
  • run target
  • set & remove breakpoint
  • set & remove watchpoint
  • pause target, and while paused
    • get general registers
    • get stack trace
    • watch code variable
    • inspect hardware peripheral registers
    • read out 1k of random RAM
    • read out 1k of random flash
  • resume target
  • disconnect & confirm target continues to run

Closing issues

No known open issues.

@dragonmux dragonmux added this to the v2.0 release milestone Apr 12, 2024
@dragonmux dragonmux added the New Target New debug target label Apr 12, 2024
@dragonmux
Copy link
Member

Before we review, do note that we recommend upgrading your ARM GCC to GCC 12.2.Rel1 - this has better diagnostics and better code generation, which is why the resulting binaries from it do fit in Flash.

@dragonmux
Copy link
Member

One of the comments made on the branch was to use defines instead of addresses directly, which doesn't seem to be common practice in kinetis.c. So for now I added the values directly as function arguments. If that's still desired, I can make a change :)

Yeah, this needs to change - so please use defines in this PR so less has to be fixed later in a follow-up PR.

Copy link
Member

@dragonmux dragonmux left a comment

Choose a reason for hiding this comment

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

Taking into account the comment about defines, the rest of this looks great and we'll be happy to merge this once that's been sorted.

@vedranMv
Copy link
Contributor Author

Changed to defines :)

Still can't get it to build though, these are the commands:

~$ meson setup build-cross --cross-file cross-file/arm-none-eabi.ini -Dprobe=native
(trimmed)
Black Magic Debug 1.10.0

  Targets
    Cortex-A/R support       : NO
    Cortex-M support         : YES
    RISC-V 32-bit support    : NO
    RISC-V 64-bit support    : NO
    Energy Micro parts       : YES
    HC32 parts               : YES
    LPC series parts         : YES
    nRF series parts         : YES
    Kinetis series parts     : YES
    Renesas parts            : YES
    RP2040                   : YES
    ATSAM series parts       : YES
    STM32 (and clones) parts : YES
    Texas Instruments parts  : YES
    Xilinx parts             : NO

  Probe
    Name                     : Black Magic Probe (native)
    Platform                 : STM32F1
    Bootloader               : Black Magic Debug Bootloader
    Load Address             : 0x8002000

  Black Magic Debug
    Debug output             : NO
    RTT support              : YES
    Advertise QStartNoAckMode: NO
    Building Firmware        : YES
    Building BMDA            : YES

  Subprojects
    libopencm3               : YES 2 warnings
 (trimmed)
~$ meson compile -C build-cross
 (trimmed)
/home/vedranmv/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld: blackmagic_native_firmware.elf section `.ARM.exidx' will not fit in region `rom'
/home/vedranmv/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld: address 0x8020e4c of blackmagic_native_firmware.elf section `.text' is not within region `rom'
/home/vedranmv/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld: region `rom' overflowed by 4044 bytes
Memory region         Used Size  Region Size  %age Used
             rom:      135116 B       128 KB    103.09%
             ram:        5672 B        20 KB     27.70%
collect2: error: ld returned 1 exit status
[447/498] Compiling C object blackmagic.p/src_target_samd.c.o
ninja: build stopped: subcommand failed.

@dragonmux
Copy link
Member

You have RTT enabled in that build, which presently does not fit on native without turning off some targets due to the space constraint - this looks to be the cause.

Copy link
Member

@dragonmux dragonmux left a comment

Choose a reason for hiding this comment

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

LGTM, merging once the builds complete. Thank you for the contribution!

@vedranMv
Copy link
Contributor Author

Great, thanks a lot for guidance. Enjoy your weekend!

@dragonmux dragonmux merged commit 9868269 into blackmagic-debug:main Apr 12, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Target New debug target
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants