Skip to content
This repository was archived by the owner on Oct 28, 2023. It is now read-only.

Commit 1efe853

Browse files
authored
Merge branch 'master' into setup.state_as_u8
2 parents 3acf9be + f1a54b1 commit 1efe853

29 files changed

+483
-3611
lines changed

esp32/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ include ../py/py.mk
1818
PORT ?= /dev/ttyUSB0
1919
BAUD ?= 921600
2020
FLASH_MODE ?= dio
21-
FLASH_FREQ ?= 40m
21+
FLASH_FREQ ?= 80m
2222
FLASH_SIZE ?= 16MB
2323
CROSS_COMPILE ?= xtensa-esp32-elf-
2424

@@ -32,7 +32,7 @@ ESPTOOL ?= $(ESPCOMP)/esptool_py/esptool/esptool.py
3232
BADGE = $(IDF_PATH)/..
3333

3434
# verify the ESP IDF version
35-
ESPIDF_SUPHASH := 8d71d38298444d859f6bbb2aa92bc1c09f19e664
35+
ESPIDF_SUPHASH := 8b274cd5a5d193a82b49aef384c303b105eda700
3636
ESPIDF_CURHASH := $(shell git -C $(ESPIDF) show -s --pretty=format:'%H')
3737
ifneq ($(ESPIDF_CURHASH),$(ESPIDF_SUPHASH))
3838
$(info ** WARNING **)
@@ -325,6 +325,7 @@ ESPIDF_APP_UPDATE_O = $(addprefix $(ESPCOMP)/app_update/,\
325325

326326
ESPIDF_BOOTLOADER_O = $(addprefix $(ESPCOMP)/bootloader_support/src/,\
327327
esp_image_format.o \
328+
bootloader_sha.o \
328329
bootloader_flash.o \
329330
)
330331

@@ -777,6 +778,7 @@ $(BUILD)/%.o: %.cpp
777778
$(BUILD)/bootloader/$(ESPCOMP)/%.o: CFLAGS += -DBOOTLOADER_BUILD=1 -I$(ESPCOMP)/bootloader_support/include_priv -I$(ESPCOMP)/bootloader/include -I$(ESPCOMP)/bootloader_support/include -I$(ESPCOMP)/micro-ecc/micro-ecc -I$(ESPCOMP)/esp32 -Wno-error=format
778779
BOOTLOADER_OBJ = $(addprefix $(BUILD)/bootloader/$(ESPCOMP)/,\
779780
bootloader_support/src/bootloader_flash.o \
781+
bootloader_support/src/bootloader_sha.o \
780782
bootloader_support/src/bootloader_random.o \
781783
bootloader_support/src/secure_boot_signatures.o \
782784
bootloader_support/src/secure_boot.o \

esp32/Roboto-Black22.c

Lines changed: 0 additions & 1 deletion
This file was deleted.

esp32/Roboto-BlackItalic24.c

Lines changed: 0 additions & 1 deletion
This file was deleted.

esp32/Roboto-Regular12.c

Lines changed: 0 additions & 1 deletion
This file was deleted.

esp32/Roboto-Regular18.c

Lines changed: 0 additions & 1 deletion
This file was deleted.

esp32/Roboto-Regular22.c

Lines changed: 0 additions & 1 deletion
This file was deleted.

esp32/esprtcmem.c

Lines changed: 63 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,77 @@
2626
* THE SOFTWARE.
2727
*/
2828

29-
#include "py/mphal.h"
29+
#include <stdint.h>
30+
#include <string.h>
31+
32+
#include <py/mphal.h>
3033

3134
#include "esprtcmem.h"
3235

33-
static uint8_t RTC_DATA_ATTR rtcmemcontents[USER_RTC_MEM_SIZE] = {0};
36+
static uint8_t RTC_DATA_ATTR rtcmemcontents[USER_RTC_MEM_SIZE] = { 0 };
37+
38+
// @return 0..255 is ok; -1 is error
39+
int
40+
esp_rtcmem_read(uint32_t location)
41+
{
42+
if (location >= USER_RTC_MEM_SIZE)
43+
{
44+
return -1;
45+
}
3446

35-
const uint8_t esp_rtcmem_read(uint32_t location) {
36-
if (location<USER_RTC_MEM_SIZE) {
37-
return rtcmemcontents[location];
38-
} else {
39-
return 0;
40-
}
47+
return rtcmemcontents[location];
4148
}
4249

43-
void esp_rtcmem_read_string(uint32_t location, char *buffer) {
44-
sprintf(buffer, "%s", rtcmemcontents+location);
50+
// @return 0 is ok; -1 is error
51+
int
52+
esp_rtcmem_write(uint32_t location, uint8_t value)
53+
{
54+
if (location >= USER_RTC_MEM_SIZE)
55+
{
56+
return -1;
57+
}
58+
59+
rtcmemcontents[location] = value;
60+
61+
return 0;
4562
}
4663

47-
void esp_rtcmem_write_string(uint32_t location, const char *buffer) {
48-
sprintf((char *)rtcmemcontents+location, "%s", buffer);
64+
// @return 0 is ok; -1 is error
65+
int
66+
esp_rtcmem_read_string(uint32_t location, char *buffer, size_t *buf_len)
67+
{
68+
if (location >= USER_RTC_MEM_SIZE)
69+
{
70+
return -1;
71+
}
72+
73+
size_t maxlen = USER_RTC_MEM_SIZE - location;
74+
size_t len = strnlen((const char *) &rtcmemcontents[location], maxlen);
75+
if (len == maxlen)
76+
{
77+
return -1;
78+
}
79+
80+
if (*buf_len <= len)
81+
{
82+
return -1;
83+
}
84+
*buf_len = len + 1;
85+
memcpy(buffer, &rtcmemcontents[location], len + 1);
86+
87+
return 0;
4988
}
5089

51-
void esp_rtcmem_write(uint32_t location, uint8_t value) {
52-
if (location<USER_RTC_MEM_SIZE) rtcmemcontents[location] = value;
90+
// @return 0 is ok; -1 is error
91+
int
92+
esp_rtcmem_write_string(uint32_t location, const char *buffer)
93+
{
94+
if (location >= USER_RTC_MEM_SIZE || location + strlen(buffer) >= USER_RTC_MEM_SIZE)
95+
{
96+
return -1;
97+
}
98+
99+
memcpy(&rtcmemcontents[location], buffer, strlen(buffer)+1);
100+
101+
return 0;
53102
}

esp32/esprtcmem.h

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,49 @@
11
#ifndef ESPRTCMEM_H
22
#define ESPRTCMEM_H
33

4-
#include "esp_attr.h"
5-
#include "rom/rtc.h"
4+
#include <stdint.h>
65

7-
#define USER_RTC_MEM_SIZE 256
6+
#include <rom/rtc.h>
7+
#include <esp_attr.h>
88

9-
const uint8_t esp_rtcmem_read(uint32_t location);
10-
void esp_rtcmem_write(uint32_t location, uint8_t value);
11-
void esp_rtcmem_read_string(uint32_t location, char *buffer);
12-
void esp_rtcmem_write_string(uint32_t location, const char *buffer);
9+
#define USER_RTC_MEM_SIZE 1024
1310

14-
#endif
11+
/**
12+
* Read byte from rtcmem on offset location.
13+
*
14+
* @param location The offset in the rtcmem.
15+
* @return 0..255 is ok; -1 is error
16+
*/
17+
extern int esp_rtcmem_read(uint32_t location);
18+
19+
/**
20+
* Write byte to rtcmem on offset location.
21+
*
22+
* @param location The offset in the rtcmem
23+
* @param value The value to write to this offset
24+
* @return 0 is ok; -1 is error
25+
*/
26+
extern int esp_rtcmem_write(uint32_t location, uint8_t value);
27+
28+
/**
29+
* Read zero-terminated string from rtcmem on offset location
30+
*
31+
* @param location The offset in the rtcmem
32+
* @param buffer The destination buffer
33+
* @param buf_len The length of the destination buffer
34+
* on input: the total buffer-length
35+
* on output: the used buffer-length
36+
* @return 0 is ok; -1 is error
37+
*/
38+
extern int esp_rtcmem_read_string(uint32_t location, char *buffer, size_t *buf_len);
39+
40+
/**
41+
* Write zero-terminated string to rtcmem on offfset location
42+
*
43+
* @param location The offset in the rtcmem
44+
* @param buffer The string to write to this offset
45+
* @return 0 is ok; -1 is error
46+
*/
47+
extern int esp_rtcmem_write_string(uint32_t location, const char *buffer);
48+
49+
#endif // ESPRTCMEM_H

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy