android tv/multimedia boxes

yes, the mac part works
the phy is the problem
cheap stuff has no external phy so it uses a kind of internal which is not quite internal. it is copackaged ac200 or ac300 chip which does audio dac/adc, composite video and ethernet phy. this chip uses an undocumented pwm channel as clock and you first activate it via i2c then the mac can talk to it via mdio (mii). you read some efuse and find out if it is ac200 or ac300. ac300 does not need the i2c part just the pwm clock and the mdio part. this hacky stuff is only used in android boxes with h6/h616. development boards usually have gigabit realtek phys
 
ok, the thermal sensors work weird (maybe thats way the linux image i tried bombed)
they work backwards from what the doc says (register values should decrease with temp, they increase)
static int sun50i_h616_thermal_init(struct ths_device *tmdev)
{
int val;

/*
* For sun50iw9p1:
* It is necessary that reg[0x03000000] bit[16] is 0.
*/


fragment is from orange-pi linux source
the bolded part is nowhere to be found in the soc docs

allwinner docs are undefeated
 
I am trying to follow along. Where will this info you gleaned from Linux end up?
You are adding functions into the designware driver in FreeBSD or building new driver?

I am noticing some standardization among rockchip boards. AXP6xx PMIC and dwc.
 
that was to unfsck the thermal sensors. otherwise they go backwards. h616 support is not great in linux mainline either so i have to check other variants . now i have an opi zeto2 with h616 which has working ethernet. the awg driver is good for the android box but it needs a phy driver. for that i need to write the pwm driver but the docs are kind of shitty like source code ii found in sunxi linux is differwnt from the manual, it differs between versions of kernel and so on
 
i managed to hack pwm + ac300 based phy
now i have the ethernet in the android tv box working
i shoved all the code in if_awg.c which is kind of ugly but writing a phy driver that works with just one specific chip and config would be equally bad or worse

once you have the pwm ticking you get the phy_ctl device on the mii bus (which is not the actual phy but a controller for the actual phy)
write some stuff to the phy_ctl and the actual phy appears once you rescan the mii bus
read some stuff from the efuses and calibrate the phy

also the phy may be provided by an AC200 chip which is controlled via i2c or an AC300 chip which is controlled via mii bus
did not bother with the i2c variant (can't test / no device -- seems that older H616 boxes use that)
once all the stuff is in place the hw acts like a generic phy and is supported by ukphy(4)
Code:
awg0: <Allwinner Gigabit Ethernet> mem 0x5030000-0x503ffff irq 35 on simplebus0
awg0: syscon offset 4
awg0: PHY type: rmii, conf mode: reg
awg0: SYSCON initial value: 00058000
awg0: EMAC clock: 0x00053fe1
awg0: AHB frequency 200000000 Hz, MDC div: 0x3
awg0: Found AC300 EPHY at @0
awg0: Found AC300 CTL at @16
awg0: Calibration data is      101
awg0: ephy cali efuse read: default!
miibus0: <MII bus> on awg0
ukphy0: <Generic IEEE 802.3u media interface> PHY 0 on miibus0
ukphy0: OUI 0x0088a0, model 0x0000, rev. 0
ukphy0:  none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto, auto-flow
awg0: bpf attached
awg0: Ethernet address: 02:32:0e:1d:80:44
awg0: link state changed to UP
 
Very interesting!

I've got a few TV boxes. I don't have a H616 but I do have a couple based on the Allwinner H6. Is there any chance one of my Allwinner H6 TV boxes might boot your port covacat? Have you uploaded any installation images or code anywhere?

Might it be possible to install FreeBSD onto ZFS on one of these TV boxes?
 
there is (some) allwinner h6 support in the official tree but
hdmi, video, sound wont work so you need to open it up and connect the serial console pins (most boards have them)
ethernet wont work for vanilla tv boxes because of the weird phy setup procedure (will work on dev boards which have proper phys)
the ethernet is 100tx so no gbe (mac is gbe but phy maxes out at 100tx)
some boxes dont have emmc but raw nand (which wont work)
can't tell if usb3 will work or not but probably it will
some voltage regulators in the tv boxes are not supported in main tree
my "giga patch" is at https://forums.freebsd.org/threads/orange-pi-zero2-and-freebsd-13-2.89267/page-3#post-621499
and is against 13.2

its not worth the trouble to try to make a useful NAS out of it but if you want to hack/experiment with aarch64 it can be kind of cool
you can find the h6 soc manual online (not perfect but workable)
 
Back
Top