Arjan,
You are correct in the reference you made related to BCM2835
1.65, 1.66. In BCM2835 1.68 I changed "... o enable this
ability, uncomment the #define BCM2835_HAVE_LIBCAP in
bcm2835.h" to be able to "If your program needs acccess
to /dev/mem but not as root, ..." Sadly the result was errors
at compile time netting out to not being able to build BCM2835
to allow non-root access to /dev/mem.
I will try your setuid code addition related example. This
will likley be in a few days. I have to work on important
application support code related for the SPI device that does
not involve any SPI functionality of the SPI device, only the
application elements related to the SPI device.
I have lots of Raspberry Pi code accessing I2C devices that has
never needed root nor setuid(0) access and I never had to do
any special coding nor library activity to allow the Raspberry
Pi to run as non-root. The code has been running for few years
now. I am fairly certain if I needed to run I2C as root I would
have remembered. If your reference to I2C needs root access is
when using the BCM2835 library, then I do not know. I have
ever used the BCM2835 library for I2C device access.
John L. Males
Toronto, Ontario
Canada
11 November 2020 13:45 -0500 EST
================================================================
2020-11-11 18:17:55+0000-UTC Time: 1605118675 PC/System time
11 Nov 18:17:55 ntpdate[83563]: ntpdate 4.2.8p12-a (1)
11 Nov 18:18:09 ntpdate[84168]: step time server 206.108.0.131
offset -0.001364 sec
FreeBSD 11.4-RELEASE-p3 FreeBSD 11.4-RELEASE-p3 #0: Tue Sep 1
08:22:33 UTC 2020
ro...@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC
(Work in progress alternative to Linux Kernel of its own right,
Debian, and
other Linux based Kernel distributions determined.)
Intel(R) Core(TM) i3-2367M CPU @ 1.40GHz
Intel(R) Core(TM) i3-2367M CPU @ 1.40GHz (1396.86-MHz K8-class
CPU) Intel(R) Core(TM) i3-2367M CPU @ 1.40GHz (1396.86-MHz
K8-class CPU) Intel(R) Core(TM) i3-2367M CPU @ 1.40GHz
(1396.86-MHz K8-class CPU) Intel(R) Core(TM) i3-2367M CPU @
1.40GHz (1396.86-MHz K8-class CPU) Intel(R) Core(TM) i3-2367M
CPU @ 1.40GHz (1396.86-MHz K8-class CPU)
dev.cpu.0.temperature: 74.0C
dev.cpu.1.temperature: 75.0C
dev.cpu.2.temperature: 73.0C
dev.cpu.3.temperature: 74.0C
hw.acpi.thermal.tz0.temperature: 74.1C
vmstat -s:
3437813664 cpu context switches
92031529 device interrupts
13315510 software interrupts
411811522 traps
279719330 system calls
27 kernel threads created
44592 fork() calls
3287 vfork() calls
0 rfork() calls
75581 swap pager pageins
305856 swap pager pages paged in
127950 swap pager pageouts
784710 swap pager pages paged out
51551 vnode pager pageins
398956 vnode pager pages paged in
357 vnode pager pageouts
381 vnode pager pages paged out
986 page daemon wakeups
692439118 pages examined by the page daemon
0 clean page reclamation shortfalls
63741852 pages reactivated by the page daemon
2382590 copy-on-write faults
6699 copy-on-write optimized faults
331753388 zero fill pages zeroed
7939 zero fill pages prezeroed
76984 intransit blocking page faults
432781459 total VM faults taken
129754 page faults requiring I/O
0 pages affected by kernel thread creation
1887153 pages affected by fork()
115312 pages affected by vfork()
0 pages affected by rfork()
416508661 pages freed
57113106 pages freed by daemon
213952713 pages freed by exiting processes
1020028 pages active
1819347 pages inactive
448731 pages in the laundry queue
684485 pages wired down
80174 pages free
4096 bytes per page
144384092 total name lookups
cache hits (83% pos + 3% neg) system 0% per-directory
deletions 0%, falsehits 0%, toolong 0%
Boot time : 1604644041
procs memory page disks
faults cpu0 cpu1 cpu2 cpu3 r b w avm
fre flt re pi po fr sr ad0 pa0 in sy cs us sy
id us sy id us sy id us sy id 0 0 0 99803696 320636 912
134 0 0 878 1459 0 0 194 589 7243 13 4 82 14 4
83 14 4 82 14 4 82
memory info:
real memory =
17179869184 (16384 MB)
avail memory = 16495013888 (15730 MB)
last pid: 86447; load averages: 0.76, 1.14, 1.04 up
5+11:50:49 18:18:10 71 processes: 2 running, 68 sleeping, 1
zombie
Mem: 3985M Active, 7107M Inact, 1753M Laundry, 2674M Wired,
1554M Buf, 312M Free Swap: 48G Total, 2735M Used, 45G Free, 5%
Inuse
hw.physmem:
17053859840
hw.usermem: 14250041344
buffers cached Mem: 16210872 8612900
7597972 0 0 0 Swap: 50331644
2800924 47530720
swapinfo:
Device 1K-blocks Used Avail Capacity
/dev/ada0s1b 50331644 2800924 47530720 6%
vmstat:
procs memory page disks
faults cpu r b w avm fre flt re pi po
fr sr ad0 pa0 in sy cs us sy id 0 0 0 99803696
320616 912 134 0 0 878 1459 0 0 194 589 7243
14 4 82
Message replied to:
Date: Wed, 11 Nov 2020 19:13:28 +0100
> Hi John,
>
> > The BCM2835 library does document a process to
> > enable non root access with the BCM2835 library, but does
> > not work at most basic level of changing the define the
> > BCM2835 library documents.
>
> Ok. This
> 1.65, 1.66 2020-04-16 Added support for use of capability
> cap_sys_rawio to determine if access to /dev/mem is available
> for non-root users. Contributed by Doug McFadyen. should
> enable non-root users accessing /dev/mem. And requires
> modifications to the source files.
>
> > I2C can work without need for root access.
> Not really. I?ve tested that scenario.
> 70: ? ? ? ? ? -- ? --
> --
> You received this message because you are subscribed to the
> Google Groups "bcm2835" group. To unsubscribe from this group
> and stop receiving emails from it, send an email to
>
bcm2835+u...@googlegroups.com. To view this discussion
> on the web visit
>
https://groups.google.com/d/msgid/bcm2835/BE93163C-06DB-4398-9974-B632A1E79F8F%40gmail.com.