Dobrica Pavlinušić's random unstructured stuff
DPS5005: Revision 14


OpenDPS

pinout

SWO-pinout.jpg

upgrade to opensource firmware

https://github.com/kanflo/opendps.git

dpavlin@nuc:/nuc$ git clone --recursive https://github.com/kanflo/opendps.git
dpavlin@nuc:/nuc$ cd opendps/
dpavlin@nuc:/nuc/opendps$ make -C libopencm3
dpavlin@nuc:/nuc/opendps$ make -C opendps


connecting rst pin to unpowered st-link stops dps5005 from booting

https://johan.kanflo.com/upgrading-your-dps5005/

openocd

pi@pihdmi:~ $ sudo openocd -f interface/stlink-v2.cfg -f target/stm32f1x.cfg
Open On-Chip Debugger 0.10.0+dev-01489-g06c7a53f1-dirty (2020-11-14-15:21)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
WARNING: interface/stlink-v2.cfg is deprecated, please switch to interface/stlink.cfg
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 1000 kHz
Info : STLINK V2J28S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.273018
Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for stm32f1x.cpu on 3333
Info : Listening on port 3333 for gdb connections

backup few states

from another terminal

pi@pihdmi:/nuc/opendps $ ./ocd-client.py all | tee 5V-off.txt

# exit openocd, turn output on

pi@pihdmi:/nuc/opendps $ ./ocd-client.py all | tee 5V-on.txt


erase

pi@pihdmi:/nuc/opendps $ telnet localhost 4444
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
> reset halt
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080010a4 msp: 0x20001ff0
> flash erase_address unlock 0x08000000 0x10000
device id = 0x10016420
flash size = 64kbytes
erased address 0x08000000 (length 65536) in 0.145284s (440.517 KiB/s)

flash

pi@pihdmi:/nuc/opendps/opendps $ make flash
  FLASH   opendps_DPS5005.srec
(echo "halt; program /nuc/opendps/opendps/opendps_DPS5005.srec verify reset" | nc -4 localhost 4444 2>/dev/null) || \
        openocd -f interface/stlink-v2.cfg \
        -f target/stm32f1x.cfg \
        -c "program opendps_DPS5005.srec verify reset exit" \
        2>/dev/null
��������Open On-Chip Debugger
> halt; program /nuc/opendps/opendps/opendps_DPS5005.srec verify reset
target halted due to debug-request, current mode: Thread
xPSR: 0x61000000 pc: 0x08000bb8 msp: 0x20001fb8
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080010a4 msp: 0x20001ff0
** Programming Started **
device id = 0x10016420
flash size = 64kbytes
** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **


pi@pihdmi:/nuc/opendps/dpsboot $ make flash
  FLASH   dpsboot.srec
(echo "halt; program /nuc/opendps/dpsboot/dpsboot.srec verify reset" | nc -4 localhost 4444 2>/dev/null) || \
        openocd -f interface/stlink-v2.cfg \
        -f target/stm32f1x.cfg \
        -c "program dpsboot.srec verify reset exit" \
        2>/dev/null
��������Open On-Chip Debugger
> halt; program /nuc/opendps/dpsboot/dpsboot.srec verify reset
target halted due to debug-request, current mode: Thread
xPSR: 0x61000000 pc: 0x08000bb8 msp: 0x20001fb8
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080010a4 msp: 0x20001ff0
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **



client software

pi@pihdmi:/nuc/opendps $ pip3 install -r requirements.txt
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting crc16==0.1.1 (from -r requirements.txt (line 1))
  Downloading https://www.piwheels.org/simple/crc16/crc16-0.1.1-cp37-cp37m-linux_armv7l.whl
Requirement already satisfied: pyserial==3.4 in /usr/lib/python3/dist-packages (from -r requirements.txt (line 2)) (3.4)
Installing collected packages: crc16
Successfully installed crc16-0.1.1
pi@pihdmi:/nuc/opendps $ cd dpsctl/

pi@pihdmi:/nuc/opendps/dpsctl $ python3 ./dpsctl.py --device /dev/ttyUSB2 --ping
Error: timeout talking to device /dev/ttyUSB2.

# swap rx/tx pins

pi@pihdmi:/nuc/opendps/dpsctl $ python3 ./dpsctl.py --device /dev/ttyUSB2 --ping
Got pong from device

pi@pihdmi:/nuc/opendps/dpsctl $ python3 ./dpsctl.py --device /dev/ttyUSB2 --query
Func       : cv (on)
  voltage  : 5000
  current  : 1000
V_in       : 10.77 V
V_out      : 5.03 V
I_out      : 0.001 A
pi@pihdmi:/nuc/opendps/dpsctl $ python3 ./dpsctl.py --device /dev/ttyUSB2 -o off

pi@pihdmi:/nuc/opendps/dpsctl $ python3 ./dpsctl.py --device /dev/ttyUSB2 --query
Func       : cv (off)
  voltage  : 5000
  current  : 1000
V_in       : 10.78 V
V_out      : 1.73 V
I_out      : 0.001 A

pi@pihdmi:/nuc/opendps/dpsctl $ python3 ./dpsctl.py --device /dev/ttyUSB2 --query
Func       : cv (off)
  voltage  : 5000
  current  : 1000
V_in       : 10.78 V
V_out      : 0.01 V
I_out      : 0.000 A


serial upgrade

pi@pihdmi:/nuc/opendps/dpsctl $ python3 dpsctl.py --device /dev/ttyUSB2 -U ../opendps/opendps_DPS5005.bin
Download progress: 2% Error: timeout talking to device /dev/ttyUSB2.

SEL on power-on to stay in bootloader

# it bricked my board first time I tried it

esp8266

I had trouble finding toolchain which works with it, I ended up using https://github.com/pfalcon/esp-open-sdk

dpavlin@nuc:/nuc/esp8266/esp-open-sdk$ git remote -v
origin  https://github.com/pfalcon/esp-open-sdk.git (fetch)
origin  https://github.com/pfalcon/esp-open-sdk.git (push)

I also needed to replace esptool, since this machine requires python3 version of it

ln -s /nuc/esp32/esptool/esptool.py /nuc/esp8266/esp-open-sdk/xtensa-lx106-elf/bin/esptool.py

build

dpavlin@nuc:/nuc/opendps$ cd esp8266-proxy/
dpavlin@nuc:/nuc/opendps/esp8266-proxy$ cat env.sh
export EOR_ROOT=`pwd`/esp-open-rtos
export PATH=/nuc/esp8266/esp-open-sdk/xtensa-lx106-elf/bin:$PATH
dpavlin@nuc:/nuc/opendps/esp8266-proxy$ . env.sh

dpavlin@nuc:/nuc/opendps/esp8266-proxy$ make

Merged 1 ELF section
dpavlin@nuc:/nuc/opendps/esp8266-proxy$ make flash
esptool.py -p /dev/ttyUSB0 --baud 115200 write_flash -fs 16m -fm qio -ff 40m \
        0x0 esp-open-rtos/bootloader/firmware_prebuilt/rboot.bin 0x1000 esp-open-rtos/bootloader/firmware_prebuilt/blank_config.bin 0x2000 ./firmware/dpsproxy.bin
WARNING: Flash size arguments in megabits like '16m' are deprecated.
Please use the equivalent size '2MB'.
Megabit arguments may be removed in a future release.
esptool.py v3.2-dev
Serial port /dev/ttyUSB0