arriven / db1000n

MIT License
1.18k stars 208 forks source link

Can you compiling file or opkg OpenWRT for MIPS, MIPSBE, MMIPS etc? ;) #545

Open 1o1o1 opened 2 years ago

1o1o1 commented 2 years ago

Can you compiling file or opkg OpenWRT for MIPS, MIPSBE, MMIPS etc? Its will be cool to use in routers too)

arriven commented 2 years ago

went ahead and added all the goarch options that did compile with the code. I can't guarantee all the features will work though

1o1o1 commented 2 years ago

Ok) OpenWRT 19.07.8 on MikroTik SXT Lite2 CPU 600MHz AR9344 mips kernel-4.14.241

db1000n_linux_mips.tar.gz

[17:15][root@OpenWrt:~]# nice -n 19 .bins/db1000n Illegal instruction

:)

deputinizer commented 2 years ago

mipsle maybe?

https://go.dev/doc/install/source#environment

  | linux | mips
  | linux | mipsle
  | linux | mips64
  | linux | mips64le
1o1o1 commented 2 years ago

with mipsle :)

[17:25][root@OpenWrt:~]# .bins/db1000n .bins/db1000n: line 1: syntax error: unexpected "("

It is MIPSBE :)

https://mikrotik.com/product/RBSXT2nDr3

need to compile for MIPSBE ....

arriven commented 2 years ago

Based on what I'm seeing, I'm not sure go can cross compile for mipsbe but I'll check a bit more thoroughly in couple hours

arriven commented 2 years ago

UPD: according to all the docs I've found mipsbe should be just mips. Go has an option to compile hardfloat vs softfloat (default being only hardfloat) though, maybe that could be the missing part?

arriven commented 2 years ago

Ideally we'd want to try and install go on that machine and inspect env variables it sets here https://go.dev/doc/install/source#environment Not sure you'd be able to easily install go on microtik but in case softfloat doesn't work it's worth a try

1o1o1 commented 2 years ago

No) I can't install go 99.5 MB) there's not enough space) available 101.5 MB :)

arriven commented 2 years ago

Have you tried mips_softfloat?

1o1o1 commented 2 years ago

yes

[08:55][root@OpenWrt:~]# nice -n 19 .bins/db1000n Segmentation fault

arriven commented 2 years ago

hmm, I think segfault in this case means that this is the architecture to use but there's a bug somewhere in the code itself that doesn't present itself on other systems (maybe some of the packages used have some bugs or logic that doesn't work for softfloat or smth like that). I'll either need to setup a VM for that or get some sort of debug build that would at least print out the goroutines when getting that segfault, I'll check what is easier during the weekend

arriven commented 2 years ago

so I've tried running mips binary via qemu and it seems to be working fine (weirdly enough it works both with softfloat and hardfloat) As for "debug" build - I haven't managed to make a code that would produce such an error message. the one I'm getting is a lot more descriptive:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x76f88a]

goroutine 1 [running]:
go.uber.org/zap.(*Logger).check(0x0, 0x0, {0xcaafb1, 0xf})
        /home/arriven/go/pkg/mod/go.uber.org/zap@v1.21.0/logger.go:270 +0x6a
go.uber.org/zap.(*Logger).Info(0xc0001a8120?, {0xcaafb1?, 0xa?}, {0x0, 0x0, 0x0})
        /home/arriven/go/pkg/mod/go.uber.org/zap@v1.21.0/logger.go:191 +0x3b
main.main()
        /home/arriven/work/db1000n/main.go:67 +0x2b3

you could try building the executable yourself on your main OS with GOOS=linux GOARCH=mips GOMIPS=softfloat go build -o db1000n but I'm not sure it will be more descriptive on your system

arriven commented 2 years ago

@1o1o1 I think I know what the issue is. How much RAM does that router have? db1000n needs at least 200mb to be able to run properly (and you'd need to provide --skip-encrypted argument, otherwise it's up to 500mb). I just tried running it in qemu with 100mb RAM and it does end up catching a panic (although it's still more descriptive) I doubt I'll be able to optimize memory usage away without sacrificing functionality but we could figure out some alternatives (i.e. https://github.com/Yneth/distress-releases/releases which doesn't have mips support yet but I could talk to the author in theory)

1o1o1 commented 2 years ago

:) MikroTik SXT Lite2 CPU 600MHz AR9344 (--> RAM 64Mb <--) NAND 128Mb

with 256-512Mb is too much expensive and usually with arm cpu :)