10 Replies Latest reply on Jul 13, 2020 3:03 PM by baga_4725781

    Issues with the USBFS UART example

    baga_4725781

      I am trying to get the USBFS_UART example working. This appears to be a variation of another. main.c says:

          "Description: This is the source code for the AnyCloud: BLE Battery Server. Example for ModusToolbox."

      There are other references to the battery server.

       

      Please note I am happy to switch over to another code example. I just need serial over USB. However, it is a bit disconcerting that example code which seems to be the correct on to use, has problems like this. Of course, I may be having a massive brainfart.

       

      I started trying to use the Echo_CDC example, but it seemed to need the PSoC Creator. I will go back to trying that. I found

      GitHub - cypresssemiconductorco/mtb-example-psoc6-usb-cdc-echo: This example demonstrates how to configure the USB block… 

       

      So: Please do not spend a lot of time on this. My primary goal is to report the issue. If I am doing something simple wrong, I would appreciate knowing about it. I am mainly trying to document. Of course, if the Echo CDC is a dead end, I will come back to this. There appears to not be any posts about this on this forum (I tried several searches).

      I am happy to report it as a bug to the  http://openocd.org/doc/doxygen/bugs.html folks.

       

      I am using the CY8CKIT-062-wifi-bt-fram pioneer kit

      Loader MPU: CY8C5868LTI-LP039

      Target MPU: CY8C6247BZI-D54

      Code example: USBFS_UART

       

      There are several problems. I was able to write and burn a blinky, so I know the toolchain and hardware works.

       

      Please note I included as much information as I could. The verbose stuff is at the end.

       

      I cannot see any other example that would allow the USB UART to do what I want: setup a com port I can then communicate over via putty. (If I get putty, I can do the rest.)  I then have everything I need to have an app on the chip to communicate with.

       

      1. The biggest is I can execute the debug version.

      The second its I cannot load the normal version - it appears to erase/burn correctly, but I then get an error and the blinky does its thing.

      This tells me the code does not get loaded.

       

      I suggest this is a bug - if the erase/burn does not happen, but the tool reports it was successful, there is a disconnect. The erase should report it was not successful. This could be because the erase is not actually dealing with the hardware, just being lied to by some intermediate emulation level.

       

      However, I can download the debug version and step through/set breakpoints. I am assuming the debug version executes out of RAM. However,  I cannot see the COM port for the USB serial device. I have two USB "C" cables to two different USB ports. The cables are new. I switched them as a test. The COM3 is expected - it is the DAP device.

       

      This tells me the debug version not only runs out of the RAM, but cannot access the target MPU hardware registers.

       

      The PC has a hardware RS232 port as COM1

       

      USB_UART_TEST1_no_serial_port.png

      2: if you look at the sequence below, it appears the debug load is interrupted.

      If I try a non-debug load, I get this - but from the above we can see the DAP device.

       

      Open On-Chip Debugger 0.10.0+dev-3.0.0.665 (2020-03-20-10:13)

      Licensed under GNU GPL v2

      For bug reports, read

          http://openocd.org/doc/doxygen/bugs.html

      Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.

      adapter speed: 2000 kHz

      ** Auto-acquire enabled, use "set ENABLE_ACQUIRE 0" to disable

      cortex_m reset_config sysresetreq

      cortex_m reset_config sysresetreq

      Info : Using CMSIS loader 'CY8C6xxx_SMIF' for bank 'psoc6_smif0_cm0' (footprint 6485 bytes)

      Warn : SFlash programming allowed for regions: USER, TOC, KEY

      Error: unable to find CMSIS-DAP device

      Error: No Valid JTAG Interface Configured.

       

      3: if I power cycle the board, I get the blinky LED. Then, if I then download the normal (non-debug) version, it says it is erasing and downloading the code. However, I then get this:

       

      Error: CMSIS-DAP command CMD_DISCONNECT failed.

      Error: error writing data: LIBUSB_ERROR_IO

      Error: CMSIS-DAP command CMD_CONNECT failed.

      Error: error writing data: LIBUSB_ERROR_IO

      Polling target psoc6.cpu.cm4 failed, trying to reexamine

      Error: error writing data: LIBUSB_ERROR_IO

      Error: CMSIS-DAP command CMD_DISCONNECT failed.

      Error: error writing data: LIBUSB_ERROR_IO

      Error: CMSIS-DAP command CMD_CONNECT failed.

      Error: error writing data: LIBUSB_ERROR_IO

      (etc)

       

      and the blinky happens.

       

      4. I keep getting "Error: FreeRTOS: uxTopUsedPriority is not defined, consult the OpenOCD manual for a work-around"

      - I have not been able to find the "OpenOCD manual work-around"

      - I did find a github example. I added it to main.c:

       

      /* https://github.com/arduino/OpenOCD/blob/master/contrib/rtos-helpers/FreeRTOS-openocd.c

      * Since at least FreeRTOS V7.5.3 uxTopUsedPriority is no longer

      * present in the kernel, so it has to be supplied by other means for

      * OpenOCD's threads awareness.

      *

      * Add this file to your project, and, if you're using --gc-sections,

      * ``--undefined=uxTopUsedPriority'' (or

      * ``-Wl,--undefined=uxTopUsedPriority'' when using gcc for final

      * linking) to your LDFLAGS; same with all the other symbols you need.

      */

       

      #include "FreeRTOSConfig.h"

      #include "FreeRTOS.h"

       

      #ifdef __GNUC__

      #define USED __attribute__((used))

      #else

      #define USED

      #endif

       

      const int USED uxTopUsedPriority = configMAX_PRIORITIES - 1;

      -----------------------------------------------------------------------------------

      FreeRTOS.h:

       

      // const int USED uxTopUsedPriority = configMAX_PRIORITIES - 1;

       

      extern const int USED uxTopUsedPriority;

      -----------------------------------------------------------------------------------

       

      5. I am also getting it at execution time, on memory accesses for invocations like:

       

      list.h: #define listCURRENT_LIST_LENGTH( pxlist )  ((pxlist) -> uxNumberOfItems)

       

      6. They also occur at the start of the Debug sequence:

       

      Started by GNU MCU Eclipse

      Open On-Chip Debugger 0.10.0+dev-3.0.0.665 (2020-03-20-10:13)

      Licensed under GNU GPL v2

      For bug reports, read

          http://openocd.org/doc/doxygen/bugs.html

      Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.

      adapter speed: 2000 kHz

      ** Auto-acquire enabled, use "set ENABLE_ACQUIRE 0" to disable

      cortex_m reset_config sysresetreq

      cortex_m reset_config sysresetreq

      Info : Using CMSIS loader 'CY8C6xxx_SMIF' for bank 'psoc6_smif0_cm0' (footprint 6485 bytes)

      Warn : SFlash programming allowed for regions: USER, TOC, KEY

      Info : CMSIS-DAP: SWD  Supported

      Info : CMSIS-DAP: FW Version = 2.0.0

      Info : CMSIS-DAP: Interface Initialised (SWD)

      Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1

      Info : CMSIS-DAP: Interface ready

      Info : KitProg3: FW version: 2.0.809

      Info : KitProg3: Pipelined transfers enabled

      Info : VTarget = 3.298 V

      Info : kitprog3: acquiring PSoC device...

      Info : clock speed 2000 kHz

      Info : SWD DPIDR 0x6ba02477

      Info : psoc6.cpu.cm0: hardware has 4 breakpoints, 2 watchpoints

      Info : psoc6.cpu.cm0: external reset detected

      ***************************************

      ** Silicon: 0xE206, Family: 0x100, Rev.: 0x23 (B2)

      ** Detected Device: CY8C6247BZI-D54

      ** Detected Main Flash size, kb: 1024

      ** Flash Boot version: 1.20.1.42

      ** Chip Protection: NORMAL

      ***************************************

      Info : psoc6.cpu.cm4: hardware has 6 breakpoints, 4 watchpoints

      Info : psoc6.cpu.cm4: external reset detected

      Info : Listening on port 3332 for gdb connections

      Info : Listening on port 3333 for gdb connections

      Info : kitprog3: acquiring PSoC device...

      target halted due to debug-request, current mode: Thread

      xPSR: 0x01000000 pc: 0x00001f34 msp: 0x080477a8

      ** Device acquired successfully

      ** psoc6.cpu.cm4: Ran after reset and before halt...

      target halted due to debug-request, current mode: Thread

      xPSR: 0x61000000 pc: 0x1600400c msp: 00000000

      Started by GNU MCU Eclipse

      Info : Listening on port 6666 for tcl connections

      Info : Listening on port 4444 for telnet connections

      Info : accepting 'gdb' connection on tcp/3333

      Info : New GDB Connection: 1, Target psoc6.cpu.cm4, state: halted

      semihosting is enabled

      Info : Auto-detected RTOS: FreeRTOS

      Error: FreeRTOS: uxTopUsedPriority is not defined, Info : Auto-detected RTOS: FreeRTOS

      consult the OpenOCD manual for a work-around

      Error: FreeRTOS: uxTopUsedPriority is not defined, consult the OpenOCD manual for a work-around

      Info : All data matches, Flash programming skipped

      target halted due to debug-request, current mode: Thread

      xPSR: 0x61000000 pc: 0x10006720 psp: 0x08002e18, semihosting

      Info : psoc6.cpu.cm4: bkpt @0x100022D1, issuing SYSRESETREQ

      Info : psoc6.cpu.cm4: external reset detected

      Info : psoc6.cpu.cm4: external reset detected

      target halted due to debug-request, current mode: Thread

      xPSR: 0x61000000 pc: 0x100022d0 msp: 0x08047800, semihosting

      Info : psoc6.cpu.cm0: external reset detected

      ===== arm v7m registers

      (0) r0 (/32): 0x40210400

      (1) r1 (/32): 0x0000000E

      (2) r2 (/32): 0x402102C0

      (3) r3 (/32): 0x10002000

      (4) r4 (/32): 0x100022D1

      (5) r5 (/32): 0xA5A5A5A5

      (6) r6 (/32): 0xA5A5A5A5

      (7) r7 (/32): 0xA5A5A5A5

      (8) r8 (/32): 0xA5A5A5A5

      (9) r9 (/32): 0xA5A5A5A5

      (10) r10 (/32): 0xA5A5A5A5

      (11) r11 (/32): 0xA5A5A5A5

      (12) r12 (/32): 0xA5A5A5A5

      (13) sp (/32): 0x08047800

      (14) lr (/32): 0xFFFFFFFF

      (15) pc (/32): 0x100022D0

      (16) xPSR (/32): 0x61000000

      (17) msp (/32): 0x08047800

      (18) psp (/32): 0x08002E18

      (20) primask (/1): 0x00

      (21) basepri (/8): 0x00

      (22) faultmask (/1): 0x00

      (23) control (/2): 0x00

      (24) d0 (/64): 0xAD4733522FB7DD13

      (25) d1 (/64): 0x9B61C908FFED6812

      (26) d2 (/64): 0x3F16F41EF93D7114

      (27) d3 (/64): 0x7D667914FDD17815

      (28) d4 (/64): 0xF5E7F8109F7291B3

      (29) d5 (/64): 0xFF776B80B9F57916

      (30) d6 (/64): 0xE4777914EB558916

      (31) d7 (/64): 0x05F5E1004CBEBC20

      (32) d8 (/64): 0xF637F853FBA5B992

      (33) d9 (/64): 0xFF77D412B37FA11C

      (34) d10 (/64): 0xB9AFF59A5597F442

      (35) d11 (/64): 0xBBE77992D9FF7A55

      (36) d12 (/64): 0x5F27713AFEB6F0D0

      (37) d13 (/64): 0xBF5E3D83FF5A5886

      (38) d14 (/64): 0x577CF081FF37C040

      (39) d15 (/64): 0xFABFD12A79793390

      (40) fpscr (/32): 0x00000000

      ===== Cortex-M DWT registers

       

       

      ===== Cortex-M DWT registers

      Error: FreeRTOS: uxTopUsedPriority is not defined, consult the OpenOCD manual for a work-around