Documentation for “Zerocat Chipflasher” as of Wed, 24 Jun 2026 07:28:27 +0200
Repository: git://zerocat.org/zerocat/projects/chipflasher.git
Version: v3.0.0-0-b445ef922
Branch: master
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2016 Parallax Inc. DBA Parallax Semiconductor.
Version 1.00.78
Compiling...
spi-flashbase.spin
Done.
Program size is 3620 bytes
______________________________________________________________________________
********************************************************* File starts here ***
Zerocat Chipflasher --- Flash free firmware, kick the Management Engine.
Copyright (C) 2020, 2021, 2022, 2024, 2025, 2026 Kai Mertens
File spi-flashbase.spin --- Provide methods to access SPI flash chip database
This file is part of Zerocat Chipflasher.
See end of file for terms of use.
******************************************************************************
# Compiler Switches
# Object Summary
Object "spi-flashbase" Interface:
PUB init
PUB set_slot(n)
PUB get_slot
PUB inc(transparent_mode)
PUB dec(transparent_mode)
PUB get_MID
PUB get_IDn(n)
PUB get_ID
PUB get_CE
PUB iscommand(cmdnum)
PUB isstatic(ireg)
PUB iswritable(ireg)
PUB isotp(ireg)
PUB isinfo(ireg) :
PUB sprintbit(ireg, bitpos, pbuf2) :
PUB isbit(ireg, bitpos, pbitname)
PUB digits :
PUB ptr_bitnames(ireg)
PUB ptr_names_n(n)
PUB ptr_names
PUB ptr_chipset
PUB ptr_mfr(testid, mode) :
PUB get_blockaddr(bnum, pbmax) :
PUB get_bits_readblockregister
PUB get_features32
PUB get_pagesize :
PUB get_size :
PUB isADS(flag)
PUB isSRL(flag)
PUB isPSECT(flag)
PUB get_features
PUB isfeature32(feature_flags)
PUB isfeature(feature_flags)
PUB isEFAIL(flag)
PUB isUNIQ(flag)
PUB isWPS(flag)
PUB isTB(flag)
PUB get_otptype(pn, ps, pk, pe, psize, popcode_r) :
PUB get_opcode_wrblocklock(mode, p_opcode, p_arg)
PUB get_opcode_rdblocklock :
PUB xref_PTABLES(s14cmp, s6sec, anytb, bplevel, bfirst_addr, bstop_addr) :
Program: 901 Longs
Variable: 1 Longs
# Loaded Objects
# Included Files
## ./blocksizes.spin
### Constants
* Common Flash Block Sizes
## SPI Command Bytes, as collected across multiple datasheets
* Obsolete Command Bytes, found on Atmel AT26DF041
* Command Bytes, understood by most SPI flash chips
* Basic Command Bytes, understood by modern SPI flash chips
* SPI Command Bytes, Identification
* SPI Command Bytes, found on Microchip SST25VF016B
* SPI Command Bytes, found on EONSSI (e.g. EN25QH256, EN25QH128-2T)
* SPI Command Bytes, found on Macronix chips (MXIC)
* SPI Command Bytes, found on Atmel AT26DFxxx, and AT25DFxxx; Macronix
* SPI Command Bytes, found on Atmel AT25DFxxx
* SPI Command Bytes for OTP, found on AMIC A25L-types
* SPI Command Bytes for OTP, found on Spansion S25FL064P
* Individual Block Protection, found on Micron M25PE-family
* Individual Block Protection, found on Winbond W25Q..JV-family
* SPI Command Bytes, found on Winbond W25Q-types
* SPI Command Bytes, found on EONSSI EN25QH-types
* SPI Extended Address Modes, found on Winbond W25Q..JV-family (e.g. W25Q512JV)
* SPI Device Reset (found on Winbond W25Q..JV-family)
* SPI Power, extended
* SPI Power, understood by most SPI flash chips
## ENUM S3_type: SPI Instruction Set 3 (security) -- Flag Numbers 96..127
* Security on Microchip (e.g. SSTVF064C)
* Security on Macronix (MXIC) and AMIC A25LQ64
* Security on Atmel AT25DF Family
* Security on AMIC
* Security on Spansion
* OTP Commands (EONSSI)
* Security on Winbond
* Sector Protection on Atmel AT25DF/26DF Family
* Individual Block Protection, found on Winbond W25Q..JV-family
## ENUM S2_type: SPI Instruction Set 2 (fast) -- Flag Numbers 64..95
* SPI Sector Protection (e.g. Micron M25PE080)
* SPI Fast Read
## ENUM S1_type: SPI Instruction Set 1 (extended) -- Flag Numbers 32..63
* SPI high bank access, found on EONSSI EN25QH-types (e.g. EN25QH256)
* SPI extended address mode (4 bytes), found on Winbond W25Q-types (e.g. W25Q512JV)
* Extended Protection Commands
* SPI Device Reset
* SPI Extended Power Commands
* SPI Pin Configuration found on Microchip SST25VF040B, SSTVF064C
## ENUM S0_type: SPI Instruction Set 0 (basic) -- Flag Numbers 0..31
* Status Register Commands
* Read Commands
* Erase and Program Commands
* Protection Commands
* Identification Commands
* Power Commands
## Set 3: Alii
## Set 1: SPI Extended Address
## Set 0: Basic Flags
Atmel AT26DF Family does not provide S0_XAB_RES and S0_X90_REMS!
## Set 0: Alii
## JEDEC_IDs
* Manufacturer IDs ...
* Chips with static status register ...
* Chips with volatile status register ...
# Constants
## SPI Flash Database
### Terminology
1) Database = all chip definition files on disc
2) Chip Set = selected chip definition files at compile time
3) Slot = one chip definition file of a chip set
### Chipset Structure, Record Sizes and Offsets
* Number of slots in the chip set: NUMBER_OF_SLOTS
* Size of a slot in bytes
* Slot offsets in bytes
### Symbols
* Horizontal Tab
* Not Applicable, N_A, (TRUE)
### Charset Offsets for Global Protection Scheme
### Feature Flags (Extended Feature Register)
* Protection Table Numbers 0..7
* P-Table Entries
* Chip Sizes
* isADS() Flags
* isSRL() Flags
* isPSECT() Flags
* Single Flags
### Feature Flags (Basic Feature Register)
* Flag Groups
* Single Flags
# Globals
* Active Slot
# Functions
_________
PUB init
Initialize memory.
________________
PUB set_slot(n)
Set active slot number.
_____________
PUB get_slot
Get active slot number.
__________________________
PUB inc(transparent_mode)
transparent (non-zero): Jump to next slot.
not transparent (zero): Jump to next slot match.
__________________________
PUB dec(transparent_mode)
transparent (non-zero): Jump to next slot, backwards.
not transparent (zero): Jump to next slot match, backwards.
____________
PUB get_MID
Return manufacturer ID of active slot.
Return 0 if last slot.
_______________
PUB get_IDn(n)
Lookup ID for a given slot number.
___________
PUB get_ID
Return JEDEC_ID of active slot.
___________
PUB get_CE
Query CE command in respect to chip's capabilities,
return N_A (TRUE) if no erase command is available.
______________________
PUB iscommand(cmdnum)
Check whether cmdnum is set in command set of current slot.
Return FALSE if not.
Return FALSE for last slot.
___________________
PUB isstatic(ireg)
Return >is_static< register bit information for the specified slot.
Return 1 for last slot, avoid >is_volatile< condition at start of program.
_____________________
PUB iswritable(ireg)
Return >is_writable< register bit information for specified slot.
Return FALSE for last slot.
________________
PUB isotp(ireg)
Return >is_otp< register bit information for specified slot.
Return FALSE for last slot.
____________________
PUB isinfo(ireg) :
Return >is_info< register bit information for specified slot.
Return FALSE for last slot.
______________________________________
PUB sprintbit(ireg, bitpos, pbuf2) :
Print a register bit name from database into buffer.
ireg - index of SR string, 0..2
bitpos - bit position in register, 7..0
pbuf2 - pointer to string buffer, size 2 longs
Returns number of characters written (without string termination 0).
Bit names are supposed to be of less than 8 characters length.
__________________________________
PUB isbit(ireg, bitpos, pbitname)
Check a bit name.
Return TRUE if bitname matches, otherwise return FALSE.
______________
PUB digits :
Return number of digits in respect to chip size for specified slot.
Return 0 for last slot.
_______________________
PUB ptr_bitnames(ireg)
Return pointer to start of indexed bitnames string for the specified slot.
Return NULL pointer for last slot.
___________________
PUB ptr_names_n(n)
Return pointer to start of names string for the specified slot.
______________
PUB ptr_names
Return pointer to start of names string for current slot.
Return NULL pointer for last slot.
________________
PUB ptr_chipset
Return pointer to start of chip set name string.
_____________________________
PUB ptr_mfr(testid, mode) :
Return pointer to start of manufacturer ID (mode = 0).
Return pointer to start of manufacturer string (mode = 1).
__________________________________
PUB get_blockaddr(bnum, pbmax) :
_______________________________
PUB get_bits_readblockregister
Return number of bits to read for reliable RSPR data.
___________________
PUB get_features32
____________________
PUB get_pagesize :
Return size of page.
Return 0 for last slot.
________________
PUB get_size :
Return size of the chip of the specified slot.
Return N_A (TRUE) for last slot.
________________
PUB isADS(flag)
________________
PUB isSRL(flag)
__________________
PUB isPSECT(flag)
_________________
PUB get_features
_______________________________
PUB isfeature32(feature_flags)
Check whether all features are available.
Return TRUE if so, otherwise FALSE.
_____________________________
PUB isfeature(feature_flags)
Check whether all features are available.
Return TRUE if so, otherwise FALSE.
__________________
PUB isEFAIL(flag)
_________________
PUB isUNIQ(flag)
________________
PUB isWPS(flag)
_______________
PUB isTB(flag)
_____________________________________________________
PUB get_otptype(pn, ps, pk, pe, psize, popcode_r) :
Return the type of OTP, if any.
Make sure code supports both, read and write.
Erase capabilities are to be queried differently.
__________________________________________________
PUB get_opcode_wrblocklock(mode, p_opcode, p_arg)
______________________________
PUB get_opcode_rdblocklock :
____________________________________________________________________________
PUB xref_PTABLES(s14cmp, s6sec, anytb, bplevel, bfirst_addr, bstop_addr) :
Return a protected block range for a given `global' protection level,
take protection scheme bits into account: TB, SEC, CMP
This method applies for a (standard) global protection scheme -- it cannot be used for
an `individual' protection scheme (based on individual per-block protection registers)
as found on some chips. Note some chips ship both schemes, selectable per WPS or WPSEL bit.
This method relies on look-up tables.
Some of the tables could get replaced by algorythms, what saves bytes.
# Data: Manufacturers
# Data: P-Table Addresses
# Data: P04-Table
# Data: P08-Table
# Data: P16-Table
# Data: P08WB-Table
# Data: P16WB-Table
# Data: P08WW-Table
# Data: P16WW-Table
# Data: Other Data
# Data: OTP Type Data
******************************************************************************
Terms of Use:
Zerocat Chipflasher is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
Zerocat Chipflasher is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with Zerocat Chipflasher. If not, see <http://www.gnu.org/licenses/>.
************************************************************** End of File ***