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    def get_chip_description(self):
18        major_rev = self.get_major_chip_version()
19        minor_rev = self.get_minor_chip_version()
20        return f"{self.CHIP_NAME} (revision v{major_rev}.{minor_rev})"
21
22
23class ESP32S3BETA2StubLoader(ESP32S3BETA2ROM):
24    """Access class for ESP32S3 stub loader, runs on top of ROM.
25
26    (Basically the same as ESP32StubLoader, but different base class.
27    Can possibly be made into a mixin.)
28    """
29
30    FLASH_WRITE_SIZE = 0x4000  # matches MAX_WRITE_BLOCK in stub_loader.c
31    STATUS_BYTES_LENGTH = 2  # same as ESP8266, different to ESP32 ROM
32    IS_STUB = True
33
34    def __init__(self, rom_loader):
35        self.secure_download_mode = rom_loader.secure_download_mode
36        self._port = rom_loader._port
37        self._trace_enabled = rom_loader._trace_enabled
38        self.cache = rom_loader.cache
39        self.flush_input()  # resets _slip_reader
40
41
42ESP32S3BETA2ROM.STUB_CLASS = ESP32S3BETA2StubLoader
43