Commit graph

106 commits

Author SHA1 Message Date
suda-morris
c0a5cb07cd support esp32 eco revision 2 and 3 2019-09-19 17:09:37 +08:00
chenjianqiang
7904cae9c1 bugfix(flash): add flash config in app startup
We fixed some flash bugs in bootloader, but for the users used the old
vrsion bootloader, they can not fix these bugs via OTA, the solution is
add these updates in app startup.

These updates include:
1. SPI flash gpio matrix and drive strength configuration
2. SPI flash clock configuration
3. SPI flash read dummy configuration
4. SPI flash cs timing configuration
5. Update flash id of g_rom_flashchip
2019-09-11 15:37:18 +08:00
Angus Gratton
a4ce828d40 flash encryption: Add config option to disable any plaintext reflashes
Enabled by default when Secure Boot is on, so Flash Encryption protection
is always available in case of a Secure Boot bypass.
2019-09-10 14:29:20 +10:00
Sagar Bijwe
0449ba7f91 docs: Added more wordings to capture secure boot and flash encryption dependency. 2019-09-10 10:11:44 +10:00
chenjianqiang
963fe19abf bugfix(flash): improve spi cs timing settings for flash
cs setup time is recomemded to be 1.5T, and cs hold time is recommended to be 2.5T.
(cs_setup = 1, cs_setup_time = 0; cs_hold = 1, cs_hold_time = 1)
2019-07-31 18:15:44 +08:00
chenjianqiang
4bce69b69a bugfix(flash): fix flash read error in DIO/26MHz mode 2019-07-11 15:26:58 +08:00
chenjianqiang
dfe06c6dfb bugfix(flash): improve flash dio read timing
When flash work in DIO Mode, in order to ensure the fast read mode of flash
is a fixed value, we merged the mode bits into address part, and the fast
read mode value is 0 (the default value).
2019-06-19 17:30:21 +08:00
Konstantin Kondrashov
ea48d2802c esp32: Add reset uart
Fixed the case when the first part of log was missed
this was happened when:
 * CONFIG_CONSOLE_UART_CUSTOM option is selected (UART1)
 * The selected CONSOLE_UART port is used also for the console component
 * in code esp_restart() or abort() functions were called.
2019-06-04 20:17:21 +08:00
Konstantin Kondrashov
4a82ad3937 bootloader_support: Fix UART RXD pin for console output (CUSTOM option)
The RXD pin is assigned as input (fix for custom uart option).

Closes: https://github.com/espressif/esp-idf/issues/2843

Closes: IDFGH-505
2019-05-20 18:37:26 +08:00
Mahavir Jain
1cbdfcc493 bootloader: add API for erasing flash region
Signed-off-by: Mahavir Jain <mahavir@espressif.com>

Closes: https://github.com/espressif/esp-idf/issues/2166
2019-04-23 21:14:35 +08:00
Angus Gratton
654d6ee594 efuse/flash encryption: Reduce FLASH_CRYPT_CNT to a 7 bit efuse field
8th bit is not used by hardware.

As reported https://esp32.com/viewtopic.php?f=2&t=7800&p=40895#p40894
2019-04-09 09:59:15 +10:00
Ivan Grokhotkov
48416c38c8 soc: define named constants for DPORT_CPUPERIOD_SEL values 2019-02-28 21:58:03 +08:00
Ivan Grokhotkov
beb8347faa bootloader: check previously used clock frequency at run time
In the situation when bootloader was compiled for 240MHz, and app was
compiled for 160MHz, and the chip is a revision 0 chip, the
bootloader will assume that the application has also been running at
240MHz. This will cause the chip to lock up later. Modify this to use
a run time check of DPORT_CPUPERIOD_SEL, which indicates which of the
PLL frequencies was used.

Closes https://github.com/espressif/esp-idf/issues/2731.
2019-02-28 21:58:03 +08:00
Jiang Jiang Jian
c6750d271e Merge branch 'bugfix/bootloader_map_size_v3.1' into 'release/v3.1'
bootloader: fix incorrect mapping size (backport v3.1)

See merge request idf/esp-idf!4139
2019-01-24 14:09:58 +08:00
Jiang Jiang Jian
9699ec9277 Merge branch 'bugfix/rom_export_functions_v3.1' into 'release/v3.1'
esp32, bootloader: fix issues related to linking order (backport v3.1)

See merge request idf/esp-idf!4135
2019-01-23 21:58:58 +08:00
Ivan Grokhotkov
205c484c49 bootloader: account for load address when mapping cache pages
Bootloader used to calculate the number of cache pages assuming that
load address was aligned, while in reality load address for DROM and
IROM was offset by 0x20 bytes from the start of 64kB page. This
caused the bootloader to map one less page if the size of the image
was 0x4..0x1c less than a multiple of 64kB.

Reported in https://esp32.com/viewtopic.php?f=13&t=6952.
2019-01-23 17:06:11 +08:00
Ivan Grokhotkov
60f4ccf303 bootloader: fix IROM and DROM swapped in log messages 2019-01-23 17:05:37 +08:00
Ivan Grokhotkov
9845219a5f bootloader_support: exclude bootloader_init.c when building app
Depending on link order of libraries, bootloader implementation of
__assert_func could be linked instead of the one provided by newlib.
2019-01-23 16:26:14 +08:00
Ivan Grokhotkov
b4939b1121 bootloader, esp32: add workaround for Tensilica erratum 572
If zero-overhead loop buffer is enabled, under certain rare conditions
when executing a zero-overhead loop, the CPU may attempt to execute an invalid instruction. Work around by disabling the buffer.
2019-01-23 16:23:08 +08:00
Ivan Grokhotkov
9ec43e1721 bootloader: verify that loaded image does not overlap bootloader code
Fixes CVE-2018-18558
2018-10-26 12:44:58 +08:00
Angus Gratton
67ad5852f6 Secure Boot & Flash encryption: Support 3/4 Coding Scheme
Includes esptool update to v2.6-beta1
2018-10-24 23:21:17 +00:00
Angus Gratton
97219eeb31 Merge branch 'feature/nvs_encr_v3.1' into 'release/v3.1'
nvs_flash: Add support for nvs encryption

See merge request idf/esp-idf!3434
2018-10-08 16:20:28 +08:00
Sagar Bijwe
68a9d1168f nvs_flash: Add support for nvs encryption 2018-10-04 19:25:12 +05:30
Angus Gratton
d7615df616 bootloader: Don't enable secure boot or flash encryption for 3/4 Coding Scheme 2018-10-04 16:51:30 +10:00
Angus Gratton
f16b3754fb bootloader: Fix secure boot digest generation for image length where (len%128 < 32) 2018-09-30 00:45:07 +10:00
Angus Gratton
52413e9925 Merge branch 'feature/signature_verify_updates_v3.1' into 'release/v3.1'
secure boot: Support signed app verification without hardware secure boot  (backport v3.1)

See merge request idf/esp-idf!3184
2018-09-18 07:56:12 +08:00
Renz Bagaporo
7edf2bf66c cmake: make main a component again 2018-09-13 11:13:27 +08:00
Angus Gratton
b069b31a2c secure boot: Support secure boot signatures without hardware secure boot
Allows OTA updates to be secured via signature checks, without requiring the overhead or complexity
of a full secure boot implementation.

Uses same signing mechanisms (build system and/or espsecure.py as Secure Boot).

Requires:
* [ ] More testing
* [ ] Documentation
2018-09-04 19:10:02 +08:00
Angus Gratton
7f50bb7e7f Merge branch 'release/v3.1' into feature/cmake_v3.1 2018-08-17 14:14:10 +10:00
Angus Gratton
45d7039623 Merge branch 'feature/support_for_XM25QU64A_v3.1' into 'release/v3.1'
feature(flash): set QIO mode for XM25QU64A(1V8_8MB_flash) (backport v3.1)

See merge request idf/esp-idf!2950
2018-08-08 16:30:09 +08:00
chenjianqiang
57ed12a019 feature(flash): support for QIO mode of XM25QU64A 2018-08-08 10:58:13 +08:00
Angus Gratton
3eaf8f1a84 Merge branch 'bugfix/secure_boot_padding_v3_1' into 'release/v3.1'
secure boot: Fix padding issue (backport v3.1)

See merge request idf/esp-idf!2833
2018-07-25 08:59:31 +08:00
Konstantin Kondrashov
7f2edf8528 bootloader: Fix issue - bs->app_count is zero but ota_data have valid entry
If we have the partition table without any ota_apps but in ota_data have
valide entry, in this case we get an error(hang). This commit fix this
case. If bs->app_count is zero when selecting the factory app.

Closes https://github.com/espressif/esp-idf/issues/2218
2018-07-24 15:41:49 +08:00
Angus Gratton
f8b191cfae secure boot: Pad to avoid data after the signature mapping into the address space
Because address space is mapped in 64KB pages, it was possible for unauthenticated data after the
app .bin to become mapped into the flash cache address space.

This problem is solved by 2 changes:

* "esptool elf2image --secure-pad" will pad the image so that the signature block ends close to the
  64KB boundary. Due to alignment constraints it will be 12 bytes too short after signing (but
  with flash encryption, these 12 bytes are still encrypted as part of the last block and can't be
  arbitrarily changed).
* By default, secure boot now requires all app partitions to be a multiple of 64KB in size.
2018-07-23 13:45:55 +10:00
Angus Gratton
ec73cebb59 bootloader: Don't verify Partition Table as part of Secure Boot
Partition Tables are still signed for backwards compatibility, but signature is no longer checked as
part of bootloader.

Closes https://github.com/espressif/esp-idf/issues/1641
2018-07-16 16:59:36 +10:00
Jiang Jiang Jian
a95678bfcd Merge branch 'bugfix/assert_v3.1' into 'release/v3.1'
assert: Fix. Move useful functions from wrapped assert functions (v3.1)

See merge request idf/esp-idf!2605
2018-06-29 19:20:35 +08:00
Konstantin Kondrashov
baa6c19700 soc: Fix check_long_hold_gpio and move def to soc
Fix factory_reset_pin init as input
Move definition a structure rtc_gpio_desc to soc

Closes https://github.com/espressif/esp-idf/issues/2030
2018-06-26 12:47:55 +05:00
Konstantin Kondrashov
f9affb9fb8 assert: Fix. Move useful functions from wrapped assert functions
Moved useful functions from wrapped assert functions, because option `CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED=y` will remove this functions.

Closes https://github.com/espressif/esp-idf/issues/2068
2018-06-25 11:05:54 +08:00
Konstantin Kondrashov
17dac0d273 spi_flash: Fix error unit tests on host
IDF had two defines ESP_PARTITION_TABLE_OFFSET and ESP_PARTITION_TABLE_ADDR. They were the same and equal by 0x8000.
A define ESP_PARTITION_TABLE_ADDR was removed from IDF.
A define ESP_PARTITION_TABLE_OFFSET depends on option CONFIG_PARTITION_TABLE_OFFSET in Kconfig.

Now using only #define ESP_PARTITION_TABLE_OFFSET CONFIG_PARTITION_TABLE_OFFSET
2018-06-19 14:30:25 +05:00
Konstantin Kondrashov
3e0ac4db79 partition_table: Expanding the space under the bootloader
Allows you to move the partition table, it gives more space for the bootloader.
Added a new utility - parttool.py. This utility can search for the offset and/or size of the partitions by name and type/subtype. Use for getting APP_OFFSET and PHY_DATA_OFFSET.
The linker(esp32.bootloader.ld) made changes that allow you to write a custom bootloader code more.

TW14125
2018-06-08 18:47:29 +05:00
Angus Gratton
6b9784cc45 Merge branch 'master' into feature/cmake_update 2018-05-31 14:46:23 +10:00
Ivan Grokhotkov
cb649e452f remove executable permission from source files 2018-05-29 20:07:45 +08:00
Angus Gratton
d775cc4c4c soc: Fix description of rtc_config_t.tieh, add macros
Usage of TIEH was correct but description had 1.8V & 3.3V backwards.

Add macro definitions for TIEH values to improve readability.
2018-05-25 14:58:37 +10:00
Konstantin Kondrashov
ae10abff2f bootloader: Add factory reset and start test app
Added feature:
- reset firmware to Factory app.(by long pressing of the button)
- boot Test app. (by long pressing of the button)
- Added feature erase data partitions from factory reset.

TW10281
TW10280
2018-05-24 16:56:49 +05:00
Wangjialin
f6927ccde9 bootloader(flash): fix flash QIO mode configuration error.
reported from github: https://github.com/espressif/esp-idf/issues/1944

1. Add SPI register setup in execute_flash_command.
2. Save and recover the SPI ctrl register in execute_flash_command.
2018-05-16 12:42:29 +00:00
Ivan Grokhotkov
254e29aca4 mbedtls: update usage of deprecated mbedtls_shaX APIs
The following mbedTLS APIs have been deprecated and replaced with the
new ones which return error codes:

mbedtls_shaX_starts -> mbedtls_shaX_starts_ret
mbedtls_shaX_update -> mbedtls_shaX_update_ret
mbedtls_shaX_finish -> mbedtls_shaX_finish_ret
mbedtls_shaX_process -> mbedtls_shaX_internal_process

Update hardware implementations of SHA functions, and other IDF
components which used above functions, to use new versions.
2018-05-09 23:15:28 +08:00
Angus Gratton
bb1f3ae264 Merge branch 'feature/psram_configure_in_runtime' into 'master'
feature(psram): update psram and flash SPI frequency in runtime

See merge request idf/esp-idf!1776
2018-05-08 15:23:47 +08:00
Angus Gratton
1cb5712463 cmake: Add component dependency support
Components should set the COMPONENT_REQUIRES & COMPONENT_PRIVATE_REQUIRES variables to define their
requirements.
2018-04-30 09:59:20 +10:00
Angus Gratton
88df8fd293 cmake: Use cmake_lint project, tidy up all CMake source files 2018-04-30 09:59:20 +10:00
Angus Gratton
4f1a856dbf cmake: Remove defaults for COMPONENT_SRCDIRS, COMPONENT_SRCS, COMPONENT_ADD_INCLUDEDIRS
* Philosophical: "explicit is better than implicit".
* Practical: Allows useful errors if invalid directories given in components as the defaults aren't
  always used. Also trims the -I path from a number of components that have no actual include
  directory.
* Simplifies knowing which components will be header-only and which won't
2018-04-30 09:59:20 +10:00