Skip to content

Commit

Permalink
reduce ASIC serial RX buf to 16 bytes (from 1024). make sure to free(…
Browse files Browse the repository at this point in the history
…) after every nvs_config_get_string()
  • Loading branch information
skot committed Aug 9, 2024
1 parent 99e4f12 commit 349b5cb
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions components/bm1397/bm1366.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ typedef struct __attribute__((__packed__))

static const char * TAG = "bm1366Module";

static uint8_t asic_response_buffer[CHUNK_SIZE];
static uint8_t asic_response_buffer[SERIAL_BUF_SIZE];
static task_result result;

/// @brief
Expand Down Expand Up @@ -523,7 +523,7 @@ uint8_t BM1366_init(uint64_t frequency, uint16_t asic_count)
{
ESP_LOGI(TAG, "Initializing BM1366");

memset(asic_response_buffer, 0, 1024);
memset(asic_response_buffer, 0, SERIAL_BUF_SIZE);

esp_rom_gpio_pad_select_gpio(BM1366_RST_PIN);
gpio_set_direction(BM1366_RST_PIN, GPIO_MODE_OUTPUT);
Expand Down
4 changes: 2 additions & 2 deletions components/bm1397/bm1368.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ typedef struct __attribute__((__packed__))

static const char * TAG = "bm1368Module";

static uint8_t asic_response_buffer[CHUNK_SIZE];
static uint8_t asic_response_buffer[SERIAL_BUF_SIZE];
static task_result result;

/// @brief
Expand Down Expand Up @@ -402,7 +402,7 @@ uint8_t BM1368_init(uint64_t frequency, uint16_t asic_count)
{
ESP_LOGI(TAG, "Initializing BM1368");

memset(asic_response_buffer, 0, 1024);
memset(asic_response_buffer, 0, SERIAL_BUF_SIZE);

esp_rom_gpio_pad_select_gpio(BM1368_RST_PIN);
gpio_set_direction(BM1368_RST_PIN, GPIO_MODE_OUTPUT);
Expand Down
4 changes: 2 additions & 2 deletions components/bm1397/bm1397.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ typedef struct __attribute__((__packed__))

static const char *TAG = "bm1397Module";

static uint8_t asic_response_buffer[CHUNK_SIZE];
static uint8_t asic_response_buffer[SERIAL_BUF_SIZE];
static uint32_t prev_nonce = 0;
static task_result result;

Expand Down Expand Up @@ -287,7 +287,7 @@ uint8_t BM1397_init(uint64_t frequency, uint16_t asic_count)
{
ESP_LOGI(TAG, "Initializing BM1397");

memset(asic_response_buffer, 0, sizeof(asic_response_buffer));
memset(asic_response_buffer, 0, SERIAL_BUF_SIZE);

esp_rom_gpio_pad_select_gpio(BM1397_RST_PIN);
gpio_set_direction(BM1397_RST_PIN, GPIO_MODE_OUTPUT);
Expand Down
2 changes: 1 addition & 1 deletion components/bm1397/include/serial.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SERIAL_H_
#define SERIAL_H_

#define CHUNK_SIZE 1024
#define SERIAL_BUF_SIZE 16

int SERIAL_send(uint8_t *, int, bool);
void SERIAL_init(void);
Expand Down
2 changes: 1 addition & 1 deletion components/bm1397/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ int16_t SERIAL_rx(uint8_t *buf, uint16_t size, uint16_t timeout_ms)
void SERIAL_debug_rx(void)
{
int ret;
uint8_t buf[CHUNK_SIZE];
uint8_t buf[100];

ret = SERIAL_rx(buf, 100, 20);
if (ret < 0)
Expand Down
1 change: 1 addition & 0 deletions main/http_server/http_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ static esp_err_t GET_swarm(httpd_req_t * req)

char * swarm_config = nvs_config_get_string(NVS_CONFIG_SWARM, "[]");
httpd_resp_sendstr(req, swarm_config);
free(swarm_config);
return ESP_OK;
}

Expand Down

0 comments on commit 349b5cb

Please sign in to comment.