# RaspBSD projects?



## balanga (May 26, 2017)

Is there anything like a list of projects that can be attempted using FreeBSD on an RPi?

I'd like to know how to do simple things like switch lights on and off for a start.

I do have a PiFace Digital board - (that's version 1), but I've never really done anything with it, not understanding electronics....


----------



## ronaldlees (Jun 6, 2017)

They have an excellent forum for this .. which is  chock full of ideas:  https://www.raspberrypi.org/forums/

Try the beginners section or the "automation, sensing, and robotics " section ...

Most of the stuff (even if it's Rasbian related) can easily be transposed to the FreeBSD platform.


----------



## balanga (Jun 6, 2017)

Thanks, I'll check things out.... Any idea if I can get SPI working on FreeBSD?

Can you give me an example of getting some very simple task  getting transposed to FreeBSD? If I have something to work with, the learning cliff will be less steep .


----------



## ronaldlees (Jun 8, 2017)

If you just want to blink some LED lights and flip some GPIO pins, you could start with something like this:

https://github.com/gonzoua/freebsd-gpio


----------



## balanga (Jun 9, 2017)

Thanks for the pointer to the sample code, but as a first step, I'm not sure how to connect my RPi to those LED lights or GPIO pins using FreeBSD...

I have a PiFace Digital but don't know how to access it from FreeBSD. Any help would be appreciated...


----------



## ralphbsz (Jun 10, 2017)

I fear that the most sensible way is to learn enough electronics (soldering, resistance, ohm's law, how to layout switches and connectors and LEDs on a PC board) to get to the GPIO pins.  Eventually, you're likely to need those skills anyhow.

I'm having a hard time figuring out how the PiFace Digital is actually connected; there are some rumors on the web that it uses SPI, and I have never used SPI before (nor have any idea what the FreeBSD support for it is).  Documentation for the PiFace digital seems a bit sparse.


----------



## Phishfry (Jun 10, 2017)

The problem with a device like the PiFace is that it has several drivers needed for it to work. My previous suggestion of trying to get a RTC working was based on experience. That was what I used to learn how to add a device to the FDT. Before that I had already done the flashing LED's.
They are where you need to start. Figure out where the pins correspond to your GPIO control software.
Turning on a LED can be even simpler if you use one of the onboard LED's. On RPi you have green LED and the red LED onboard RPI to manipulate.
They show up as ordinary GPIO pins and can be controlled with `gpioctl`.
I would call that GPIO 101. The most basic function from the GPIO pins without buying anything.
You literally can't screw up. Worst case you set the wrong pin on or off and something on the board freezes. Simply reboot and back to normal.

Some of this post is old but Vadim's site is quite useful and I have learned much from his posts.
https://vzaigrin.wordpress.com/2014/12/20/gpioled-in-the-freebsd-on-the-raspberry-pi/

The other useful site is Gonzo's website who has several examples of GPIO work.
https://kernelnomicon.org/?p=757


----------



## balanga (Jun 10, 2017)

ralphbsz said:


> I fear that the most sensible way is to learn enough electronics (soldering, resistance, ohm's law, how to layout switches and connectors and LEDs on a PC board) to get to the GPIO pins.  Eventually, you're likely to need those skills anyhow.


I'd love to have a basic understanding of electronics, but have always been intimidated by the subject, and I'm really useless when it comes to soldering.  One reason I bought the PiFace Digital in the first place was to try a few simple tasks without soldering  and start to understand the world of electronics...


> I'm having a hard time figuring out how the PiFace Digital is actually connected; there are some rumors on the web that it uses SPI, and I have never used SPI before (nor have any idea what the FreeBSD support for it is).  Documentation for the PiFace digital seems a bit sparse.



This means nothing to me but, I see FreeBSD and SPI linked in this post:-

https://lists.freebsd.org/pipermail/freebsd-arm/2013-August/006323.html

Maybe it could shed some light on how to access the PiFace Digital from FreeBSD...


----------



## balanga (Jun 10, 2017)

Phishfry said:


> The problem with a device like the PiFace is that it has several drivers needed for it to work. My previous suggestion of trying to get a RTC working was based on experience. That was what I used to learn how to add a device to the FDT. Before that I had already done the flashing LED's.
> They are where you need to start. Figure out where the pins correspond to your GPIO control software.
> Turning on a LED can be even simpler if you use one of the onboard LED's. On RPi you have green LED and the red LED onboard RPI to manipulate.
> They show up as ordinary GPIO pins and can be controlled with `gpioctl`.
> ...



The idea of controlling the LEDs on the RPi board hadn't even crossed my mind. I was assuming the LEDs mentioned by ronaldlees had to be attached somehow... I'll give this a try shortly.


----------



## Phishfry (Jun 11, 2017)

On Vadims blog I linked to I think the comments section are more relevant.

`gpioctl 16 0` /* This turns off the pin */
`gpioctl 16 1` /* This turns it on */
But if you look at the comments you will notice that different Pi boards have different LED's and pin assignments are different.
Pi B+ = Pin 35 Power LED and Pin 47 for Activity LED
So if 16 don't work maybe also try to toggle pin 47:
`gpioctl 47 0`
`gpioctl 47 1`

`gpioctl -lv` shows all the pins and their states for your board.


----------



## Phishfry (Jun 11, 2017)

Checking my RaspberryPi2 you can see it is using Pin 35 and 47 for LED's. You can also see my OneWire pin assignments.
So Pin 47 is the Green LED and Pin 35 is Red LED

```
root@rpi2:~ # gpioctl -l
pin 00:   0   pin 0<>
pin 01:   0   pin 1<>
pin 02:   1   pin 2<>
pin 03:   1   pin 3<>
pin 04:   1   pin 4<IN>
pin 05:   1   pin 5<IN>
pin 06:   1   pin 6<IN>
pin 07:   1   pin 7<>
pin 08:   1   pin 8<>
pin 09:   1   owc4<IN>
pin 10:   0   owc3<>
pin 11:   1   owc5<IN>
pin 12:   0   pin 12<IN>
pin 13:   0   pin 13<IN>
pin 14:   1   pin 14<>
pin 15:   1   pin 15<>
pin 16:   0   pin 16<IN>
pin 17:   1   owc0<IN>
pin 18:   0   pin 18<IN>
pin 19:   0   pin 19<IN>
pin 20:   0   pin 20<IN>
pin 21:   0   pin 21<IN>
pin 22:   1   owc2<IN>
pin 23:   0   pin 23<IN>
pin 24:   0   pin 24<IN>
pin 25:   0   pin 25<IN>
pin 26:   0   pin 26<IN>
pin 27:   1   owc1<IN>
pin 28:   1   pin 28<IN>
pin 29:   1   pin 29<IN>
pin 30:   0   pin 30<IN>
pin 31:   1   pin 31<OUT>
pin 32:   0   pin 32<OUT>
pin 33:   0   pin 33<IN>
pin 34:   1   pin 34<IN>
pin 35:   0   gpioled0<OUT>
pin 36:   1   pin 36<IN>
pin 37:   0   pin 37<IN>
pin 38:   0   pin 38<OUT>
pin 39:   0   pin 39<IN>
pin 40:   0   pin 40<>
pin 41:   0   pin 41<OUT>
pin 42:   1   pin 42<IN>
pin 43:   1   pin 43<IN>
pin 44:   1   pin 44<>
pin 45:   0   pin 45<>
pin 46:   0   pin 46<IN>
pin 47:   0   gpioled1<OUT>
pin 48:   0   pin 48<>
pin 49:   1   pin 49<>
pin 50:   1   pin 50<>
pin 51:   1   pin 51<>
pin 52:   1   pin 52<>
pin 53:   1   pin 53<>
```


----------



## balanga (Jun 12, 2017)

Phishfry said:


> On Vadims blog I linked to I think the comments section are more relevant.
> 
> `gpioctl 16 0` /* This turns off the pin */
> `gpioctl 16 1` /* This turns it on */
> ...




I did think that I would have to install this `gpioctl` so didn't try it straight away, but I've found it's built in!

Strange satisfaction from running `gpioctl -t 16` and watching the LED switching on and then off ...


----------

