Milliways
Posts: 293
Joined: Fri Apr 25, 2014 12:18 am

Gertboard with Pi2 Jessie

Sat Oct 07, 2017 1:53 am

I just pulled out my Gertboard, and plugged it into a Pi2 running Jessie.
I have enabled SPI from the raspi-config menu.

I have not used the Gertboard for some time, and then on a Pi B+

I tried the dtoa.c sample, in preparation for some project I want to work on.

This seems to hang in the

Code: Select all

write_dac()
function.

Have there been any changes/updates to the gertboard software, or is there any reason it doesn't work on the Pi2?

I will go back and try further tests, but thought there may be some existing answers.

EDIT: just tested

Code: Select all

gpio gbw 0 128
writes to the DAC successfully, so there is a software issue.

User avatar
Gert van Loo
Posts: 2474
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertboard with Pi2 Jessie

Sat Oct 07, 2017 9:01 am

Have there been any changes/updates to the gertboard software, or is there any reason it doesn't work on the Pi2?
The biggest change to all The raspberry-Pi I/O has been a while ago when they added a device tree.
I'll be honest: I never understood how that worked but you can no longer 'just' access any of the I/O devices.

Milliways
Posts: 293
Joined: Fri Apr 25, 2014 12:18 am

Re: Gertboard with Pi2 Jessie

Sat Oct 07, 2017 10:14 am

Gert van Loo wrote:
Sat Oct 07, 2017 9:01 am
Have there been any changes/updates to the gertboard software, or is there any reason it doesn't work on the Pi2?
The biggest change to all The raspberry-Pi I/O has been a while ago when they added a device tree.
I'll be honest: I never understood how that worked but you can no longer 'just' access any of the I/O devices.
I guess this implicitly answers my question; there have been no updates.

I can't see that Device Tree would change anything that the gertboard software does, as it only seems to impact the boot process (and considerably simplify module loading).

The change in port mapping on the Pi2/3 would certainly impact addressing, and the serial and I²C changes probably as well.

After some initial testing to verify that WiringPi could address the DAC using SPI, I bit the bullet and wrote my own code using WiringPi, which seems to be working OK.

User avatar
Gert van Loo
Posts: 2474
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertboard with Pi2 Jessie

Sat Oct 07, 2017 1:46 pm

The change in port mapping on the Pi2/3
That remark reminded me: On the Pi2 and Pi3 the peripheral base address has been moved!!

On Pi1 it is 0x20000000 on Pi2 and 3 it is 0x3F000000.

gb_common.c:
#define BCM2708_PERI_BASE ...

User avatar
JohnBeardmore
Posts: 206
Joined: Thu Nov 15, 2012 11:03 pm
Location: Derbyshire UK.
Contact: Website

Re: Gertboard with Pi2 Jessie

Fri Jan 05, 2018 9:21 pm

Hi Gert,

I'm having problems getting the SPI DAC to work too. I don't suppose you want to share the code you wrote ?

Re the change of BCM2708_PERI_BASE, it might be worth shouting that from the roof tops given that people are still using the Gertboard code as examples of how to do IO on the Pi !

Cheers, J/.
Author of oBeMS open source Building energy Management System.
Automatic Meter Reading (AMR), Building Management System (BMS),
Building Energy Management System (BEMS), Infrastructure Control System (ICS).
See: http://t4sustainability.co.uk/oBeMS/

User avatar
JohnBeardmore
Posts: 206
Joined: Thu Nov 15, 2012 11:03 pm
Location: Derbyshire UK.
Contact: Website

Re: Gertboard with Pi2 Jessie

Fri Jan 05, 2018 9:43 pm

Come to think of it, could BCM2708_PERI_BASE ... be set automatically somehow so that the Gertboard can sensibly be used with the Pi 2 and the P 3 ?

Cheers, J/.
Author of oBeMS open source Building energy Management System.
Automatic Meter Reading (AMR), Building Management System (BMS),
Building Energy Management System (BEMS), Infrastructure Control System (ICS).
See: http://t4sustainability.co.uk/oBeMS/

User avatar
Gert van Loo
Posts: 2474
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertboard with Pi2 Jessie

Fri Jan 05, 2018 10:30 pm

JohnBeardmore wrote:
Fri Jan 05, 2018 9:43 pm
Come to think of it, could BCM2708_PERI_BASE ... be set automatically somehow so that the Gertboard can sensibly be used with the Pi 2 and the P 3 ?

Cheers, J/.
Makes sense. I will write new code.
In the meantime the old example code for SPI and DAC can be found here: https://www.gertbot.com/other_products.html
That is also where the new version will appear.

It seems I have to get the version using 'uname' as I can't find a define set in the OS which tells the HW version.
That again means I have to drop using the define and set all the pointers directly.
Which means changing a lot of code.
Additional problem is that I do not have a gertbot test environment setup so I can't fully test all the new code
(It never rains, it pours) :-(

Alternative is setting the BCM2708_PERI_BASE in the makefile using 'uname'. But not everybody uses makefiles...

User avatar
Gert van Loo
Posts: 2474
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertboard with Pi2 Jessie

Fri Jan 05, 2018 11:26 pm

Untested! Alpha release is there. (Untested means compiled and run on a Pi but not with a Gertboard as it is 00:30 at night here.)

Was not as much code change as thought as I could replace the hard macro BCM2708_PERI_BASE with a variable bcm_periperal_base
which is set by SW using a system uname call:

Code: Select all

...
//#define BCM2708_PERI_BASE        0x20000000
#define CLOCK_BASE               (bcm_periperal_base + 0x101000) /* Clocks */
#define GPIO_BASE                (bcm_periperal_base + 0x200000) /* GPIO   */
#define PWM_BASE                 (bcm_periperal_base + 0x20C000) /* PWM    */
#define SPI0_BASE                (bcm_periperal_base + 0x204000) /* SPI0 controller */
#define UART0_BASE               (bcm_periperal_base + 0x201000) /* Uart 0 */
#define UART1_BASE               (bcm_periperal_base + 0x215000) /* Uart 1 (not used) */
...
uint bcm_periperal_base;
...
uint get_periperal_base()
{ 
  int status;
  // Get hardware, compare against armv7, send output into black hole
  status = system("uname -m | grep armv7 >/dev/null");
//  printf("Status is %d\n",status);
  if (status==0)
     return 0x3F000000; // It is an armv7
  else
     return 0x20000000; // Assume old 1176
}

Return to “Add-ons”

Who is online

Users browsing this forum: No registered users and 6 guests