Skip to content

Increase the RAM size to 1 MB for debugging #39

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

Open
wants to merge 1 commit into
base: tk1
Choose a base branch
from

Conversation

jthornblad
Copy link

@jthornblad jthornblad commented Jul 8, 2025

Description

When making TKey apps that need a lot of debugging information and be build with -O0 optimization, the binary size can greatly exceed what the final optimized binary size will be.

To be able to debug in an efficient manner, increase the emulated RAM to 1 MB.

Type of change

Please tick any that are relevant to this PR and remove any that aren't.

  • Bugfix (non breaking change which resolve an issue)
  • Feature (non breaking change which adds functionality)
  • Breaking Change (a change which would cause existing functionality to not work as expected)
  • Documentation (a change to documentation)

Submission checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my changes
  • I have tested and verified my changes on target
  • My changes are well written and CI is passing
  • I have squashed my work to relevant commits and rebased on main for linear history
  • I have added a "Co-authored-by: x" if several people contributed, either pair programming or by squashing commits from different authors.
  • I have updated the documentation where relevant (readme, dev.tillitis.se etc.)
  • QEMU is updated to reflect changes

When making TKey apps that need a lot of debugging information
and be build with -O0 optimization, the binary size can greatly
exceed what the final optimized binary size will be.

To be able to debug in an efficient manner, increase the emulated
RAM to 1 MB.
@jthornblad jthornblad requested review from agren and mchack-work July 8, 2025 12:49
@mchack-work
Copy link
Member

How about making the RAM configurable by some command line argument? Maybe just differentiate between the real thing and debug mode, or possible being able to set the exact amount of RAM?

@agren
Copy link
Member

agren commented Jul 10, 2025

Having 128k as default, and increase the RAM size when needed seems like the least surprising behavior to me.

To set an arbitrary RAM size we could probably use the existing -m flag (configure guest RAM). When I try to run QEmu with 1 MiB RAM:

qemu-system-riscv32 -m 1M -nographic -M tk1-castor,fifo=chrid -bios qemu_firmware.elf -chardev pty,id=chrid -s -d guest_errors -drive file=flash.bin,if=mtd,format=raw,index=0

I get the following error:

qemu-system-riscv32: Invalid RAM size, should be 128 KiB.

Which comes from a check in tk1.c. It might be as easy as removing the check to get configurable size.

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.

3 participants