Skip to content

Commit 06aa6cc

Browse files
authored
BAckport esp8266#7514 (part2)
1 parent d4c3ef0 commit 06aa6cc

File tree

2 files changed

+52
-34
lines changed

2 files changed

+52
-34
lines changed

tests/host/common/MockEsp.cpp

+23-2
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,15 @@ FlashMode_t EspClass::magicFlashChipMode(uint8_t byte)
159159
return FM_DOUT;
160160
}
161161

162-
bool EspClass::flashWrite(uint32_t offset, uint32_t *data, size_t size)
162+
bool EspClass::flashWrite(uint32_t offset, const uint32_t *data, size_t size)
163+
{
164+
(void)offset;
165+
(void)data;
166+
(void)size;
167+
return true;
168+
}
169+
170+
bool EspClass::flashWrite(uint32_t offset, const uint8_t *data, size_t size)
163171
{
164172
(void)offset;
165173
(void)data;
@@ -175,6 +183,14 @@ bool EspClass::flashRead(uint32_t offset, uint32_t *data, size_t size)
175183
return true;
176184
}
177185

186+
bool EspClass::flashRead(uint32_t offset, uint8_t *data, size_t size)
187+
{
188+
(void)offset;
189+
(void)data;
190+
(void)size;
191+
return true;
192+
}
193+
178194
uint32_t EspClass::magicFlashChipSize(uint8_t byte) {
179195
switch(byte & 0x0F) {
180196
case 0x0: // 4 Mbit (512KB)
@@ -208,7 +224,7 @@ uint32_t EspClass::getFlashChipSize(void)
208224

209225
String EspClass::getFullVersion ()
210226
{
211-
return "host-emulation";
227+
return "emulation-on-host";
212228
}
213229

214230
uint32_t EspClass::getFreeContStack()
@@ -221,6 +237,11 @@ void EspClass::resetFreeContStack()
221237
}
222238

223239
uint32_t EspClass::getCycleCount()
240+
{
241+
return esp_get_cycle_count();
242+
}
243+
244+
uint32_t esp_get_cycle_count()
224245
{
225246
timeval t;
226247
gettimeofday(&t, NULL);

tests/host/common/mock.h

+29-32
Original file line numberDiff line numberDiff line change
@@ -30,42 +30,14 @@
3030
*/
3131

3232
#define CORE_MOCK 1
33-
34-
// include host's STL before any other include file
35-
// because core definition like max() is in the way
36-
37-
#ifdef __cplusplus
38-
#include <vector>
39-
#endif
40-
#include <stddef.h>
41-
42-
43-
#ifdef __cplusplus
44-
extern "C" {
45-
#endif
46-
//#include <stdlib_noniso.h>
47-
char* itoa (int val, char *s, int radix);
48-
char* ltoa (long val, char *s, int radix);
49-
#ifdef __cplusplus
50-
}
51-
#endif
52-
53-
size_t strlcat(char *dst, const char *src, size_t size);
54-
size_t strlcpy(char *dst, const char *src, size_t size);
55-
56-
// exotic typedefs used in the sdk
57-
58-
#include <stdint.h>
59-
typedef uint8_t uint8;
60-
typedef uint32_t uint32;
33+
#define MOCK "(mock) " // TODO: provide common logging API instead of adding this string everywhere?
6134

6235
//
6336

6437
#define ARDUINO 267
6538
#define ESP8266 1
6639
#define A0 0
6740
#define LED_BUILTIN 0
68-
#define F_CPU 80000000
6941
#define LWIP_OPEN_SRC
7042
#define TCP_MSS 536
7143
#define LWIP_FEATURES 1
@@ -82,13 +54,38 @@ typedef uint32_t uint32;
8254
#define D7 7
8355
#define D8 8
8456

85-
//
57+
#include <stddef.h>
8658

87-
#include <Arduino.h>
59+
#ifdef __cplusplus
60+
extern "C" {
61+
#endif
62+
// TODO: #include <stdlib_noniso.h> ?
63+
char* itoa (int val, char *s, int radix);
64+
char* ltoa (long val, char *s, int radix);
65+
66+
67+
size_t strlcat(char *dst, const char *src, size_t size);
68+
size_t strlcpy(char *dst, const char *src, size_t size);
69+
70+
#ifdef __cplusplus
71+
}
72+
#endif
73+
74+
// exotic typedefs used in the sdk
75+
76+
#include <stdint.h>
77+
typedef uint8_t uint8;
78+
typedef uint32_t uint32;
8879

8980
//
9081

91-
#include <stdlib.h>
82+
#include <c_types.h>
83+
#include <core_esp8266_features.h>
84+
85+
uint32_t esp_get_cycle_count();
86+
87+
#include <Arduino.h>
88+
9289
#define RANDOM_REG32 ((uint32_t)random())
9390

9491
// net tweak

0 commit comments

Comments
 (0)