]> granicus.if.org Git - esp-idf/commitdiff
partition_table: Move from 0x4000 to 0x8000
authorAngus Gratton <angus@espressif.com>
Mon, 7 Nov 2016 03:35:23 +0000 (14:35 +1100)
committerAngus Gratton <angus@espressif.com>
Mon, 14 Nov 2016 00:08:42 +0000 (11:08 +1100)
Also fix a bug with correctly padding bootloader image when length is
already a multiple of 16.

components/bootloader_support/src/bootloader_flash.c
components/bootloader_support/src/esp_image_format.c
components/esp32/include/esp_flash_data_types.h
components/partition_table/Makefile.projbuild

index a50cd157e93f6cb9c0eda35e64b91156eee25fd7..fcaf24ad2c1d5247010d364a98c328b2995b7b89 100644 (file)
@@ -94,11 +94,11 @@ void bootloader_unmap(const void *mapping)
 esp_err_t bootloader_flash_read(size_t src_addr, void *dest, size_t size)
 {
     if(src_addr & 3) {
-        ESP_LOGE(TAG, "bootloader_flash_read src_addr not 4-byte aligned");
+        ESP_LOGE(TAG, "bootloader_flash_read src_addr 0x%x not 4-byte aligned", src_addr);
         return ESP_FAIL;
     }
     if((intptr_t)dest & 3) {
-        ESP_LOGE(TAG, "bootloader_flash_read dest not 4-byte aligned");
+        ESP_LOGE(TAG, "bootloader_flash_read dest 0x%x not 4-byte aligned", (intptr_t)dest);
         return ESP_FAIL;
     }
 
index ad3cd33f137c3f65e924aeca7513d8cb6b4c0db5..3e7dcafa9eb70b93f30f0ba8076518cfeaa8f0ee 100644 (file)
@@ -62,6 +62,7 @@ esp_err_t esp_image_load_segment_header(uint8_t index, uint32_t src_addr, const
     }
 
     for(int i = 0; i <= index && err == ESP_OK; i++) {
+        ESP_LOGV(TAG, "loading segment header %d at offset 0x%x", i, next_addr);
         err = bootloader_flash_read(next_addr, segment_header, sizeof(esp_image_segment_header_t));
         if (err == ESP_OK) {
             if ((segment_header->data_len & 3) != 0
@@ -69,6 +70,7 @@ esp_err_t esp_image_load_segment_header(uint8_t index, uint32_t src_addr, const
                 ESP_LOGE(TAG, "invalid segment length 0x%x", segment_header->data_len);
                 err = ESP_ERR_IMAGE_INVALID;
             }
+            ESP_LOGV(TAG, "segment data length 0x%x", segment_header->data_len);
             next_addr += sizeof(esp_image_segment_header_t);
             *segment_data_offset = next_addr;
             next_addr += segment_header->data_len;
@@ -140,7 +142,11 @@ esp_err_t esp_image_basic_verify(uint32_t src_addr, uint32_t *p_length)
     }
 
     /* image padded to next full 16 byte block, with checksum byte at very end */
-    length += 15 - (length % 16);
+    ESP_LOGV(TAG, "unpadded image length 0x%x", length);
+    length += 16; /* always pad by at least 1 byte */
+    length = length - (length % 16);
+    ESP_LOGV(TAG, "padded image length 0x%x", length);
+    ESP_LOGD(TAG, "reading checksum block at 0x%x", src_addr + length - 16);
     bootloader_flash_read(src_addr + length - 16, buf, 16);
     if (checksum != buf[15]) {
         ESP_LOGE(TAG, "checksum failed. Calculated 0x%x read 0x%x",
index ce4acb7bc9a36180ddf93615d75f7ecdb265a35a..783f2c59bbe62f7e4197c1646fca75a1f7f197bb 100644 (file)
@@ -21,7 +21,7 @@ extern "C"
 {
 #endif
 
-#define ESP_PARTITION_TABLE_ADDR 0x4000
+#define ESP_PARTITION_TABLE_ADDR 0x8000
 #define ESP_PARTITION_MAGIC 0x50AA
 
 /* OTA selection structure (two copies in the OTA data partition.)
index e6f3bce8f92dcbe00609eb05ec54a6b826134255..4273f53c3a97176d7554720b9275749ae144f7a2 100644 (file)
@@ -11,6 +11,8 @@
 # NB: gen_esp32part.py lives in the sdk/bin/ dir not component dir
 GEN_ESP32PART := $(PYTHON) $(COMPONENT_PATH)/gen_esp32part.py -q
 
+PARTITION_TABLE_OFFSET := 0x8000
+
 # Path to partition CSV file is relative to project path for custom
 # partition CSV files, but relative to component dir otherwise.$
 PARTITION_TABLE_ROOT := $(call dequote,$(if $(CONFIG_PARTITION_TABLE_CUSTOM),$(PROJECT_PATH),$(COMPONENT_PATH)))
@@ -27,8 +29,8 @@ endif
 
 all_binaries: $(PARTITION_TABLE_BIN)
 
-PARTITION_TABLE_FLASH_CMD = $(ESPTOOLPY_SERIAL) write_flash 0x4000 $(PARTITION_TABLE_BIN)
-ESPTOOL_ALL_FLASH_ARGS += 0x4000 $(PARTITION_TABLE_BIN)
+PARTITION_TABLE_FLASH_CMD = $(ESPTOOLPY_SERIAL) write_flash $(PARTITION_TABLE_OFFSET) $(PARTITION_TABLE_BIN)
+ESPTOOL_ALL_FLASH_ARGS += $(PARTITION_TABLE_OFFSET) $(PARTITION_TABLE_BIN)
 
 partition_table: $(PARTITION_TABLE_BIN)
        @echo "Partition table binary generated. Contents:"