Skip to content

Comments

use SWIM pins as UART#498

Closed
cuvoodoo wants to merge 98 commits intoblackmagic-debug:mainfrom
cuvoodoo:swim_uart
Closed

use SWIM pins as UART#498
cuvoodoo wants to merge 98 commits intoblackmagic-debug:mainfrom
cuvoodoo:swim_uart

Conversation

@cuvoodoo
Copy link

@cuvoodoo cuvoodoo commented Aug 3, 2019

some STM ST-LINK/V2 also provide SWIM functionality to flash STM8.
the SWIM pins are connected to UART (USART1 REMAP):

  • SWIM_RST is connected to PB6/USART1_TX
  • SWIM is connected to PB7/USART1_RX (pulled up by 680R)

cheap ST-LINK/V2 clones in form of USB dongle with aluminium case
provide SWD and SWIM signals.
since blackmagic does not support SWIM functionality, the pins can
be re-used as UART port for the USB to UART bridge.

STM ST-LINK/V2 can also offer UART, using USART2, but then the
SWIM signals are not present.
this changes verifies if the SWIM signals are present and remaps
them to USART1 if this is the case.

dlaw and others added 9 commits May 30, 2019 14:01
This commit modifies lpc_iap_call() to work with IAP commands that
return additional data. If the "result" argument is non-null, 16
bytes of data (the maximum returned by any IAP command) are copied
to the specified address.
Restore the RAM and registers which are clobbered by an LPC IAP call.
This does not restore any additional RAM which might be clobbered
by a *particular* IAP call. (For example, flash programming always
clobbers the last page of RAM.)
some STM ST-LINK/V2 also provide SWIM functionality to flash STM8.
the SWIM pins are connected to UART (USART1 REMAP):
- SWIM_RST is connected to PB6/USART1_TX
- SWIM is connected to PB7/USART1_RX (pulled up by 680R)

cheap ST-LINK/V2 clones in form of USB dongle with aluminium case
provide SWD and SWIM signals.
since blackmagic does not support SWIM functionality, the pins can
be re-used as UART port for the USB to UART bridge.

STM ST-LINK/V2 can also offer UART, using USART2, but then the
SWIM signals are not present.
this changes verifies if the SWIM signals are present and remaps
them to USART1 if this is the case.
This prepares to allow other architectures than pc
that don't use libopencm3.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
This allows the platform to specify another optimization level than
the default (like -Os if space is limited)

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
It's a global symbol and LTO will complain if the one in this file and
the one in EFM32 target are inconsistent.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
snprintf is needed anyway, that's one less function to have :p
And it's bad practice anyway.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
@UweBonnes
Copy link
Contributor

Did you check that your patches do not collide with the SWO functionality?

UweBonnes and others added 3 commits August 13, 2019 19:58
Required fixes:
 * use usbd_request_return_codes -- commit 54b117c
 * drop deprecated timer_reset() -- commit 034dbf2
 * drop 48 & 120 MHz configs -- commit a9dde28
 * ld scripts: drop duplication of standard sections -- commit 9a05dcb
@cuvoodoo
Copy link
Author

I did not test it.

For the stlink platform SWO is defined on UART1_RX/PA10
On the baite and mini/aluminium ST-Link/V2 clones with SWIM, PA10 is not connected.
The baite has JTDI, but it cannot be reused as SWO since it's only on the GPIO PA4.
Thus the clones do not support SWO.

The ST-Link/V2-1 supports SWO on UART1_RX/PA10, but since it is not detected as clone with SWIM support, the UART1 is not re-used on the SWIM pin.
Thus this functionality should not be affected.

Ideally for the clones with SWIM, PLATFORM_HAS_TRACESWO should be set to 0.
But since we are trying get use the same platform this should not be redefined with less support.
The clone user should just not use the SWO functionality.

esden and others added 16 commits August 26, 2019 17:22
FIXME: Writing CPU registers on M4 of STM32H745 seems not to work.
Fix as seen in openocd.
SYSROM_PIDR2 has only 3 bits for the JEP106 identity code field, bits [6:4].
After update of GNU make the tests for Windows OS are no longer needed. Note that GNU make 4.2.1 is used to build BMP under Windows OS.
Make native working

Again, the newer version of GCC make does not need the OS tests.
swlink: Remove redundant conditional usbart_init().
Added braces for compatibility with python3, should still be valid python2 which interpretes these braces as a tuple with a single element and simplifies it to that element.
Replaced whitespaces with tabs as required by python3, since indentation must be uniform (either whitespaces or tabs).
Removed trailing whitespaces.

Tested by flashing various STM32 boards with blackmagic firmware using python3.7.
ruabmbua and others added 22 commits December 8, 2019 14:34
Add LPC11xx command to read out unique ID from target. Restore Ram and registers after call.
This is a bit in the Lock Bit (LB) flash page, so it can only be
cleared by this routine
Supported functionality through this AP:
* Issuing a DEVICEERASE command
Rebase EFM patch blackmagic-debug#438, compiling fine in all intermediate steps
Needed when reading some memory region of unknown size.
- Program, read and verify flash
- Test mode: Probe and attach to device and exit
Command line interaction for pc-hosted platforms.
Issue reset only when flashing or when reset was requested.
Both V2 and V21 switch to (ST) bootloader with powered reset.
some STM ST-LINK/V2 also provide SWIM functionality to flash STM8.
the SWIM pins are connected to UART (USART1 REMAP):
- SWIM_RST is connected to PB6/USART1_TX
- SWIM is connected to PB7/USART1_RX (pulled up by 680R)

cheap ST-LINK/V2 clones in form of USB dongle with aluminium case
provide SWD and SWIM signals.
since blackmagic does not support SWIM functionality, the pins can
be re-used as UART port for the USB to UART bridge.

STM ST-LINK/V2 can also offer UART, using USART2, but then the
SWIM signals are not present.
this changes verifies if the SWIM signals are present and remaps
them to USART1 if this is the case.
@dragonmux dragonmux added this to the v1.9 release milestone Jun 28, 2022
@dragonmux dragonmux added Enhancement General project improvement HwIssue Mitigation Solving or mitigating a Hardware issue in Software BMP Firmware Black Magic Probe Firmware (not PC hosted software) and removed New Host Board New hardware to run Black Magic firmware on labels Jun 28, 2022
@dragonmux
Copy link
Member

Thank you for the contribution, however unfortunately it is a duplicate of #396 and doesn't really fit the direction the project is being taken. Closing in favour of #396.

@dragonmux dragonmux closed this Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BMP Firmware Black Magic Probe Firmware (not PC hosted software) Enhancement General project improvement HwIssue Mitigation Solving or mitigating a Hardware issue in Software

Projects

None yet

Development

Successfully merging this pull request may close these issues.