Skip to content

How to unlock all API s

Georgi Angelov edited this page Sep 13, 2019 · 14 revisions

At the beginning - Тhere is nowhere a license how to use the Azure Sphere, only recommendations.

and This is not hack ... ( maybe little )

Can work with Visual Studio SDK and with this project ( VSCode + PlatformIO )

Tested with last sysroot 19.05

DEMO ( used wolfSSL ) MQTT to Amazon, Google

./proc/meminfo
MemTotal:           3532 kB
MemFree:             992 kB
MemAvailable:       1152 kB
Buffers:               0 kB
Cached:              124 kB
SwapCached:            0 kB
Active:              636 kB
Inactive:             76 kB
Active(anon):        588 kB
Inactive(anon):        0 kB
Active(file):         48 kB
Inactive(file):       76 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:           600 kB
Mapped:                0 kB
Shmem:                 0 kB
Slab:               1224 kB
SReclaimable:        148 kB
SUnreclaim:         1076 kB
KernelStack:         136 kB
PageTables:           60 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:        1764 kB
Committed_AS:       1752 kB
VmallocTotal:    1032192 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB

BaseAPI information

Significant portions of the following C standard library features are excluded:

  • file system paths (why not)
  • terminal support (not need, for the most part FS is read only)
  • ioctl and fcntl functions (need)
  • authentication and authorization (!?)
  • syscall functions
  • System V

So, what we know - Azure Sphere is built in large part by Open Source tools and libraries:

What is missing

Configurations and header files - explore github with upper links and follow the logic

Example:

struct dirent
{
	unsigned int ino;
	unsigned int off;
	unsigned short len;	
	char name[256];     
    unsigned char type;
};

Let`s begin

Part 1

Basically, the user application is a dynamic object that only needs the name of the function from static library

and sysroot/2+Beta1905/usr/lib/libs.so is a fake stub to the real static library ../lib/ld-musl-armhf.so.1

The "Hack"

  • Open folder Sysroots/2+Beta19xx/lib/
  • Rename ld-musl-armhf.so.1 to _ld-musl-armhf.so.1 (don`t delete, backup)
  • Copy _ld-musl-armhf.so.1
  • Open folder .../2+Beta19xx/usr/lib/ and paste _ld-musl-armhf.so.1
  • Rename libc.so to _libc.so (don`t delete, backup)
  • Rename _ld-musl-armhf.so.1 to libc.so

And now you have ALL C functions (library musl)

You can test:

int open(const char *, int, ...); // define missing function

char buf[1024];
int fd = open("/proc/meminfo", 0); // don not write, FS is read only
read(fd, buf, sizeof(buf))
LogDebug("%.*s", sizeof(buf), buf);
close(fd);

Work ? 🥇

Part 2

There is /usr/lib/libXXXXX fake and missing libraries

So, you need to download from Azure Sphere all static libraries as libwolf(SSL), libapplibs.so, libazureiot.so ... and put to /usr/lib/

How? I leave it to you ... be smart and

Happy IoT-thing

PS: do not search the shadow file :)

Clone this wiki locally