// init bcm2835 lib (need this for DRDY polling)
if (!bcm2835_init())
{
printf("%s ERROR: bcm2835_init() failed!\n", __FUNCTION__);
return -1;
}
else
{
printf("%s INFO: BCM2835 Library Version %d successfully initialised.\n", __FUNCTION__, bcm2835_version());
};
// DRDY pin is input
bcm2835_gpio_fsel(DRDY, BCM2835_GPIO_FSEL_INPT);
bcm2835_gpio_set_pud(DRDY, BCM2835_GPIO_PUD_UP);
bcm2835_gpio_fsel(RST, BCM2835_GPIO_FSEL_OUTP);
bcm2835_gpio_fsel(SYNC, BCM2835_GPIO_FSEL_OUTP);open("/proc/device-tree/soc/ranges", O_RDONLY) = 4
fstat64(4, {st_mode=S_IFREG|0444, st_size=12, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x76fbe000
_llseek(4, 0, [0], SEEK_SET) = 0
read(4, "~\0\0\0", 4) = 4
read(4, "?\0\0\0\1\0\0\0", 4096) = 8
_llseek(4, 12, [12], SEEK_SET) = 0
close(4) = 0
munmap(0x76fbe000, 4096) = 0
geteuid32() = 1001
open("/dev/gpiomem", O_RDWR|O_SYNC) = 4
mmap2(NULL, 16777216, PROT_READ|PROT_WRITE, MAP_SHARED, 4, 0) = 0x75d70000
close(4) = 0
write(1, "ADS1256_Init INFO: BCM2835 Libra"..., 75ADS1256_Init INFO: BCM2835 Library Version 10050 successfully initialised.
) = 75
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x7} ---
+++ killed by SIGSEGV +++
Segmentation fault
ADS1256_Init INFO: BCM2835 Library Version 10050 successfully initialised.
bcm2835_peri_read paddr 20200004
bcm2835_peri_write paddr 20200004, value 00000000
bcm2835_peri_write paddr 20200094, value 00000002
bcm2835_delayMicroseconds 10
bcm2835_peri_write paddr 20200098, value 00020000
bcm2835_delayMicroseconds 10
bcm2835_peri_write paddr 20200094, value 00000000
bcm2835_peri_write paddr 20200098, value 00000000
bcm2835_peri_read paddr 20200004
bcm2835_peri_write paddr 20200004, value 01000000
bcm2835_peri_read paddr 20200008
bcm2835_peri_write paddr 20200008, value 00200000Hello,
hard to say why its crashing without seeing your code, but I suspect you are
accessing a non GPIO peripheral as non-root.
The delays are required as part of setting the PUD registers.
The delays are required as part of setting the PUD registers.
bcm2835_gpio_set_pud(DRDY, BCM2835_GPIO_PUD_UP);
I would expect that if you are using the latest version of the library, in
this case you would not get a seg fault, but instead the PUD functions would
return without doing anything:
uint32_t bcm2835_gpio_pad(uint8_t group)
{
if (bcm2835_pads == MAP_FAILED)
return 0;
.....
bcm2835_gpio_set_pud()
anymore
This has now been done for the next release.