cpu/*: replace #if ENABLE_DEBUG with IS_ACTIVE
This commit is contained in:
parent
2d3d047fd6
commit
94171b7389
@ -203,10 +203,10 @@ static int _esp_eth_send(netdev_t *netdev, const iolist_t *iolist)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||||
printf ("%s: send %d byte\n", __func__, dev->tx_len);
|
printf ("%s: send %d byte\n", __func__, dev->tx_len);
|
||||||
/* esp_hexdump (dev->tx_buf, dev->tx_len, 'b', 16); */
|
/* esp_hexdump (dev->tx_buf, dev->tx_len, 'b', 16); */
|
||||||
#endif
|
}
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
@ -253,9 +253,9 @@ static int _esp_eth_recv(netdev_t *netdev, void *buf, size_t len, void *info)
|
|||||||
return -ENOBUFS;
|
return -ENOBUFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||||
/* esp_hexdump (dev->rx_buf, dev->rx_len, 'b', 16); */
|
esp_hexdump (dev->rx_buf, dev->rx_len, 'b', 16);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
/* copy received date and reset the receive length */
|
/* copy received date and reset the receive length */
|
||||||
memcpy(buf, dev->rx_buf, dev->rx_len);
|
memcpy(buf, dev->rx_buf, dev->rx_len);
|
||||||
|
|||||||
@ -316,13 +316,14 @@ unsigned int IRAM timer_read(tim_t dev)
|
|||||||
{
|
{
|
||||||
CHECK_PARAM_RET (dev < HW_TIMER_NUMOF, -1);
|
CHECK_PARAM_RET (dev < HW_TIMER_NUMOF, -1);
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||||
uint32_t count_lo = timer_get_counter_lo(dev);
|
uint32_t count_lo = timer_get_counter_lo(dev);
|
||||||
DEBUG("%s %u\n", __func__, count_lo);
|
DEBUG("%s %u\n", __func__, count_lo);
|
||||||
return count_lo;
|
return count_lo;
|
||||||
#else
|
}
|
||||||
return timer_get_counter_lo(dev);
|
else {
|
||||||
#endif
|
return timer_get_counter_lo(dev);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM timer_start(tim_t dev)
|
void IRAM timer_start(tim_t dev)
|
||||||
|
|||||||
@ -167,30 +167,30 @@ NORETURN void IRAM call_start_cpu0 (void)
|
|||||||
rtc_clk_apb_freq_get(), rtc_clk_xtal_freq_get()*MHZ,
|
rtc_clk_apb_freq_get(), rtc_clk_xtal_freq_get()*MHZ,
|
||||||
rtc_clk_slow_freq_get_hz());
|
rtc_clk_slow_freq_get_hz());
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||||
ets_printf("reset reason: %d\n", reset_reason);
|
ets_printf("reset reason: %d\n", reset_reason);
|
||||||
ets_printf("_stack %p\n", sp);
|
ets_printf("_stack %p\n", sp);
|
||||||
ets_printf("_bss_start %p\n", &_bss_start);
|
ets_printf("_bss_start %p\n", &_bss_start);
|
||||||
ets_printf("_bss_end %p\n", &_bss_end);
|
ets_printf("_bss_end %p\n", &_bss_end);
|
||||||
#ifndef MODULE_ESP_IDF_HEAP
|
if (!IS_ACTIVE(MODULE_ESP_IDF_HEAP)) {
|
||||||
ets_printf("_heap_start %p\n", &_sheap);
|
ets_printf("_heap_start %p\n", &_sheap);
|
||||||
ets_printf("_heap_end %p\n", &_eheap);
|
ets_printf("_heap_end %p\n", &_eheap);
|
||||||
ets_printf("_heap_free %u\n", get_free_heap_size());
|
ets_printf("_heap_free %u\n", get_free_heap_size());
|
||||||
#endif /* MODULE_ESP_IDF_HEAP */
|
}
|
||||||
#endif /* ENABLE_DEBUG */
|
}
|
||||||
|
|
||||||
LOG_STARTUP("PRO cpu is up (single core mode, only PRO cpu is used)\n");
|
LOG_STARTUP("PRO cpu is up (single core mode, only PRO cpu is used)\n");
|
||||||
|
|
||||||
/* disable APP cpu */
|
/* disable APP cpu */
|
||||||
DPORT_CLEAR_PERI_REG_MASK(DPORT_APPCPU_CTRL_B_REG, DPORT_APPCPU_CLKGATE_EN);
|
DPORT_CLEAR_PERI_REG_MASK(DPORT_APPCPU_CTRL_B_REG, DPORT_APPCPU_CLKGATE_EN);
|
||||||
|
|
||||||
#ifdef MODULE_ESP_IDF_HEAP
|
if (IS_ACTIVE(MODULE_ESP_IDF_HEAP)) {
|
||||||
/* init heap */
|
/* init heap */
|
||||||
heap_caps_init();
|
heap_caps_init();
|
||||||
#if ENABLE_DEBUG
|
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||||
ets_printf("Heap free: %u byte\n", get_free_heap_size());
|
ets_printf("Heap free: %u byte\n", get_free_heap_size());
|
||||||
#endif /* ENABLE_DEBUG */
|
}
|
||||||
#endif /* MODULE_ESP_IDF_HEAP */
|
}
|
||||||
|
|
||||||
/* init SPI RAM if enabled */
|
/* init SPI RAM if enabled */
|
||||||
#if CONFIG_SPIRAM_SUPPORT && CONFIG_SPIRAM_BOOT_INIT
|
#if CONFIG_SPIRAM_SUPPORT && CONFIG_SPIRAM_BOOT_INIT
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
#include "esp_heap_trace.h"
|
#include "esp_heap_trace.h"
|
||||||
#include "priv/esp_heap_caps_priv.h"
|
#include "priv/esp_heap_caps_priv.h"
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
#if IS_ACTIVE(ENABLE_DEBUG)
|
||||||
#define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE
|
#define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -154,12 +154,12 @@ static void IRAM_ATTR esp_now_scan_peers_done(void)
|
|||||||
critical_exit_var(state);
|
critical_exit_var(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||||
esp_now_peer_num_t peer_num;
|
esp_now_peer_num_t peer_num;
|
||||||
esp_now_get_peer_num(&peer_num);
|
esp_now_get_peer_num(&peer_num);
|
||||||
DEBUG("associated peers total=%d, encrypted=%d\n",
|
DEBUG("associated peers total=%d, encrypted=%d\n",
|
||||||
peer_num.total_num, peer_num.encrypt_num);
|
peer_num.total_num, peer_num.encrypt_num);
|
||||||
#endif /* ENABLE_DEBUG */
|
}
|
||||||
|
|
||||||
_esp_now_scan_peers_done = true;
|
_esp_now_scan_peers_done = true;
|
||||||
|
|
||||||
|
|||||||
@ -594,12 +594,13 @@ static int _esp_wifi_send(netdev_t *netdev, const iolist_t *iolist)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||||
ESP_WIFI_DEBUG("send %d byte", dev->tx_len);
|
ESP_WIFI_DEBUG("send %d byte", dev->tx_len);
|
||||||
#if MODULE_OD && ENABLE_DEBUG_HEXDUMP
|
if (IS_ACTIVE(ENABLE_DEBUG_HEXDUMP) && IS_USED(MODULE_OD)) {
|
||||||
od_hex_dump(dev->tx_buf, dev->tx_len, OD_WIDTH_DEFAULT);
|
od_hex_dump(dev->tx_buf, dev->tx_len, OD_WIDTH_DEFAULT);
|
||||||
#endif /* MODULE_OD && ENABLE_DEBUG_HEXDUMP */
|
}
|
||||||
#endif
|
}
|
||||||
|
|
||||||
critical_exit();
|
critical_exit();
|
||||||
|
|
||||||
#ifdef MODULE_ESP_WIFI_AP
|
#ifdef MODULE_ESP_WIFI_AP
|
||||||
@ -665,15 +666,15 @@ static int _esp_wifi_recv(netdev_t *netdev, void *buf, size_t len, void *info)
|
|||||||
ringbuffer_remove(&dev->rx_buf, sizeof(uint16_t));
|
ringbuffer_remove(&dev->rx_buf, sizeof(uint16_t));
|
||||||
ringbuffer_get(&dev->rx_buf, buf, size);
|
ringbuffer_get(&dev->rx_buf, buf, size);
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||||
ethernet_hdr_t *hdr = (ethernet_hdr_t *)buf;
|
ethernet_hdr_t *hdr = (ethernet_hdr_t *)buf;
|
||||||
|
ESP_WIFI_DEBUG("received %u byte from addr " MAC_STR,
|
||||||
|
size, MAC_STR_ARG(hdr->src));
|
||||||
|
|
||||||
ESP_WIFI_DEBUG("received %u byte from addr " MAC_STR,
|
if (IS_ACTIVE(ENABLE_DEBUG_HEXDUMP) && IS_USED(MODULE_OD)) {
|
||||||
size, MAC_STR_ARG(hdr->src));
|
od_hex_dump(buf, size, OD_WIDTH_DEFAULT);
|
||||||
#if MODULE_OD && ENABLE_DEBUG_HEXDUMP
|
}
|
||||||
od_hex_dump(buf, size, OD_WIDTH_DEFAULT);
|
}
|
||||||
#endif /* MODULE_OD && ENABLE_DEBUG_HEXDUMP */
|
|
||||||
#endif /* ENABLE_DEBUG */
|
|
||||||
|
|
||||||
critical_exit();
|
critical_exit();
|
||||||
return size;
|
return size;
|
||||||
|
|||||||
@ -488,15 +488,15 @@ void IRAM_ATTR spi_transfer_bytes(spi_t bus, spi_cs_t cs, bool cont,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||||
if (out) {
|
if (out) {
|
||||||
DEBUG("out = ");
|
DEBUG("out = ");
|
||||||
for (size_t i = 0; i < len; i++) {
|
for (size_t i = 0; i < len; i++) {
|
||||||
DEBUG("%02x ", ((const uint8_t *)out)[i]);
|
DEBUG("%02x ", ((const uint8_t *)out)[i]);
|
||||||
|
}
|
||||||
|
DEBUG("\n");
|
||||||
}
|
}
|
||||||
DEBUG("\n");
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (cs != SPI_CS_UNDEF) {
|
if (cs != SPI_CS_UNDEF) {
|
||||||
gpio_clear(cs);
|
gpio_clear(cs);
|
||||||
@ -524,13 +524,13 @@ void IRAM_ATTR spi_transfer_bytes(spi_t bus, spi_cs_t cs, bool cont,
|
|||||||
gpio_set (cs);
|
gpio_set (cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||||
if (in) {
|
if (in) {
|
||||||
DEBUG("in = ");
|
DEBUG("in = ");
|
||||||
for (size_t i = 0; i < len; i++) {
|
for (size_t i = 0; i < len; i++) {
|
||||||
DEBUG("%02x ", ((const uint8_t *)in)[i]);
|
DEBUG("%02x ", ((const uint8_t *)in)[i]);
|
||||||
|
}
|
||||||
|
DEBUG("\n");
|
||||||
}
|
}
|
||||||
DEBUG("\n");
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,7 +48,7 @@ static inline void eeprom_native_write(void)
|
|||||||
DEBUG("Writing data to EEPROM file %s:\n", eeprom_file);
|
DEBUG("Writing data to EEPROM file %s:\n", eeprom_file);
|
||||||
fwrite(_eeprom_buf, 1, ARRAY_SIZE(_eeprom_buf), fp);
|
fwrite(_eeprom_buf, 1, ARRAY_SIZE(_eeprom_buf), fp);
|
||||||
|
|
||||||
if (ENABLE_DEBUG) {
|
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(_eeprom_buf); i++) {
|
for (size_t i = 0; i < ARRAY_SIZE(_eeprom_buf); i++) {
|
||||||
DEBUG("0x%02X ", _eeprom_buf[i]);
|
DEBUG("0x%02X ", _eeprom_buf[i]);
|
||||||
if ((i + 1) % 16 == 0) {
|
if ((i + 1) % 16 == 0) {
|
||||||
@ -69,7 +69,7 @@ void eeprom_native_read(void)
|
|||||||
|
|
||||||
DEBUG("Reading data from EEPROM file %s:\n", eeprom_file);
|
DEBUG("Reading data from EEPROM file %s:\n", eeprom_file);
|
||||||
fread(_eeprom_buf, 1, ARRAY_SIZE(_eeprom_buf), fp);
|
fread(_eeprom_buf, 1, ARRAY_SIZE(_eeprom_buf), fp);
|
||||||
if (ENABLE_DEBUG) {
|
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(_eeprom_buf); i++) {
|
for (size_t i = 0; i < ARRAY_SIZE(_eeprom_buf); i++) {
|
||||||
DEBUG("0x%02X ", _eeprom_buf[i]);
|
DEBUG("0x%02X ", _eeprom_buf[i]);
|
||||||
if ((i + 1) % 16 == 0) {
|
if ((i + 1) % 16 == 0) {
|
||||||
|
|||||||
@ -164,7 +164,7 @@ void uart_write(uart_t uart, const uint8_t *data, size_t len)
|
|||||||
{
|
{
|
||||||
DEBUG("writing to serial port ");
|
DEBUG("writing to serial port ");
|
||||||
|
|
||||||
if (ENABLE_DEBUG) {
|
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||||
for (size_t i = 0; i < len; i++) {
|
for (size_t i = 0; i < len; i++) {
|
||||||
DEBUG("%02x ", (unsigned char) data[i]);
|
DEBUG("%02x ", (unsigned char) data[i]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -183,14 +183,14 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info)
|
|||||||
(unsigned)len, (void *)info);
|
(unsigned)len, (void *)info);
|
||||||
if ((buf == NULL) || (len == 0)) {
|
if ((buf == NULL) || (len == 0)) {
|
||||||
int res = real_ioctl(dev->sock_fd, FIONREAD, &size);
|
int res = real_ioctl(dev->sock_fd, FIONREAD, &size);
|
||||||
#if ENABLE_DEBUG
|
|
||||||
if (res < 0) {
|
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||||
DEBUG("socket_zep::recv: error reading FIONREAD: %s",
|
if (res < 0) {
|
||||||
strerror(errno));
|
DEBUG("socket_zep::recv: error reading FIONREAD: %s",
|
||||||
|
strerror(errno));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
(void)res;
|
|
||||||
#endif
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
else if (len > 0) {
|
else if (len > 0) {
|
||||||
|
|||||||
@ -44,9 +44,6 @@
|
|||||||
#include "native_internal.h"
|
#include "native_internal.h"
|
||||||
|
|
||||||
#define ENABLE_DEBUG 0
|
#define ENABLE_DEBUG 0
|
||||||
#if ENABLE_DEBUG
|
|
||||||
#define LOCAL_DEBUG (1)
|
|
||||||
#endif
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
ssize_t (*real_read)(int fd, void *buf, size_t count);
|
ssize_t (*real_read)(int fd, void *buf, size_t count);
|
||||||
@ -109,16 +106,18 @@ int (*real_clock_gettime)(clockid_t clk_id, struct timespec *tp);
|
|||||||
void _native_syscall_enter(void)
|
void _native_syscall_enter(void)
|
||||||
{
|
{
|
||||||
_native_in_syscall++;
|
_native_in_syscall++;
|
||||||
#if LOCAL_DEBUG
|
|
||||||
real_write(STDERR_FILENO, "> _native_in_syscall\n", 21);
|
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||||
#endif
|
real_write(STDERR_FILENO, "> _native_in_syscall\n", 21);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _native_syscall_leave(void)
|
void _native_syscall_leave(void)
|
||||||
{
|
{
|
||||||
#if LOCAL_DEBUG
|
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||||
real_write(STDERR_FILENO, "< _native_in_syscall\n", 21);
|
real_write(STDERR_FILENO, "< _native_in_syscall\n", 21);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
_native_in_syscall--;
|
_native_in_syscall--;
|
||||||
if (
|
if (
|
||||||
(_native_sigpend > 0)
|
(_native_sigpend > 0)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user