Skip to content

Commit 96382c4

Browse files
authored
Merge pull request #27 from Dzarda7/fix/esp8266_undefined_functions
fix(esp8266): Add missing function definitions for flash and uart
2 parents ee4ee25 + d4344cf commit 96382c4

File tree

5 files changed

+47
-10
lines changed

5 files changed

+47
-10
lines changed

include/esp-stub-lib/rom_wrappers.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extern "C" {
1717
*
1818
* @param us Number of microseconds to delay.
1919
*/
20-
void esp_stub_lib_delay_us(uint32_t us);
20+
void stub_lib_delay_us(uint32_t us);
2121

2222
/**
2323
* @brief Compute little-endian CRC16 over a byte buffer.
@@ -27,27 +27,27 @@ void esp_stub_lib_delay_us(uint32_t us);
2727
* @param len Number of bytes to process.
2828
* @return Updated CRC16 value.
2929
*/
30-
uint16_t esp_stub_lib_crc16_le(uint16_t crc, const uint8_t *buf, uint32_t len);
30+
uint16_t stub_lib_crc16_le(uint16_t crc, const uint8_t *buf, uint32_t len);
3131

3232
/**
3333
* @brief Transmit a single byte over UART.
3434
*
3535
* @param c Byte to transmit.
3636
* @return 0 if successful, non-zero if error occurred.
3737
*/
38-
uint8_t esp_stub_lib_tx_one_char(uint8_t c);
38+
uint8_t stub_lib_uart_tx_one_char(uint8_t c);
3939

4040
/**
4141
* @brief Receive a single byte (blocking) from UART.
4242
*
4343
* @return Received byte.
4444
*/
45-
uint8_t esp_stub_lib_rx_one_char(void);
45+
uint8_t stub_lib_uart_rx_one_char(void);
4646

4747
/**
4848
* @brief Flush any buffered transmit data.
4949
*/
50-
void esp_stub_lib_tx_flush(void);
50+
void stub_lib_uart_tx_flush(void);
5151

5252
#ifdef __cplusplus
5353
}

src/rom_wrappers.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@ extern uint8_t uart_tx_one_char(uint8_t ch);
1111
extern uint8_t uart_rx_one_char(void);
1212
extern void uart_tx_flush(void);
1313

14-
void esp_stub_lib_delay_us(uint32_t us)
14+
void stub_lib_delay_us(uint32_t us)
1515
{
1616
ets_delay_us(us);
1717
}
1818

19-
uint16_t esp_stub_lib_crc16_le(uint16_t crc, const uint8_t *buf, uint32_t len)
19+
uint16_t stub_lib_crc16_le(uint16_t crc, const uint8_t *buf, uint32_t len)
2020
{
2121
return crc16_le(crc, buf, len);
2222
}
2323

24-
uint8_t esp_stub_lib_tx_one_char(uint8_t c)
24+
uint8_t stub_lib_uart_tx_one_char(uint8_t c)
2525
{
2626
return uart_tx_one_char(c);
2727
}
2828

29-
uint8_t esp_stub_lib_rx_one_char(void)
29+
uint8_t stub_lib_uart_rx_one_char(void)
3030
{
3131
return uart_rx_one_char();
3232
}
3333

34-
void esp_stub_lib_tx_flush(void)
34+
void stub_lib_uart_tx_flush(void)
3535
{
3636
uart_tx_flush();
3737
}

src/target/esp8266/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ set(srcs
22
src/uart.c
33
src/flash.c
44
src/rom-patched.c
5+
src/rom-missings.c
56
)
67

78
add_library(${ESP_TARGET_LIB} STATIC ${srcs})

src/target/esp8266/src/flash.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
* SPDX-License-Identifier: Apache-2.0 OR MIT
55
*/
66

7+
#include <stdint.h>
8+
#include <err.h>
79
#include <target/flash.h>
10+
#include <private/rom_flash.h>
11+
12+
extern esp_rom_spiflash_chip_t g_rom_flashchip;
813

914
void stub_target_flash_init(void *state)
1015
{
@@ -18,8 +23,22 @@ void stub_target_flash_deinit(const void *state)
1823
// TODO: Implement
1924
}
2025

26+
const struct esp_rom_spiflash_chip *stub_target_flash_get_config(void)
27+
{
28+
return &g_rom_flashchip;
29+
}
30+
2131
uint32_t stub_target_flash_get_flash_id(void)
2232
{
2333
// TODO: Implement
2434
return 0;
2535
}
36+
37+
int stub_target_flash_read_buff(uint32_t addr, void *buffer, uint32_t size)
38+
{
39+
(void)addr;
40+
(void)buffer;
41+
(void)size;
42+
// TODO: Implement
43+
return STUB_LIB_FAIL;
44+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0 OR MIT
5+
*/
6+
#include <stdint.h>
7+
#include "private/soc_utils.h"
8+
9+
void uart_tx_flush(void)
10+
{
11+
const uint32_t UART0_STATUS_REG = 0x60000F1C;
12+
const uint32_t UART_STATUS_TX_EMPTY = 0xFF << 16;
13+
14+
while (REG_READ(UART0_STATUS_REG) & UART_STATUS_TX_EMPTY) {
15+
// wait for TX fifo to be empty, ROM code works the same way
16+
}
17+
}

0 commit comments

Comments
 (0)