Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

From upstream #947

Merged
merged 50 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
ea53001
jtag: move in interface.h the adapter_driver's declaration
borneoa Apr 30, 2023
faf7202
nand: declare exported function in core.h
borneoa Apr 30, 2023
247d8df
helper: replacements: rework including replacements.h
borneoa May 6, 2023
cc29abe
pld: fix new warnings from sparse
borneoa May 6, 2023
d15f58a
target: arm_dpm: with pointers, use NULL instead of 0
borneoa May 6, 2023
d2afdef
helper: types: rework h_u32_to_le() and similar for sparse
borneoa May 6, 2023
04a1181
hello: include hello.h
borneoa May 6, 2023
7fa29dc
jtag: move declaration outside function
borneoa May 6, 2023
d5c177c
server: gdb: export gdb_actual_connections through a function
borneoa May 6, 2023
5308bd9
flash: nand: move in include file the declaration of 'nand_devices'
borneoa May 6, 2023
fb34eeb
target: arm_adi_v5: move in include file the declaration of dap_ops
borneoa May 6, 2023
aaa67f7
rtos: move prototype of rtos_thread_packet() in rtos.h
borneoa May 7, 2023
17f86fd
rtos: uCOS-III: split struct ucos_iii_params
borneoa May 7, 2023
f20173a
HACKING: add info on usage of sparse
borneoa May 7, 2023
3c2cc6e
pld/virtex2: check error propagated by virtex2_read_stat()
borneoa May 6, 2023
d422519
flash/jtagspi: handle error return values where needed
danselmi Dec 29, 2022
30b0e9a
tcl/target: Add support for TMS570LC43xx
RA-Phil-K May 9, 2023
c164906
jtag/drivers/bcm2835gpio: don't touch pad setting on /dev/gpiomem
tom-van Nov 15, 2022
b41b368
jtag/drivers/bcm2835gpio: extend peripheral_base to off_t
tom-van May 12, 2023
5c46a5d
jtag/drivers/bcm2835gpio: add peripheral_mem_dev config command
tom-van May 13, 2023
4defa3b
flash/stm32l4x: support STM32C0x devices
tarek-bochkati Dec 3, 2021
5924d9f
target/riscv-013: clear sticky error when DMI operation fails
pamaury May 17, 2023
3733cf1
flash/nor/stm32f2x: Fix typos in log messages
matthijskooijman Apr 27, 2023
a5d3420
flash/nor/stm32f2x: Show error message when unprotecting OTP
matthijskooijman Apr 27, 2023
144d940
Revert "target/image: zero-initialize ELF segments up to p_memsz"
borneoa May 6, 2023
a0fecd6
target/espressif: add system level tracing feature
erhankur Apr 13, 2023
0f0a4b1
target: espressif: apptrace: declare a local function as static
borneoa May 6, 2023
22ababc
target: rewrite command 'arp_examine' as COMMAND_HANDLER
borneoa Mar 27, 2023
fe6befb
target: rewrite command 'arp_waitstate' as COMMAND_HANDLER
borneoa Mar 27, 2023
da76f8f
target: use unsigned int for timeout_ms
borneoa Mar 27, 2023
5dd047f
jtag: rewrite commands 'jtag newtap' and 'swd newdap' as COMMAND_HANDLER
borneoa Jan 2, 2023
8297836
jtag: rewrite jim_jtag_tap_enabler() as COMMAND_HANDLER
borneoa Jan 2, 2023
df12552
jtag/adapter: Removed unused include of strings.h
May 15, 2023
2dd34cb
target/xtensa: add file-IO support
ianstcdns Mar 24, 2023
78688fe
flash/jtagspi: sending command and setting parameters without probing.
danselmi Mar 21, 2023
4a57f3e
target: armv8: fix support of pointer authentication
borneoa May 25, 2023
72131e0
cortex_m: fix reading of DCB_DSCSR register
bohdan-tymkiv May 23, 2023
00603bf
flash: psoc4: fix clang error
borneoa May 27, 2023
0e52631
flash: jtagspi: fix clang build warning
borneoa May 27, 2023
00cbf7b
Add/Correct STM8L15xx2/3/4/6/8 devices
Werni2A May 18, 2023
b02cbaf
tcl/board/calao-usb-a9g20-c01: add proper initialization
wsakernel Mar 28, 2023
4dc4280
target/espressif: fix clang scan-build warning
erhankur May 28, 2023
81cf948
jtag/vdebug: fix endianness support
jacekmw8 May 29, 2023
146fec5
jtag/vdebug: using tap_state
jacekmw8 May 29, 2023
24b656b
jtag/vdebug: adding xtensa config
jacekmw8 May 29, 2023
370bf43
flash/nor: add support for NXP QN908x
iosabi Apr 9, 2020
0854c83
gdb_server: add debug signal reason prints
MarekVCodasip May 29, 2023
71180e6
gdb_server: refactor and unify function gdb_get_char_inner
MarekVCodasip May 30, 2023
9f23a1d
semihosting: fix non-zero value on Windows isatty()
MarekVCodasip May 30, 2023
f02fe09
Merge commit '9f23a1d7c1e27c556ef9787b9d3f263f5c1ecf24' into from_ups…
timsifive Oct 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions HACKING
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,21 @@ patch:
Now every time OpenOCD is run, coverage info in your build directory is
updated. Running `gcov src/path/file.c` will generate a report.

- Sparse Static Analyzer

Using this tool allows identifying some bug in C code.
In the future, OpenOCD would use the sparse attribute 'bitwise' to
detect incorrect endianness assignments.

Example usage:
@code
mkdir build-sparse; cd build-sparse
../configure CC=cgcc CFLAGS="-Wsparse-all -Wno-declaration-after-statement \
-Wno-unknown-attribute -Wno-transparent-union -Wno-tautological-compare \
-Wno-vla -Wno-flexible-array-array -D__FLT_EVAL_METHOD__=0"
make
@endcode

Please consider performing these additional checks where appropriate
(especially Clang Static Analyzer for big portions of new code) and
mention the results (e.g. "Valgrind-clean, no new Clang analyzer
Expand Down
165 changes: 163 additions & 2 deletions doc/openocd.texi
Original file line number Diff line number Diff line change
Expand Up @@ -3322,15 +3322,32 @@ GPIO numbers >= 32 can't be used for performance reasons. GPIO configuration is
handled by the generic command @ref{adapter gpio, @command{adapter gpio}}.

See @file{interface/raspberrypi-native.cfg} for a sample config and
pinout.
@file{interface/raspberrypi-gpio-connector.cfg} for pinout.

@deffn {Config Command} {bcm2835gpio speed_coeffs} @var{speed_coeff} @var{speed_offset}
Set SPEED_COEFF and SPEED_OFFSET for delay calculations. If unspecified,
speed_coeff defaults to 113714, and speed_offset defaults to 28.
@end deffn

@deffn {Config Command} {bcm2835gpio peripheral_mem_dev} @var{device}
Set the device path for access to the memory mapped GPIO control registers.
Uses @file{/dev/gpiomem} by default, this is also the preferred option with
respect to system security.
If overridden to @file{/dev/mem}:
@itemize @minus
@item OpenOCD needs @code{cap_sys_rawio} or run as root to open @file{/dev/mem}.
Please be aware of security issues imposed by running OpenOCD with
elevated user rights and by @file{/dev/mem} itself.
@item correct @command{peripheral_base} must be configured.
@item GPIO 0-27 pads are set to the limited slew rate
and drive strength is reduced to 4 mA (2 mA on RPi 4).
@end itemize

@end deffn

@deffn {Config Command} {bcm2835gpio peripheral_base} @var{base}
Set the peripheral base register address to access GPIOs. For the RPi1, use
Set the peripheral base register address to access GPIOs.
Ignored if @file{/dev/gpiomem} is used. For the RPi1, use
0x20000000. For RPi2 and RPi3, use 0x3F000000. For RPi4, use 0xFE000000. A full
list can be found in the
@uref{https://www.raspberrypi.org/documentation/hardware/raspberrypi/peripheral_addresses.md, official guide}.
Expand Down Expand Up @@ -7355,6 +7372,116 @@ Note: only Main and Work flash regions support Erase operation.
@end deffn
@end deffn

@deffn {Flash Driver} {qn908x}
The NXP QN908x microcontrollers feature a Cortex-M4F with integrated Bluetooth
LE 5 support and an internal flash of up to 512 KiB. These chips only support
the SWD interface.

The @var{qn908x} driver uses the internal "Flash Memory Controller" block via
SWD to erase, program and read the internal flash. This driver does not
support the ISP (In-System Programming) mode which is an alternate way to
program the flash via UART, SPI or USB.

The internal flash is 512 KiB in size in all released chips and it starts at
the address 0x01000000, although it can be mapped to address 0 and it is
aliased to other addresses. This driver only recognizes the bank starting at
address 0x01000000.

The internal bootloader stored in ROM is in charge of loading and verifying
the image from flash, or enter ISP mode. The programmed image must start at
the beginning of the flash and contain a valid header and a matching CRC32
checksum. Additionally, the image header contains a "Code Read Protection"
(CRP) word which indicates whether SWD access is enabled, as well as whether
ISP mode is enabled. Therefore, it is possible to program an image that
disables SWD and ISP making it impossible to program another image in the
future through these interfaces, or even debug the current image. While this is
a valid use case for production deployments where the chips are locked down, by
default this driver doesn't allow such images that disable the SWD interface.
To program such images see the @command{qn908x allow_brick} command.

Apart from the CRP field which is located in the image header, the last page
of the flash memory contains a "Flash lock and protect" descriptor which allows
to individually protect each 2 KiB page, as well as disabling SWD access to the
flash and RAM. If this access is disabled it is not possible to read, erase or
program individual pages from the SWD interface or even access the read-only
"Flash information page" with information about the bootloader version and
flash size. However when this protection is in place, it is still possible to
mass erase the whole chip and then program a new image, for which you can use
the @command{qn908x mass_erase}.

Example:
@example
flash bank $FLASHNAME qn908x 0x01000000 0 0 0 $TARGETNAME calc_checksum
@end example

Parameters:
@itemize
@item @option{calc_checksum} optional parameter to compute the required
checksum of the first bytes in the vector table.
@quotation Note
If the checksum in the header of your image is invalid and you don't provide the
@option{calc_checksum} option the boot ROM will not boot your image and it may
render the flash inaccessible. On the other hand, if you use this option to
compute the checksum keep in mind that @command{verify_image} will fail on
those four bytes of the checksum since those bytes in the flash will have the
updated checksum.
@end quotation
@end itemize

@deffn {Command} {qn908x allow_brick}
Allow the qn908x driver to program images with a "Code Read Protection" byte
that disables the SWD access. Programming such image will cause OpenOCD to
not be able to reach the target over SWD anymore after the new image is
programmed and its configuration takes effect, e.g. after a reboot. After
executing @command{qn908x allow_brick} these images will be allowed to be
programmed when writing to the flash.
@end deffn

@deffn {Command} {qn908x disable_wdog}
Disable the watchdog timer (WDT) by resetting its CTRL field. The WDT starts
enabled after a @command{reset halt} and it doesn't run while the target is
halted. However, the verification process in this driver uses the generic
Cortex-M verification process which executes a payload in RAM and thus
requires the watchdog to be disabled before running @command{verify_image}
after a reset halt or any other condition where the watchdog is running.
Note that this is not done automatically and you must run this command in
those scenarios.
@end deffn

@deffn {Command} {qn908x mass_erase}
Erases the complete flash using the mass_erase method. Mass erase is only
allowed if enabled in the Lock Status Register 8 (LOCK_STAT_8) which is read
from the last sector of the flash on boot. However, this mass_erase lock
protection can be bypassed and this command does so automatically.

In the same LOCK_STAT_8 the flash and RAM access from SWD can be disabled by
setting two bits in this register. After a mass_erase, all the bits of the
flash would be set, making it the default to restrict SWD access to the flash
and RAM regions. This new after erase LOCK_STAT_8 value only takes effect after
being read from flash on the next reboot for example. After a mass_erase the
LOCK_STAT_8 register is changed by the hardware to allow access to flash and
RAM regardless of the value on flash, but only right after a mass_erase and
until the next boot. Therefore it is possible to perform a mass_erase, program
a new image, verify it and then reboot to a valid image that's locked from the
SWD access.

The @command{qn908x mass_erase} command clears the bits that would be loaded
from the flash into LOCK_STAT_8 after erasing the whole chip to allow SWD
access for debugging or re-flashing an image without a mass_erase by default.
If the image being programmed also programs the last page of the flash with its
own settings, this mass_erase behavior will interfere with that write since a
new erase of at least the last page would need to be performed before writing
to it again. For this reason the optional @option{keep_lock} argument can be
used to leave the flash and RAM lock set. For development environments, the
default behavior is desired.

The mass erase locking mechanism is independent from the individual page
locking bits, so it is possible that you can't erase a given page that is
locked and you can't unprotect that page because the locking bits are also
locked, but can still mass erase the whole flash.
@end deffn
@end deffn

@deffn {Flash Driver} {rp2040}
Supports RP2040 "Raspberry Pi Pico" microcontroller.
RP2040 is a dual-core device with two CM0+ cores. Both cores share the same
Expand Down Expand Up @@ -11487,6 +11614,40 @@ w/o OpenOCD command and keeps only the latest data window which fit into the buf
Data will be stored to specified destination.
@end deffn

@deffn {Command} {esp sysview} (start file://<outfile1> [file://<outfile2>] [<poll_period> [<trace_size> [<stop_tmo> [<wait4halt> [<skip_size>]]]]])
Starts @uref{https://www.segger.com/products/development-tools/systemview/, SEGGER SystemView}
compatible tracing. Data will be stored to specified destination.
For dual-core chips traces from every core will be saved to separate files.
Resulting files can be open in "SEGGER SystemView" application.
@url{https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/app_trace.html#openocd-systemview-tracing-command-options}
The meaning of the arguments is identical to @command{esp apptrace start}.
@end deffn

@deffn {Command} {esp sysview} (stop)
Stops SystremView compatible tracing started with above command.
@url{https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/app_trace.html#openocd-systemview-tracing-command-options}
@end deffn

@deffn {Command} {esp sysview} (status)
Requests ongoing SystremView compatible tracing status.
@url{https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/app_trace.html#openocd-systemview-tracing-command-options}
@end deffn

@deffn {Command} {esp sysview_mcore} (start file://<outfile> [<poll_period> [<trace_size> [<stop_tmo> [<wait4halt> [<skip_size>]]]]])
This command is identical to @command{esp sysview start}, but uses Espressif multi-core extension to
@uref{https://www.segger.com/products/development-tools/systemview/, SEGGER SystemView} data format.
Data will be stored to specified destination. Tracing data from all cores are saved in the same file.
The meaning of the arguments is identical to @command{esp sysview start}.
@end deffn

@deffn {Command} {esp sysview_mcore} (stop)
Stops Espressif multi-core SystremView tracing started with above command.
@end deffn

@deffn {Command} {esp sysview_mcore} (status)
Requests ongoing Espressif multi-core SystremView tracing status.
@end deffn

@anchor{softwaredebugmessagesandtracing}
@section Software Debug Messages and Tracing
@cindex Linux-ARM DCC support
Expand Down
3 changes: 3 additions & 0 deletions src/flash/nand/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ enum oob_formats {
NAND_OOB_YAFFS2 = 0x100,/* when writing, use YAFFS2 OOB layout */
};

extern struct nand_device *nand_devices;

struct nand_device *get_nand_device_by_num(int num);

Expand All @@ -202,6 +203,8 @@ int nand_calculate_ecc(struct nand_device *nand,
const uint8_t *dat, uint8_t *ecc_code);
int nand_calculate_ecc_kw(struct nand_device *nand,
const uint8_t *dat, uint8_t *ecc_code);
int nand_correct_data(struct nand_device *nand, u_char *dat,
u_char *read_ecc, u_char *calc_ecc);

int nand_register_commands(struct command_context *cmd_ctx);

Expand Down
2 changes: 0 additions & 2 deletions src/flash/nand/lpc32xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
static int lpc32xx_reset(struct nand_device *nand);
static int lpc32xx_controller_ready(struct nand_device *nand, int timeout);
static int lpc32xx_tc_ready(struct nand_device *nand, int timeout);
extern int nand_correct_data(struct nand_device *nand, u_char *dat,
u_char *read_ecc, u_char *calc_ecc);

/* These are offset with the working area in IRAM when using DMA to
* read/write data to the SLC controller.
Expand Down
3 changes: 0 additions & 3 deletions src/flash/nand/tcl.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
#include "fileio.h"
#include <target/target.h>

/* to be removed */
extern struct nand_device *nand_devices;

COMMAND_HANDLER(handle_nand_list_command)
{
struct nand_device *p;
Expand Down
1 change: 1 addition & 0 deletions src/flash/nor/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ NOR_DRIVERS = \
%D%/psoc4.c \
%D%/psoc5lp.c \
%D%/psoc6.c \
%D%/qn908x.c \
%D%/renesas_rpchf.c \
%D%/rp2040.c \
%D%/rsl10.c \
Expand Down
13 changes: 13 additions & 0 deletions src/flash/nor/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,19 @@ int get_flash_bank_by_num(unsigned int num, struct flash_bank **bank);
*/
COMMAND_HELPER(flash_command_get_bank, unsigned name_index,
struct flash_bank **bank);
/**
* Retrieves @a bank from a command argument, reporting errors parsing
* the bank identifier or retrieving the specified bank. The bank
* may be identified by its bank number or by @c name.instance, where
* @a instance is driver-specific.
* @param name_index The index to the string in args containing the
* bank identifier.
* @param bank On output, contains a pointer to the bank or NULL.
* @param do_probe Does auto-probing when set, otherwise without probing.
* @returns ERROR_OK on success, or an error indicating the problem.
*/
COMMAND_HELPER(flash_command_get_bank_probe_optional, unsigned int name_index,
struct flash_bank **bank, bool do_probe);
/**
* Returns the flash bank like get_flash_bank_by_num(), without probing.
* @param num The flash bank number.
Expand Down
1 change: 1 addition & 0 deletions src/flash/nor/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ extern const struct flash_driver psoc5lp_eeprom_flash;
extern const struct flash_driver psoc5lp_flash;
extern const struct flash_driver psoc5lp_nvl_flash;
extern const struct flash_driver psoc6_flash;
extern const struct flash_driver qn908x_flash;
extern const struct flash_driver renesas_rpchf_flash;
extern const struct flash_driver rp2040_flash;
extern const struct flash_driver rsl10_flash;
Expand Down
1 change: 1 addition & 0 deletions src/flash/nor/drivers.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ static const struct flash_driver * const flash_drivers[] = {
&psoc5lp_eeprom_flash,
&psoc5lp_nvl_flash,
&psoc6_flash,
&qn908x_flash,
&renesas_rpchf_flash,
&rp2040_flash,
&sh_qspi_flash,
Expand Down
Loading
Loading