Raspberry Pi 4B

2826 views
Skip to first unread message

Tobias Spitzbart

unread,
Jul 4, 2019, 5:30:06 AM7/4/19
to bcm2835
Hi Mike,

in the past I used your lib often. Thanks for your work.

Will be there be a version that is compatible to the Rasberry Pi 4?

Greetings Tobias

Christoph Orth

unread,
Jul 10, 2019, 12:45:43 PM7/10/19
to bcm2835
Hi Mike

I also use the library for some projects.
It seems to be not compatible yet with Raspbian Buster.

I get this error:

bcm2835_init: gpio mmap failed: Cannot allocate memory

Would be great if you can have a look.

Christoph

Arjan van Vught

unread,
Jul 10, 2019, 12:51:21 PM7/10/19
to bcm...@googlegroups.com
The SoC on the Raspberry Pi 4B board is completely different from the previous used SoC’s

There would be some -major- coding in order to support the new SoC on the Raspberry Pi 4B board.

- Arjan
--
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 post to this group, send email to bcm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bcm2835/046ac376-5b49-4a2e-aded-547362b6521b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christoph Orth

unread,
Jul 10, 2019, 2:11:06 PM7/10/19
to bcm2835
I see, that is unfortunate. But without this functionality, the Raspberry is not even half as useful for me.
We should try to write a new version of the library which does work.

Am Mittwoch, 10. Juli 2019 18:51:21 UTC+2 schrieb Arjan van Vught:
The SoC on the Raspberry Pi 4B board is completely different from the previous used SoC’s

There would be some -major- coding in order to support the new SoC on the Raspberry Pi 4B board.

- Arjan
Op 10 jul. 2019, om 18:45 heeft Christoph Orth <c....@ugreen.eu> het volgende geschreven:

Hi Mike

I also use the library for some projects.
It seems to be not compatible yet with Raspbian Buster.

I get this error:

bcm2835_init: gpio mmap failed: Cannot allocate memory

Would be great if you can have a look.

Christoph



Am Donnerstag, 4. Juli 2019 11:30:06 UTC+2 schrieb Tobias Spitzbart:
Hi Mike,

in the past I used your lib often. Thanks for your work.

Will be there be a version that is compatible to the Rasberry Pi 4?

Greetings Tobias

--
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 bcm...@googlegroups.com.

Mike McCauley

unread,
Jul 10, 2019, 4:34:18 PM7/10/19
to bcm...@googlegroups.com, Christoph Orth
Hello,

On Thursday, 11 July 2019 02:45:43 AEST Christoph Orth wrote:
> Hi Mike
>
> I also use the library for some projects.
> It seems to be not compatible yet with Raspbian Buster.

bcm2835 is compatible with Debian Buster. I testsed it yersterday on a RPi 3

I expect you mean its not compatible with RPI 4, which is true and is not
likely to change soon, especialy since I dont have any of those devices.

Cheers.

>
> I get this error:
>
> bcm2835_init: gpio mmap failed: Cannot allocate memory
>
> Would be great if you can have a look.
>
> Christoph
>
> Am Donnerstag, 4. Juli 2019 11:30:06 UTC+2 schrieb Tobias Spitzbart:
> > Hi Mike,
> >
> > in the past I used your lib often. Thanks for your work.
> >
> > Will be there be a version that is compatible to the Rasberry Pi 4?
> >
> > Greetings Tobias


--
Mike McCauley VK4AMM mi...@airspayce.com
Airspayce Pty Ltd 9 Bulbul Place Currumbin Waters QLD 4223 Australia
http://www.airspayce.com 5R3MRFM2+X6
Phone +61 7 5598-7474



Christoph Orth

unread,
Jul 11, 2019, 1:50:07 AM7/11/19
to bcm2835
Hi Mike,

thanks. Yes, I meant RPI4 (I did not have much time for testing and incorrectly assumed it is a Buster problem)

Christoph

Christoph Orth

unread,
Jul 12, 2019, 3:34:37 AM7/12/19
to bcm2835
I managed to get the library running on the RPi 4B now.

Turns out to require only a minimal adaptation (at least for SPI and GPIO, which is all I tested so far)

I don't have the time to implement this properly right now, but if you just want a very dirty patch, hard-code the peripherals_base address as:

bcm2835_peripherals_base = 0xfe000000;
bcm2835_peripherals_size
= 16777216;

within the function

int bcm2835_init(void)

To implement this more properly, one would have to change the
BMC2835_RPI2_DT_PERI_BASE_ADDRESS_OFFSET
BMC2835_RPI2_DT_PERI_SIZE_OFFSET

for the RPi4 to their new values as found in
/proc/device-tree/soc/ranges


Mark Dootson

unread,
Jul 14, 2019, 12:07:19 AM7/14/19
to bcm2835
Hi,

Attached patch if anyone would like to test to provide RPI 4 compatibility.
I've amended the base address code in init. Basically on RPI4 the address ranges have an extra value - currently zero - that needs to be skipped.
I imagine it's there for 64 bitness.

The RPI 4 has different Pull -up/down registers that behave differently. 
There's no clocking values in which makes keeping compatibility a little awkward.
On the plus side, you can now read the current PUD setting on RPI 4 so added
bcm2835_gpio_get_pud.

It works for me on RPI4 debian buster, RPI3 debian buster, RPI3 debian stretch.

Cheers

Mark
bcm2835_rpi4.patch

Tobias Spitzbart

unread,
Jul 15, 2019, 2:59:11 AM7/15/19
to bcm2835
Hi Mark,

sorry that I ask, but how can I install your patch?

Greetings Tobias

Mark Dootson

unread,
Jul 15, 2019, 3:25:24 AM7/15/19
to bcm2835
Hi,

tar zxvf bcm2835-1.59.tar.gz
cd bcm2835-1.59
patch -lNp1 --input=/path/to/patch/bcm2835_rpi4.patch

Regards

Mark

Tobias Spitzbart

unread,
Jul 16, 2019, 3:09:43 AM7/16/19
to bcm2835
Hi Mark,

thanks! It works.

Greetings

Mike McCauley

unread,
Jul 22, 2019, 7:23:23 PM7/22/19
to bcm...@googlegroups.com, Mark Dootson
Thanks Mark,

your patch has now been applied in new veriosn 1.60.
I wasnt able to test it here (no RPi4) but it stil works fine on earlier
models.

Cheers.

Peter Sommerlad

unread,
Oct 29, 2019, 12:18:36 PM10/29/19
to bcm2835
Hi,

I have a student trying to use a ADC HAT on a Pi4B. I wonder if anybody successfully used 1.60 SPI on a Raspberry Pi 4B?

THX
Peter.

Mr Bond

unread,
Oct 29, 2019, 3:46:38 PM10/29/19
to bcm2835
Hi petet,
Ive been using it on a 2gb pi4 for quite some time now for communication with spi sensors. Havent had any problems so far

Wilson Chan

unread,
Mar 14, 2020, 10:46:10 AM3/14/20
to bcm2835
Hi Mark ,
   i got this issues and i have download the bcm2835_rpi4.patch and enter patch -lNp1 --input=/home/pi/bcm2835_rpi4.patch. then screen will ask the file path , is it the current bcm2835 path? sorry that i am no idea on this. 

Wilson
Reply all
Reply to author
Forward
0 new messages