Skip to content

Commit

Permalink
Merge pull request #25 from adafruit/support-c6
Browse files Browse the repository at this point in the history
  • Loading branch information
hathach authored Jul 5, 2024
2 parents 0de33c2 + 1805552 commit 4fb2c08
Show file tree
Hide file tree
Showing 9 changed files with 22,149 additions and 61 deletions.
23 changes: 18 additions & 5 deletions examples/Brain/program_esp_cdc/esp_binaries.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@
#define ESP_BINARIES_H_

// Configuration: select which bins to flash
#define BIN_FILES BIN_FEATHER_8266_BLINKY
#define BIN_FILES BIN_C6_BLINK_IO8

//--------------------------------------------------------------------+
// LIST OF BINARIES
//--------------------------------------------------------------------+

#define BIN_ESP32_NINA_1_7_4 0 // nina 1.7.4
#define BIN_ESP32_WIFI_AP_SKETCH \
1 // esp32 wifi accesspoint sketch with ssdi "YourAP"
#define BIN_ESP32_NINA_1_7_4 0 // nina 1.7.4
#define BIN_ESP32_WIFI_AP_SKETCH 1 // esp32 AP with ssdi "YourAP"
#define BIN_FEATHER_ESP32_V2_BLINKY 2 // Feather esp32 v2 blinky sketch

#define BIN_FEATHER_S2 10 // Feather esp32s2 factory firmware
Expand All @@ -46,6 +45,8 @@

#define BIN_FEATHER_8266_BLINKY 30 // Feather esp8266 blinky sketch

#define BIN_C6_BLINK_IO8 40 // Blink sketch for C6 with LED on IO8

//--------------------------------------------------------------------+
// Binaries include
//--------------------------------------------------------------------+
Expand Down Expand Up @@ -77,6 +78,12 @@
#elif BIN_FILES == BIN_FEATHER_8266_BLINKY
#include "esp_binaries/feather_esp8266_blinky.h"

#elif BIN_FILES == BIN_C6_BLINK_IO8
#include "esp_binaries/c6_blink_io8.h"

#else
#error "Please select BIN_FILES in esp_binaries.h"

#endif

struct {
Expand Down Expand Up @@ -128,8 +135,14 @@ struct {
#elif BIN_FILES == BIN_FEATHER_8266_BLINKY
{0x0000, &Blink_ino},

#elif BIN_FILES == BIN_C6_BLINK_IO8
{0x00000, &c6_blink_io8_bootloader},
{0x8000, &c6_blink_io8_partitions},
{0xe000, &boot_app0},
{0x10000, &c6_blink_io8},

#else
#error bin_files[] not defined
#error "Please select BIN_FILES in esp_binaries.h"
#endif
};

Expand Down
10,840 changes: 10,840 additions & 0 deletions examples/Brain/program_esp_cdc/esp_binaries/c6_blink_io8.h

Large diffs are not rendered by default.

27 changes: 21 additions & 6 deletions examples/Brain/program_esp_uart/esp_binaries.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@
#define ESP_BINARIES_H_

// Configuration: select which bins to flash
#define BIN_FILES BIN_METRO_S2
#define BIN_FILES BIN_C6_BLINK_IO8

//------------- Binaries Define -------------//
//--------------------------------------------------------------------+
// LIST OF BINARIES
//--------------------------------------------------------------------+

#define BIN_ESP32_NINA_1_7_4 0 // nina 1.7.4
#define BIN_ESP32_WIFI_AP_SKETCH \
1 // esp32 wifi accesspoint sketch with ssdi "YourAP"
#define BIN_ESP32_NINA_1_7_4 0 // nina 1.7.4
#define BIN_ESP32_WIFI_AP_SKETCH 1 // esp32 AP with ssdi "YourAP"

#define BIN_FEATHER_S2 10 // Feather esp32s2 factory firmware
#define BIN_FEATHER_S3 11 // Feather esp32s3 factory firmware
Expand All @@ -43,7 +44,11 @@

#define BIN_ESP8266 30 // Espressif esp8266

//------------- Binaries include -------------//
#define BIN_C6_BLINK_IO8 40 // Blink sketch for C6 with LED on IO8

//--------------------------------------------------------------------+
// Binaries include
//--------------------------------------------------------------------+

#if BIN_FILES == BIN_ESP32_WIFI_AP_SKETCH
#include "esp_binaries/wifi_ap_binaries.h"
Expand All @@ -69,6 +74,9 @@
#elif BIN_FILES == BIN_ESP8266
#include "esp_binaries/esp8266_binaries.h"

#elif BIN_FILES == BIN_C6_BLINK_IO8
#include "esp_binaries/c6_blink_io8.h"

#else
#error "Please select BIN_FILES in esp_binaries.h"

Expand Down Expand Up @@ -116,6 +124,13 @@ struct {

#elif BIN_FILES == BIN_ESP8266
{0x00000, &esp8266_blink_io0},

#elif BIN_FILES == BIN_C6_BLINK_IO8
{0x00000, &c6_blink_io8_bootloader},
{0x8000, &c6_blink_io8_partitions},
{0xe000, &boot_app0},
{0x10000, &c6_blink_io8},

#else
#error "Please select BIN_FILES in esp_binaries.h"
#endif
Expand Down
10,840 changes: 10,840 additions & 0 deletions examples/Brain/program_esp_uart/esp_binaries/c6_blink_io8.h

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/Adafruit_TestBed.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "Adafruit_TestBed.h"

// change to 1 to skip pre-flash md5 check for testing
#define SKIP_PRE_FLASH_MD5_CHECK 0

static inline uint32_t div_ceil(uint32_t v, uint32_t d) {
return (v + d - 1) / d;
}
Expand Down Expand Up @@ -521,7 +524,7 @@ Adafruit_TestBed::_esp32_programFlashDefl_impl(const esp32_zipfile_t *zfile,
// Check if MD5 matches to skip this file
uint8_t esp_md5[16];

#if 1 // change to 0 to skip pre-flash md5 check for testing
#if !SKIP_PRE_FLASH_MD5_CHECK
esp32boot->md5Flash(addr, zfile->uncompressed_len, esp_md5);
Serial.print("Flash MD5: ");
print_buf(esp_md5, 16);
Expand Down
37 changes: 11 additions & 26 deletions src/ESP32BootROM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

// https://docs.espressif.com/projects/esptool/en/latest/esp32/advanced-topics/serial-protocol.html

#if defined(ARDUINO_RASPBERRY_PI_PICO) || defined(__SAMD51__) || \
(defined(ARDUINO_ARCH_SAMD) && defined(ARM_MATH_CM0PLUS))

#include "ESP32BootROM.h"
#include "stub_esp32.h"
#include "stub_esp.h"

#ifdef USE_TINYUSB
#include "Adafruit_TinyUSB.h"
Expand Down Expand Up @@ -252,36 +254,19 @@ uint32_t ESP32BootROMClass::begin(unsigned long baudrate) {
Serial.printf("Chip Detect: 0x%08lX\r\n", _chip_detect);

const esp32_stub_loader_t *stub = NULL;
switch (_chip_detect) {
case CHIP_DETECT_MAGIC_ESP32:
// only ESP32 have SUPPORTS_ENCRYPTED_FLASH = false
Serial.println("Found ESP32");
stub = &stub_esp32;
_supports_encrypted_flash = false;
break;
case CHIP_DETECT_MAGIC_ESP32S2:
Serial.println("Found ESP32-S2");
stub = &stub_esp32s2;
break;

case CHIP_DETECT_MAGIC_ESP32S3:
Serial.println("Found ESP32-S3");
stub = &stub_esp32s3;
break;

case CHIP_DETECT_MAGIC_ESP8266:
Serial.println("Found ESP8266");
stub = &stub_esp8266;
break;

default:
Serial.println("Found unknown ESP");
break;
for (uint32_t i = 0; i < ESP_STUB_COUNT; i++) {
if (stub_esp_arr[i]->chip_detect == _chip_detect) {
stub = stub_esp_arr[i];
break;
}
}

if (stub) {
Serial.printf("Found %s\r\n", stub->chip_name);
VERIFY(uploadStub(stub));
VERIFY(syncStub(3000));
} else {
Serial.println("Found unknown ESP chip");
}

if (baudrate != ESP_ROM_BAUD) {
Expand Down
3 changes: 3 additions & 0 deletions src/ESP32BootROM.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,19 @@ enum {
CHIP_DETECT_MAGIC_ESP32S2 = 0x000007C6,
CHIP_DETECT_MAGIC_ESP32S3 = 0x9,
CHIP_DETECT_MAGIC_ESP8266 = 0xFFF0C101,
CHIP_DETECT_MAGIC_ESP32C6 = 0x2CE0806F,
};

typedef struct {
uint32_t chip_detect;
uint32_t entry;
uint32_t text_start;
uint32_t text_length;
const uint8_t *text;
uint32_t data_start;
uint32_t data_length;
const uint8_t *data;
const char *chip_name;
} esp32_stub_loader_t;

class ESP32BootROMClass {
Expand Down
Loading

0 comments on commit 4fb2c08

Please sign in to comment.