Skip to content

Commit

Permalink
Merge pull request #911 from riscv/from_upstream
Browse files Browse the repository at this point in the history
From upstream
  • Loading branch information
timsifive authored Sep 11, 2023
2 parents 53f2133 + 0801c66 commit 67c2835
Show file tree
Hide file tree
Showing 23 changed files with 379 additions and 269 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,11 @@ GTAGS

# checkpatch script files
.checkpatch-camelcase.*

# clangd (e.g. for advanced code completion and linting) generates cache files
# into .cache
.cache

# A compile_commands.json can be generated using bear and will help tools such
# as clangd to locate header files and use correct $CFLAGS
compile_commands.json
2 changes: 1 addition & 1 deletion README.Windows
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ port depending on which application to use.

For more information, see:

http://msdn.microsoft.com/en-us/library/windows/hardware/jj649944(v=vs.85).aspx
https://learn.microsoft.com/en-us/windows-hardware/drivers/usbcon/usb-device-specific-registry-settings
http://www.ftdichip.com/Support/Knowledgebase/index.html?ignorehardwareserialnumber.htm
2 changes: 1 addition & 1 deletion doc/openocd.texi
Original file line number Diff line number Diff line change
Expand Up @@ -2480,7 +2480,7 @@ This command is only available if your libusb1 is at least version 1.0.16.
Specifies the @var{serial_string} of the adapter to use.
If this command is not specified, serial strings are not checked.
Only the following adapter drivers use the serial string from this command:
arm-jtag-ew, cmsis_dap, ft232r, ftdi, hla (stlink, ti-icdi), jlink, kitprog, opendus,
arm-jtag-ew, cmsis_dap, esp_usb_jtag, ft232r, ftdi, hla (stlink, ti-icdi), jlink, kitprog, opendus,
openjtag, osbdm, presto, rlink, st-link, usb_blaster (ublast2), usbprog, vsllink, xds110.
@end deffn

Expand Down
134 changes: 134 additions & 0 deletions doc/usb_adapters/esp_usb_jtag/303a_1001_esp_usb_jtag.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# SPDX-License-Identifier: GPL-2.0-or-later OR GFDL-1.2-no-invariants-or-later

# Optional comment

Bus 002 Device 035: ID 303a:1001
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x303a
idProduct 0x1001
bcdDevice 1.01
iManufacturer 1 Espressif
iProduct 2 USB JTAG/serial debug unit
iSerial 3 7C:DF:A1:A2:8F:38
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x0062
bNumInterfaces 3
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
Self Powered
MaxPower 500mA
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 0
bInterfaceCount 2
bFunctionClass 2 Communications
bFunctionSubClass 2 Abstract (modem)
bFunctionProtocol 0
iFunction 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 2 Communications
bInterfaceSubClass 2 Abstract (modem)
bInterfaceProtocol 0
iInterface 0
CDC Header:
bcdCDC 1.10
CDC ACM:
bmCapabilities 0x02
line coding and serial state
CDC Union:
bMasterInterface 0
bSlaveInterface 1
CDC Call Management:
bmCapabilities 0x03
call management
use DataInterface
bDataInterface 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 10 CDC Data
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 1
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
Device Status: 0x0001
Self Powered
1 change: 1 addition & 0 deletions doc/usb_adapters/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ OpenOCD gerrit, as explained in HACKING.

The dumps are organized in subfolders corresponding to OpenOCD drivers:
- cmsis_dap;
- esp_usb_jtag;
- ft232r;
- ftdi;
- icdi;
Expand Down
5 changes: 0 additions & 5 deletions src/flash/nor/psoc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,9 +651,6 @@ static int psoc4_write(struct flash_bank *bank, const uint8_t *buffer,
if (row_offset)
memset(row_buffer, bank->default_padded_value, row_offset);

/* Mask automatic polling triggered by execution of halted events */
bool save_poll_mask = jtag_poll_mask();

while (count) {
uint32_t chunk_size = psoc4_info->row_size - row_offset;
if (chunk_size > count) {
Expand Down Expand Up @@ -693,8 +690,6 @@ static int psoc4_write(struct flash_bank *bank, const uint8_t *buffer,
}

cleanup:
jtag_poll_unmask(save_poll_mask);

free(sysrq_buffer);
return retval;
}
Expand Down
1 change: 1 addition & 0 deletions src/flash/nor/stm32l4x.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ static const struct stm32l4_rev stm32g49_g4axx_revs[] = {

static const struct stm32l4_rev stm32u57_u58xx_revs[] = {
{ 0x1000, "A" }, { 0x1001, "Z" }, { 0x1003, "Y" }, { 0x2000, "B" },
{ 0x2001, "X" }, { 0x3000, "C" },
};

static const struct stm32l4_rev stm32wb1xx_revs[] = {
Expand Down
2 changes: 2 additions & 0 deletions src/helper/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ noinst_LTLIBRARIES += %D%/libhelper.la
%D%/configuration.c \
%D%/log.c \
%D%/command.c \
%D%/crc32.c \
%D%/time_support.c \
%D%/replacements.c \
%D%/fileio.c \
Expand All @@ -24,6 +25,7 @@ noinst_LTLIBRARIES += %D%/libhelper.la
%D%/types.h \
%D%/log.h \
%D%/command.h \
%D%/crc32.h \
%D%/time_support.h \
%D%/replacements.h \
%D%/fileio.h \
Expand Down
50 changes: 50 additions & 0 deletions src/helper/crc32.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// SPDX-License-Identifier: GPL-2.0-or-later

/***************************************************************************
* Copyright (C) 2013-2014 by Franck Jullien *
* [email protected] *
* *
* Copyright (C) 2022 Otto-von-Guericke-Universität Magdeburg *
* [email protected] *
***************************************************************************/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "crc32.h"
#include <stdint.h>
#include <stddef.h>

static uint32_t crc_le_step(uint32_t poly, uint32_t crc, uint32_t data_in,
unsigned int data_bits)
{
for (unsigned int i = 0; i < data_bits; i++) {
uint32_t d, c;
d = ((data_in >> i) & 0x1) ? 0xffffffff : 0;
c = (crc & 0x1) ? 0xffffffff : 0;
crc = crc >> 1;
crc = crc ^ ((d ^ c) & poly);
}

return crc;
}

uint32_t crc32_le(uint32_t poly, uint32_t seed, const void *_data,
size_t data_len)
{
if (((uintptr_t)_data & 0x3) || (data_len & 0x3)) {
/* data is unaligned, processing data one byte at a time */
const uint8_t *data = _data;
for (size_t i = 0; i < data_len; i++)
seed = crc_le_step(poly, seed, data[i], 8);
} else {
/* data is aligned, processing 32 bit at a time */
data_len >>= 2;
const uint32_t *data = _data;
for (size_t i = 0; i < data_len; i++)
seed = crc_le_step(poly, seed, data[i], 32);
}

return seed;
}
37 changes: 37 additions & 0 deletions src/helper/crc32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */

/***************************************************************************
* Copyright (C) 2022 Otto-von-Guericke-Universität Magdeburg *
* [email protected] *
***************************************************************************/

#ifndef OPENOCD_HELPER_CRC32_H
#define OPENOCD_HELPER_CRC32_H

#include <stdint.h>
#include <stddef.h>

/** @file
* A generic CRC32 implementation
*/

/**
* CRC32 polynomial commonly used for little endian CRC32
*/
#define CRC32_POLY_LE 0xedb88320

/**
* Calculate the CRC32 value of the given data
* @param poly The polynomial of the CRC
* @param seed The seed to use (mostly either `0` or `0xffffffff`)
* @param data The data to calculate the CRC32 of
* @param data_len The length of the data in @p data in bytes
* @return The CRC value of the first @p data_len bytes at @p data
* @note This function can be used to incrementally compute the CRC one
* chunk of data at a time by using the CRC32 of the previous chunk
* as @p seed for the next chunk.
*/
uint32_t crc32_le(uint32_t poly, uint32_t seed, const void *data,
size_t data_len);

#endif /* OPENOCD_HELPER_CRC32_H */
4 changes: 1 addition & 3 deletions src/jtag/hla/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ noinst_LTLIBRARIES += %D%/libocdhla.la

%C%_libocdhla_la_SOURCES = \
%D%/hla_transport.c \
%D%/hla_tcl.c \
%D%/hla_interface.c \
%D%/hla_layout.c \
%D%/hla_transport.h \
%D%/hla_interface.h \
%D%/hla_layout.h \
%D%/hla_tcl.h
%D%/hla_layout.h
1 change: 0 additions & 1 deletion src/jtag/hla/hla_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <transport/transport.h>
#include <helper/time_support.h>

#include <jtag/hla/hla_tcl.h>
#include <jtag/hla/hla_layout.h>
#include <jtag/hla/hla_transport.h>
#include <jtag/hla/hla_interface.h>
Expand Down
1 change: 0 additions & 1 deletion src/jtag/hla/hla_layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <helper/time_support.h>

#include <jtag/hla/hla_layout.h>
#include <jtag/hla/hla_tcl.h>
#include <jtag/hla/hla_transport.h>
#include <jtag/hla/hla_interface.h>

Expand Down
Loading

0 comments on commit 67c2835

Please sign in to comment.