Commit Graph

279 Commits

Author SHA1 Message Date
KonstantinKondrashov
ace832abf5 newlib: Mitigate UT - time adjustment happens linearly 2022-02-23 16:51:28 +08:00
Mahavir Jain
bd5176f108 Merge branch 'bugfix/vfs_io_disabled_console_v4.3' into 'release/v4.3'
Fix console output flushing when CONFIG_VFS_SUPPORT_IO is disabled (v4.3)

See merge request espressif/esp-idf!15653
2021-12-22 13:12:21 +00:00
Ivan Grokhotkov
8e7b11f6d1 newlib: set errno in the explicitly provided reent structure
Since these functions receive the pointer to reent structure, they
should set errno in it rather than using thread-local errno.

This didn't cause practical issues because console functions in IDF
are only called from threads, and in that case 'r' is a pointer to
the thread-local structure, so &errno is the same thing as
&__errno_r(r). Still, fixing this for consistency.
2021-12-21 01:25:49 +00:00
Ivan Grokhotkov
3d91e6d993 newlib: implement _fstat_r stub for console
When CONFIG_VFS_SUPPORT_IO is disabled, _read_r and _write_r
implementations in syscalls.c are used to provide console I/O via
esp_rom_uart_tx_one_char/esp_rom_uart_rx_one_char.

When newlib opens a (FILE*) stream, it calls fstat to check if the
underlying file is character-oriented. In this case, it configures the
stream to use line buffering. Otherwise (or if fstat fails) the stream
is opened as block buffered.

Since fstat wasn't provided, stdin/stdout/stderr streams got opened in
block buffered mode. For console, we need line buffered output so that
the stream buffer is flushed each time a complete line (ending with
'\n') is sent to stdout or stderr.

Fix by implementing _fstat_r stub, setting st->st_mdoe=S_IFCHR.
2021-12-21 01:25:49 +00:00
Ivan Grokhotkov
bd598e36ea newlib: stdatomic: implement missing "op_fetch", "nand" builtins
* Adds implementations of __{atomic,sync}_nand_fetch_n. These builtins
  were implemented for other operations but were not defined for NAND.
* Adds implementation of __atomic_OP_fetch_n for all OPs.
* Adds implementation of __sync_OP_and_fetch_n for all OPs.

Reported in https://github.com/espressif/arduino-esp32/issues/5948
2021-12-21 02:16:02 +01:00
Andrei Safronov
6a57c4d5d5 newlib: fix clang atomics
Correction of the SYNC_LOCK_* macros in stdatomic
2021-11-02 16:24:18 +01:00
Scott Mabin
710c1f2fad remove __clang ifdef around atomic emulation
* CI errors led me to believe these were needed, but as it turns out the
load/store intrinsics are required even when idf is built by gcc when
linking to a clang based project.
* remove ... postfix inside `SYNC_LOCK_TEST_AND_SET` expansion
2021-11-02 16:24:18 +01:00
Scott Mabin
b01c197505 newlib: provide missing atomic libcalls
Provide emulated atomic load & store libcalls for u8, u16 & u32 integer
types. This is required when building with Clang as llvm does not lower
these operations to native load / stores, where as gcc does.

Provide `sync_lock_test_and_set` atomic implementations for all
supported integer types.

Closes https://github.com/espressif/esp-idf/issues/7591.
Closes https://github.com/espressif/esp-idf/issues/7592.
2021-11-02 16:24:18 +01:00
Andrei Safronov
de5e0fa3bd newlib,clang: implement __sync_* atomics for clang/llvm toolchain. 2021-11-02 16:24:18 +01:00
Ivan Grokhotkov
d4f2e03e4a newlib: stdatomic: emulate 64-bit atomics on 32-bit SMP SoCs
Closes https://github.com/espressif/esp-idf/issues/3163
2021-11-02 16:24:18 +01:00
Ivan Grokhotkov
be520f975a newlib: stdatomic: fix prototypes, don't disable compiler warnings 2021-11-02 16:24:18 +01:00
Sachin Parekh
2250da111e stdatomic: Implemented legacy __sync APIs and __atomic_exchange_n
These APIs are used when the architecture doesn't have atomic
instruction support

Closes https://github.com/espressif/esp-idf/issues/6463
2021-11-02 16:24:18 +01:00
Renz Bagaporo
5f2fabb2b1 arch: move stdatomic 2021-11-02 16:24:18 +01:00
Konstantin Kondrashov
8140b10a16 esp_system: Adds sync of FRC & RTC counters in esp_restart (v4.3) 2021-10-28 17:33:46 +00:00
Konstantin Kondrashov
fa85714845 Systimer reset alternative on S2 (and others) (v4.3) 2021-10-28 08:00:28 +00:00
Ivan Grokhotkov
746f2e2d49 Merge branch 'bugfix/newlib_dirent_decls_4.3' into 'release/v4.3'
newlib: add C++ guards to the platform-specific dirent.h  (backport 4.3)

See merge request espressif/esp-idf!14621
2021-09-09 18:46:58 +00:00
Mahavir Jain
94667365d3 Merge branch 'esp32c3/override_assert_v4.3' into 'release/v4.3'
newlib: Override __assert and __assert_func (v4.3)

See merge request espressif/esp-idf!14685
2021-09-09 13:24:01 +00:00
Sachin Parekh
659cfcb1f6 newlib: Override __assert and __assert_func
Default assert implementation calls fiprintf, which tries to acquire a
lock and fails if it is executing in critical section or ISR
2021-09-08 16:32:09 +08:00
Ivan Grokhotkov
03109eb013 newlib: add C++ guards to the platform-specific dirent.h
Before newlib 3.3.0, <dirent.h> bundled in newlib did not include any
function declarations. Instead, the file included the platform-
specific <sys/dirent.h>. This inclusion was inside a C++ guard block.
ESP-IDF provided sys/dirent.h inside newlib component, and this file
contained all the necessary function and structure declarations.

Since da418955f5,
common function declarations have been added to <dirent.h> in newlib.
However, the inclusion of sys/dirent.h has been moved out of the C++
guard block. However we didn't notice this change and did not update
sys/dirent.h in ESP-IDF newlib component to and the now-required
C++ guards there.

This commit adds the missing C++ guards to the platform-specific
sys/dirent.h.

The declarations of common dirent.h functions are now present both in
<dirent.h> (provided by newlib) and in sys/dirent.h (provided by IDF).
We keep the declarations in sys/dirent.h for compatibility, since some
ESP-IDF files and applications may include <sys/dirent.h> directly,
rather than <dirent.h>.

Closes https://github.com/espressif/esp-idf/issues/7204
2021-08-03 13:53:34 +08:00
Renz Bagaporo
cebab7fa7f newlib: init microseconds offset 2021-07-30 10:13:41 +08:00
Anton Maklakov
99115d7e52 ci: fix test_build_system* fails 2021-06-25 11:48:26 +07:00
Anton Maklakov
29b8f3b719 newlib: Add ESP_ROM_HAS_RETARGETABLE_LOCKING capability for C3 and S3 chips 2021-06-25 11:48:25 +07:00
Angus Gratton
97f007c08c Merge branch 'bugfix/add-MAXNAMLEN-definition' into 'release/v4.3'
newlib: add the definition of MAXNAMLEN in sys/dirent.h (backport v4.3)

See merge request espressif/esp-idf!13757
2021-06-22 07:12:56 +00:00
Marius Vikhammer
57442c38bd core: fix cases where riscv SP were not 16 byte aligned
RISC-V stack pointer should always be 16 byte aligned, but for some cases where
we were doing manual SP manipulation this was not always the case.
2021-06-02 16:02:10 +08:00
WangQixiang
ac362cc662 change MAXNAMLEN to 255 2021-05-28 20:41:25 +08:00
WangQixiang
a29fe72cc9 add the definition of MAXNAMLEN in sys/dirent.h 2021-05-28 20:41:10 +08:00
Angus Gratton
7703fcbd8d Merge branch 'bugfix/silent_asserts_v4.3' into 'release/v4.3'
freertos/lw ip: Support silent assertions (v4.3)

See merge request espressif/esp-idf!13011
2021-04-13 04:30:09 +00:00
Renz Bagaporo
11970e65a1 newlib: persist rtc clk corrections 2021-04-07 06:40:28 +08:00
Angus Gratton
bf6ddf2557 bootloader: Allow 'silent assert' config to work in bootloader
Requires adding the 'newlib' component to the bootloader project, for
platform_include header.
2021-04-02 11:03:21 +11:00
Marius Vikhammer
360e7c4d51 system: enable shared stack watchpoint
Enable shared stack watchpoint for overflow detection

Enable unit tests:
 * "test printf using shared buffer stack" for C3
 * "Test vTaskDelayUntil" for S2
 * "UART can do poll()" for C3
2021-02-19 16:59:29 +08:00
ninh
25dcc68b5d newlib: keep esp_rtc_get_time_us when rewrite the value of RTC_SLOW_CLK_CAL_REG 2021-01-21 02:28:21 +00:00
morris
753a929525 global: fix sign-compare warnings 2021-01-12 14:05:08 +08:00
KonstantinKondrashov
aec5776091 newlib: Fix a case in FD_ISSET macro when n==-1 2021-01-06 20:54:24 +00:00
ninh
e908a32381 put pm_slp_iram_opt and pm_rtos_iram_opt related attributes in esp_pm/linker.lf 2021-01-06 03:40:28 +00:00
Marius Vikhammer
f54e9269f3 esp_system: Don't compile sleep_mode.c on c3 2020-12-31 15:20:05 +11:00
Marius Vikhammer
3458469204 newlib: Update esp32c3 ROM support, use single init function 2020-12-31 09:27:37 +11:00
Ivan Grokhotkov
b7b9ea4361 newlib: add _RETARGETABLE_LOCKING support
This adds support for the retargetable locking implementation in
newlib 3. This feature will be enabled in the future toolchain builds.
With the present version of the toolchain, this code doesn't get used.

When _RETARGETABLE_LOCKING gets enabled, newlib locking implementation
will be modified as follows:

- Legacy ESP-specific _lock_xxx functions are preserved. This is done
  because ROM copies of newlib in ESP32 and ESP32-S2 rely on these
  functions through the function pointer table. Also there is some
  code in IDF which still uses these locking functions.

- New __retarget_lock_xxx functions are introduced. Newlib expects
  these functions to be provided by the system. These functions work
  pretty much the same way as the ESP-specific _lock_xxx functions,
  except one major difference: _lock_acquire receives the lock pointer
  by value, and as such doesn't support lazy initialization.

- Static locks used by newlib are now explicitly initialized at
  startup. Since it is unlikely that these static locks are used at
  the same time, all compatible locks are set to point to the same
  mutex. This saves a bit of RAM. Note that there are still many locks
  not initialized statically, in particular those inside FILE
  structures.
2020-12-29 16:18:04 +01:00
Angus Gratton
99d93c1227 newlib: Update unit tests for ESP32-C3 2020-12-24 14:18:01 +11:00
Liu Ning
57aa65eeed components/pm: Add sleep related code iram opt chioce 2020-12-23 14:45:36 +08:00
Angus Gratton
5228d9f9ce esp32c3: Apply one-liner/small changes for ESP32-C3 2020-12-01 10:58:50 +11:00
Angus Gratton
420aef1ffe Updates for riscv support
* Target components pull in xtensa component directly
* Use CPU HAL where applicable
* Remove unnecessary xtensa headers
* Compilation changes necessary to support non-xtensa gcc types (ie int32_t/uint32_t is no
  longer signed/unsigned int).

Changes come from internal branch commit a6723fc
2020-11-13 07:49:11 +11:00
Angus Gratton
66fb5a29bb Whitespace: Automated whitespace fixes (large commit)
Apply the pre-commit hook whitespace fixes to all files in the repo.

(Line endings, blank lines at end of file, trailing whitespace)
2020-11-11 07:36:35 +00:00
Renz Bagaporo
b3a7c6e27e components: remove some unneeded headers from source files 2020-10-22 19:37:10 +08:00
Angus Gratton
4df4bd9558 Merge branch 'bugfix/clock_getres_accuracy_resolution' into 'master'
newlib: Fix clock_getres() improves accuracy

See merge request espressif/esp-idf!10743
2020-10-22 16:50:29 +08:00
Konstantin Kondrashov
9386cafbc3 time: Fix gettimeofday for ESP32-S3 2020-10-20 14:09:32 +08:00
Felipe Neves
3057b76a7e tests: re-add all disabled tests and all disabled configurations 2020-10-14 16:11:49 +11:00
Felipe Neves
bd9b921713 heap_tlsf: added implementation of TLSF allocator
heap: ported tlsf allocator into multi heap

heap_host_tests: added tlsf allocator into host test

heap_host_test: update freebytes after using free

heap_tests: tlsf now passing on host tests without poisoning

multi_heap: added support for memalign using tlsf implementation

heap_caps: removed heap_caps_aligned_free

heap/test: fixed broken aligned alloc test build

heap: added poisoning pattern when blocks are being merged

heap/tests: added timing tests for memory allocation

heap: reduced tlsf structure overhead

heap/tlsf: made all short functions inside of tlsf  module as inline to improve timings

heap: moved tlsf heap routines outside of flash memory

newlib: linked multiheap memalign with newlib memalign function

heap: moved block member functions to a separate file so multi_heap can use the functions

heap/test: improved the tlsf timing test

heap/test: added memalign on aligned alloc tests

heap: moved tlsf configuration constants to a separated file

heap: added random allocations test with timings

heap: modified the calculation of heap free bytes

heap: make aligned free true deprecated functions and update their documentation

heap: add extra assert after successive mallocs on small allocation host test

heap: remove legacy aligned alloc implementation.

performance: added malloc and free time performance default values
2020-10-13 23:52:03 +00:00
KonstantinKondrashov
7ae7adf16a newlib: Fix clock_getres() improves accuracy
Returns not rounded value of resolution for WITH_RTC and !WITH_FRC
2020-10-07 18:01:35 +08:00
morris
9fa06719fa global: enable build uinit test for esp32-s3 2020-09-22 15:15:03 +08:00
morris
61f89b97c6 bringup esp32-s3 on FPGA 2020-09-22 15:15:03 +08:00