06-25-2021, 09:35 AM
Compiling OpenOCD (with gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0) as described in https://github.com/pulp-platform/pulpiss...l-platform, section "GDB and OpenOCD":
This error was encountered:
SOLUTION: see https://githubmemory.com/repo/STMicroele...OCD/issues, user nretro's comment:
After fixing that error, this one appears:
SOLUTION: see https://github.com/rr-debugger/rr/commit...49d49cfe5d
Apply these changes to pulp-sdk/tools/riscv-openocd/src/helper/options.c:
Posted here so you don't have to waste the time we did. After that, the compilation works. Good luck.
Code:
source sourceme.sh && ./pulp-tools/bin/plpbuild checkout build --p openocd --stdout
This error was encountered:
Code:
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/x86_64-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));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [Makefile:3344: src/flash/mflash.lo] Error 1
make[2]: Leaving directory '/home/thom/Argus/pulpissimo/pulp-sdk/tools/riscv-openocd'
make[1]: *** [Makefile:4283: install-recursive] Error 1
make[1]: Leaving directory '/home/thom/Argus/pulpissimo/pulp-sdk/tools/riscv-openocd'
make: *** [Makefile:4585: install] Error 2
Reached EOF with exit status 2
FATAL ERROR: the command 'build' has failed
SOLUTION: see https://githubmemory.com/repo/STMicroele...OCD/issues, user nretro's comment:
Quote: In src/flash/mflash.h the line
Code:
mg_io_uint8 reserved7[186];
Quote: should be changed to
Code:
mg_io_uint8 reserved7[190];
Quote: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.
After fixing that error, this one appears:
Code:
In file included from src/helper/options.c:38:
/usr/include/x86_64-linux-gnu/sys/sysctl.h:21:2: error: #warning "The <sys/sysctl.h> header is deprecated and will be removed." [-Werror=cpp]
21 | #warning "The <sys/sysctl.h> header is deprecated and will be removed."
| ^~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [Makefile:3359: src/helper/libhelper_la-options.lo] Error 1
make[2]: Leaving directory '/home/thom/Argus/pulpissimo/pulp-sdk/tools/riscv-openocd'
make[1]: *** [Makefile:4283: install-recursive] Error 1
make[1]: Leaving directory '/home/thom/Argus/pulpissimo/pulp-sdk/tools/riscv-openocd'
make: *** [Makefile:4585: install] Error 2
Reached EOF with exit status 2
FATAL ERROR: the command 'build' has failed
SOLUTION: see https://github.com/rr-debugger/rr/commit...49d49cfe5d
Apply these changes to pulp-sdk/tools/riscv-openocd/src/helper/options.c:
Code:
#if IS_DARWIN
#include <libproc.h>
#endif
#include <sys/syscall.h>
//#ifdef HAVE_SYS_SYSCTL_H
//#include <sys/sysctl.h>
//#endif
#ifndef CTL_KERN
#define CTL_KERN 1
#endif
#ifndef KERN_RTSIGMAX
#define KERN_RTSIGMAX 33
#endif
(...)
char *path = malloc(PATH_MAX);
if (path == NULL)
break;
int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
size_t size = PATH_MAX;
if (syscall(RR__sysctl, mib, (u_int)ARRAY_SIZE(mib), path, &size, NULL, 0) != 0)
//if (sysctl(mib, (u_int)ARRAY_SIZE(mib), path, &size, NULL, 0) != 0)
break;
Posted here so you don't have to waste the time we did. After that, the compilation works. Good luck.