We have designed a proprietary PC board to plug into the 40-pin connector.
The board contains the following subsystems:
1) An I2C bus where we have connected the following devices
- An EEPROM for storage of config data
- An AWS encryption chip
- An RTC circuit with battery to keep accurate time in the absence of Internet connection
2) The second I2C bus for the HAT EEPROM where we have connected an EEPROM (same type as above)
3) An RS232 level shifter that connects the RPi serial port at 3V level to a board connector with RS232 levels
4) Two relays connected to the GPIO output port
5) A couple of opto-isolated outputs connected to GPIO output pins
6) A few optocouplers hooked to the GPIO input port and driven from an external connector
Ideally I would like to set up the HAT functionality so that on startup the system will detect what is available and use it, but it seems like a really uphill battle trying to figure out how that would be done...
So my question is:
How can I best detect that our board is available so it can be used from Linux?
Proprietary add-on board, how to detect its presence?
Bo Berglund
Sweden
Sweden
Re: Proprietary add-on board, how to detect its presence?
You've already got the HAT EEPROM which does this. Look in /proc/device-tree/hat/
-
- Posts: 7544
- Joined: Sat Jan 12, 2013 3:01 am
- Location: Grants Pass, OR, USA
- Contact: Website
Re: Proprietary add-on board, how to detect its presence?
Maybe attempt to read from the eeprom or RTC. I would think that if they were not present an error of some sort would be generated.
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.
Re: Proprietary add-on board, how to detect its presence?
Code: Select all
ls -la /proc/device-tree/hat/
ls: cannot access '/proc/device-tree/hat/': No such file or directory
The RPi HAT specification is rather dense and I did not get my head around it enough to find out how to actually configure the board via HAT.
So this EEPROM is currently empty....
I have verified that all of the peripherals including the HAT I2C bus works on the board.
The RTC is actually recognized by Raspbian after I added this to the /boot/config.txt file:
Code: Select all
dtoverlay=i2c-rtc,ds3231
So I want:
- The RTC to be recognized and used
- The RPi serial port assigned to this board (and not to Bluetooth for example)
- The I/O pins for the relays and and optical I/O reserved for the board (or at least set up properly)
- Some kind of presence marker for the board noted in the system
Is that possible?
Bo Berglund
Sweden
Sweden
Re: Proprietary add-on board, how to detect its presence?
You need to program the HAT EEPROM with the correct data for your board. Use https://github.com/raspberrypi/hats/blo ... ttings.txt as a template. You'll probably need a DT fragment for the RTC.
Re: Proprietary add-on board, how to detect its presence?
Thanks!
I can use a clarification on the settings file format:
When setting up the GPIO map in the eeprom_settings.txt file, what do I do with pins used for:
- The serial port (GPIO14/15)
- The I2C bus (GPIO2/3)
Either I do not remove the comment on those lines or I set the pins as OUTPUT/INPUT as needed.
This causes no problem for the serial port, but the I2C SDA line is bidirectional....
If I leave these pins commented out will they then be handled appropriately by the Serial and I2C handlers on the system?
With all used pins configured in the file, the GPIO section looks like this:
Oh, another thing:
Can I add a comment on the pin usage on each line like this:
I can use a clarification on the settings file format:
When setting up the GPIO map in the eeprom_settings.txt file, what do I do with pins used for:
- The serial port (GPIO14/15)
- The I2C bus (GPIO2/3)
Either I do not remove the comment on those lines or I set the pins as OUTPUT/INPUT as needed.
This causes no problem for the serial port, but the I2C SDA line is bidirectional....
If I leave these pins commented out will they then be handled appropriately by the Serial and I2C handlers on the system?
With all used pins configured in the file, the GPIO section looks like this:
Code: Select all
# GPIO FUNCTION PULL
# ---- -------- ----
setgpio 2 INPUT DEFAULT
setgpio 3 OUTPUT DEFAULT
#setgpio 4 INPUT DEFAULT
setgpio 5 INPUT DEFAULT
#setgpio 6 INPUT DEFAULT
#setgpio 7 INPUT DEFAULT
#setgpio 8 INPUT DEFAULT
#setgpio 9 INPUT DEFAULT
#setgpio 10 INPUT DEFAULT
setgpio 11 INPUT DEFAULT
setgpio 12 INPUT DEFAULT
setgpio 13 OUTPUT DEFAULT
setgpio 14 OUTPUT DEFAULT
setgpio 15 INPUT DEFAULT
#setgpio 16 INPUT DEFAULT
#setgpio 17 INPUT DEFAULT
#setgpio 18 INPUT DEFAULT
setgpio 19 OUTPUT DEFAULT
setgpio 20 INPUT DEFAULT
setgpio 21 INPUT DEFAULT
#setgpio 22 INPUT DEFAULT
#setgpio 23 INPUT DEFAULT
#setgpio 24 INPUT DEFAULT
#setgpio 25 INPUT DEFAULT
setgpio 26 INPUT DEFAULT
#setgpio 27 INPUT DEFAULT
Can I add a comment on the pin usage on each line like this:
Code: Select all
setgpio 13 OUTPUT DEFAULT # START relay
setgpio 19 OUTPUT DEFAULT # POWER relay
Bo Berglund
Sweden
Sweden