HLK-7628N Devkit bringup

Hi there, everyone.
My friend and I are building software support for a kit that will have RS-485, a SPI display, USB, (possible) 2 ethernet ports and a SD-Card slot for storage space, breakout of SPI and i2c to a header.

We are using the HiLink HLK-7628N module.

I already made some good progress with regards to the device-tree, etc.
What works and is detected:
SDCard is detected
Port0 of Ethernet is eth0, the esw is not being used atm. (May have to use port 2 in the future)
i2c-0 appears to show up in /dev/
spi 0.1 appears to show up in /dev/, commented out, moved to display.

What does not work:
USB not working (ohci driver not loaded, not sure why, did specify it in the makefile, lsusb bails out with error -99), plan to use a USB serial chip with auto direction control on RS485. WCH347)
SPI lcd (using fbtft -> kmod-fb-tft, Waveshare ST7735S)
Factory reset button (connected to REFCLK pin, pressing the button does nothing)

Used most of the current device-tree contents of the hilink 7628 module.

I know that there was some issues with regards to SPI being broken, only half-duplex?
Has that been addressed yet?

Here's my device-tree with regards to the SPI LCD:

display@1 {
                compatible = "sitronix,st7735r";
                reg = <1>;
                spi-max-frequency = <10000000>;
                reset-gpios = <&gpio 16 GPIO_ACTIVE_HIGH>;
                dc-gpios = <&gpio 17 GPIO_ACTIVE_HIGH>;
        };

The "reset" button dts definition remains unchanged from the hlk-7628N dts.

I would appreciate it if someone can leave a comment or question.

I made some good progress with regards to the device-tree definitions.

USB appears to be fixed (no idea why it was broken/missing), going to use one Ethernet port, (finalised the &esw config), i2c appears to be fine. Currently, since I want to get full-duplex SPI, I decided to use some free GPIO pins for bitbanging SPI (spi slave, as gpio)
leaving the current implemented SPI bus for the NOR-flash device.

I found out that the WDT_RST input doubles as a reboot and factory reset button.
When I compile the drivers including kmod-fb, kmod-fb-tft, it is compiled, but not included. How do I enable the DISPLAY_SUPPORT property for my device?

Hello @MeestaR,

I'm using the same module but am not able to detect or mount an sd-card, I tried all possible solutions available on different threads like editing dts files, then making changes in kernel_menuconfig and installing kmod-mmc, kmod-sdhci, kmod-sdhci-mt7620. Still no luck can you guide me on this what else I'm missing ?

Thanks.

On my module USB works okay, Have you done impedance matching on both traces?

It appears that MediaTek is not very clear on this, but you cannot use the other 4 "LAN" ports and have a eMMC/SD interface. Enable the SDCard overlay, and disable the esw port, since the pinmux can either be the Ethernet pins or eMMC/SD.

Once I disabled the esw port, it came up with the SDCard being detected as normal.

Also make sure that the mmc drivers are loaded at boot time.

As for the device tree, make sure you have a override of: &sdhci { status ="okay"; } and for the esw: &esw { status = "disabled"; }

As for USB, mine is working, appears that I missed something with drivers, since I was compiling some other stuff too.

@geek1111 @MeestaR
I'm also facing same issue. I have tried method to modify .dts files with status = "disabled" to status = "okay". However there is no issue monuting USB.

can you help with .config or other config related to sd card?

Hi @MeestaR @hardeep-97,

I tried both methods still my module is not detecting the memory card, I'm not sure what I'm missing.

@MeestaR It'll be great if you can guide us on the same,

Is your kernel reporting any sdcard drivers?

I noticed even when the SDCard is not detected, the kernel drivers should be present and loaded.

I do not have my devkit nearby for the dmesg log, but check in the dmesg log in the lines of "sd" and "pierre ossman". If it is not there, then your kernel does not have the drivers.
You can also check with the "lsmod" command

If it is present, please check your SD-Card detect pin, CS pin and the datalines.
Try to clean your build-environment and try again, there may be something contaminating it.
I had to clean mine very often, as something creeped in, and did not build the kernel module as required.

If you are using the same module as linked in here, please check your pinout on page 9: (Does not include 3.3v and GND for the SDcard)
https://datasheet.lcsc.com/lcsc/1912111437_HI-LINK-HLK-7628N_C209920.pdf

Hello @MeestaR,

Yes, it's reporting SD card drivers, The full boot log is attached for reference,
I also attached an SD card to the HLK-MT7628 schematic [R21 is not placed]
CD pin goes low when the card is inserted.

Starting kernel ...

[    0.000000] Linux version 5.15.134 (builder@buildhost) (mipsel-openwrt-linux-musl-gcc (OpenWrt GCC 12.3.0 r23497-6637af95aa) 12.3.0, GNU ld (GNU Binutils) 2.40.0) #0 Mon Oct 9 21:45:35 2023
[    0.000000] Board has DDR2
[    0.000000] Analog PMU set to hw control
[    0.000000] Digital PMU set to hw control
[    0.000000] SoC Type: MediaTek MT7628AN ver:1 eco:2
[    0.000000] printk: bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019655 (MIPS 24KEc)
[    0.000000] MIPS: machine is HILINK HLK-7628N
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
[    0.000000] Primary data cache 32kB, 4-way, PIPT, no aliases, linesize 32 bytes
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 32480
[    0.000000] Kernel command line: console=ttyS0,57600 rootfstype=squashfs,jffs2
[    0.000000] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes, linear)
[    0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes, linear)
[    0.000000] Writing ErrCtl register=00000000
[    0.000000] Readback ErrCtl register=00000000
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 121000K/131072K available (5968K kernel code, 607K rwdata, 748K rodata, 1180K init, 217K bss, 10072K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 256
[    0.000000] intc: using register map from devicetree
[    0.000000] CPU Clock: 580MHz
[    0.000000] timer_probe: no matching timers found
[    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 6590553264 ns
[    0.000002] sched_clock: 32 bits at 290MHz, resolution 3ns, wraps every 7405115902ns
[    0.015476] Calibrating delay loop... 385.84 BogoMIPS (lpj=1929216)
[    0.087659] pid_max: default: 32768 minimum: 301
[    0.097962] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.112319] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.136912] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.156320] futex hash table entries: 256 (order: -1, 3072 bytes, linear)
[    0.169937] pinctrl core: initialized pinctrl subsystem
[    0.182550] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[    0.194883] thermal_sys: Registered thermal governor 'step_wise'
[    0.226382] clocksource: Switched to clocksource MIPS
[    0.238274] NET: Registered PF_INET protocol family
[    0.248160] IP idents hash table entries: 2048 (order: 2, 16384 bytes, linear)
[    0.263623] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.280135] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.295362] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.310508] TCP bind hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.324440] TCP: Hash tables configured (established 1024 bind 1024)
[    0.337198] UDP hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.350076] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.364292] NET: Registered PF_UNIX/PF_LOCAL protocol family
[    0.375486] PCI: CLS 0 bytes, default 32
[    0.388280] workingset: timestamp_bits=14 max_order=15 bucket_order=1
[    0.408373] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.419859] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.440923] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252)
[    0.459129] mt7621_gpio 10000600.gpio: registering 32 gpios
[    0.470553] mt7621_gpio 10000600.gpio: registering 32 gpios
[    0.481957] mt7621_gpio 10000600.gpio: registering 32 gpios
[    0.493651] Serial: 8250/16550 driver, 16 ports, IRQ sharing enabled
[    0.509800] printk: console [ttyS0] disabled
[    0.518404] 10000c00.uartlite: ttyS0 at MMIO 0x10000c00 (irq = 28, base_baud = 2500000) is a 16550A
[    0.536229] printk: console [ttyS0] enabled
[    0.536229] printk: console [ttyS0] enabled
[    0.552714] printk: bootconsole [early0] disabled
[    0.552714] printk: bootconsole [early0] disabled
[    0.572474] 10000d00.uart1: ttyS1 at MMIO 0x10000d00 (irq = 29, base_baud = 2500000) is a 16550A
[    0.592195] spi-mt7621 10000b00.spi: sys_freq: 193333333
[    0.632007] spi-nor spi0.0: w25q256 (32768 Kbytes)
[    0.641667] 4 fixed-partitions partitions found on MTD device spi0.0
[    0.654304] OF: Bad cell count for /palmbus@10000000/spi@b00/flash@0/partitions
[    0.668831] OF: Bad cell count for /palmbus@10000000/spi@b00/flash@0/partitions
[    0.683878] OF: Bad cell count for /palmbus@10000000/spi@b00/flash@0/partitions
[    0.698465] OF: Bad cell count for /palmbus@10000000/spi@b00/flash@0/partitions
[    0.713204] Creating 4 MTD partitions on "spi0.0":
[    0.722745] 0x000000000000-0x000000030000 : "u-boot"
[    0.736832] 0x000000030000-0x000000040000 : "u-boot-env"
[    0.749966] 0x000000040000-0x000000050000 : "factory"
[    0.761553] 0x000000050000-0x000002000000 : "firmware"
[    0.775314] 2 uimage-fw partitions found on MTD device firmware
[    0.787157] Creating 2 MTD partitions on "firmware":
[    0.797003] 0x000000000000-0x000000233ab6 : "kernel"
[    0.806848] mtd: partition "kernel" doesn't end on an erase/write block -- force read-only
[    0.825643] 0x000000233ab6-0x000001fb0000 : "rootfs"
[    0.835578] mtd: partition "rootfs" doesn't start on an erase/write block boundary -- force read-only
[    0.855270] mtd: setting mtd5 (rootfs) as root device
[    0.866627] 1 squashfs-split partitions found on MTD device rootfs
[    0.878970] 0x000000720000-0x000001fb0000 : "rootfs_data"
[    0.922864] rt3050-esw 10110000.esw: mediatek esw at 0xb0110000, irq 25 initialized
[    0.939338] mtk_soc_eth 10100000.ethernet eth0: mediatek frame engine at 0xb0100000, irq 5
[    0.958530] NET: Registered PF_INET6 protocol family
[    0.976456] Segment Routing with IPv6
[    0.983826] In-situ OAM (IOAM) with IPv6
[    0.991790] NET: Registered PF_PACKET protocol family
[    1.001977] bridge: filtering via arp/ip/ip6tables is no longer available by default. Update your scripts to load br_netfilter if you need this.
[    1.028066] 8021q: 802.1Q VLAN Support v1.8
[    1.051036] VFS: Mounted root (squashfs filesystem) readonly on device 31:5.
[    1.071556] Freeing unused kernel image (initmem) memory: 1180K
[    1.083315] This architecture does not have kernel memory protection.
[    1.096089] Run /sbin/init as init process
[    2.162132] init: Console is alive
[    2.169701] init: - watchdog -
[    5.051357] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[    5.163872] usbcore: registered new interface driver usbfs
[    5.174929] usbcore: registered new interface driver hub
[    5.185641] usbcore: registered new device driver usb
[    5.252603] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    5.279497] SCSI subsystem initialized
[    5.294512] fsl-ehci: Freescale EHCI Host controller driver
[    5.309281] ehci-platform: EHCI generic platform driver
[    5.330311] phy phy-10120000.usbphy.0: remote usb device wakeup disabled
[    5.343618] phy phy-10120000.usbphy.0: UTMI 16bit 30MHz
[    5.353971] ehci-platform 101c0000.ehci: EHCI Host Controller
[    5.365393] ehci-platform 101c0000.ehci: new USB bus registered, assigned bus number 1
[    5.381299] ehci-platform 101c0000.ehci: irq 26, io mem 0x101c0000
[    5.416398] ehci-platform 101c0000.ehci: USB 2.0 started, EHCI 1.00
[    5.430184] hub 1-0:1.0: USB hub found
[    5.438700] hub 1-0:1.0: 1 port detected
[    5.455566] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    5.469696] ohci-platform: OHCI generic platform driver
[    5.480698] ohci-platform 101c1000.ohci: Generic Platform OHCI controller
[    5.494246] ohci-platform 101c1000.ohci: new USB bus registered, assigned bus number 2
[    5.510168] ohci-platform 101c1000.ohci: irq 26, io mem 0x101c1000
[    5.591614] hub 2-0:1.0: USB hub found
[    5.600212] hub 2-0:1.0: 1 port detected
[    5.612497] uhci_hcd: USB Universal Host Controller Interface driver
[    5.630226] ohci-pci: OHCI PCI platform driver
[    5.702584] sdhci: Secure Digital Host Controller Interface driver
[    5.714913] sdhci: Copyright(c) Pierre Ossman
[    5.726581] sdhci-pltfm: SDHCI platform and OF driver helper
[    5.743605] usbcore: registered new interface driver usb-storage
[    5.761048] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[    5.786243] init: - preinit -
[    5.792261] usb 1-1: new high-speed USB device number 2 using ehci-platform
[    6.478523] hub 1-1:1.0: USB hub found
[    6.692754] hub 1-1:1.0: 4 ports detected
[    6.701297] random: procd: uninitialized urandom read (4 bytes read)
[    7.634817] random: jshn: uninitialized urandom read (4 bytes read)
[    7.766550] random: jshn: uninitialized urandom read (4 bytes read)
[    8.080269] random: jshn: uninitialized urandom read (4 bytes read)
[    8.162900] random: jshn: uninitialized urandom read (4 bytes read)
Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
[   11.224441] jffs2: notice: (370) jffs2_build_xattr_subsystem: complete building xattr subsystem, 16 of xdatum (0 unchecked, 5 orphan) and 19 of xref (5 dead, 0 orphan) found.
[   11.258129] mount_root: switching to jffs2 overlay
[   11.274019] overlayfs: upper fs does not support tmpfile.
[   11.294891] urandom-seed: Seeding with /etc/urandom.seed
[   11.474367] procd: - early -
[   11.480843] procd: - watchdog -
[   12.389285] procd: - watchdog -
[   12.397788] procd: - ubus -
[   12.586257] random: ubusd: uninitialized urandom read (4 bytes read)
[   12.602203] random: ubusd: uninitialized urandom read (4 bytes read)
[   12.615591] random: ubusd: uninitialized urandom read (4 bytes read)
[   12.652529] procd: - init -
Please press Enter to activate this console.
[   13.864016] random: jshn: uninitialized urandom read (4 bytes read)
[   13.932970] random: ubusd: uninitialized urandom read (4 bytes read)
[   14.221127] kmodloader: loading kernel modules from /etc/modules.d/*
[   14.844878] i2c_dev: i2c /dev entries driver
[   14.896780] ntfs3: Max link count 4000
[   14.904275] ntfs3: Enabled Linux POSIX ACLs support
[   14.958581] Loading modules backported from Linux version v6.1.24-0-g0102425ac76b
[   14.973503] Backport generated by backports.git v5.15.92-1-44-gd6ea70fafd36
[   15.059964] usbcore: registered new interface driver ums-alauda
[   15.097837] usbcore: registered new interface driver ums-cypress
[   15.118058] usbcore: registered new interface driver ums-datafab
[   15.147844] usbcore: registered new interface driver ums-freecom
[   15.177989] usbcore: registered new interface driver ums-isd200
[   15.208109] usbcore: registered new interface driver ums-jumpshot
[   15.237858] usbcore: registered new interface driver ums-karma
[   15.268428] usbcore: registered new interface driver ums-sddr09
[   15.298110] usbcore: registered new interface driver ums-sddr55
[   15.328303] usbcore: registered new interface driver ums-usbat
[   15.880561] mt76_wmac 10300000.wmac: ASIC revision: 76280001
[   16.938748] mt76_wmac 10300000.wmac: Firmware Version: 20151201
[   16.950579] mt76_wmac 10300000.wmac: Build Time: 20151201183641
[   17.037447] mt76_wmac 10300000.wmac: firmware init done
[   17.159436] urngd: v1.0.2 started.
[   17.579890] PPP generic driver version 2.4.2
[   17.617674] NET: Registered PF_PPPOX protocol family
[   17.696950] kmodloader: done loading kernel modules from /etc/modules.d/*
[   22.239308] random: crng init done
[   22.246069] random: 30 urandom warning(s) missed due to ratelimiting

I had some luck with 4k7 resistors, 10k seems a little bit high. I left the CD pin as not connected, and pulled the SD_WP pin high.
Remove the ESD protection chip, to see if that does not cause the issue?
SD_CLK pin should not have a pullup to 3.3v, but as you said, R21 is not populated.
Remove the C9 cap as well?

I referenced the Vonger Vocore2 SDcard schematic, only pullup resistors on the data pins and SD_CMD, none on SD_CLK.

Digging through my commits a bit, it seems that you need to tell the 02_network config file not to configure the "switch" controller with extra ports, and not disable the switch controller. I honestly forgot how this thing actually worked and what I had done to get it working.
See here: (Git patch)

+++ b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network
@@ -14,6 +14,7 @@ ramips_setup_interfaces()
 	glinet,microuter-n300|\
 	glinet,vixmini|\
 	hak5,wifi-pineapple-mk7|\
+	hilink,hlk-7628n|\
 	mediatek,linkit-smart-7688|\
 	minew,g1-c|\
 	onion,omega2p|\
@@ -36,7 +37,6 @@ ramips_setup_interfaces()
 		;;
 	asus,rt-ac1200|\
 	asus,rt-ac1200-v2|\
-	hilink,hlk-7628n|\
 	hilink,hlk-7688a|\
 	hiwifi,hc5861b|\
 	skylab,skw92a|\

Also, i left the esw enabled (I added this to my DTS file), and configured the portmap as:

&esw {
	mediatek,portmap = <0x2f>;
	mediatek,portdisable = <0x3e>;
};

&sdhci {
     status = "okay";
};

Hi, @MeestaR,

I kept 10K pull-up resistors on the SD card interface, and I was able to mount the SD card by making the changes mentioned above to the 02_network config file. However, as a result of this modification, the wan on port p0 stopped functioning.

Hmm, OK.

Looking at my patchfiles, this works on 22.03.
I am planning to migrate to 23.05 soon, no reason it should not work on the latest release version.

Without mounting the SDCard first (meaning, mount it manually to the Linux filesystem) and your SDCard plugged in, does that detect it?
Dmesg is telling me this on my devit:
root@OpenWrt:/# dmesg | grep mmc

[    6.169188] mmc0: new high speed SDHC card at address b368                   
[    6.193767] mmcblk0: mmc0:b368 SD    3.77 GiB                                
[    6.624371]  mmcblk0: p1 p2

Also, mine logs everytime my eth0 port state changes on the console (plugging in a cable):

[  899.458117] rt3050-esw 10110000.esw: port 0 link up          
[  899.467892] br-lan: port 1(eth0) entered blocking state                      
[  899.478273] br-lan: port 1(eth0) entered forwarding state                    
[  899.492916] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready

Unplug:

[  964.258757] rt3050-esw 10110000.esw: port 0 link down                        
[  964.269147] br-lan: port 1(eth0) entered disabled state

As a note, when I factory reset or reflash my devkit, the webpage/ping becomes unresponsive for a bit after it rebooted, so I just give mine a few minutes to settle down, and the ethernet port works again. This only happens when you boot it for the first time after a flash or factory reset.

This mt76 CPU is designed in a rush (as heard from other devs working on this chip) primarily designed as a IoT-like "router", meaning it can act as a 5 port networking device, with a AP and USB for maybe a USB LTE modem or as a storage network share.

SPI is broken, not even full duplex transfers is working properly. Not sure about i2c, i2s. The fact that they pinmuxed the SDCard/eMMC pins to the 4 "LAN" ports, tells me that this chip was designed in a rush, and it should be fixed in software is blatant ignorance on MediaTek's part.

/Rant over/

1 Like