stansotn
stansotn

Build fails on raspberry pi 4

Describe the bug
Compilation throws

libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I./src -I./src -I./src/helper -DPKGDATADIR=\"/usr/local/share/openocd\" -DBINDIR=\"/usr/local/bin\" -I./jimtcl -I./jimtcl -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -g -O2 -MT src/flash/mflash.lo -MD -MP -MF src/flash/.deps/mflash.Tpo -c src/flash/mflash.c -o src/flash/mflash.o
In file included from /usr/include/string.h:495,
                 from ./src/helper/system.h:27,
                 from ./config.h:338,
                 from src/flash/mflash.c:19:
In function ‘memset’,
    inlined from ‘mg_gen_ataid’ at src/flash/mflash.c:1162:2,
    inlined from ‘mg_storage_config’ at src/flash/mflash.c:1174:2:
/usr/include/aarch64-linux-gnu/bits/string_fortified.h:71:10: error: ‘__builtin_memset’ offset [509, 512] from the object at ‘buff’ is out of the bounds of referenced subobject ‘reserved7’ with type ‘mg_io_uint8[186]’ {aka ‘unsigned char[186]’} at offset 322 [-Werror=array-bounds]
   71 |   return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
      |     

How To Reproduce

  1. Clean install Ubuntu 20.04 on Raspberry pi 4 (4gb)
  2. Install libusb and clone this repo.
sudo apt install libusb-1.0-0 libusb-1.0-0-dev
git clone --recursive https://github.com/STMicroelectronics/OpenOCD.git
cd OpenOCD
  1. Try to build
./bootstrap
./configure
make

Also tried with:

./configure --enable-sysfsgpio --enable-bcm2835gpio

Additional Context
Raspberry pi support would be very handy. Please let me know if I am doing anything wrong.

AlefeFelipe
AlefeFelipe

Failed to read memory

Failed to read memory at 0x080f6004

This happen when I try execute a read command using flash read_bank.

Target: stm32wbx
Interface: raspberrypi2-native (SWD)

If I use the same command, but with st-link as interface, it works

AlefeFelipe
AlefeFelipe

stlink_usb Assertion `handle != NULL' failed

In src/jtag/drivers/stlink_usb.c:1169 - stlink_usb_mode_leave: Assertion `handle != NULL' failed.

This happen when I try execute a mass erase command using flash erase_sector or stm32l4x mass_erase.

The null pointer is passed hardcode to the stlink_dap_arp_init function when there's a STLINK_SWD_AP_STICKY_ERROR

Target: stm32wbx
Interface: stlink

nretro
nretro

Out of bound error

In src/flash/mflash.h the line

mg_io_uint8 reserved7[186];

should be changed to

mg_io_uint8 reserved7[190];

This is obviously an error, since in mflash.c reserved7 is accessed using
memset(pSegIdDrvInfo->reserved7, 0x00, 190);

Current gcc compiler flags this with an out of bound warning. In combination with the "Werror" flag, the compilation will be aborted.

ladislas
ladislas

STM32F769 based board with different QSPI pins

Hi there --

We are working on a custom board using an STM32F769BI and might choose different pins for the QSPI flash.

I'm wondering how we would need to change proc qspi_init { } for it work on different pins?

Do we need to change other things as well?

Thanks for your help!