SXTSQ 5ac Support

Let me try that, there's a few settings on my branch that are most likely incorrect and a busybox shell should at least help a bit.

Making a dump of info:

# cat /proc/cmdline
root=/dev/ram0 bootimage=1 no-uart no-buzzer no-nand parts=1 boot_part_size=16777216 eth_mac=CC:2D:E0:C4:46:F8 board=lhg-dk Board=lhg-dk board_rev=US ver=6.41.3 hw_opt=00204001 boot=1 mlc=11
# cat /proc/devices
Character devices:
  1 mem
  5 /dev/tty
  5 /dev/console
  5 /dev/ptmx
 10 misc
 13 input
 60 logring
 89 i2c
 90 mtd
128 ptm
136 pts
153 spi
252 ttyS
253 ttyS
254 msm_sps

Block devices:
259 blkext
  8 sd
 31 mtdblock
 65 sd
 66 sd
 67 sd
 68 sd
 69 sd
 70 sd
 71 sd
128 sd
129 sd
130 sd
131 sd
132 sd
133 sd
134 sd
135 sd
# cat /proc/iomem
078b5000-078b55ff : spi_qsd
0b017000-0b01703f : wdt
80000000-8fffffff : System RAM
  80008000-803dfc07 : Kernel code
  80414000-8047312b : Kernel data
# cat /proc/meminfo
MemTotal:         238828 kB
MemFree:          190436 kB
Buffers:               0 kB
Cached:            22156 kB
SwapCached:            0 kB
Active:             7420 kB
Inactive:          18520 kB
Active(anon):       3836 kB
Inactive(anon):       56 kB
Active(file):       3584 kB
Inactive(file):    18464 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:          3808 kB
Mapped:             4616 kB
Shmem:               108 kB
Slab:              15660 kB
SReclaimable:       1804 kB
SUnreclaim:        13856 kB
KernelStack:         544 kB
PageTables:          348 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:      119412 kB
Committed_AS:       8800 kB
VmallocTotal:    1810432 kB
VmallocUsed:       17108 kB
VmallocChunk:    1643192 kB
# cat /proc/version
Linux version 3.3.5 (build@builder) (gcc version 4.8.2 (GCC) ) #2 SMP Wed Feb 28 10:26:17 UTC 2018
# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00f00000 00001000 "RouterOS"
mtd1: 00040000 00001000 "RouterBoot"
# cat /proc/partitions
major minor  #blocks  name

  31        0      15360 mtdblock0
  31        1        256 mtdblock1
# cat /proc/modules
ipt_TARPIT 1785 0 - Live 0x7f6fb000
ipt_REJECT 1702 0 - Live 0x7f6f7000
iptable_filter 952 1 - Live 0x7f6f3000
ipt_NETMAP 778 0 - Live 0x7f6ef000
ipt_SAME 984 0 - Live 0x7f6eb000
ipt_REDIRECT 786 0 - Live 0x7f6e7000
ipt_MASQUERADE 1191 1 - Live 0x7f6e3000
iptable_nat 3085 0 - Live 0x7f6df000
nf_defrag_ipv4 864 0 - Live 0x7f6db000
ipt_psd 1860 0 - Live 0x7f6d7000
ip_tables 8646 2 iptable_filter,iptable_nat, Live 0x7f6d1000
ipt_snif 761 0 - Live 0x7f6cd000
snif 2426 1 ipt_snif, Live 0x7f6c9000
ipt_ulog 1100 0 - Live 0x7f6c5000
xt_tls 1435 0 - Live 0x7f6bd000
xt_layer7 6864 0 - Live 0x7f6b8000
xt_HL 1420 0 - Live 0x7f6b4000
xt_DSCP 1546 0 - Live 0x7f6b0000
xt_TCPMSS 2556 0 - Live 0x7f6ac000
xt_NOTRACK 667 0 - Live 0x7f6a8000
xt_policy 1998 3 - Live 0x7f6a4000
xt_addrtype 2044 0 - Live 0x7f6a0000
xt_hl 926 0 - Live 0x7f69c000
xt_realm 609 0 - Live 0x7f698000
xt_physdev 1404 0 - Live 0x7f694000
xt_length 805 0 - Live 0x7f690000
xt_connbytes 1377 0 - Live 0x7f68c000
xt_helper 948 0 - Live 0x7f688000
xt_tcpmss 1018 0 - Live 0x7f684000
xt_dscp 1146 0 - Live 0x7f680000
xt_hashlimit 6721 0 - Live 0x7f67b000
xt_statistic 917 0 - Live 0x7f677000
xt_string 856 0 - Live 0x7f673000
xt_connmark 1248 0 - Live 0x7f66f000
xt_conntrack 2348 7 - Live 0x7f66b000
xt_multiport 1348 0 - Live 0x7f667000
xt_mark 772 0 - Live 0x7f663000
xt_mac 755 0 - Live 0x7f65f000
xt_tcpudp 1784 0 - Live 0x7f65b000
ts_kmp 1286 0 - Live 0x7f657000
xt_misc 10088 4 - Live 0x7f651000
x_tables 10113 38 ipt_TARPIT,ipt_REJECT,iptable_filter,ipt_NETMAP,ipt_SAME,ipt_REDIRECT,ipt_MASQUERADE,iptable_nat,ipt_psd,ip_tables,ipt_snif,ipt_ulog,xt_tls,xt_layer7,xt_HL,xt_DSCP,xt_TCPMSS,xt_NOTRACK,xt_policy,xt_addrtype,xt_hl,xt_realm
,xt_physdev,xt_length,xt_connbytes,xt_helper,xt_tcpmss,xt_dscp,xt_hashlimit,xt_statistic,xt_string,xt_connmark,xt_conntrack,xt_multiport,xt_mark,xt_mac,xt_tcpudp,xt_misc, Live 0x7f64b000
nf_nat_proto_sctp 813 0 - Live 0x7f647000
nf_conntrack_proto_sctp 4470 0 - Live 0x7f642000
nf_nat_proto_dccp 797 0 - Live 0x7f63e000
nf_conntrack_proto_dccp 6045 0 - Live 0x7f639000
nf_nat_proto_udplite 791 0 - Live 0x7f635000
nf_conntrack_proto_udplite 2039 0 - Live 0x7f631000
nf_nat_pptp 2026 0 - Live 0x7f62d000
nf_nat_proto_gre 903 1 nf_nat_pptp, Live 0x7f629000
nf_conntrack_pptp 3271 1 nf_nat_pptp, Live 0x7f625000
nf_conntrack_proto_gre 3640 1 nf_conntrack_pptp, Live 0x7f621000
nf_nat_sip 5627 0 - Live 0x7f61c000
nf_conntrack_sip 15140 1 nf_nat_sip, Live 0x7f615000
nf_nat_h323 5333 0 - Live 0x7f610000
nf_conntrack_h323 32787 1 nf_nat_h323, Live 0x7f604000
nf_nat_irc 1006 0 - Live 0x7f600000
nf_conntrack_irc 2543 1 nf_nat_irc, Live 0x7f5fc000
nf_nat_tftp 641 0 - Live 0x7f5f8000
nf_conntrack_tftp 2429 1 nf_nat_tftp, Live 0x7f5f4000
nf_nat_ftp 1208 0 - Live 0x7f5f0000
nf_conntrack_ftp 4517 1 nf_nat_ftp, Live 0x7f5eb000
nf_nat 11443 15 ipt_NETMAP,ipt_SAME,ipt_REDIRECT,ipt_MASQUERADE,iptable_nat,nf_nat_proto_sctp,nf_nat_proto_dccp,nf_nat_proto_udplite,nf_nat_pptp,nf_nat_proto_gre,nf_nat_sip,nf_nat_h323,nf_nat_irc,nf_nat_tftp,nf_nat_ftp, Live 0x7f5e5000
nf_conntrack_ipv4 5100 10 iptable_nat,nf_nat, Live 0x7f5e0000
nf_conntrack_netlink 11359 0 - Live 0x7f5da000
nfnetlink 2251 1 nf_conntrack_netlink, Live 0x7f5d6000
dakota_eth 8934 0 - Live 0x7f5d0000
ath8327 30872 1 dakota_eth, Live 0x7f4fc000
sch_sfq 5166 1 - Live 0x7f31d000
ipq4019_ahb 65100 0 - Live 0x7f305000
ath 123791 1 ipq4019_ahb,[permanent], Live 0x7f2d7000
sha256_generic 8288 0 - Live 0x7f235000
dakota_crypto 88481 0 - Live 0x7f14a000
des_generic 17334 0 - Live 0x7f137000
panics 2064 0 - Live 0x7f0fe000
wlan 338275 5 ipq4019_ahb,ath, Live 0x7f0a1000
rb 2647 1 - Live 0x7f09d000
capsmanglue 433 1 wlan, Live 0x7f08b000
ledgroup 2605 0 - Live 0x7f087000
stm8_fan 9659 0 - Live 0x7f081000
btest 5393 0 - Live 0x7f07c000
ticker 3608 1 - Live 0x7f074000
ipqwdt 1384 1 - Live 0x7f070000
ulog 3474 2 ipt_ulog, Live 0x7f06c000
bridge2 48648 0 - Live 0x7f05b000
switch 26162 3 dakota_eth,ath8327,bridge2, Live 0x7f050000
phy_helper 15348 2 ath8327,switch, Live 0x7f049000
packet_hook 95318 16 xt_layer7,xt_misc,dakota_eth,ath,wlan,bridge2,switch, Live 0x7f02b000
nf_conntrack 42938 28 ipt_MASQUERADE,iptable_nat,xt_NOTRACK,xt_connbytes,xt_helper,xt_connmark,xt_conntrack,xt_misc,nf_conntrack_proto_sctp,nf_conntrack_proto_dccp,nf_conntrack_proto_udplite,nf_nat_pptp,nf_conntrack_pptp,nf_conntrack_proto
_gre,nf_nat_sip,nf_conntrack_sip,nf_nat_h323,nf_conntrack_h323,nf_nat_irc,nf_conntrack_irc,nf_nat_tftp,nf_conntrack_tftp,nf_nat_ftp,nf_conntrack_ftp,nf_nat,nf_conntrack_ipv4,nf_conntrack_netlink,packet_hook, Live 0x7f01b000
logring 21427 96 - Live 0x7f009000
flash 22338 4 ath8327,ipq4019_ahb,panics,rb, Live 0x7f000000
# cat /proc/yaffs
YAFFS built:Feb 20 2018 13:07:58
$Id: yaffs_fs.c,v 1.53 2006/10/03 10:13:03 charles Exp $
$Id: yaffs_guts.c,v 1.35 2006/06/05 04:10:49 charles Exp $

Device 0 "RouterOS"
startBlock......... 0
endBlock........... 239
chunkGroupBits..... 0
chunkGroupSize..... 1
nErasedBlocks...... 18
nTnodesCreated..... 1200
nFreeTnodes........ 98
nObjectsCreated.... 600
nFreeObjects....... 107
nFreeChunks........ 3847
nPageWrites........ 857
nPageReads......... 13767
nBlockErasures..... 8
nGCCopies.......... 10
garbageCollections. 8
passiveGCs......... 8
nRetriedWrites..... 0
nRetireBlocks...... 0
nBadBlocks......... 0
eccFixed........... 0
eccUnfixed......... 0
tagsEccFixed....... 0
tagsEccUnfixed..... 0
cacheHits.......... 113
nDeletedFiles...... 181
nUnlinkedFiles..... 513
nBackgroudDeletions 0
useNANDECC......... 1
isYaffs2........... 1

# cat /proc/mounts
rootfs / rootfs rw 0 0
proc /proc proc rw,relatime 0 0
tmpfs /ram tmpfs rw,relatime 0 0
devtmpfs /dev devtmpfs rw,relatime,size=119268k,nr_inodes=29817,mode=755 0 0
/dev/mtdBoot /flash yaffs rw,noatime,nodiratime 0 0
2:4096 / squashfs ro,relatime 0 0
tmpfs /flash/rw/pckg tmpfs rw,relatime,size=16384k 0 0
devpts /dev/pts devpts rw,relatime,mode=600 0 0
sysfs /sys sysfs rw,relatime 0 0
debugfs /sys/kernel/debug debugfs rw,relatime 0 0
proc /ram/netns/main proc rw,relatime 0 0
# cat /bndl/wireless/lib/modules/3.3.5/modules.dep.wireless 
a5212:  wlan ath
ipq4019_ahb:    wlan ath flash
ath:    wlan packet_hook
a9300:  wlan ath flash
qca9984_pci:    wlan ath flash
a5211_pci:      a5211
a5416_pci:      a5416
wil6210:        packet_hook wlan
a5212_pci:      a5212
a5416:  wlan ath flash
a9300_pci:      a9300
capsman:        capsmanglue packet_hook ipv6stub
wlan:   capsmanglue packet_hook
ar9888_pci:     wlan ath flash
a5211:  ath wlan

binwalk show a kernel and dtb

user@useri3:~/Desktop/4018/routerboot$ binwalk RouterBoot 

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
0             0x0             ELF, 32-bit LSB executable, ARM, version 1 (SYSV)
65536         0x10000         device tree image (dtb)


The extracted dts file is quite large

user@useri3:~/Desktop/4018/routerboot/dtb$ la -lah
total 308K
drwxrwxr-x 2 user user 4.0K May 25 16:22 .
drwxrwxr-x 4 user user 4.0K May 25 16:13 ..
-rw-rw-r-- 1 user user  64K May 25 16:13 00_kernel
-rw-rw-r-- 1 user user 192K May 25 16:13 01_dtbdump_qcom,ipq40xx-apdk01.1.dtb
-rw-rw-r-- 1 user user  41K May 25 16:22 file.dts

Were you able to extract anything from the dts?

I also tried binwalk on the stock firmware (routeros-arm-6.41.3.npk) and had trouble extracting it:

$ ~/_routeros-arm-6.41.3.npk-1.extracted # dd bs=1  skip=476 if=8DD212 of=trim
34986+0 records in
34986+0 records out
34986 bytes (35 kB, 34 KiB) copied, 0.110798 s, 316 kB/s
$ ~/_routeros-arm-6.41.3.npk-1.extracted # dtc -I dtb trim -O dts
FATAL ERROR: EOF before reading 16793940 bytes of DT blob

For some reason the first 475 bytes of the dtb are some other data.

I think I have the device tree close on my branch, but the block device setup is not right. There are two block devices on the system but I the partition layout is different from the work that robimarko did on the LHGG-60ad.

# cat /proc/partitions 
major minor  #blocks  name

  31        0      15360 mtdblock0
  31        1        256 mtdblock1

Yes, i extracted out of RouterBoot

using binwalk and extract-dtb and dtc

Awesome, will take a look!

If you want to take a look at the updates I made to the device tree on my branch let me know. I think the LED setup is missing, but I want to get the block device figured out first.

I updated my branch with what should be the proper led device tree settings based on:

# cat /sys/kernel/debug/gpio       
GPIOs 0-151, msmgpio.3:
 gpio-0   (power-led           ) out hi
 gpio-1   (led2                ) out lo
 gpio-2   (led3                ) out lo
 gpio-3   (user-led            ) out lo
 gpio-4   (led4                ) out lo
 gpio-5   (led5                ) out lo
 gpio-58  (led1                ) out lo
 gpio-63  (button              ) in  hi

Hi @hodgesds,

What's the curret status of the support for the device? I'm also working on it, but I got stuck on the Ethernet part.

I tried the DTS from your branch, but the device didn't boot. Is it working for you?

Thanks,
Roger

It's not quite there yet, I think I'm at a similar place as you. I've been juggling a few projects so progress has been slow. I used a lot of the work robimarko had done for similar Mikrotik ARM devices. There's still a few things that need worked out; The bootloader/disk configuration in the device tree is most likely incorrect. The network configuration needs to be double checked as well. If you downgrade to 6.41.3 you can use bytheway to get a root shell. For downloading specific configuration files you can symlink in the public directory and download via HTTP. I'll try to take a look at bootloader/disk more this weekend.

Hi,

Based on Robert's commit and then testing different network configurations I finally got it working. https://github.com/openwrt/openwrt/pull/3108

If you can test it, please, let me know.

1 Like

@rogerpueyo

yes, thank you those changes and commit dc49391, sysupgrade working!!

1 Like

@markbirss,

Is it OK for you if I add the following line to the commit?

Tested-by: Your Name your@email.tld

Please let me know what exactly should I put there. Thanks!

1 Like

Sure

Mark Birss - mark.birss@gmail.com

May I add your Tested-by, @hodgesds?

Sure thing!

Hello,

How did you manage to extract dtb from stock firmware ? I'm getting same error ;(

Andrejus

On the Mikrotik ARM (ipq40xx) devices I have seen, the DTB is on the SPI-NOR flash in the partition RouterOS calls RouterBoot. This has this bootloader, configs, and a DTB. The partition bounds details are shown in console, or decoded supout: ./04_.startup: 19.21@0: 0x000000080000-0x0000000c0000 : "RouterBoot", but this is generally the same over Mikrotik devices that share the platform. To get a DTB copy: You can root old version of RouterOS (1 or 2), netboot a similar OpenWrt initramfs, or manually dump the NOR chip (SOIC8 clip).

Might be better to open a new topic if this is for a different device, and provide more details.
Happy to help.