diff --git a/components/esp32/Kconfig b/components/esp32/Kconfig index 79e0b3741..4112b3372 100644 --- a/components/esp32/Kconfig +++ b/components/esp32/Kconfig @@ -138,6 +138,27 @@ config NEWLIB_STDOUT_ADDCR is usually done by an added CR character. Enabling this will make the standard output code automatically add a CR character before a LF. +config NEWLIB_NANO_FORMAT + bool "Enable 'nano' formatting options for printf/scanf family" + default n + help + ESP32 ROM contains parts of newlib C library, including printf/scanf family + of functions. These functions have been compiled with so-called "nano" + formatting option. This option doesn't support 64-bit integer formats and C99 + features, such as positional arguments. + + For more details about "nano" formatting option, please see newlib readme file, + search for '--enable-newlib-nano-formatted-io': + https://sourceware.org/newlib/README + + If this option is enabled, build system will use functions available in + ROM, reducing the application binary size. Functions available in ROM run + faster than functions which run from flash. Functions available in ROM can + also run when flash instruction cache is disabled. + + If you need 64-bit integer formatting support or C99 features, keep this + option disabled. + choice CONSOLE_UART prompt "UART for console output" default CONSOLE_UART_DEFAULT diff --git a/components/esp32/component.mk b/components/esp32/component.mk index 6c0d65d9c..858b5471b 100644 --- a/components/esp32/component.mk +++ b/components/esp32/component.mk @@ -8,6 +8,10 @@ LIBS := core net80211 phy rtc pp wpa smartconfig coexist wps wpa2 LINKER_SCRIPTS += -T esp32_out.ld -T esp32.common.ld -T esp32.rom.ld -T esp32.peripherals.ld +ifeq ("$(CONFIG_NEWLIB_NANO_FORMAT)","y") +LINKER_SCRIPTS += -T esp32.rom.nanofmt.ld +endif + COMPONENT_ADD_LDFLAGS := -lesp32 \ $(COMPONENT_PATH)/libhal.a \ -L$(COMPONENT_PATH)/lib \ diff --git a/components/esp32/ld/esp32.rom.ld b/components/esp32/ld/esp32.rom.ld index af9522976..b557271fa 100644 --- a/components/esp32/ld/esp32.rom.ld +++ b/components/esp32/ld/esp32.rom.ld @@ -26,14 +26,6 @@ PROVIDE ( asctime = 0x40059588 ); PROVIDE ( asctime_r = 0x40000ec8 ); PROVIDE ( __ashldi3 = 0x4000c818 ); PROVIDE ( __ashrdi3 = 0x4000c830 ); -PROVIDE ( asiprintf = 0x40056d9c ); -PROVIDE ( _asiprintf_r = 0x40056d4c ); -PROVIDE ( asniprintf = 0x40056cd8 ); -PROVIDE ( _asniprintf_r = 0x40056c64 ); -PROVIDE ( asnprintf = 0x40056cd8 ); -PROVIDE ( _asnprintf_r = 0x40056c64 ); -PROVIDE ( asprintf = 0x40056d9c ); -PROVIDE ( _asprintf_r = 0x40056d4c ); PROVIDE ( atoi = 0x400566c4 ); PROVIDE ( _atoi_r = 0x400566d4 ); PROVIDE ( atol = 0x400566ec ); @@ -230,10 +222,6 @@ PROVIDE ( __ffssi2 = 0x4000c804 ); PROVIDE ( FilePacketSendDeflatedReqMsgProc = 0x40008b24 ); PROVIDE ( FilePacketSendReqMsgProc = 0x40008860 ); PROVIDE ( _findenv_r = 0x40001f44 ); -PROVIDE ( fiprintf = 0x40056efc ); -PROVIDE ( _fiprintf_r = 0x40056ed8 ); -PROVIDE ( fiscanf = 0x40058884 ); -PROVIDE ( _fiscanf_r = 0x400588b4 ); PROVIDE ( __fixdfdi = 0x40002ac4 ); PROVIDE ( __fixdfsi = 0x40002a78 ); PROVIDE ( __fixsfdi = 0x4000244c ); @@ -255,16 +243,12 @@ PROVIDE ( __floatundisf = 0x4000c8b0 ); PROVIDE ( __floatunsidf = 0x4000c938 ); PROVIDE ( __floatunsisf = 0x4000c864 ); PROVIDE ( __fp_lock_all = 0x40001f1c ); -PROVIDE ( fprintf = 0x40056efc ); -PROVIDE ( _fprintf_r = 0x40056ed8 ); PROVIDE ( __fp_unlock_all = 0x40001f30 ); PROVIDE ( fputwc = 0x40058ea8 ); PROVIDE ( __fputwc = 0x40058da0 ); PROVIDE ( _fputwc_r = 0x40058e4c ); PROVIDE ( free = 0x4000beb8 ); PROVIDE ( _free_r = 0x4000bbcc ); -PROVIDE ( fscanf = 0x40058884 ); -PROVIDE ( _fscanf_r = 0x400588b4 ); PROVIDE ( _fstat_r = 0x4000bccc ); PROVIDE ( _fwalk = 0x4000c738 ); PROVIDE ( _fwalk_reent = 0x4000c770 ); @@ -337,15 +321,11 @@ PROVIDE ( hmac_sha1_vector = 0x400609e4 ); PROVIDE ( hmac_sha256 = 0x40060d58 ); PROVIDE ( hmac_sha256_vector = 0x40060c84 ); PROVIDE ( intr_matrix_set = 0x4000681c ); -PROVIDE ( iprintf = 0x40056978 ); -PROVIDE ( _iprintf_r = 0x40056944 ); PROVIDE ( isalnum = 0x40000f04 ); PROVIDE ( isalpha = 0x40000f18 ); PROVIDE ( isascii = 0x4000c20c ); PROVIDE ( _isatty_r = 0x40000ea0 ); PROVIDE ( isblank = 0x40000f2c ); -PROVIDE ( iscanf = 0x40058760 ); -PROVIDE ( _iscanf_r = 0x4005879c ); PROVIDE ( iscntrl = 0x40000f50 ); PROVIDE ( isdigit = 0x40000f64 ); PROVIDE ( isgraph = 0x40000f94 ); @@ -511,11 +491,6 @@ PROVIDE ( __powidf2 = 0x400638d4 ); PROVIDE ( __powisf2 = 0x4006389c ); PROVIDE ( _Pri_4_HandlerAddress = 0x3ffe0648 ); PROVIDE ( _Pri_5_HandlerAddress = 0x3ffe064c ); -PROVIDE ( printf = 0x40056978 ); -PROVIDE ( _printf_common = 0x40057338 ); -PROVIDE ( _printf_float = 0x4000befc ); -PROVIDE ( _printf_i = 0x40057404 ); -PROVIDE ( _printf_r = 0x40056944 ); PROVIDE ( qsort = 0x40056424 ); PROVIDE ( _raise_r = 0x4000bc70 ); PROVIDE ( rand = 0x40001058 ); @@ -1500,11 +1475,6 @@ PROVIDE ( rwip_rf_p_get = 0x400558f4 ); PROVIDE ( r_XorKey = 0x400112c0 ); PROVIDE ( sbrk = 0x400017f4 ); PROVIDE ( _sbrk_r = 0x4000bce4 ); -PROVIDE ( scanf = 0x40058760 ); -PROVIDE ( _scanf_chars = 0x40058384 ); -PROVIDE ( _scanf_float = 0x4000bf18 ); -PROVIDE ( _scanf_i = 0x4005845c ); -PROVIDE ( _scanf_r = 0x4005879c ); PROVIDE ( __sccl = 0x4000c498 ); PROVIDE ( __sclose = 0x400011b8 ); PROVIDE ( SelectSpiFunction = 0x40061f84 ); @@ -1549,13 +1519,9 @@ PROVIDE ( sip_is_active = 0x4000b3c0 ); PROVIDE ( sip_post_init = 0x4000aed8 ); PROVIDE ( sip_reclaim_from_host_cmd = 0x4000adbc ); PROVIDE ( sip_reclaim_tx_data_pkt = 0x4000ad5c ); -PROVIDE ( siprintf = 0x40056c08 ); -PROVIDE ( _siprintf_r = 0x40056bbc ); PROVIDE ( sip_send = 0x4000af54 ); PROVIDE ( sip_to_host_chain_append = 0x4000aef8 ); PROVIDE ( sip_to_host_evt_send_done = 0x4000ac04 ); -PROVIDE ( siscanf = 0x400587d0 ); -PROVIDE ( _siscanf_r = 0x40058830 ); PROVIDE ( slc_add_credits = 0x4000baf4 ); PROVIDE ( slc_enable = 0x4000b64c ); PROVIDE ( slc_from_host_chain_fetch = 0x4000b7e8 ); @@ -1568,10 +1534,6 @@ PROVIDE ( slc_send_to_host_chain = 0x4000b6a0 ); PROVIDE ( slc_set_host_io_max_window = 0x4000b89c ); PROVIDE ( slc_to_host_chain_recycle = 0x4000b758 ); PROVIDE ( __smakebuf_r = 0x40059108 ); -PROVIDE ( sniprintf = 0x40056b4c ); -PROVIDE ( _sniprintf_r = 0x40056ae4 ); -PROVIDE ( snprintf = 0x40056b4c ); -PROVIDE ( _snprintf_r = 0x40056ae4 ); PROVIDE ( software_reset = 0x4000824c ); PROVIDE ( software_reset_cpu = 0x40008264 ); PROVIDE ( specialModP256 = 0x4001600c ); @@ -1607,20 +1569,13 @@ PROVIDE ( SPI_Write_Encrypt_Disable = 0x40062e60 ); PROVIDE ( SPI_Write_Encrypt_Enable = 0x40062df4 ); /* This is static function, but can be used, not generated by script*/ PROVIDE ( SPI_write_status = 0x400622f0 ); -PROVIDE ( sprintf = 0x40056c08 ); -PROVIDE ( _sprintf_r = 0x40056bbc ); -PROVIDE ( __sprint_r = 0x400577e4 ); PROVIDE ( srand = 0x40001004 ); PROVIDE ( __sread = 0x40001118 ); PROVIDE ( __srefill_r = 0x400593d4 ); -PROVIDE ( sscanf = 0x400587d0 ); -PROVIDE ( _sscanf_r = 0x40058830 ); PROVIDE ( __sseek = 0x40001184 ); PROVIDE ( __ssprint_r = 0x40056ff8 ); PROVIDE ( __ssputs_r = 0x40056f2c ); PROVIDE ( __ssrefill_r = 0x40057fec ); -PROVIDE ( __ssvfiscanf_r = 0x4005802c ); -PROVIDE ( __ssvfscanf_r = 0x4005802c ); PROVIDE ( __stack = 0x3ffe3f20 ); PROVIDE ( __stack_app = 0x3ffe7e30 ); PROVIDE ( _stack_sentry = 0x3ffe1320 ); @@ -1673,11 +1628,6 @@ PROVIDE ( SubtractFromSelfBigHexSign256 = 0x40015dc8 ); PROVIDE ( __subvdi3 = 0x40002d20 ); PROVIDE ( __subvsi3 = 0x40002cf8 ); PROVIDE ( _sungetc_r = 0x40057f6c ); -PROVIDE ( _svfiprintf_r = 0x40057100 ); -PROVIDE ( __svfiscanf_r = 0x40057b08 ); -PROVIDE ( _svfprintf_r = 0x40057100 ); -PROVIDE ( __svfscanf = 0x40057f04 ); -PROVIDE ( __svfscanf_r = 0x40057b08 ); PROVIDE ( __swbuf = 0x40058cb4 ); PROVIDE ( __swbuf_r = 0x40058bec ); PROVIDE ( __swrite = 0x40001150 ); @@ -1756,44 +1706,8 @@ PROVIDE ( user_code_start = 0x3ffe0400 ); PROVIDE ( _UserExceptionVector = 0x40000340 ); PROVIDE ( utoa = 0x40056258 ); PROVIDE ( __utoa = 0x400561f0 ); -PROVIDE ( vasiprintf = 0x40056eb8 ); -PROVIDE ( _vasiprintf_r = 0x40056e80 ); -PROVIDE ( vasniprintf = 0x40056e58 ); -PROVIDE ( _vasniprintf_r = 0x40056df8 ); -PROVIDE ( vasnprintf = 0x40056e58 ); -PROVIDE ( _vasnprintf_r = 0x40056df8 ); -PROVIDE ( vasprintf = 0x40056eb8 ); -PROVIDE ( _vasprintf_r = 0x40056e80 ); PROVIDE ( VerifyFlashMd5Proc = 0x40008c44 ); PROVIDE ( veryBigHexP256 = 0x3ff9736c ); -PROVIDE ( vfiprintf = 0x40057ae8 ); -PROVIDE ( _vfiprintf_r = 0x40057850 ); -PROVIDE ( vfiscanf = 0x40057eb8 ); -PROVIDE ( _vfiscanf_r = 0x40057f24 ); -PROVIDE ( vfprintf = 0x40057ae8 ); -PROVIDE ( _vfprintf_r = 0x40057850 ); -PROVIDE ( vfscanf = 0x40057eb8 ); -PROVIDE ( _vfscanf_r = 0x40057f24 ); -PROVIDE ( viprintf = 0x400569b4 ); -PROVIDE ( _viprintf_r = 0x400569e4 ); -PROVIDE ( viscanf = 0x40058698 ); -PROVIDE ( _viscanf_r = 0x400586c8 ); -PROVIDE ( vprintf = 0x400569b4 ); -PROVIDE ( _vprintf_r = 0x400569e4 ); -PROVIDE ( vscanf = 0x40058698 ); -PROVIDE ( _vscanf_r = 0x400586c8 ); -PROVIDE ( vsiprintf = 0x40056ac4 ); -PROVIDE ( _vsiprintf_r = 0x40056a90 ); -PROVIDE ( vsiscanf = 0x40058740 ); -PROVIDE ( _vsiscanf_r = 0x400586f8 ); -PROVIDE ( vsniprintf = 0x40056a68 ); -PROVIDE ( _vsniprintf_r = 0x40056a14 ); -PROVIDE ( vsnprintf = 0x40056a68 ); -PROVIDE ( _vsnprintf_r = 0x40056a14 ); -PROVIDE ( vsprintf = 0x40056ac4 ); -PROVIDE ( _vsprintf_r = 0x40056a90 ); -PROVIDE ( vsscanf = 0x40058740 ); -PROVIDE ( _vsscanf_r = 0x400586f8 ); PROVIDE ( wcrtomb = 0x40058920 ); PROVIDE ( _wcrtomb_r = 0x400588d8 ); PROVIDE ( __wctomb = 0x3ff96540 ); diff --git a/components/esp32/ld/esp32.rom.nanofmt.ld b/components/esp32/ld/esp32.rom.nanofmt.ld new file mode 100644 index 000000000..ae843dff2 --- /dev/null +++ b/components/esp32/ld/esp32.rom.nanofmt.ld @@ -0,0 +1,100 @@ +/* + Address table for printf/scanf family of functions in ESP32 ROM. + These functions are compiled with newlib "nano" format option. + As such, they don's support 64-bit integer formats. + Floating point formats are supported by setting _printf_float and + _scanf_float entries in syscall table. This is done automatically + by startup code. + + Generated for ROM with MD5sum: + ab8282ae908fe9e7a63fb2a4ac2df013 eagle.pro.rom.out +*/ + +PROVIDE ( asiprintf = 0x40056d9c ); +PROVIDE ( _asiprintf_r = 0x40056d4c ); +PROVIDE ( asniprintf = 0x40056cd8 ); +PROVIDE ( _asniprintf_r = 0x40056c64 ); +PROVIDE ( asnprintf = 0x40056cd8 ); +PROVIDE ( _asnprintf_r = 0x40056c64 ); +PROVIDE ( asprintf = 0x40056d9c ); +PROVIDE ( _asprintf_r = 0x40056d4c ); +PROVIDE ( fiprintf = 0x40056efc ); +PROVIDE ( _fiprintf_r = 0x40056ed8 ); +PROVIDE ( fiscanf = 0x40058884 ); +PROVIDE ( _fiscanf_r = 0x400588b4 ); +PROVIDE ( fprintf = 0x40056efc ); +PROVIDE ( _fprintf_r = 0x40056ed8 ); +PROVIDE ( iprintf = 0x40056978 ); +PROVIDE ( _iprintf_r = 0x40056944 ); +PROVIDE ( printf = 0x40056978 ); +PROVIDE ( _printf_common = 0x40057338 ); +PROVIDE ( _printf_float = 0x4000befc ); +PROVIDE ( _printf_i = 0x40057404 ); +PROVIDE ( _printf_r = 0x40056944 ); +PROVIDE ( siprintf = 0x40056c08 ); +PROVIDE ( _siprintf_r = 0x40056bbc ); +PROVIDE ( sniprintf = 0x40056b4c ); +PROVIDE ( _sniprintf_r = 0x40056ae4 ); +PROVIDE ( snprintf = 0x40056b4c ); +PROVIDE ( _snprintf_r = 0x40056ae4 ); +PROVIDE ( sprintf = 0x40056c08 ); +PROVIDE ( _sprintf_r = 0x40056bbc ); +PROVIDE ( __sprint_r = 0x400577e4 ); +PROVIDE ( _svfiprintf_r = 0x40057100 ); +PROVIDE ( __svfiscanf_r = 0x40057b08 ); +PROVIDE ( _svfprintf_r = 0x40057100 ); +PROVIDE ( __svfscanf = 0x40057f04 ); +PROVIDE ( __svfscanf_r = 0x40057b08 ); +PROVIDE ( vasiprintf = 0x40056eb8 ); +PROVIDE ( _vasiprintf_r = 0x40056e80 ); +PROVIDE ( vasniprintf = 0x40056e58 ); +PROVIDE ( _vasniprintf_r = 0x40056df8 ); +PROVIDE ( vasnprintf = 0x40056e58 ); +PROVIDE ( _vasnprintf_r = 0x40056df8 ); +PROVIDE ( vasprintf = 0x40056eb8 ); +PROVIDE ( _vasprintf_r = 0x40056e80 ); +PROVIDE ( vfiprintf = 0x40057ae8 ); +PROVIDE ( _vfiprintf_r = 0x40057850 ); +PROVIDE ( vfiscanf = 0x40057eb8 ); +PROVIDE ( _vfiscanf_r = 0x40057f24 ); +PROVIDE ( vfprintf = 0x40057ae8 ); +PROVIDE ( _vfprintf_r = 0x40057850 ); +PROVIDE ( vfscanf = 0x40057eb8 ); +PROVIDE ( _vfscanf_r = 0x40057f24 ); +PROVIDE ( viprintf = 0x400569b4 ); +PROVIDE ( _viprintf_r = 0x400569e4 ); +PROVIDE ( viscanf = 0x40058698 ); +PROVIDE ( _viscanf_r = 0x400586c8 ); +PROVIDE ( vprintf = 0x400569b4 ); +PROVIDE ( _vprintf_r = 0x400569e4 ); +PROVIDE ( vscanf = 0x40058698 ); +PROVIDE ( _vscanf_r = 0x400586c8 ); +PROVIDE ( vsiprintf = 0x40056ac4 ); +PROVIDE ( _vsiprintf_r = 0x40056a90 ); +PROVIDE ( vsiscanf = 0x40058740 ); +PROVIDE ( _vsiscanf_r = 0x400586f8 ); +PROVIDE ( vsniprintf = 0x40056a68 ); +PROVIDE ( _vsniprintf_r = 0x40056a14 ); +PROVIDE ( vsnprintf = 0x40056a68 ); +PROVIDE ( _vsnprintf_r = 0x40056a14 ); +PROVIDE ( vsprintf = 0x40056ac4 ); +PROVIDE ( _vsprintf_r = 0x40056a90 ); +PROVIDE ( vsscanf = 0x40058740 ); +PROVIDE ( _vsscanf_r = 0x400586f8 ); +PROVIDE ( fscanf = 0x40058884 ); +PROVIDE ( _fscanf_r = 0x400588b4 ); +PROVIDE ( iscanf = 0x40058760 ); +PROVIDE ( _iscanf_r = 0x4005879c ); +PROVIDE ( scanf = 0x40058760 ); +PROVIDE ( _scanf_chars = 0x40058384 ); +PROVIDE ( _scanf_float = 0x4000bf18 ); +PROVIDE ( _scanf_i = 0x4005845c ); +PROVIDE ( _scanf_r = 0x4005879c ); +PROVIDE ( siscanf = 0x400587d0 ); +PROVIDE ( _siscanf_r = 0x40058830 ); +PROVIDE ( sscanf = 0x400587d0 ); +PROVIDE ( _sscanf_r = 0x40058830 ); +PROVIDE ( __ssvfiscanf_r = 0x4005802c ); +PROVIDE ( __ssvfscanf_r = 0x4005802c ); + + diff --git a/components/newlib/component.mk b/components/newlib/component.mk index 4f567242b..432780f65 100644 --- a/components/newlib/component.mk +++ b/components/newlib/component.mk @@ -1,4 +1,10 @@ -COMPONENT_ADD_LDFLAGS := $(COMPONENT_PATH)/lib/libc.a $(COMPONENT_PATH)/lib/libm.a -lnewlib + +ifdef CONFIG_NEWLIB_NANO_FORMAT +LIBC_PATH := $(COMPONENT_PATH)/lib/libc_nano.a +else +LIBC_PATH := $(COMPONENT_PATH)/lib/libc.a +endif + +COMPONENT_ADD_LDFLAGS := $(LIBC_PATH) $(COMPONENT_PATH)/lib/libm.a -lnewlib COMPONENT_ADD_INCLUDEDIRS := include platform_include - diff --git a/components/newlib/lib/extracted/romsyms b/components/newlib/lib/extracted/romsyms deleted file mode 100644 index 61a10cdfb..000000000 --- a/components/newlib/lib/extracted/romsyms +++ /dev/null @@ -1,639 +0,0 @@ -abort -abs -__adddf3 -__any_on -app_gpio_arg -app_gpio_handler -__ascii_wctomb -asctime -asctime_r -asiprintf -_asiprintf_r -asniprintf -_asniprintf_r -asnprintf -_asnprintf_r -asprintf -_asprintf_r -atoi -_atoi_r -atol -_atol_r -__b2d -_Balloc -_Bfree -_bss_end -_bss_start -btdummy_bss -btdummy_text -bzero -cache_flash_mmu_set -Cache_Flush -Cache_Read_Disable -Cache_Read_Enable -Cache_Read_Init -cache_sram_mmu_set -calloc -_calloc_r -check_pos -_cleanup -_cleanup_r -close -_close_r -__copybits -creat -ctime -ctime_r -__d2b -_data_end -_data_start -_daylight -_DebugExceptionVector -debug_timer -debug_timerfn -div -__divdf3 -__divsi3 -_DoubleExceptionVector -__dummy_lock -__dummy_lock_try -environ -__env_lock -__env_unlock -eprintf -eprintf_init_buf -eprintf_to_host -__eqdf2 -est_get_printf_buf_remain_len -est_reset_printf_buf_len -_etext -ets_aes_crypt -ets_aes_set_endian -ets_aes_setkey_dec -ets_aes_setkey_enc -ets_aes_start -ets_aes_stop -ets_bigint_disable -ets_bigint_enable -ets_bigint_mod_mult_getz -ets_bigint_mod_mult_prepare -ets_bigint_mod_power_getz -ets_bigint_mod_power_prepare -ets_bigint_montgomery_mult_getz -ets_bigint_montgomery_mult_prepare -ets_bigint_mult_getz -ets_bigint_mult_prepare -ets_bigint_wait_finish -ets_delay_us -ets_efuse_get_8M_clock -ets_efuse_get_spiconfig -ets_efuse_program_op -ets_efuse_read_op -ets_efuse_start -ets_efuse_stop -ets_external_printf -ets_get_cpu_frequency -ets_get_detected_xtal_freq -ets_get_xtal_scale -ets_install_external_printf -ets_install_putc1 -ets_install_putc2 -ets_install_uart_printf -ets_intr_count -ets_intr_lock -ets_intr_unlock -ets_isr_attach -ets_isr_mask -ets_isr_unmask -ets_post -ets_printf -ets_readySet_ -ets_run -ets_secure_boot_check -ets_secure_boot_check_finish -ets_secure_boot_check_start -ets_secure_boot_finish -ets_secure_boot_hash -ets_secure_boot_obtain -ets_secure_boot_rd_abstract -ets_secure_boot_rd_iv -ets_secure_boot_start -ets_set_appcpu_boot_addr -ets_set_idle_cb -ets_set_startup_callback -ets_set_user_start -ets_sha_finish -ets_sha_init -ets_sha_start -ets_sha_stop -ets_sha_update -ets_startup_callback -ets_task -ets_timer_arm -ets_timer_arm_us -ets_timer_disarm -ets_timer_done -ets_timer_handler_isr -ets_timer_init -ets_timer_setfn -ets_uart_printf -ets_unpack_flash_code -ets_update_cpu_frequency -ets_waiti0 -_exit_r -fclose -_fclose_r -fflush -_fflush_r -FilePacketSendDeflatedReqMsgProc -FilePacketSendReqMsgProc -_findenv_r -fiprintf -_fiprintf_r -fiscanf -_fiscanf_r -__fixdfsi -__fixunsdfsi -FlashDwnLdDeflatedStartMsgProc -FlashDwnLdParamCfgMsgProc -FlashDwnLdStartMsgProc -FlashDwnLdStopDeflatedReqMsgProc -FlashDwnLdStopReqMsgProc -__floatsidf -__floatunsidf -__fpclassifyd -__fp_lock_all -fprintf -_fprintf_r -__fp_unlock_all -fputwc -__fputwc -_fputwc_r -free -_free_r -fscanf -_fscanf_r -_fstat_r -_fwalk -_fwalk_reent -__gedf2 -_GeneralException -__get_current_time_locale -_getenv_r -__gethex -_getpid_r -__getreent -_gettimeofday_r -__gettzinfo -GetUartDevice -_global_impure_ptr -gmtime -gmtime_r -gpio_init -gpio_input_get -gpio_input_get_high -gpio_intr_ack -gpio_intr_ack_high -gpio_intr_handler_register -gpio_intr_pending -gpio_intr_pending_high -gpio_matrix_in -gpio_matrix_out -gpio_output_set -gpio_output_set_high -gpio_pad_unhold -gpio_pending_mask -gpio_pending_mask_high -gpio_pin_intr_state_set -gpio_pin_wakeup_disable -gpio_pin_wakeup_enable -gpio_register_get -gpio_register_set -__gtdf2 -gTxMsg -__hexdig_fun -__hexnan -__hi0bits -__i2b -intr_matrix_set -iprintf -_iprintf_r -isalnum -isalpha -isascii -_isatty_r -isblank -iscanf -_iscanf_r -iscntrl -isdigit -isgraph -islower -isprint -ispunct -isspace -isupper -itoa -__itoa -_KernelExceptionVector -_kill_r -labs -ldiv -__ledf2 -_Level2FromVector -_Level2Vector -_Level3FromVector -_Level3Vector -_Level4FromVector -_Level4Vector -_Level5FromVector -_Level5Vector -_LevelOneInterrupt -_link_r -lldesc_build_chain -lldesc_num2link -lldesc_set_owner -__lo0bits -__locale_charset -__locale_cjk_lang -localeconv -_localeconv_r -__locale_mb_cur_max -__locale_msgcharset -localtime -localtime_r -_lock_acquire -_lock_acquire_recursive -_lock_close -_lock_close_recursive -_lock_init -_lock_init_recursive -_lock_release -_lock_release_recursive -_lock_try_acquire -_lock_try_acquire_recursive -longjmp -_lseek_r -__lshift -__ltdf2 -main -malloc -_malloc_r -__mcmp -MD5Final -MD5Init -MD5Update -md5_vector -__mdiff -memccpy -memchr -memcmp -memcpy -MemDwnLdStartMsgProc -MemDwnLdStopReqMsgProc -memmove -MemPacketSendReqMsgProc -memrchr -memset -mktime -mmu_init -_mprec_log10 -__muldf3 -__multadd -__multiply -multofup -mz_adler32 -mz_crc32 -mz_free -nanf -__nedf2 -_NMIExceptionVector -open -_open_r -__pow5mult -printf -_printf_common -_printf_float -_printf_i -_printf_r -print_rom_meminfo -qsort -_raise_r -rand -rand_r -__ratio -RcvMsg -read -_read_r -realloc -_realloc_r -RecvBuff -recv_packet -_rename_r -_ResetHandler -_ResetVector -_rom_store -_rom_store_table -roundup2 -rtc_boot_control -rtc_get_reset_reason -rtc_get_wakeup_cause -rtc_select_apb_bridge -__s2b -sbrk -_sbrk_r -scanf -_scanf_chars -_scanf_float -_scanf_i -_scanf_r -__sccl -__sclose -SelectSpiFunction -SelectSpiQIO -SendMsg -send_packet -__seofread -setjmp -setlocale -_setlocale_r -sf_dump -__sflush_r -__sfmoreglue -__sfp -__sfp_lock_acquire -__sfp_lock_release -__sfputs_r -__sfvwrite_r -__sinit -__sinit_lock_acquire -__sinit_lock_release -sip_alloc_to_host_evt -sip_get_ptr -sip_get_state -sip_init_attach -sip_install_rx_ctrl_cb -sip_install_rx_data_cb -sip_post_init -sip_reclaim_from_host_cmd -sip_reclaim_tx_data_pkt -siprintf -_siprintf_r -sip_send -sip_to_host_chain_append -sip_to_host_evt_send_done -siscanf -_siscanf_r -slc_add_credits -slc_enable -slc_from_host_chain_fetch -slc_from_host_chain_recycle -slc_has_pkt_to_host -slc_init_attach -slc_init_credit -slc_reattach -slc_select_tohost_gpio -slc_select_tohost_gpio_mode -slc_send_to_host_chain -slc_set_host_io_max_window -slc_to_host_chain_recycle -__smakebuf_r -sniprintf -_sniprintf_r -snprintf -_snprintf_r -software_reset -software_reset_app_cpu -software_reset_pro_cpu -spi_cache_sram_init -SPIClkConfig -SPI_Common_Command -SPI_Encrypt_Write -SPIEraseArea -SPIEraseBlock -SPIEraseChip -SPIEraseSector -spi_flash_attach -SPILock -SPIMasterReadModeCnfig -SPIParamCfg -SPI_Prepare_Encrypt_Data -SPIRead -SPIReadModeCnfig -SPIUnlock -SPIWrite -SPI_Write_Encrypt_Disable -SPI_Write_Encrypt_Enable -sprintf -_sprintf_r -__sprint_r -srand -__sread -__srefill_r -sscanf -_sscanf_r -__sseek -__ssprint_r -__ssputs_r -__ssrefill_r -__ssvfiscanf_r -__ssvfscanf_r -__stack -__stack_app -_stack_sentry -_stack_sentry_app -_start -start_tb_console -_stat_r -_stext -strcasecmp -strcasestr -strcat -strchr -strcmp -strcoll -strcpy -strcspn -strdup -_strdup_r -strftime -strlcat -strlcpy -strlen -strlwr -strncasecmp -strncat -strncmp -strncpy -strndup -_strndup_r -strnlen -strrchr -strsep -strspn -strstr -strtod -_strtod_r -strtof -__strtok_r -strtok_r -strtol -_strtol_r -strtoul -_strtoul_r -strupr -__subdf3 -__submore -_sungetc_r -_svfiprintf_r -__svfiscanf_r -_svfprintf_r -__svfscanf -__svfscanf_r -__swbuf -__swbuf_r -__swrite -__swsetup_r -_SyscallException -syscall_table_ptr_app -syscall_table_ptr_pro -_system_r -tdefl_compress -tdefl_compress_buffer -tdefl_compress_mem_to_heap -tdefl_compress_mem_to_mem -tdefl_compress_mem_to_output -tdefl_get_adler32 -tdefl_get_prev_return_status -tdefl_init -tdefl_write_image_to_png_file_in_memory -tdefl_write_image_to_png_file_in_memory_ex -time -__time_load_locale -times -_times_r -_timezone -tinfl_decompress -tinfl_decompress_mem_to_callback -tinfl_decompress_mem_to_heap -tinfl_decompress_mem_to_mem -toascii -tolower -toupper -__truncdfsf2 -__tzcalc_limits -__tz_lock -tzset -_tzset_r -__tz_unlock -uartAttach -uart_baudrate_detect -uart_buff_switch -UartConnCheck -UartConnectProc -UartDev -uart_div_modify -UartDwnLdProc -UartGetCmdLn -Uart_Init -UartRegReadProc -UartRegWriteProc -uart_rx_intr_handler -uart_rx_one_char -uart_rx_one_char_block -uart_rx_readbuff -UartRxString -UartSetBaudProc -UartSpiAttachProc -UartSpiReadProc -uart_tx_flush -uart_tx_one_char -uart_tx_one_char2 -uart_tx_switch -uart_tx_wait_idle -__udivdi3 -__ulp -__umoddi3 -ungetc -_ungetc_r -_unlink_r -__unorddf2 -user_code_start -_UserExceptionVector -utoa -__utoa -vasiprintf -_vasiprintf_r -vasniprintf -_vasniprintf_r -vasnprintf -_vasnprintf_r -vasprintf -_vasprintf_r -VerifyFlashMd5Proc -vfiprintf -_vfiprintf_r -vfiscanf -_vfiscanf_r -vfprintf -_vfprintf_r -vfscanf -_vfscanf_r -viprintf -_viprintf_r -viscanf -_viscanf_r -vprintf -_vprintf_r -vscanf -_vscanf_r -vsiprintf -_vsiprintf_r -vsiscanf -_vsiscanf_r -vsniprintf -_vsniprintf_r -vsnprintf -_vsnprintf_r -vsprintf -_vsprintf_r -vsscanf -_vsscanf_r -wcrtomb -_wcrtomb_r -_wctomb_r -_WindowOverflow12 -_WindowOverflow4 -_WindowOverflow8 -_WindowUnderflow12 -_WindowUnderflow4 -_WindowUnderflow8 -write -_write_r -xthal_bcopy -xthal_copy123 -xthal_get_ccompare -xthal_get_ccount -xthal_get_interrupt -xthal_get_intread -xthal_memcpy -xthal_set_ccompare -xthal_set_intclear -_xtos_alloca_handler -_xtos_cause3_handler -_xtos_c_wrapper_handler -_xtos_ints_off -_xtos_ints_on -_xtos_l1int_handler -_xtos_p_none -_xtos_restore_intlevel -_xtos_return_from_exc -_xtos_set_exception_handler -_xtos_set_interrupt_handler -_xtos_set_interrupt_handler_arg -_xtos_set_intlevel -_xtos_set_min_intlevel -_xtos_set_vpri -_xtos_syscall_handler -_xtos_unhandled_exception -_xtos_unhandled_interrupt diff --git a/components/newlib/lib/fixlibc.sh b/components/newlib/lib/fixlibc.sh deleted file mode 100755 index 5a9e3fd00..000000000 --- a/components/newlib/lib/fixlibc.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -ROMELF=~/esp8266/esp32/rom_image/eagle.pro.rom.out - -rm -rf extracted -mkdir extracted -cd extracted -mkdir inrom -ar x ../libc.a -cp ../libc.a ../libc-minusrom.a - -nm $ROMELF | grep -e ' [TB] ' | cut -d ' ' -f 3- > romsyms - -for x in *.o; do - nm $x | grep -e ' [TB] ' | cut -d ' ' -f 3- | while read a; do - if [ -e "$x" ] && cat romsyms | grep -q '^'$a'$'; then - echo "$a found in rom" - mv $x inrom - ar -d ../libc-minusrom.a $x - fi - done -done - diff --git a/components/newlib/lib/libc-minusrom.a b/components/newlib/lib/libc-minusrom.a deleted file mode 100644 index 6f593d058..000000000 Binary files a/components/newlib/lib/libc-minusrom.a and /dev/null differ diff --git a/components/newlib/lib/libc.a b/components/newlib/lib/libc.a index 263a4d885..4377fa252 100644 Binary files a/components/newlib/lib/libc.a and b/components/newlib/lib/libc.a differ diff --git a/components/newlib/lib/libc_nano.a b/components/newlib/lib/libc_nano.a new file mode 100644 index 000000000..2a99a9c49 Binary files /dev/null and b/components/newlib/lib/libc_nano.a differ diff --git a/components/newlib/lib/libc_rom.a b/components/newlib/lib/libc_rom.a deleted file mode 100644 index e79ed8a92..000000000 Binary files a/components/newlib/lib/libc_rom.a and /dev/null differ diff --git a/components/newlib/lib/libg.a b/components/newlib/lib/libg.a index f583174f1..27bf971e0 100644 Binary files a/components/newlib/lib/libg.a and b/components/newlib/lib/libg.a differ diff --git a/components/newlib/lib/libm.a b/components/newlib/lib/libm.a index f3fe6dab3..aa683ac0b 100644 Binary files a/components/newlib/lib/libm.a and b/components/newlib/lib/libm.a differ diff --git a/components/newlib/syscall_table.c b/components/newlib/syscall_table.c index feed76817..624ffcffa 100644 --- a/components/newlib/syscall_table.c +++ b/components/newlib/syscall_table.c @@ -25,6 +25,7 @@ #include "rom/libc_stubs.h" #include "esp_vfs.h" #include "esp_newlib.h" +#include "sdkconfig.h" static struct _reent s_reent; @@ -76,8 +77,13 @@ static struct syscall_stub_table s_stub_table = { ._lock_try_acquire_recursive = &_lock_try_acquire_recursive, ._lock_release = &_lock_release, ._lock_release_recursive = &_lock_release_recursive, +#ifdef CONFIG_NEWLIB_NANO_FORMAT ._printf_float = &_printf_float, ._scanf_float = &_scanf_float, +#else + ._printf_float = NULL, + ._scanf_float = NULL, +#endif }; void esp_setup_syscall_table() diff --git a/components/newlib/test/test_newlib.c b/components/newlib/test/test_newlib.c index b498b4bd4..1d86cd4a9 100644 --- a/components/newlib/test/test_newlib.c +++ b/components/newlib/test/test_newlib.c @@ -1,10 +1,11 @@ #include +#include #include #include #include #include #include "unity.h" - +#include "sdkconfig.h" TEST_CASE("test ctype functions", "[newlib]") { @@ -22,6 +23,10 @@ TEST_CASE("test atoX functions", "[newlib]") TEST_ASSERT_EQUAL_INT(2147483647, atoi("2147483647")); TEST_ASSERT_EQUAL_INT(42, atoi("000000042")); TEST_ASSERT_EQUAL_INT(0, strtol("foo", NULL, 10)); + TEST_ASSERT_EQUAL(0.123443, atof("0.123443")); + TEST_ASSERT_EQUAL(0.123443f, atoff("0.123443")); + TEST_ASSERT_EQUAL(31.41238, strtod("0.3141238e2", NULL)); + TEST_ASSERT_EQUAL(0.025f, strtof("0.025", NULL)); } TEST_CASE("test sprintf function", "[newlib]") @@ -81,22 +86,64 @@ TEST_CASE("test time functions", "[newlib]") } -static int checkFnRom(void *fn, char *name) +static bool fn_in_rom(void *fn, char *name) { - int fnaddr = (int)fn; - printf("%s: 0X%x\n", name, fnaddr); - if ((fnaddr >= 0x40000000) && (fnaddr < 0x40070000)) { - return 1; - } else { - return 0; - } + const int fnaddr = (int)fn; + return (fnaddr >= 0x40000000) && (fnaddr < 0x40070000); } -TEST_CASE("check if ROM is used for functions", "[newlib]") +TEST_CASE("check if ROM or Flash is used for functions", "[newlib]") { - TEST_ASSERT(checkFnRom(printf, "printf")); - TEST_ASSERT(checkFnRom(sscanf, "sscanf")); - TEST_ASSERT(checkFnRom(atoi, "atoi")); - TEST_ASSERT(checkFnRom(strtol, "strtol")); -} \ No newline at end of file +#ifdef CONFIG_NEWLIB_NANO_FORMAT + TEST_ASSERT(fn_in_rom(printf, "printf")); + TEST_ASSERT(fn_in_rom(sscanf, "sscanf")); +#else + TEST_ASSERT_FALSE(fn_in_rom(printf, "printf")); + TEST_ASSERT_FALSE(fn_in_rom(sscanf, "sscanf")); +#endif + TEST_ASSERT(fn_in_rom(atoi, "atoi")); + TEST_ASSERT(fn_in_rom(strtol, "strtol")); +} + +#ifndef CONFIG_NEWLIB_NANO_FORMAT +TEST_CASE("test 64bit int formats", "[newlib]") +{ + char* res = NULL; + const uint64_t val = 123456789012LL; + + asprintf(&res, "%llu", val); + TEST_ASSERT_NOT_NULL(res); + TEST_ASSERT_EQUAL_STRING("123456789012", res); + + uint64_t sval; + int ret = sscanf(res, "%llu", &sval); + free(res); + + TEST_ASSERT_EQUAL(1, ret); + TEST_ASSERT_EQUAL(val, sval); +} +#else +TEST_CASE("test 64bit int formats", "[newlib]") +{ + char* res = NULL; + const uint64_t val = 123456789012LL; + + asprintf(&res, "%llu", val); + TEST_ASSERT_NOT_NULL(res); + TEST_ASSERT_EQUAL_STRING("lu", res); + + uint64_t sval; + int ret = sscanf(res, "%llu", &sval); + free(res); + + TEST_ASSERT_EQUAL(0, ret); +} +#endif + + +TEST_CASE("fmod and fmodf work as expected", "[newlib]") +{ + TEST_ASSERT_EQUAL(0.1, fmod(10.1, 2.0)); + TEST_ASSERT_EQUAL(0.1f, fmodf(10.1f, 2.0f)); +}