• I got back to this and implemented SWDCON console for Espruino devices (should work on any ARM Cortex with SWD). Currently it sits in https://github.com/fanoush/Espruino/tree/f-swdcon and somehow works for me with openocd
    When it is built in and enabled in board file, it can be used like this (see also openocd docs 15.6 Real Time Transfer (RTT)):

    rtt setup 0x20000000 262144 "SEGGER RTT"
    rtt polling_interval 50
    rtt start
    rtt server start 2222 0
    

    then you can telnet to localhost port 2222 press enter and then wake up device if it is sleeping and the console should be switched and work. For telnet command it is better to switch it to character mode via ctrl+] and typing mode character. For better usage with telnet the console would need to implement some telnet protocol handshaking but not sure it is worth it. Also due to this there is some garbage in the console when the mode is switched so just press enter again (and/or ctrl+c).

    To turn it back off execute something like Serial1.setConsole() or for Bangle2 setConsole(null,true) in the SWD console and then something like

    rtt stop server 2222
    rtt stop
    mww 0xE000EDF0 0xA05F0000; nrf52.dap dpreg 4 0 ; shutdown
    

    This is meant to work also with BANGLE 2 devices with broken Bluetooth which are otherwise inaccessible. For those there is some extra code to force the console switch even if it is already forced to null - which is the state when you turn off the programmable checkbox in settings. For now it is not usable with WebIDE as it does not support telnet but when I'll finish the custom SWD/RTT debugger host implemented in espruino javascript then any other espruino device can redirect its console to this and act as a proxy to Bangle2 over two GPIO pins.Then one could install apps also over cable.

About

Avatar for fanoush @fanoush started