Optimized build for IPQ40xx devices

Ok, I don't mean to ask a dumb/noob question but is this ready to go for hosting an external HDD as an FTP server/media server?

I'd like to wipe my EA6350v3 and load this but I don't want to lose the linksys partition and I'm afraid of bricking the router as well!

Thank you

No, it doesn't contain minidlna, ftp server or such and no ntfs support (which I wouldn't recommend using anyway).

Ok so I would need to download FTP server and minidlna.

Downloading those while in Luci still overwrites the other partition, correct?

And do you know if the bin made by NoTengoBattery is any better than the wiki?

Being a custom firmware it's unlikely to work with the official repo but I guess you could try...

You are totally wrong. It works with all packages from OpenWrt, but kernel packages.
If that's the case anyway, the ROM includes all installable ipks. I'm not new at this, dear. I know what I do.

@sassriverrat the router has full USB support already but the official OpenWrt image does not have installed the SCSI driver (needed for most forms of USB storage). Talking about my distro, it have full support for USB storage, but not all filesystems are supported out of the box.

Regarding to minidlna, it is a huge package and the device only have a total of 30MB effective of ROM, it probably won't install and you will need to use extroot.

Also: regarding to reverting back to Linksys, I've developed and @bill888 has documented a way to reverting back without problems or known risks.


The firmware contains samba if you are interested, and I may build a version with minidlna and any filesystem preinstalled. But you still need to use a swap device because the device only have 256MB of RAM.

1 Like

While optimization is a good thing in most cases you will run into situations where it causes issues.

You're not applying to "just" the kernel, you're applying to everything except for the few packages that strips the optimization flags and this will bite you in the end for sure. Issues like "O3 causes segmentation fault, O2 works" are not uncommon and is one of many reasons why the majority of distributions doesn't use it by default. This blog post also touches the issue on why it's not a great idea to apply blindly. https://developers.redhat.com/blog/2018/03/21/compiler-and-linker-flags-gcc/

As for packages the same rule applies as with any other firmware built using master, it will get desynced and it's usually just a matter of days before you'll get a library (package) mismatch. RH also mentions that O3 might not be fully ABI compatible.

Regarding minidlna it'll work just fine with that amount of space and leave alot free for other software.

Still speaking about x86 which have many ABIs. ARM uses the AAPCS ABI which is standardized and respected by GCC (in particular the GNU AAPCS). In fact, that being true the hand made assembly of OpenSSL won't work and it's not the case.

In x86 you should care about the ABI because macOS uses a custom sysv ABI, Microsoft has it's own PE ABI and Linux uses the gnu-sysv ABI.

The kernel ABI is stable and standardized so no problems when talking to the kernel using either sysfs, procfs or syscalls including sysctl.

Also: clang is ABI incompatible with GCC in Windows, but works just fine macOS, Linux x86 and on Linux ARM. The only risks about the ABI in Linux ARM is about using programs with mixed hard or soft float. That does not make Clang buggy and also makes no O3 buggy un GCC.

This build uses the same ABI and float ABI as the OpenWrt and therefore all OpenWrt packages work. Still seeing not problem or valid reason.

And let me ask you: did you ever tried using this build? You don't tust? Build one yourself with O3 and let's see if it breaks something. Till then, I'll kindly ask you to stop being noisy.

Thanks for your interest.

In fact, dear @diizzy, Linksys itself builds it's firmware using O3. That's why I included it in my configuration and following OEM's practices I've built a fully preemptive kernel.
They even overclocked the SoC and yet not burnt out devices or reports of random crashes using the OEM firmware so far.

Ok....so how is it that linksys is able to put a dlna server in their OS? Just curious. I haven't gotten a very definitive on either direction in terms what is better for the long term (I can learn a UI and Luci wasn't too bad...although I still like dd-wrt!)

The firmware gets compressed during build, it's a SQUASHFS read-only image. When you install it appart, you get it inside a read-write UBIFS partition that is "appended" to the firmware image, that fills the 30 MB but it's fully uncompressed. So you won't get all of these 30 MB, if the image weights like 20 MB then you will only get 10 MB.

Also the OEM uses another partition, called syscfg which is 42 MB long and fully empty, we could use it but it will cause some "problems" as OpenWrt itself is not designed to use that space.


If you want, I can build one with DLNA installed within the compressed firmware.

@NoTengoBattery

What do you recommend? I'm very open ears.

As I said, my intentions are as follows:

  1. 2.4GHz radio will be on, no wan connection (so no internet access) and only local access with a USB external hdd attached that's full of movies.

  2. 5GHz radio will be on, wan connection (internet access) AND have access as well to the USB external HDD.

  3. External is currently formatted NTFS and is 4tb in size but I can change format. Ideally something windows recognizes as the movies are most likely to be added (well new movies added) by plugging into a laptop and loading them on.

Most critical- users on 2.4 radio can only get onto the HDD and cannot get the internet connection. 5ghz has internet access. I'm working on a satellite connection for the wan- the ethernet connection to the modem is obviously good but from the modem to internet is shaky....so if that were to somehow cause instability in the router, that's an issue. (the linksys doesn't always like it)

I almost just wish I had two routers...it would make the internet setup easier, but that's how I found OpenWRT!

Well, let me help a bit with some recommendations:

  1. For setting WLAN as you want you'll probably need to do heavy modifications to the LAN interface, I think you will need to add a second LAN just for local access (non routed LAN). Anyway, with 2.4GHz the maximun bandwith of 300 MBPs will be only 37.5 MB/s to the disk.
    1.1 I do recommend asking about it in the https://forum.openwrt.org/c/general section because it have less to do with the firmware (the Linux OS running behind the scenes) you use but more on how you use OpenWrt itself.
  2. I would not recommend NTFS for a NAS. It's very CPU inefficient and will cap the bandwith of the disk to 10 MB/s if you are lucky, while pushing the CPU at 100% (I've already tried). I would recommend using XFS (a lightweigth, low overhead filesystem for Linux) and for reading/writing to the disk in Windows/macOS clients you can use Samba (Network Shares).
  3. For DLNA to work, specially if you have huge collections, you will need physical swap for the first run as minidlna indexes all files at once in RAM. The device has 256 MB of RAM which may invoke the oom_reaper which will kill either Samba or minidlna.
    3.1 By default, OpenWrt stores the DLNA database inside the RAM's tmpfs which will make the RAM problem just worse. I recommend storing the DLNA database inside a real storage that will survive reboots (thus avoiding recreating large databases every time you reboot).
    3.2 The default OpenWrt will look like crashed (no network traffic at all) while indexing, but this build is optimized for avoiding this from things I've learnt from the Linsys firmware. So I will recommend you using this build if OpenWrt does not seems to be fluent enough.

It's totally doable, the harder part is to get those details in hand. I've saved you a lot of headache if you follow my recommendation.

Note: current builds does not include DLNA, but I can build one ready-to-go with DLNA (I've be using it myself, other users can just disable it if they don't use it).

hmmm... all sounds good thus far.

So to ask further questions-

  1. By modifications, can these be done inside of Luci or whatever your interface is? I was able to setup the system I wanted (just without the external storage because I couldn't get the HDD recognized) in terms of 2.4 and 5ghz access on the router that I bricked. If you mean modifying by using command line, I'll definitely have to seek help what commands I'll need....
    That bandwidth is 37.5 across all devices, right (meaning 10 devices could split it down to 3.7 MB/s each....right)? I guess it doesn't really matter, that's all I have to deal with.

  2. XFS- is Samba a program? I need something that Android and iOS users can use as well.....thus I was running the FTP server using the linksys OS.

  3. Yes, my collection is about 2tb total right now, but always growing....
    So in regards to 3.1- can this all be done using JUST the router and external HDD? Due to mounting and equipment restraints, I don't have the ability to put anything else in....at least not at the moment. There may be the ability in the future to put a dedicated PC to use for the media server but not right now.

Addressing your question: if you managed to get your WLAN working then you're set with it.

Samba is a program for Linux that is a client and server for the Microsoft SMB protocol. Therefore it works natively in Windows. macOS have it's own version of Samba for working with Windows shares. It's fully configurable inside LuCI by using the "Network Shares": https://openwrt.org/docs/guide-user/services/nas/samba_configuration
No additional software needed in either Windows or macOS, it "just works".

Regarding to if you need only your disk, the answer is "yes". You probably want to format your disk to XFS or EXT4 (as the router is not a server, it has a very limited CPU to use NTFS). You probably want a swap partition: https://help.ubuntu.com/community/SwapFaq which can be reserved inside the disk itself. I recommended 2GB for such a large library. Swap can be added in LuCI, too.

Oh this sounds perfect then! I'm not sure why there's so much animosity on here with you; you've been nothing but super helpful and going above and beyond to help me and I appreciate it a lot more than I could express through this message, so thank you!

Out of curiosity where did you find this?
I looked at the source code released by Linksys and couldn't find any references that they hardset -O3 globally but I might have missed it.

./linux/patches/000_BSP.patch sets the kernel to -O2 unless CONFIG_CC_OPTIMIZE_FOR_SIZE is defined (L5641).

The generic Makefile which is in several directories only mentions -O3 for OpenSSL
./dnsmasq/Makefile (L79)

A few other Makefiles sets -O2 such as ./swconfig/src/Makefile

./src dir of http://downloads.linksys.com/downloads/gpl/EA6350_v3.1.10.191322_GPL.tar.gz which seems to be the newest source available.

Yes, -O3 is the devil. Deal With It, it should be so sad to get sleeples nights thinking about how terrible -O3 is. Good bless your poor sould.

I didn't ever wanted to answer you because you're totaly don't deserve the effort but whatever... At least you keeping my thread alive which, opposed to affect me, it actually helps me. Think that you are smart? Go ahead, keep this thread alive, keep posting nonsenses and whatever you want. Just I'm making sure to flag both your posts and mine as Offtopic.

In case you couldn't tell it's a honest question instead of answering you're turning to insults instead. I guess that answers the question unfortunately....

1 Like

Insults? If that's true, ask the mod to remove the post. I dare you.

These are some results of the optimizations for the memory subsystem. Of course, more feedback is needed and always welcome!

System under normal load (large adblock list, samba4, minidlna)

Gathering stats info for zswap subsystem

ZSWAP
-----
Compressor                - lz4hc
zmalloc zpool             - z3fold
Memory pool               - 18.00 %

STATS
-----
Pool total size           - 15.95 MiB
Original data size        - 44.93 MiB
Estimated savings         - 28.97 MiB
Written back pages        - 0
Stored (cached) pages     - 11501
Uncompressible pages      - 4
Compression ratio         - 2.82

Gathering stats info for zram device "zram0"

ZRAM
----
Block device              - /sys/block/zram0
Device size               - 185 MiB
Compression algo          - lzo lz4 lz4hc [zstd]
Compression streams       - 4

DATA
----
Original data size        - 1.80 MiB
Compressed data size      - 1.58 MiB
Estimated savings         - 0.22 MiB
Compression ratio         - 1.14
Expected c. ratio         - 4.25

MEMORY
------
Memory used, total        - 1.63 MiB
Allocator overhead        - 0.05 MiB
Allocator efficiency      - 96.71 %
Maximum memory ever used  - 1.79 MiB
Memory limit              - 43.53 MiB

PAGES
-----
Same pages count          - 0
Pages compacted           - 0
Free pages discarded      - 114232

System after forced load

stress --vm 4 --vm-bytes 250M --timeout 10s

Gathering stats info for zswap subsystem

ZSWAP
-----
Compressor                - lz4hc
zmalloc zpool             - z3fold
Memory pool               - 18.00 %

STATS
-----
Pool total size           - 3.20 MiB
Original data size        - 8.46 MiB
Estimated savings         - 5.27 MiB
Written back pages        - 10803
Stored (cached) pages     - 2167
Uncompressible pages      - 5
Compression ratio         - 2.65

Gathering stats info for zram device "zram0"

ZRAM
----
Block device              - /sys/block/zram0
Device size               - 185 MiB
Compression algo          - lzo lz4 lz4hc [zstd]
Compression streams       - 4

DATA
----
Original data size        - 44.04 MiB
Compressed data size      - 10.59 MiB
Estimated savings         - 33.45 MiB
Compression ratio         - 4.16
Expected c. ratio         - 4.25

MEMORY
------
Memory used, total        - 11.56 MiB
Allocator overhead        - 0.98 MiB
Allocator efficiency      - 91.55 %
Maximum memory ever used  - 11.77 MiB
Memory limit              - 43.53 MiB

PAGES
-----
Same pages count          - 0
Pages compacted           - 0
Free pages discarded      - 148670

Swap usage after the forced load

root@EA6350v3:~# stress --vm 4 --vm-bytes 250M --timeout 10s
stress: info: [21889] dispatching hogs: 0 cpu, 0 io, 4 vm, 0 hdd
stress: info: [21889] successful run completed in 11s
root@EA6350v3:~# swapon -s
Filename				Type		Size	Used	Priority
/dev/sdb1                               partition	4194300	0	-2
/dev/zram0                              partition	189436	49308	1

For the future release (nov 15, 2019) you can check all of that information by running zram status in your terminal/shell (however you call it).