Use own implementation instead of ROM functions, re-add memchr (#2896)

* Use own implementation instead of ROM functions, re-add memchr ROM function

* CHANGELOG.md

* Improve

* Cast
This commit is contained in:
Björn Quentin 2025-01-08 08:12:04 +01:00 committed by GitHub
parent 5a64d9ba8f
commit 6b4312fb90
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 30 additions and 16 deletions

View File

@ -16,5 +16,5 @@ PROVIDE ( strchr = 0x4000c53c );
PROVIDE ( strlcpy = 0x4000c584 ); PROVIDE ( strlcpy = 0x4000c584 );
PROVIDE ( strstr = 0x4000c674 ); PROVIDE ( strstr = 0x4000c674 );
PROVIDE ( strcasecmp = 0x400011cc ); PROVIDE ( strcasecmp = 0x400011cc );
PROVIDE ( strdup = 0x4000143c );
PROVIDE ( atoi = 0x400566c4 ); PROVIDE ( memchr = 0x4000c244 );

View File

@ -13,5 +13,3 @@ PROVIDE ( strchr = 0x40000514 );
PROVIDE ( strlcpy = 0x40000524 ); PROVIDE ( strlcpy = 0x40000524 );
PROVIDE ( strstr = 0x400004ac ); PROVIDE ( strstr = 0x400004ac );
PROVIDE ( strcasecmp = 0x40000504 ); PROVIDE ( strcasecmp = 0x40000504 );
PROVIDE ( strdup = 0x40000510 );
PROVIDE ( atoi = 0x40000580 );

View File

@ -17,5 +17,5 @@ PROVIDE( strchr = 0x400003e0 );
PROVIDE( strlcpy = 0x400003f0 ); PROVIDE( strlcpy = 0x400003f0 );
PROVIDE( strstr = 0x40000378 ); PROVIDE( strstr = 0x40000378 );
PROVIDE( strcasecmp = 0x400003d0 ); PROVIDE( strcasecmp = 0x400003d0 );
PROVIDE( strdup = 0x400003dc );
PROVIDE( atoi = 0x4000044c ); PROVIDE( memchr = 0x400003c8 );

View File

@ -15,5 +15,3 @@ PROVIDE(strchr = 0x40000534);
PROVIDE(strlcpy = 0x40000544); PROVIDE(strlcpy = 0x40000544);
PROVIDE(strstr = 0x400004cc); PROVIDE(strstr = 0x400004cc);
PROVIDE(strcasecmp = 0x40000524); PROVIDE(strcasecmp = 0x40000524);
PROVIDE(strdup = 0x40000530);
PROVIDE(atoi = 0x400005a0);

View File

@ -15,5 +15,5 @@ PROVIDE( strchr = 0x4000052c );
PROVIDE( strlcpy = 0x4000053c ); PROVIDE( strlcpy = 0x4000053c );
PROVIDE( strstr = 0x400004c4 ); PROVIDE( strstr = 0x400004c4 );
PROVIDE( strcasecmp = 0x4000051c ); PROVIDE( strcasecmp = 0x4000051c );
PROVIDE( strdup = 0x40000528 );
PROVIDE( atoi = 0x40000598 ); PROVIDE( memchr = 0x40000514 );

View File

@ -17,4 +17,3 @@ PROVIDE ( strchr = 0x4001adb0 );
PROVIDE ( strlcpy = 0x4001adf8 ); PROVIDE ( strlcpy = 0x4001adf8 );
PROVIDE ( strstr = 0x4001aee8 ); PROVIDE ( strstr = 0x4001aee8 );
PROVIDE ( strcasecmp = 0x40007b38 ); PROVIDE ( strcasecmp = 0x40007b38 );
PROVIDE ( strdup = 0x40007d84 );

View File

@ -19,5 +19,3 @@ PROVIDE( strchr = 0x4000138c );
PROVIDE( strlcpy = 0x400013bc ); PROVIDE( strlcpy = 0x400013bc );
PROVIDE( strstr = 0x40001254 ); PROVIDE( strstr = 0x40001254 );
PROVIDE( strcasecmp = 0x4000135c ); PROVIDE( strcasecmp = 0x4000135c );
PROVIDE( strdup = 0x40001380 );
PROVIDE( atoi = 0x400014d0 );

View File

@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- Fixed triggering a debug-assertion during scan (#2612) - Fixed triggering a debug-assertion during scan (#2612)
- Fix WPA2-ENTERPRISE functionality (#2896)
### Removed ### Removed

View File

@ -1,5 +1,6 @@
// these are not called but needed for linking use crate::compat::malloc::malloc;
// these are not called but needed for linking
#[no_mangle] #[no_mangle]
unsafe extern "C" fn fwrite(ptr: *const (), size: usize, count: usize, stream: *const ()) -> usize { unsafe extern "C" fn fwrite(ptr: *const (), size: usize, count: usize, stream: *const ()) -> usize {
todo!("fwrite {:?} {} {} {:?}", ptr, size, count, stream) todo!("fwrite {:?} {} {} {:?}", ptr, size, count, stream)
@ -20,8 +21,27 @@ unsafe extern "C" fn fclose(stream: *const ()) -> i32 {
todo!("fclose {:?}", stream); todo!("fclose {:?}", stream);
} }
// not available in ROM on ESP32-S2 // We cannot just use the ROM function since it needs to allocate memory
#[cfg(feature = "esp32s2")] #[no_mangle]
unsafe extern "C" fn strdup(str: *const core::ffi::c_char) -> *const core::ffi::c_char {
trace!("strdup {:?}", str);
unsafe {
let s = core::ffi::CStr::from_ptr(str);
let len = s.count_bytes() + 1;
let p = malloc(len);
if !p.is_null() {
core::ptr::copy_nonoverlapping(str, p.cast(), len);
}
p.cast()
}
}
// We cannot just use the ROM function since it calls `__getreent`
//
// From docs: The __getreent() function returns a per-task pointer to struct
// _reent in newlib libc. This structure is allocated on the TCB of each task.
// i.e. it assumes a FreeRTOS task calling it.
#[no_mangle] #[no_mangle]
unsafe extern "C" fn atoi(str: *const i8) -> i32 { unsafe extern "C" fn atoi(str: *const i8) -> i32 {
trace!("atoi {:?}", str); trace!("atoi {:?}", str);