1# SPDX-FileCopyrightText: 2014-2022 Fredrik Ahlberg, Angus Gratton,
2# Espressif Systems (Shanghai) CO LTD, other contributors as noted.
3#
4# SPDX-License-Identifier: GPL-2.0-or-later
5
6from .esp32s3 import ESP32S3ROM
7
8
9class ESP32S3BETA2ROM(ESP32S3ROM):
10    CHIP_NAME = "ESP32-S3(beta2)"
11    IMAGE_CHIP_ID = 4
12
13    CHIP_DETECT_MAGIC_VALUE = [0xEB004136]
14
15    EFUSE_BASE = 0x6001A000  # BLOCK0 read base address
16
17
18class ESP32S3BETA2StubLoader(ESP32S3BETA2ROM):
19    """Access class for ESP32S3 stub loader, runs on top of ROM.
20
21    (Basically the same as ESP32StubLoader, but different base class.
22    Can possibly be made into a mixin.)
23    """
24
25    FLASH_WRITE_SIZE = 0x4000  # matches MAX_WRITE_BLOCK in stub_loader.c
26    STATUS_BYTES_LENGTH = 2  # same as ESP8266, different to ESP32 ROM
27    IS_STUB = True
28
29    def __init__(self, rom_loader):
30        self.secure_download_mode = rom_loader.secure_download_mode
31        self._port = rom_loader._port
32        self._trace_enabled = rom_loader._trace_enabled
33        self.cache = rom_loader.cache
34        self.flush_input()  # resets _slip_reader
35
36
37ESP32S3BETA2ROM.STUB_CLASS = ESP32S3BETA2StubLoader
38