One way to update the application software on Linux is to use a bootloader. Cypress supplies a bootloader component, that can communicate over UART, I2C, and USB HID.
First we have to flash the bootloader itself; we can use OpenOCD, which has support for KitProg. The Linux kernel detect KitProg (ID 04b4:f139) as a USB HID device and a serial port.
[ 1995.852252] usb 1-1.2.2: new full-speed USB device number 11 using ehci-pciAfter building openocd from the source, openocd detects KitProg,
[ 1995.968208] usb 1-1.2.2: New USB device found, idVendor=04b4, idProduct=f139, bcdDevice= 2.11
[ 1995.968217] usb 1-1.2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=128
[ 1995.968222] usb 1-1.2.2: Product: Cypress KitProg
[ 1995.968227] usb 1-1.2.2: Manufacturer: Cypress Semiconductor
[ 1995.968231] usb 1-1.2.2: SerialNumber: 1016163201324400
[ 1995.970949] hid-generic 0003:04B4:F139.0003: hiddev0,hidraw1: USB HID v1.11 Device [Cypress Semiconductor Cypress KitProg] on usb-0000:00:1a.0-1.2.2/input0
[ 1996.015524] cdc_acm 1-1.2.2:1.2: ttyACM0: USB ACM device
[ 1996.017170] usbcore: registered new interface driver cdc_acm
[ 1996.017172] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
./src/openocd -s ./tcl/ -c "interface kitprog" -f target/psoc5lp.cfg -c "targets"
Open On-Chip Debugger 0.10.0+dev-g9a363c9 (2020-02-09-14:02)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'swd'
cortex_m reset_config sysresetreq
TargetName Type Endian TapName State
-- ------------------ ---------- ------ ------------------ ------------
0* psoc5lp.cpu cortex_m little psoc5lp.cpu unknown
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : KitProg v2.17
Info : Hardware version: 17
Info : VTARG = 4.755 V
Info : This adapter doesn't support configurable speed
Info : SWD DPIDR 0x2ba01477
Info : psoc5lp.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
Info : accepting 'telnet' connection on tcp/4444
To program the bootloader,
../Cypress-OpenOCD/src/openocd -s ../Cypress-OpenOCD/tcl/ -c "interface kitprog; kitprog_init_acquire_psoc" -f target/psoc5lp.cfg -c "init; halt; program output/debug/Bootloader_USBUART.elf verify reset exit"If the hex file is used, the error message is different,
Open On-Chip Debugger 0.10.0+dev-g9a363c9 (2020-02-09-14:02)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'swd'
cortex_m reset_config sysresetreq
Info : KitProg v2.17
Info : Hardware version: 17
Info : VTARG = 4.758 V
Info : This adapter doesn't support configurable speed
Info : SWD DPIDR 0x2ba01477
Info : psoc5lp.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : psoc5lp.cpu: external reset detected
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0x41000000 pc: 0x000004b8 msp: 0x20007fc8
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000010 msp: 0x20008000
** Programming Started **
auto erase enabled
Info : Padding image section 0 at 0x00001869 with 3 bytes
Info : Flash write discontinued at 0x00001de0, next section at 0x0003ffc0
Warn : Adding extra erase range, 0x0003c000 .. 0x0003ffbf
Error: Writes must be row-aligned, got offset 0x0003ffc0
Error: error writing to flash at address 0x00000000 at offset 0x0003ffc0
** Programming Failed **
shutdown command invoked
Error: Sequence 2 not supported.
** Programming Started **Despite of the error message, the programming of the bootloader seems to have succeeded.
auto erase enabled
Warn : no flash bank found for address 0x80000000
Warn : There is no erase operation for NV Latches
Error: failed erasing sectors 0 to 0
** Programming Failed **
shutdown command invoked
Error: Sequence 2 not supported.
The UART bootloader works with a Linux version of bootloader_host, cyhostboot, built around the source for Bootloader Host Tool provided by Cypress, available on Github.
../cypress_linux_tools/cyhostboot/cyhostboot -f output/debug/PSoC5ino.cyacd
Programing file output/debug/PSoC5ino.cyacd
Start programing on serial /dev/ttyACM0, baudrate 115200
no parity
Got silicon id 0x2e161069, rev 0x00
Progress: array_id 0, row_num 30
Progress: array_id 0, row_num 31
...
Progress: array_id 0, row_num 149It takes about 2 minutes to program about 30KB.
Progress: array_id 3, row_num 255
programing OK !