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

[feature] st-util with SWO support possible? #613

Open
4 tasks done
mhanuel26 opened this issue Jul 11, 2017 · 9 comments
Open
4 tasks done

[feature] st-util with SWO support possible? #613

mhanuel26 opened this issue Jul 11, 2017 · 9 comments

Comments

@mhanuel26
Copy link

mhanuel26 commented Jul 11, 2017

  • Stlink/v2-onboard
  • Linux
  • st-util
  • STM32F769 Discovery

I was wondering if it's possible to have SWO output from target. It will be great to have sort of printf window for debug messages.
The closest minimalist solution I have found is explained here, but depends on STM32 ST-Link Utility or Keil uVision for it.

Please let me know your thoughts,

@xor-gate xor-gate added this to the Unplanned (Contributions Welcome) milestone Jul 11, 2017
@xor-gate
Copy link
Member

Its possible, but not implemented. OpenOCD has support for this to write ITM port 0 or 1 to a file.

@shizacat
Copy link

Hello,
Do you plan to implement swo?

@romansavrulin
Copy link

+1 on SWO feature

@Nightwalker-87 Nightwalker-87 modified the milestones: Unplanned (Contributions Welcome), Next Feb 19, 2020
@Nightwalker-87 Nightwalker-87 modified the milestones: General, v1.7.0, Feedback required Mar 14, 2020
@Nightwalker-87 Nightwalker-87 changed the title st-util with SWO support possible? [feature] st-util with SWO support possible? Mar 30, 2020
@Nightwalker-87 Nightwalker-87 modified the milestones: Feedback required, v1.6.2 Mar 30, 2020
@langhaarschneider
Copy link

also +1 on SWO feature

@Nightwalker-87 Nightwalker-87 added this to To do in Release v1.7.0 via automation May 24, 2020
@Nightwalker-87 Nightwalker-87 removed this from To do in Release v1.7.0 Dec 25, 2020
@Nightwalker-87 Nightwalker-87 modified the milestones: v1.6.2, v1.6.3 Dec 25, 2020
@Nightwalker-87 Nightwalker-87 added this to To do in Release v1.8.0 via automation May 14, 2021
@Nightwalker-87 Nightwalker-87 modified the milestones: v1.8.0, v1.7.1 May 14, 2021
@simplerobot
Copy link
Collaborator

Hi @mhanuel26, @shizacat, @langhaarschneider,
The stlink project now contains a st-trace utility program that will read SWO output from a target. (Run "st-trace --help" for more details.) Does this meet your needs? If not, can you explain how you would like this to work?

@Ant-ON
Copy link
Collaborator

Ant-ON commented Jun 18, 2021

@simplerobot Viewing the SWO output while debugging would be a nice touch. Currently only the semihosting is supported:

ret = stlink_status(sl);
if (ret) { DLOG("Semihost: status failed\n"); }
if (sl->core_stat == TARGET_HALTED) {
struct stlink_reg reg;
stm32_addr_t pc;
stm32_addr_t addr;
int offset = 0;
uint16_t insn;
if (!st->semihosting) { break; }
ret = stlink_read_all_regs (sl, &reg);
if (ret) { DLOG("Semihost: read_all_regs failed\n"); }
// read PC
pc = reg.r[15];
// compute aligned value
offset = pc % 4;
addr = pc - offset;
// read instructions (address and length must be aligned).
ret = stlink_read_mem32(sl, addr, (offset > 2 ? 8 : 4));
if (ret != 0) {
DLOG("Semihost: cannot read instructions at: 0x%08x\n", addr);
break;
}
memcpy(&insn, &sl->q_buf[offset], sizeof(insn));
if (insn == 0xBEAB && !has_breakpoint(addr)) {
ret = do_semihosting (sl, reg.r[0], reg.r[1], &reg.r[0]);
if (ret) { DLOG("Semihost: do_semihosting failed\n"); }
// write return value
ret = stlink_write_reg(sl, reg.r[0], 0);
if (ret) { DLOG("Semihost: write_reg failed for return value\n"); }
// jump over the break instruction
ret = stlink_write_reg(sl, reg.r[15] + 2, 15);
if (ret) { DLOG("Semihost: write_reg failed for jumping over break\n"); }
// continue execution
cache_sync(sl);
ret = stlink_run(sl, RUN_NORMAL);
if (ret) { DLOG("Semihost: continue execution failed with stlink_run\n"); }
} else {
break;
}
}

@Nightwalker-87 Nightwalker-87 added this to To do in Release v1.8.0 via automation Jan 3, 2022
@Nightwalker-87 Nightwalker-87 modified the milestones: v1.7.1, Longlist Oct 23, 2022
@Nightwalker-87 Nightwalker-87 removed this from To do in Release v1.8.0 Oct 23, 2022
@stlink-org stlink-org deleted a comment from ChrisIdema Jun 19, 2023
@stlink-org stlink-org deleted a comment from ChrisIdema Jan 21, 2024
@Nightwalker-87 Nightwalker-87 pinned this issue Jan 21, 2024
@Nightwalker-87 Nightwalker-87 unpinned this issue Mar 10, 2024
@linuxguy123
Copy link

linuxguy123 commented Mar 12, 2024

What is the status of SWO working with STLink (st-util) such that Cortex-Debug and uScope (RTT viewer, https://github.com/DEMCON/uscope) can use it ?

If it now does work, does one need to reflash the STLink device to make SWO work or just update st-util ?

If it doesn't work, what can I do to help the situation ?

@linuxguy123
Copy link

Hi @mhanuel26, @shizacat, @langhaarschneider, The stlink project now contains a st-trace utility program that will read SWO output from a target. (Run "st-trace --help" for more details.) Does this meet your needs? If not, can you explain how you would like this to work?

Speaking as a VSCode user, how would I configure VSCode to work with st-trace ? Let's assume I want to use uScope (https://github.com/DEMCON/uscope) as my rtt viewer.

@Nightwalker-87
Copy link
Member

@linuxguy123 There have been no action or any efforts on this topic since the last response of @Ant-ON.
I personally can't contribute to this topic, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants