Skip to content

Commit 0799f78

Browse files
committed
more IRAM_ATTR fixes
1 parent 0e9b2e5 commit 0799f78

8 files changed

+50
-44
lines changed

cores/esp8266/LwipDhcpServer.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,13 @@ void DhcpServer::send_nak(struct dhcps_msg* m)
496496
#endif
497497
return;
498498
}
499-
LWIP_IS_OK("dhcps send nak", udp_sendto(pcb_dhcps, p, &broadcast_dhcps, DHCPS_CLIENT_PORT));
499+
if (!LWIP_IS_OK("dhcps send nak",
500+
udp_sendto(pcb_dhcps, p, &broadcast_dhcps, DHCPS_CLIENT_PORT)))
501+
{
502+
#if DHCPS_DEBUG
503+
os_printf("dhcps: send_nak>>udp_sendto failed\n");
504+
#endif
505+
}
500506
if (p->ref != 0)
501507
{
502508
#if DHCPS_DEBUG

cores/esp8266/WString.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#define String_class_h
2424
#ifdef __cplusplus
2525

26-
#include <pgmspace.h>
26+
#include <sys/pgmspace.h>
2727

2828
#include <cstdlib>
2929
#include <cstdint>

cores/esp8266/core_esp8266_phy.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,9 @@ static const uint8_t ICACHE_FLASH_ATTR phy_init_data[128] =
299299

300300
static bool spoof_init_data = false;
301301

302-
extern int __real_spi_flash_read(uint32_t addr, uint32_t* dst, size_t size);
303-
extern int IRAM_ATTR __wrap_spi_flash_read(uint32_t addr, uint32_t* dst, size_t size);
304-
extern int __get_adc_mode();
302+
int __real_spi_flash_read(uint32_t addr, uint32_t* dst, size_t size);
303+
int __wrap_spi_flash_read(uint32_t addr, uint32_t* dst, size_t size);
304+
int __get_adc_mode();
305305

306306
/*
307307
Verified that the wide filtering of all 128 byte flash reads during
@@ -314,7 +314,7 @@ extern int __get_adc_mode();
314314
flash read 0xFB000 128 // PHY_DATA (EEPROM address space)
315315
flash read 0xFC000 628 // RC_CAL
316316
*/
317-
extern int IRAM_ATTR __wrap_spi_flash_read(uint32_t addr, uint32_t* dst, size_t size)
317+
int IRAM_ATTR __wrap_spi_flash_read(uint32_t addr, uint32_t* dst, size_t size)
318318
{
319319
if (!spoof_init_data || size != 128) {
320320
return __real_spi_flash_read(addr, dst, size);
@@ -328,20 +328,20 @@ extern int IRAM_ATTR __wrap_spi_flash_read(uint32_t addr, uint32_t* dst, size_t
328328
return 0;
329329
}
330330

331-
extern int __get_rf_mode(void) __attribute__((weak));
332-
extern int __get_rf_mode(void)
331+
int __get_rf_mode(void) __attribute__((weak));
332+
int __get_rf_mode(void)
333333
{
334334
return -1; // mode not set
335335
}
336336

337-
extern int __get_adc_mode(void) __attribute__((weak));
338-
extern int __get_adc_mode(void)
337+
int __get_adc_mode(void) __attribute__((weak));
338+
int __get_adc_mode(void)
339339
{
340340
return 33; // default ADC mode
341341
}
342342

343-
extern void __run_user_rf_pre_init(void) __attribute__((weak));
344-
extern void __run_user_rf_pre_init(void)
343+
void __run_user_rf_pre_init(void) __attribute__((weak));
344+
void __run_user_rf_pre_init(void)
345345
{
346346
return; // default do nothing
347347
}
@@ -376,4 +376,4 @@ void user_rf_pre_init()
376376

377377
void IRAM_ATTR user_spi_flash_dio_to_qio_pre_init() {}
378378

379-
};
379+
} // extern "C"

cores/esp8266/core_esp8266_si2c.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -136,23 +136,23 @@ class Twi
136136
ETSTimer timer;
137137

138138
// Event/IRQ callbacks, so they can't use "this" and need to be static
139-
static void IRAM_ATTR onSclChange(void);
140-
static void IRAM_ATTR onSdaChange(void);
141-
static void eventTask(ETSEvent* e);
142-
static void IRAM_ATTR onTimer(void* unused);
139+
static void onSclChange(void);
140+
static void onSdaChange(void);
141+
static void eventTask(ETSEvent* e);
142+
static void onTimer(void* unused);
143143

144144
// Allow not linking in the slave code if there is no call to setAddress
145145
bool _slaveEnabled = false;
146146

147147
// Internal use functions
148-
void IRAM_ATTR busywait(unsigned int v);
149-
bool write_start(void);
150-
bool write_stop(void);
151-
bool write_bit(bool bit);
152-
bool read_bit(void);
153-
bool write_byte(unsigned char byte);
154-
unsigned char read_byte(bool nack);
155-
void IRAM_ATTR onTwipEvent(uint8_t status);
148+
void busywait(unsigned int v);
149+
bool write_start(void);
150+
bool write_stop(void);
151+
bool write_bit(bool bit);
152+
bool read_bit(void);
153+
bool write_byte(unsigned char byte);
154+
uint8_t read_byte(bool nack);
155+
void onTwipEvent(uint8_t status);
156156

157157
// Handle the case where a slave needs to stretch the clock with a time-limited busy wait
158158
inline void WAIT_CLOCK_STRETCH()
@@ -185,8 +185,8 @@ class Twi
185185
uint8_t transmit(const uint8_t* data, uint8_t length);
186186
void attachSlaveRxEvent(void (*function)(uint8_t*, size_t));
187187
void attachSlaveTxEvent(void (*function)(void));
188-
void IRAM_ATTR reply(uint8_t ack);
189-
void IRAM_ATTR releaseBus(void);
188+
void reply(uint8_t ack);
189+
void releaseBus(void);
190190
void enableSlave();
191191
};
192192

cores/esp8266/core_esp8266_waveform_phase.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ extern "C" void enablePhaseLockedWaveform (void)
5555

5656
// No-op calls to override the PWM implementation
5757
extern "C" void _setPWMFreq_weak(uint32_t freq) { (void) freq; }
58-
extern "C" IRAM_ATTR bool _stopPWM_weak(int pin) { (void) pin; return false; }
58+
extern "C" bool _stopPWM_weak(int pin) { (void) pin; return false; }
5959
extern "C" bool _setPWM_weak(int pin, uint32_t val, uint32_t range) { (void) pin; (void) val; (void) range; return false; }
6060

6161

@@ -111,7 +111,7 @@ namespace {
111111
}
112112

113113
// Interrupt on/off control
114-
static IRAM_ATTR void timer1Interrupt();
114+
static void timer1Interrupt();
115115

116116
// Non-speed critical bits
117117
#pragma GCC optimize ("Os")
@@ -218,7 +218,7 @@ int startWaveformClockCycles_weak(uint8_t pin, uint32_t highCcys, uint32_t lowCc
218218
}
219219

220220
// Stops a waveform on a pin
221-
IRAM_ATTR int stopWaveform_weak(uint8_t pin) {
221+
int IRAM_ATTR stopWaveform_weak(uint8_t pin) {
222222
// Can't possibly need to stop anything if there is no timer active
223223
if (!waveform.timer1Running) {
224224
return false;

cores/esp8266/core_esp8266_waveform_pwm.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static WVFState wvfState;
9494
#pragma GCC optimize ("Os")
9595

9696
// Interrupt on/off control
97-
static IRAM_ATTR void timer1Interrupt();
97+
static void timer1Interrupt();
9898
static bool timerRunning = false;
9999

100100
static __attribute__((noinline)) void initTimer() {
@@ -108,7 +108,7 @@ static __attribute__((noinline)) void initTimer() {
108108
}
109109
}
110110

111-
static IRAM_ATTR void forceTimerInterrupt() {
111+
static void IRAM_ATTR forceTimerInterrupt() {
112112
if (T1L > microsecondsToClockCycles(10)) {
113113
T1L = microsecondsToClockCycles(10);
114114
}
@@ -145,7 +145,7 @@ static uint32_t _pwmPeriod = microsecondsToClockCycles(1000000UL) / _pwmFreq;
145145

146146
// If there are no more scheduled activities, shut down Timer 1.
147147
// Otherwise, do nothing.
148-
static IRAM_ATTR void disableIdleTimer() {
148+
static void IRAM_ATTR disableIdleTimer() {
149149
if (timerRunning && !wvfState.waveformEnabled && !pwmState.cnt && !wvfState.timer1CB) {
150150
ETS_FRC_TIMER1_NMI_INTR_ATTACH(NULL);
151151
timer1_disable();
@@ -156,7 +156,7 @@ static IRAM_ATTR void disableIdleTimer() {
156156

157157
// Notify the NMI that a new PWM state is available through the mailbox.
158158
// Wait for mailbox to be emptied (either busy or delay() as needed)
159-
static IRAM_ATTR void _notifyPWM(PWMState *p, bool idle) {
159+
static void IRAM_ATTR _notifyPWM(PWMState *p, bool idle) {
160160
p->pwmUpdate = nullptr;
161161
pwmState.pwmUpdate = p;
162162
MEMBARRIER();
@@ -238,7 +238,7 @@ static void _cleanAndRemovePWM(PWMState *p, int pin) {
238238

239239
// Disable PWM on a specific pin (i.e. when a digitalWrite or analogWrite(0%/100%))
240240
extern bool _stopPWM_weak(uint8_t pin) __attribute__((weak));
241-
IRAM_ATTR bool _stopPWM_weak(uint8_t pin) {
241+
bool IRAM_ATTR _stopPWM_weak(uint8_t pin) {
242242
if (!((1<<pin) & pwmState.mask)) {
243243
return false; // Pin not actually active
244244
}
@@ -261,7 +261,7 @@ IRAM_ATTR bool _stopPWM_weak(uint8_t pin) {
261261
return true;
262262
}
263263
static bool _stopPWM_bound(uint8_t pin) __attribute__((weakref("_stopPWM_weak")));
264-
IRAM_ATTR bool _stopPWM(uint8_t pin) {
264+
bool IRAM_ATTR _stopPWM(uint8_t pin) {
265265
return _stopPWM_bound(pin);
266266
}
267267

@@ -431,7 +431,7 @@ void setTimer1Callback(uint32_t (*fn)()) {
431431

432432
// Stops a waveform on a pin
433433
extern int stopWaveform_weak(uint8_t pin) __attribute__((weak));
434-
IRAM_ATTR int stopWaveform_weak(uint8_t pin) {
434+
int IRAM_ATTR stopWaveform_weak(uint8_t pin) {
435435
// Can't possibly need to stop anything if there is no timer active
436436
if (!timerRunning) {
437437
return false;
@@ -455,7 +455,7 @@ IRAM_ATTR int stopWaveform_weak(uint8_t pin) {
455455
return true;
456456
}
457457
static int stopWaveform_bound(uint8_t pin) __attribute__((weakref("stopWaveform_weak")));
458-
IRAM_ATTR int stopWaveform(uint8_t pin) {
458+
int IRAM_ATTR stopWaveform(uint8_t pin) {
459459
return stopWaveform_bound(pin);
460460
}
461461

@@ -465,14 +465,14 @@ IRAM_ATTR int stopWaveform(uint8_t pin) {
465465
// Normally would not want two copies like this, but due to different
466466
// optimization levels the inline attribute gets lost if we try the
467467
// other version.
468-
static inline IRAM_ATTR uint32_t GetCycleCountIRQ() {
468+
static inline uint32_t IRAM_ATTR GetCycleCountIRQ() {
469469
uint32_t ccount;
470470
__asm__ __volatile__("rsr %0,ccount":"=a"(ccount));
471471
return ccount;
472472
}
473473

474474
// Find the earliest cycle as compared to right now
475-
static inline IRAM_ATTR uint32_t earliest(uint32_t a, uint32_t b) {
475+
static inline uint32_t IRAM_ATTR earliest(uint32_t a, uint32_t b) {
476476
uint32_t now = GetCycleCountIRQ();
477477
int32_t da = a - now;
478478
int32_t db = b - now;
@@ -497,7 +497,7 @@ static inline IRAM_ATTR uint32_t earliest(uint32_t a, uint32_t b) {
497497
// When the time to the next edge is greater than this, RTI and set another IRQ to minimize CPU usage
498498
#define MINIRQTIME microsecondsToClockCycles(4)
499499

500-
static IRAM_ATTR void timer1Interrupt() {
500+
static void IRAM_ATTR timer1Interrupt() {
501501
// Flag if the core is at 160 MHz, for use by adjust()
502502
bool turbo = (*(uint32_t*)0x3FF00014) & 1 ? true : false;
503503

cores/esp8266/mmu_iram.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ DBG_MMU_FLUSH(0)
109109
* in IROM, review printing method and comments in hwdt_app_entry.cpp.
110110
*
111111
*/
112-
void IRAM_ATTR mmu_wrap_irom_fn(void (*fn)(void));
112+
void mmu_wrap_irom_fn(void (*fn)(void));
113113

114114
static inline __attribute__((always_inline))
115115
bool mmu_is_iram(const void *addr) {

cores/esp8266/umm_malloc/umm_local.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ static bool check_poison_neighbors(umm_heap_context_t *_context, uint16_t cur);
5050

5151

5252
#if defined(UMM_STATS) || defined(UMM_STATS_FULL)
53-
void ICACHE_FLASH_ATTR umm_print_stats(int force);
53+
void umm_print_stats(int force);
5454
#endif
5555

5656

5757

58-
int ICACHE_FLASH_ATTR umm_info_safe_printf_P(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
58+
int umm_info_safe_printf_P(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
5959
#define UMM_INFO_PRINTF(fmt, ...) umm_info_safe_printf_P(PSTR(fmt),##__VA_ARGS__)
6060

6161

0 commit comments

Comments
 (0)