1#!/usr/bin/env python 2# This file describes eFuses fields and registers for ESP32 chip 3# 4# Copyright (C) 2020 Espressif Systems (Shanghai) PTE LTD 5# 6# This program is free software; you can redistribute it and/or modify it under 7# the terms of the GNU General Public License as published by the Free Software 8# Foundation; either version 2 of the License, or (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, but WITHOUT 11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13# 14# You should have received a copy of the GNU General Public License along with 15# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin 16# Street, Fifth Floor, Boston, MA 02110-1301 USA. 17from __future__ import division, print_function 18 19from collections import namedtuple 20 21 22class EfuseRegistersBase(object): 23 # Coding Scheme values 24 CODING_SCHEME_NONE = 0 25 CODING_SCHEME_34 = 1 26 CODING_SCHEME_REPEAT = 2 27 CODING_SCHEME_NONE_RECOVERY = 3 28 CODING_SCHEME_RS = 4 29 30 EFUSE_BURN_TIMEOUT = 0.250 # seconds 31 32 33class EfuseBlocksBase(object): 34 35 BLOCKS = None 36 NamedtupleBlock = namedtuple('Block', 'name alias id rd_addr wr_addr write_disable_bit read_disable_bit len key_purpose') 37 38 @staticmethod 39 def get(tuple_block): 40 return EfuseBlocksBase.NamedtupleBlock._make(tuple_block) 41 42 def get_blocks_for_keys(self): 43 list_of_names = [] 44 for block in self.BLOCKS: 45 blk = self.get(block) 46 if blk.id > 0: 47 if blk.name: 48 list_of_names.append(blk.name) 49 if blk.alias: 50 for alias in blk.alias: 51 list_of_names.append(alias) 52 return list_of_names 53 54 55class EfuseFieldsBase(object): 56 57 NamedtupleField = namedtuple('Efuse', 'name category block word pos type write_disable_bit read_disable_bit class_type description dictionary') 58 59 @staticmethod 60 def get(tuple_field): 61 return EfuseFieldsBase.NamedtupleField._make(tuple_field) 62