8000 Merge branch 'master' into dns-doc-sta · esp8266/Arduino@73947ef · GitHub
[go: up one dir, main page]

Skip to content

Commit 73947ef

Browse files
authored
Merge branch 'master' into dns-doc-sta
2 parents 6122465 + 03ea61a commit 73947ef

File tree

8 files changed

+318
-12
lines changed

8 files changed

+318
-12
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ tools/sdk/lwip/src/liblwip_src.a
1111
tools/sdk/ld/backup
1212
tools/sdk/ld/eagle.app.v6.common.ld
1313

14+
tests/hosts/lcov/
15+
1416
*.pyc
1517
*.gch
1618

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ install:
3838
}
3939
make -C $HOME/astyle/build/gcc prefix=$HOME install;
4040
} || true
41+
- sudo apt-get install valgrind lcov
4142

4243
script:
4344
- $TRAVIS_BUILD_DIR/tests/common.sh

cores/esp8266/WString.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,9 @@ unsigned char String::concat(const String &s) {
270270
return 1;
271271
if (!reserve(newlen))
272272
return 0;
273-
memcpy(s.buffer + len, s.buffer, len);
273+
memcpy(buffer + len, buffer, len);
274274
len = newlen;
275+
buffer[len] = 0;
275276
return 1;
276277
} else {
277278
return concat(s.buffer, s.len);

libraries/SPI/SPI.cpp

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,25 @@ uint16_t SPIClass::transfer16(uint16_t data) {
323323
return out.val;
324324
}
325325

326+
void SPIClass::transfer(void *buf, uint16_t count) {
327+
uint8_t *cbuf = reinterpret_cast<uint8_t*>(buf);
328+
329+
// cbuf may not be 32bits-aligned
330+
for (; (((unsigned long)cbuf) & 3) && count; cbuf++, count--)
331+
*cbuf = transfer(*cbuf);
332+
333+
// cbuf is now aligned
334+
// count may not be a multiple of 4
335+
uint16_t count4 = count & ~3;
336+
transferBytes(cbuf, cbuf, count4);
337+
338+
// finish the last <4 bytes
339+
cbuf += count4;
340+
count -= count4;
341+
for (; count; cbuf++, count--)
342+
*cbuf = transfer(*cbuf);
343+
}
344+
326345
void SPIClass::write(uint8_t data) {
327346
while(SPI1CMD & SPIBUSY) {}
328347
// reset to 8Bit mode
@@ -511,6 +530,14 @@ void SPIClass::transferBytes(const uint8_t * out, uint8_t * in, uint32_t size) {
511530
}
512531
}
513532

533+
/**
534+
* Note:
535+
* in and out need to be aligned to 32Bit
536+
* or you get an Fatal exception (9)
537+
* @param out uint8_t *
538+
* @param in uint8_t *
539+
* @param size uint8_t (max 64)
540+
*/
514541
void SPIClass::transferBytes_(const uint8_t * out, uint8_t * in, uint8_t size) {
515542
while(SPI1CMD & SPIBUSY) {}
516543
// Set in/out Bits to transfer
@@ -539,12 +566,13 @@ void SPIClass::transferBytes_(const uint8_t * out, uint8_t * in, uint8_t size) {
539566
while(SPI1CMD & SPIBUSY) {}
540567

541568
if(in) {
542-
volatile uint8_t * fifoPtr8 = (volatile uint8_t *) &SPI1W0;
543-
dataSize = size;
569+
uint32_t * dataPtr = (uint32_t*) in;
570+
fifoPtr = &SPI1W0;
571+
dataSize = ((size + 3) / 4);
544572
while(dataSize--) {
545-
*in = *fifoPtr8;
546-
in++;
547-
fifoPtr8++;
573+
*dataPtr = *fifoPtr;
574+
dataPtr++;
575+
fifoPtr++;
548576
}
549577
}
550578
}

libraries/SPI/SPI.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class SPIClass {
6464
void beginTransaction(SPISettings settings);
6565
uint8_t transfer(uint8_t data);
6666
uint16_t transfer16(uint16_t data);
67+
void transfer(void *buf, uint16_t count);
6768
void write(uint8_t data);
6869
void write16(uint16_t data);
6970
void write16(uint16_t data, bool msb);

tests/host/Makefile

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
BINARY_DIRECTORY := bin
2+
LCOV_DIRECTORY := lcov
23
OUTPUT_BINARY := $(BINARY_DIRECTORY)/host_tests
34
CORE_PATH := ../../cores/esp8266
45

@@ -8,6 +9,9 @@ CC ?= gcc
89
CXX ?= g++
910
endif
1011
GCOV ?= gcov
12+
VALGRIND ?= valgrind
13+
LCOV ?= lcov
14+
GENHTML ?= genhtml
1115

1216
CORE_CPP_FILES := $(addprefix $(CORE_PATH)/,\
1317
StreamString.cpp \
@@ -49,11 +53,12 @@ TEST_CPP_FILES := \
4953
fs/test_fs.cpp \
5054
core/test_pgmspace.cpp \
5155
core/test_md5builder.cpp \
56+
core/test_string.cpp
5257

53-
54-
CXXFLAGS += -std=c++11 -Wall -coverage -O0 -fno-common
55-
CFLAGS += -std=c99 -Wall -coverage -O0 -fno-common
58+
CXXFLAGS += -std=c++11 -Wall -Werror -coverage -O0 -fno-common -g
59+
CFLAGS += -std=c99 -Wall -Werror -coverage -O0 -fno-common -g
5660
LDFLAGS += -coverage -O0
61+
VALGRINDFLAGS += --leak-check=full --track-origins=yes --error-limit=no --show-leak-kinds=all --error-exitcode=999
5762

5863
remduplicates = $(strip $(if $1,$(firstword $1) $(call remduplicates,$(filter-out $(firstword $1),$1))))
5964

@@ -69,7 +74,7 @@ CPP_OBJECTS = $(CPP_OBJECTS_CORE) $(CPP_OBJECTS_TESTS)
6974
OBJECTS = $(C_OBJECTS) $(CPP_OBJECTS)
7075
COVERAGE_FILES = $(OBJECTS:.o=.gc*)
7176

72-
all: build-info $(OUTPUT_BINARY) test gcov
77+
all: build-info $(OUTPUT_BINARY) valgrind test gcov
7378

7479
test: $(OUTPUT_BINARY)
7580
$(OUTPUT_BINARY)
@@ -81,11 +86,18 @@ clean-objects:
8186
rm -rf $(OBJECTS)
8287

8388
clean-coverage:
84-
rm -rf $(COVERAGE_FILES) *.gcov
89+
rm -rf $(COVERAGE_FILES) $(LCOV_DIRECTORY) *.gcov
8590

8691
gcov: test
8792
find $(CORE_PATH) -name "*.gcno" -exec $(GCOV) -r -pb {} +
8893

94+
valgrind: $(OUTPUT_BINARY)
95+
mkdir -p $(LCOV_DIRECTORY)
96+
$(LCOV) --directory ../../cores/esp8266/ --zerocounters
97+
$(VALGRIND) $(VALGRINDFLAGS) $(OUTPUT_BINARY)
98+
$(LCOV) --directory $(CORE_PATH) --capture --output-file $(LCOV_DIRECTORY)/app.info
99+
$(GENHTML) $(LCOV_DIRECTORY)/app.info -o $(LCOV_DIRECTORY)
100+
89101
build-info:
90102
@echo "-------- build tools info --------"
91103
@echo "CC: " $(CC)

tests/host/core/test_md5builder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ TEST_CASE("MD5Builder::addHexString works as expected", "[core][MD5Builder]")
3838
WHEN("A char array is parsed"){
3939
MD5Builder builder;
4040
builder.begin();
41-
const char * myPayload = "1234567890abcdeffedcba98765432106469676974616c7369676e61747572656170706c69636174696f6e73";
41+
const char * myPayload = "1234567890abcdeffedcba98765432106469676974616c7369676e61747572656170706c69636174696F6e73";
4242
builder.addHexString(myPayload);
4343
builder.calculate();
4444
REQUIRE(builder.toString() == "47b937a6f9f12a4c389fa5854e023efb");

0 commit comments

Comments
 (0)
0