Merge branch 'newlib'

This commit is contained in:
Angus Gratton 2015-07-15 16:01:18 +10:00
commit 86188c01fd
133 changed files with 23672 additions and 578 deletions

View file

@ -206,7 +206,7 @@ INLINED bool _timer_set_frequency_impl(const timer_frc_t frc, uint32_t freq)
counts = timer_freq_to_count(frc, freq, div);
if(counts == 0)
{
printf("ABORT: No counter for timer %d frequency %d\r\n", frc, freq);
printf("ABORT: No counter for timer %u frequency %lu\r\n", frc, freq);
abort();
}

71
core/newlib_syscalls.c Normal file
View file

@ -0,0 +1,71 @@
/* newlib_syscalls.c - newlib syscalls for ESP8266
*
* Part of esp-open-rtos
* Copyright (C) 2105 Superhouse Automation Pty Ltd
* BSD Licensed as described in the file LICENSE
*/
#include <sys/reent.h>
#include <sys/types.h>
#include <espressif/sdk_private.h>
#include <stdlib.h>
caddr_t _sbrk_r (struct _reent *r, int incr)
{
extern char _heap_start; /* linker script defined */
static char * heap_end;
char * prev_heap_end;
if (heap_end == NULL)
heap_end = &_heap_start;
prev_heap_end = heap_end;
/* TODO: Check stack collision
if (heap_end + incr > stack_ptr)
{
_write (1, "_sbrk: Heap collided with stack\n", 32);
while(1) {}
}
*/
heap_end += incr;
return (caddr_t) prev_heap_end;
}
/* syscall implementation for stdio write to UART
at the moment UART functionality is all still in the binary SDK
*/
long _write_r(struct _reent *r, int fd, const char *ptr, int len )
{
for(int i = 0; i < len; i++)
sdk_os_putc(ptr[i]);
return len;
}
/* syscall implementation for stdio read from UART
at the moment UART functionality is all still in the binary SDK
*/
long _read_r( struct _reent *r, int fd, char *ptr, int len )
{
for(int i = 0; i < len; i++)
ptr[i] = sdk_uart_rx_one_char();
return len;
}
/* These are stub implementations for the reentrant syscalls that
* newlib is configured to expect */
int _fstat_r(struct _reent *r, int fd, void *buf)
{
return -1;
}
int _close_r(struct _reent *r, int fd)
{
return -1;
}
off_t _lseek_r(struct _reent *r, int fd, off_t offset, int whence)
{
return (off_t)-1;
}

15
core/sdk_compat.c Normal file
View file

@ -0,0 +1,15 @@
/*
* Wrappers for functions called by binary espressif libraries
*
* Part of esp-open-rtos
* Copyright (C) 2015 Superhouse Automation Pty Ltd
* BSD Licensed as described in the file LICENSE
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
void *zalloc(size_t nbytes)
{
return calloc(1, nbytes);
}