Direct to internet device build fails with unrecognized operands (OpenWRT)

I’m trying to cross-compile the st-device-sdk-c for OpenWRT (Omega2) and it fails compiling mbedtls/bignum.c
I don’t want to use mbedtls and I’d rather use openssl available in OpenWRT, but I can’t get around compiling it, and compiling it throws a bunch of “invalid operands” errors.

[  8%] Building C object src/deps/mbedtls/mbedtls/library/CMakeFiles/mbedcrypto.dir/bignum.c.o
mipsel-openwrt-linux-gcc: warning: environment variable 'STAGING_DIR' not defined
{standard input}: Assembler messages:
{standard input}:191: Error: invalid operands `lw $10,36($sp)'
{standard input}:192: Error: invalid operands `lw $11,32($sp)'
{standard input}:193: Error: invalid operands `lw $12,40($sp)'
{standard input}:194: Error: invalid operands `lw $13,28($sp)'
{standard input}:195: Error: invalid operands `lw $14,0($10)'
{standard input}:196: Error: invalid operands `multu $13,$14'
{standard input}:197: Error: unrecognized opcode `addi $10,$10,4'
{standard input}:198: Error: invalid operands `mflo $14'
....
{standard input}:584: Error: invalid operands `sw $11,32($sp)'
{standard input}:585: Error: invalid operands `sw $10,36($sp)'
src/deps/mbedtls/mbedtls/library/CMakeFiles/mbedcrypto.dir/build.make:230: recipe for target 'src/deps/mbedtls/mbedtls/library/CMakeFiles/mbedcrypto.dir/bignum.c.o' failed
make[2]: *** [src/deps/mbedtls/mbedtls/library/CMakeFiles/mbedcrypto.dir/bignum.c.o] Error 1
CMakeFiles/Makefile2:321: recipe for target 'src/deps/mbedtls/mbedtls/library/CMakeFiles/mbedcrypto.dir/all' failed
make[1]: *** [src/deps/mbedtls/mbedtls/library/CMakeFiles/mbedcrypto.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

Is there a solution?

As no one had any solutions, I made one myself. Maybe someone will find it useful.
Removed all the unnecessary branches from all the CMakeLists (all except posix and all the mbedtls branches)
Removed all the remnants of mbedtls.
Built libsodium for my target and added its “src/.libs” and “src/include” to the project CMAKE_C_FLAGS
Ran cmake & make for my target