PetrSmetana
Posts: 5
Joined: Fri Aug 05, 2022 9:28 am

HAT for stacking TV hats

Fri Aug 05, 2022 9:53 am

Hi, I read some threads here already about possible stacking of TV hats.

viewtopic.php?t=227520#p1415904

This is the answer I kind of like - except the part where it's not possible for the hobbyist :)

If I understand it well, the main problem is in the CS, which needs to be dedicated for each device.

So If I would build a new HAT with connectors for multiple TV HATS, where the CS of each TV HAT card would be dedicated to another GPIO port, then I would probably need to modify the device tree compatibility - somehow (I don't know how - yet) here https://github.com/raspberrypi/linux/bl ... verlay.dts

place this file into /boot/dts/overlays/rpi-tv-overlay.dts ... or do I have to go into the core/modules source code and do the modification for multiple TV HAT support also there?

Are there any other challenges?

It would be cool, to be able to save the PRi devices these days, when there is a huge lack of them on the market.

User avatar
B.Goode
Posts: 14125
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: HAT for stacking TV hats

Fri Aug 05, 2022 10:45 am

If you are going to design a HAT, presumably you will have read the specification of HAT as defined by Raspberry PI:
https://github.com/raspberrypi/hats

User avatar
DougieLawson
Posts: 42217
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: HAT for stacking TV hats

Fri Aug 05, 2022 10:51 am

PetrSmetana wrote:
Fri Aug 05, 2022 9:53 am
I read some threads here already about possible stacking of TV hats.
You can ignore them all as HATs are not stackable.
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

PetrSmetana
Posts: 5
Joined: Fri Aug 05, 2022 9:28 am

Re: HAT for stacking TV hats

Fri Aug 05, 2022 11:08 am

DougieLawson wrote:
Fri Aug 05, 2022 10:51 am
PetrSmetana wrote:
Fri Aug 05, 2022 9:53 am
I read some threads here already about possible stacking of TV hats.
You can ignore them all as HATs are not stackable.
Ok let's assume, that I'll put away the "stackable" word. Where should I start to be able to design a hat, which would allow multiple TV HATs to operate together with one RPi board.

I somehow understand, how the SPI bus works in general - so there is just need to have own CS wire for each device. The other thing is the system logic itself, which would allow to handle multiple spi connected devices. Am I wrong? Why I can't map free GPIO ports to be able to act as a CS for other devices?

What are other challenges which are standing in the way? Here I saw that TV HAT is also using I2C - https://pinout.xyz/pinout/tv_hat which can be solved by TCA9548A I2C multiplexer.

I would love to start digging deeper, I'm just asking for a direction to reduce the time. thx

User avatar
rpdom
Posts: 20380
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: HAT for stacking TV hats

Fri Aug 05, 2022 11:38 am

PetrSmetana wrote:
Fri Aug 05, 2022 11:08 am
What are other challenges which are standing in the way? Here I saw that TV HAT is also using I2C - https://pinout.xyz/pinout/tv_hat which can be solved by TCA9548A I2C multiplexer.
That won't work. The system i2c is used to identify the HAT. The EEPROM is at a fixed address (0x50?). There can only be one HAT EEPROM on that bus (There are certain exceptions like the PoE HAT).

I would probably "de-HAT" the boards by not connecting the i2c lines. This would mean the Pi can no longer auto detect the boards, but they can be enabled manually. That coupled with changing the CS line will possibly work with some custom overlays as long as the driver supports multiple devices.
Unreadable squiggle

PetrSmetana
Posts: 5
Joined: Fri Aug 05, 2022 9:28 am

Re: HAT for stacking TV hats

Fri Aug 05, 2022 11:50 am

rpdom wrote:
Fri Aug 05, 2022 11:38 am
PetrSmetana wrote:
Fri Aug 05, 2022 11:08 am
What are other challenges which are standing in the way? Here I saw that TV HAT is also using I2C - https://pinout.xyz/pinout/tv_hat which can be solved by TCA9548A I2C multiplexer.
That won't work. The system i2c is used to identify the HAT. The EEPROM is at a fixed address (0x50?). There can only be one HAT EEPROM on that bus (There are certain exceptions like the PoE HAT).

I would probably "de-HAT" the boards by not connecting the i2c lines. This would mean the Pi can no longer auto detect the boards, but they can be enabled manually. That coupled with changing the CS line will possibly work with some custom overlays as long as the driver supports multiple devices.
Ok, so let's assume, that if the purpose is only for detection, there might be eeprom which would detect a "MULTI TV HAT HAT" ... and it might setup correct driver afterwards. Which would have modified CS to GPIO ports. Is this right?

User avatar
thagrol
Posts: 7693
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: HAT for stacking TV hats

Fri Aug 05, 2022 11:53 am

DougieLawson wrote:
Fri Aug 05, 2022 10:51 am
PetrSmetana wrote:
Fri Aug 05, 2022 9:53 am
I read some threads here already about possible stacking of TV hats.
You can ignore them all as HATs are not stackable.
They are if you disable the EEPROM check in config.txt and do the configuration manually.
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

User avatar
thagrol
Posts: 7693
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: HAT for stacking TV hats

Fri Aug 05, 2022 11:58 am

PetrSmetana wrote:
Fri Aug 05, 2022 9:53 am
Are there any other challenges?
Bandwdith of the SPI bus? Is there enough to support more than one tuner?
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

User avatar
rpdom
Posts: 20380
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: HAT for stacking TV hats

Fri Aug 05, 2022 12:20 pm

PetrSmetana wrote:
Fri Aug 05, 2022 11:50 am
Ok, so let's assume, that if the purpose is only for detection, there might be eeprom which would detect a "MULTI TV HAT HAT" ... and it might setup correct driver afterwards. Which would have modified CS to GPIO ports. Is this right?
That will probably work, if you take into account thagrol's point about the SPI bus capacity.
Unreadable squiggle

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 13123
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: HAT for stacking TV hats

Fri Aug 05, 2022 2:30 pm

Connect one TV HAT directly through using SPI0 on GPIOs 8-11. (Also route some power).
Connect one TV HAT to SPI1 on GPIOs 18-21 (along with some power).
Do not connect GPIOs 0&1 through from the 40pin header to the TV HATs.
Create a new dtoverlay for the pair of TV HATs.
Either add a HAT EEPROM of your own to GPIOs 0&1, or manually load the new overlay.

You may be able to connect multiple TV HATs to the same SPI bus with different chip selects. The SPI interface is meant to be running at 50MHz, so you can probably get a couple of DVB-T streams on there (typically about 6-7Mbit/s for HD streams).
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

PetrSmetana
Posts: 5
Joined: Fri Aug 05, 2022 9:28 am

Re: HAT for stacking TV hats

Fri Aug 05, 2022 7:32 pm

6by9 wrote:
Fri Aug 05, 2022 2:30 pm
Connect one TV HAT directly through using SPI0 on GPIOs 8-11. (Also route some power).
Connect one TV HAT to SPI1 on GPIOs 18-21 (along with some power).
Do not connect GPIOs 0&1 through from the 40pin header to the TV HATs.
Create a new dtoverlay for the pair of TV HATs.
Either add a HAT EEPROM of your own to GPIOs 0&1, or manually load the new overlay.

You may be able to connect multiple TV HATs to the same SPI bus with different chip selects. The SPI interface is meant to be running at 50MHz, so you can probably get a couple of DVB-T streams on there (typically about 6-7Mbit/s for HD streams).
I need to be able to reach 3-4 multiplexes simultaneously in our country to have full spectrum of reachable channels, so I need to have at least 3-4 TV HATS. That's why I would like to use one SPI channel with separated CS...

drgeoff
Posts: 13129
Joined: Wed Jan 25, 2012 6:39 pm

Re: HAT for stacking TV hats

Fri Aug 05, 2022 11:49 pm

PetrSmetana wrote:
Fri Aug 05, 2022 7:32 pm
I need to be able to reach 3-4 multiplexes simultaneously in our country to have full spectrum of reachable channels, so I need to have at least 3-4 TV HATS. That's why I would like to use one SPI channel with separated CS...
Do you mean you want one SPI channel to simultaneously receive all the stations in all the multiplexes?
Quis custodiet ipsos custodes?

PetrSmetana
Posts: 5
Joined: Fri Aug 05, 2022 9:28 am

Re: HAT for stacking TV hats

Sat Aug 06, 2022 5:22 am

drgeoff wrote:
Fri Aug 05, 2022 11:49 pm
PetrSmetana wrote:
Fri Aug 05, 2022 7:32 pm
I need to be able to reach 3-4 multiplexes simultaneously in our country to have full spectrum of reachable channels, so I need to have at least 3-4 TV HATS. That's why I would like to use one SPI channel with separated CS...
Do you mean you want one SPI channel to simultaneously receive all the stations in all the multiplexes?
Exactly

drgeoff
Posts: 13129
Joined: Wed Jan 25, 2012 6:39 pm

Re: HAT for stacking TV hats

Sat Aug 06, 2022 7:04 am

PetrSmetana wrote:
Sat Aug 06, 2022 5:22 am
drgeoff wrote:
Fri Aug 05, 2022 11:49 pm
PetrSmetana wrote:
Fri Aug 05, 2022 7:32 pm
I need to be able to reach 3-4 multiplexes simultaneously in our country to have full spectrum of reachable channels, so I need to have at least 3-4 TV HATS. That's why I would like to use one SPI channel with separated CS...
Do you mean you want one SPI channel to simultaneously receive all the stations in all the multiplexes?
Exactly
6b9 has written above "The SPI interface is meant to be running at 50MHz". Is thst compatible with your goal?
Quis custodiet ipsos custodes?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 13123
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: HAT for stacking TV hats

Sat Aug 06, 2022 7:29 am

drgeoff wrote:
Sat Aug 06, 2022 7:04 am
PetrSmetana wrote:
Sat Aug 06, 2022 5:22 am
drgeoff wrote:
Fri Aug 05, 2022 11:49 pm
Do you mean you want one SPI channel to simultaneously receive all the stations in all the multiplexes?
Exactly
6b9 has written above "The SPI interface is meant to be running at 50MHz". Is thst compatible with your goal?
Barely.

In the UK a DVB-T mux is generally 64QAM and FEC 3/4 or 2/3 with a single mux carrying about 24 or 27Mbit/s.
DVB-T2 muxes are running as 256QAM and FEC 2/3, which is 40Mbit/s on a mux.
(I'm using https://ukfree.tv/transmitters/tv/Sandy_Heath as the info for more local transmitter, and details of DTG-3, DTG-6, and DTG-8 configurations).
SPI running at 50MHz has a minor overhead, but being only 1bit wide has a maximum throughput of 50Mbit/s. It's going to be just on the edge for a single SPI interface with one chip select. Trying to run multiple chip selects on the one interface is unlikely to cut it.

Pi4 does have more SPI interfaces. I haven't checked in detail how many you can actually route out through the alt mappings of the GPIOs available on the 40 pin header, but it looks like you should be able to get 4 of them with a single CS each.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “HATs and other add-ons”