StratifyOS

Stratify OS includes two main APIs for users: the STDC and the POSIX API.

Details

define SOS_VERSION_2_1_0

define SOS_VERSION_2_2_0

define SOS_VERSION

define SOS_TRACE_MESSAGE

define SOS_TRACE_WARNING

define SOS_TRACE_CRITICAL

define SOS_TRACE_FATAL

define SOS_SCHEDULER_TIMEVAL_SECONDS

define STFY_SCHEDULER_TIMEVAL_SECONDS

define SOS_USECOND_PERIOD

define STFY_USECOND_PERIOD

define SOS_PROCESS_TIMER_COUNT

define SOS_DEFAULT_START_STACK_SIZE

define SOS_DECLARE_TASK_TABLE

define SOS_USER_ROOT

define SOS_USER

int hibernate(

int seconds
)

This function puts the controller in hibernate mode. All CPU and peripheral activity is stopped. The RTC continues running and will wake up the controller after seconds has elapsed. When the controller wakes up, it resumes execution in the same state as before hibernate() was called.

Hibernate corresponds to CORE_SLEEP_DEEPSLEEP. It can be woken up before seconds elapsed if other interrupts are enabled such as pin change interrupts. See the device specific documentation for wakeup events for CORE_SLEEP_DEEPSLEEP.

Parameters

  • seconds Number of seconds to hibernate (zero to hibernate indefinitely)

void powerdown(

int seconds
)

This function turns the controller off. The RTC stays on and wakes up the controller after seconds has elapsed. When the controller wakes up from power down, it resets.

Parameters

  • seconds Number of seconds to powerdown (zero to powedown indefinitely)

void * sos_default_thread(

void * arg
)

This function is weakly bound to code that initializes each filesystem and starts any processes that are designed to auto-run. It can be completely replaced so that users can customize the startup sequence.


int mkfs(

const char * path
)

Format the filesystem that is mounted at path.

Returns

Zero on success


int mount(

const char * path
)

Mount the filesystem specified at path

Parameters

  • path The path to the filesystem (specified at build time)

Returns

Zero on success


int unmount(

const char * path
)

Unmount the filesystem specified at path

Parameters

  • path The path to the filesystem (specified at build time)

Returns

Zero on success


int launch(

const char * path,
char * exec_path,
const char * args,
int options,
int ram_size,
int(*)(const void *, int, int) update_progress,
const void * update_context,
char *const envp
)

Launch an application from a data file system.

The options are:

  • APPFS_FLAG_IS_REPLACE
  • APPFS_FLAG_IS_FLASH
  • APPFS_FLAG_IS_STARTUP (only with APPFS_FLAG_IS_FLASH)
  • APPFS_FLAG_IS_REPLACE
  • APPFS_FLAG_IS_ORPHAN

Here is an example of launching a new application:

#include <caos.h>

pid_t p;
int status;
char exec_path[PATH_MAX];

p = launch("/home/HelloWorld", exec_path, 0, APPFS_FLAG_IS_FLASH, 0, 0, 0);

wait(&status); //wait until hello world is done running
unlink(exec_path); //delete the installed image (or just leave it there to run again)

Parameters

  • path Path to launch binary

  • exec_path The path to store the path where the binary is installed (e.g. /app/flash/0-HelloWorld)

  • args Pointer to the arguments for launch

  • options Install options mask (flash, startup, etc)

  • ram_size The amount of RAM that will be allocated to stack/heap (excludes code even if running from RAM), set to zero for default RAM size

  • update_progress Callback to show progress of install/launch

  • envp Null for this version

Returns

Zero on success


int install(

const char * path,
char * exec_path,
int options,
int ram_size,
int(*)(const void *, int, int) update_progress,
const void * update_context
)

This function installs an application in flash or RAM

Parameters

  • path The source path

  • exec_path A destination buffer for the path to execute once installed

  • options Install options

  • ram_size The number of bytes to use for heap/stack

  • update_progress Callback to show progress of the install

Returns

Zero on success


void htoa(

char * dest,
int num
)


char htoc(

int nibble
)


int kernel_request(

int request,
void * data
)

Parameters

  • request Request to execute

  • data Single argument to the request

Returns

Returns result of request operation


const void * kernel_request_api(

u32 request
)

Parameters

  • request The request API unique identifier

Returns

Returns a pointer to the API if it is installed, zero otherwise

This function can be implemented to return libraries that are stored in the kernel and shared between applications.

For example, the following libraries are requests are supported in the StratifyAPI

  • MBED TLS for secure sockets
  • Jansson Json library
  • Stratify Graphics
  • Stratify Object notation

void sos_trace_event(

link_trace_event_id_t event_id,
const void * data_ptr,
size_t data_len
)


void sos_trace_event_addr_tid(

link_trace_event_id_t event_id,
const void * data_ptr,
size_t data_len,
u32 addr,
int tid
)


void sos_trace_root_trace_event(

link_trace_event_id_t event_id,
const void * data_ptr,
size_t data_len
)


void sos_led_startup()

void sos_led_svcall_enable(

void * args
)


void sos_led_svcall_disable(

void * args
)


void sos_led_svcall_error(

void * args
)


void sos_led_root_enable()

void sos_led_root_disable()

void sos_led_root_error()

struct::scheduler_fault_t

u32 tid

s32 free_stack_size

s32 free_heap_size

u32 pid

fault_t fault

struct::sos_process_timer_t

u32 o_flags

struct mcu_timeval value

struct mcu_timeval interval

struct sigevent sigevent

struct::sched_task_t

pthread_attr_t attr

This holds the task’s pthread attributes

void * block_object

The blocking object

int exit_status

The task’s exit status

void ( init

Task 0 init routine

union sched_task_t::@1 @2

pthread_mutex_t * signal_delay_mutex

The mutex to lock if the task cannot be interrupted

struct mcu_timeval wake

When to wake the task

u16 flags

This indicates whether the process is active or not

trace_id_t trace_id

Trace ID is PID is being traced (0 otherwise)

sos_process_timer_t timer

struct::sos_board_config_t

This structure holds the compiler-link time configuration data.

u8 clk_usecond_tmr

Hardware timer used for usecond counter

u8 task_total

Total number of supported tasks

u16 start_stack_size

Stack size of the first thread (when in doubt use SOS_DEFAULT_START_STACK_SIZE)

const char * stdin_dev

Device used for standard input

const char * stdout_dev

Device used for standard output

const char * stderr_dev

Device used for standard error

const char * trace_dev

Device used for tracing

const char * sys_name

System (or board) name

const char * sys_version

System (or board) version (distinct from kernel version)

const char * sys_id

System ID (globally unique cloud identifier for board)

int sys_memory_size

Memory size reserved for the system

int o_sys_flags

System flags

void ( start

The start routine (when in doubt use sos_default_thread())

void * start_args

Arguments passed to the start routine (for sos_default_thread() use a pointer to the link transport driver)

const sos_socket_api_t * socket_api

Socket API (zero if sockets are not supported)

void(* trace_event

This will trace an event (zero if not supported)

void(* request

Send an interrupt request to the link master (0 if not supported)

const char * git_hash

A pointer to the git hash string


X

Thanks for Coming!

Subscribe to news and updates