/* SPDX-License-Identifier: GPL-2.0-or-later *//*************************************************************************** * Copyright (C) 2011 by Rodrigo L. Rosa * * rodrigorosa.LG@gmail.com * * * * Based on dsp563xx_once.h written by Mathias Kuester * * mkdorg@users.sourceforge.net * ***************************************************************************//* ... */#ifndefOPENOCD_TARGET_DSP5680XX_H#defineOPENOCD_TARGET_DSP5680XX_H#include<jtag/jtag.h>/** * @file dsp5680xx.h * @author Rodrigo Rosa <rodrigorosa.LG@gmail.com> * @date Thu Jun 9 18:54:38 2011 * * @brief Basic support for the 5680xx DSP from Freescale. * The chip has two taps in the JTAG chain, the Master tap and the Core tap. * In this code the Master tap is only used to unlock the flash memory by executing a JTAG instruction. * *//* ... */#defineS_FILE_DATA_OFFSET0x200000#defineTIME_DIV_FREESCALE0.3/** ---------------------------------------------------------------- * JTAG *---------------------------------------------------------------- *//* ... */#defineDSP5680XX_JTAG_CORE_TAP_IRLEN4#defineDSP5680XX_JTAG_MASTER_TAP_IRLEN8#defineJTAG_STATUS_MASK0x0F#defineJTAG_STATUS_NORMAL0x01#defineJTAG_STATUS_STOPWAIT0x05#defineJTAG_STATUS_BUSY0x09#defineJTAG_STATUS_DEBUG0x0D#defineJTAG_STATUS_DEAD0x0f#defineJTAG_INSTR_EXTEST0x0#defineJTAG_INSTR_SAMPLE_PRELOAD0x1#defineJTAG_INSTR_IDCODE0x2#defineJTAG_INSTR_EXTEST_PULLUP0x3#defineJTAG_INSTR_HIGHZ0x4#defineJTAG_INSTR_CLAMP0x5#defineJTAG_INSTR_ENABLE_ONCE0x6#defineJTAG_INSTR_DEBUG_REQUEST0x7#defineJTAG_INSTR_BYPASS0xF/** * ---------------------------------------------------------------- *//* ... *//** ---------------------------------------------------------------- * Master TAP instructions from MC56F8000RM.pdf * ---------------------------------------------------------------- *//* ... */#defineMASTER_TAP_CMD_BYPASS0xF#defineMASTER_TAP_CMD_IDCODE0x2#defineMASTER_TAP_CMD_TLM_SEL0x5#defineMASTER_TAP_CMD_FLASH_ERASE0x8/** * ---------------------------------------------------------------- *//* ... *//** ---------------------------------------------------------------- * EOnCE control register info * ---------------------------------------------------------------- *//* ... */#defineDSP5680XX_ONCE_OCR_EX(1<<5)/* EX Bit Definition 0 Remain in the Debug Processing State 1 Leave the Debug Processing State *//* ... */#defineDSP5680XX_ONCE_OCR_GO(1<<6)/* GO Bit Definition 0 Inactive—No Action Taken 1 Execute Controller Instruction *//* ... */#defineDSP5680XX_ONCE_OCR_RW(1<<7)/** RW Bit Definition * 0 Write To the Register Specified by the RS[4:0] Bits * 1 ReadFrom the Register Specified by the RS[4:0] Bits * ---------------------------------------------------------------- *//* ... *//** ---------------------------------------------------------------- * EOnCE Status Register * ---------------------------------------------------------------- *//* ... */#defineDSP5680XX_ONCE_OSCR_OS1(1<<5)#defineDSP5680XX_ONCE_OSCR_OS0(1<<4)/** * ---------------------------------------------------------------- *//* ... *//** ---------------------------------------------------------------- * EOnCE Core Status - Describes the operating status of the core controller * ---------------------------------------------------------------- *//* ... */#defineDSP5680XX_ONCE_OSCR_NORMAL_M(0)/* 00 - Normal - Controller Core Executing Instructions or in Reset */#defineDSP5680XX_ONCE_OSCR_STOPWAIT_M(DSP5680XX_ONCE_OSCR_OS0)/* 01 - Stop/Wait - Controller Core in Stop or Wait Mode */#defineDSP5680XX_ONCE_OSCR_BUSY_M(DSP5680XX_ONCE_OSCR_OS1)/* 10 - Busy - Controller is Performing External or Peripheral Access (Wait States) */#defineDSP5680XX_ONCE_OSCR_DEBUG_M(DSP5680XX_ONCE_OSCR_OS0|DSP5680XX_ONCE_OSCR_OS1)/* 11 - Debug - Controller Core Halted and in Debug Mode */#defineEONCE_STAT_MASK0x30/** * ---------------------------------------------------------------- *//* ... *//** ---------------------------------------------------------------- * Register Select Encoding (eonce_rev.1.0_0208081.pdf:14) * ---------------------------------------------------------------- *//* ... */#defineDSP5680XX_ONCE_NOREG0x00/* No register selected */#defineDSP5680XX_ONCE_OCR0x01/* OnCE Debug Control Register */#defineDSP5680XX_ONCE_OCNTR0x02/* OnCE Breakpoint and Trace Counter */#defineDSP5680XX_ONCE_OSR0x03/* EOnCE status register */#defineDSP5680XX_ONCE_OBAR0x04/* OnCE Breakpoint Address Register */#defineDSP5680XX_ONCE_OBASE0x05/* EOnCE Peripheral Base Address register */#defineDSP5680XX_ONCE_OTXRXSR0x06/* EOnCE TXRX Status and Control Register (OTXRXSR) */#defineDSP5680XX_ONCE_OTX0x07/* EOnCE Transmit register (OTX) */#defineDSP5680XX_ONCE_OPDBR0x08/* EOnCE Program Data Bus Register (OPDBR) */#defineDSP5680XX_ONCE_OTX10x09/* EOnCE Upper Transmit register (OTX1) */#defineDSP5680XX_ONCE_OPABFR0x0A/* OnCE Program Address Register—Fetch cycle */#defineDSP5680XX_ONCE_ORX0x0B/* EOnCE Receive register (ORX) */#defineDSP5680XX_ONCE_OCNTR_C0x0C/* Clear OCNTR */#defineDSP5680XX_ONCE_ORX10x0D/* EOnCE Upper Receive register (ORX1) */#defineDSP5680XX_ONCE_OTBCR0x0E/* EOnCE Trace Buffer Control Reg (OTBCR) */#defineDSP5680XX_ONCE_OPABER0x10/* OnCE Program Address Register—Execute cycle */#defineDSP5680XX_ONCE_OPFIFO0x11/* OnCE Program address FIFO */#defineDSP5680XX_ONCE_OBAR10x12/* EOnCE Breakpoint 1 Unit 0 Address Reg.(OBAR1) */#defineDSP5680XX_ONCE_OPABDR0x13/* OnCE Program Address Register—Decode cycle (OPABDR) *//** * ---------------------------------------------------------------- *//* ... */#defineFLUSH_COUNT_READ_WRITE8192/* This value works, higher values (and lower...) may work as well. */#defineFLUSH_COUNT_FLASH8192/** ---------------------------------------------------------------- * HFM (flash module) Commands (ref:MC56F801xRM.pdf:159) * ---------------------------------------------------------------- *//* ... */#defineHFM_ERASE_VERIFY0x05#defineHFM_CALCULATE_DATA_SIGNATURE0x06#defineHFM_WORD_PROGRAM0x20#defineHFM_PAGE_ERASE0x40#defineHFM_MASS_ERASE0x41#defineHFM_CALCULATE_IFR_BLOCK_SIGNATURE0x66/** * ---------------------------------------------------------------- *//* ... *//** ---------------------------------------------------------------- * Flashing (ref:MC56F801xRM.pdf:159) * ---------------------------------------------------------------- *//* ... */#defineHFM_BASE_ADDR0x0F400/** In x: mem. (write to S_FILE_DATA_OFFSET+HFM_BASE_ADDR * to get data into x: mem.) *//* ... *//** * The following are register addresses, not memory * addresses (though all registers are memory mapped) *//* ... */#defineHFM_CLK_DIV0x00/* r/w */#defineHFM_CNFG0x01/* r/w */#defineHFM_SECHI0x03/* r */#defineHFM_SECLO0x04/* r */#defineHFM_PROT0x10/* r/w */#defineHFM_PROTB0x11/* r/w */#defineHFM_USTAT0x13/* r/w */#defineHFM_CMD0x14/* r/w */#defineHFM_DATA0x18/* r */#defineHFM_OPT10x1B/* r */#defineHFM_TSTSIG0x1D/* r */#defineHFM_EXEC_COMPLETE0x40/* User status register (USTAT) masks (MC56F80XXRM.pdf:6.7.5) */#defineHFM_USTAT_MASK_BLANK0x4#defineHFM_USTAT_MASK_PVIOL_ACCER0x30/** * The value used on for the FM clock is important to prevent flashing errors and to prevent deterioration of the FM. * This value was calculated using a spreadsheet tool available on the Freescale website under FAQ 25464. * *//* ... */#defineHFM_CLK_DEFAULT0x27/* 0x27 according to freescale cfg, but 0x40 according to freescale spreadsheet... */#defineHFM_FLASH_BASE_ADDR0x0#defineHFM_SIZE_BYTES0x4000/* bytes */#defineHFM_SIZE_WORDS0x2000/* words */#defineHFM_SECTOR_SIZE0x200/* Size in bytes */#defineHFM_SECTOR_COUNT0x20/* A 16K block in pages of 256 words. *//** * Writing HFM_LOCK_FLASH to HFM_LOCK_ADDR_L and HFM_LOCK_ADDR_H will enable security on flash after the next reset. *//* ... */#defineHFM_LOCK_FLASH0xE70A#defineHFM_LOCK_ADDR_L0x1FF7#defineHFM_LOCK_ADDR_H0x1FF8/** * ---------------------------------------------------------------- *//* ... *//** ---------------------------------------------------------------- * Register Memory Map (eonce_rev.1.0_0208081.pdf:16) * ---------------------------------------------------------------- *//* ... */#defineMC568013_EONCE_OBASE_ADDR0xFF/* The following are relative to EONCE_OBASE_ADDR (EONCE_OBASE_ADDR<<16 + ...) */#defineMC568013_EONCE_TX_RX_ADDR0xFFFE#defineMC568013_EONCE_TX1_RX1_HIGH_ADDR0xFFFF/* Relative to EONCE_OBASE_ADDR */#defineMC568013_EONCE_OCR0xFFA0/* Relative to EONCE_OBASE_ADDR *//** * ---------------------------------------------------------------- *//* ... *//** ---------------------------------------------------------------- * SIM addresses & commands (MC56F80xx.h from freescale) * ---------------------------------------------------------------- *//* ... */#defineMC568013_SIM_BASE_ADDR0xF140#defineMC56803X_2X_SIM_BASE_ADDR0xF100#defineSIM_CMD_RESET0x10/** * ---------------------------------------------------------------- *//* ... *//** * ---------------------------------------------------------------- * ERROR codes - enable automatic parsing of output * ---------------------------------------------------------------- *//* ... */#defineDSP5680XX_ERROR_UNKNOWN_OR_ERROR_OPENOCD-100#defineDSP5680XX_ERROR_JTAG_COMM-1#defineDSP5680XX_ERROR_JTAG_RESET-2#defineDSP5680XX_ERROR_JTAG_INVALID_TAP-3#defineDSP5680XX_ERROR_JTAG_DR_LEN_OVERFLOW-4#defineDSP5680XX_ERROR_INVALID_IR_LEN-5#defineDSP5680XX_ERROR_JTAG_TAP_ENABLE_MASTER-6#defineDSP5680XX_ERROR_JTAG_TAP_ENABLE_CORE-7#defineDSP5680XX_ERROR_JTAG_TAP_FIND_MASTER-8#defineDSP5680XX_ERROR_JTAG_TAP_FIND_CORE-9#defineDSP5680XX_ERROR_JTAG_DRSCAN-10#defineDSP5680XX_ERROR_JTAG_IRSCAN-11#defineDSP5680XX_ERROR_ENTER_DEBUG_MODE-12#defineDSP5680XX_ERROR_RESUME-13#defineDSP5680XX_ERROR_WRITE_WITH_TARGET_RUNNING-14#defineDSP5680XX_ERROR_INVALID_DATA_SIZE_UNIT-15#defineDSP5680XX_ERROR_PROTECT_CHECK_INVALID_ARGS-16#defineDSP5680XX_ERROR_FM_BUSY-17#defineDSP5680XX_ERROR_FM_CMD_TIMED_OUT-18#defineDSP5680XX_ERROR_FM_EXEC-19#defineDSP5680XX_ERROR_FM_SET_CLK-20#defineDSP5680XX_ERROR_FLASHING_INVALID_WORD_COUNT-21#defineDSP5680XX_ERROR_FLASHING_CRC-22#defineDSP5680XX_ERROR_FLASHING-23#defineDSP5680XX_ERROR_NOT_IMPLEMENTED_STEP-24#defineDSP5680XX_ERROR_HALT-25#defineDSP5680XX_ERROR_EXIT_DEBUG_MODE-26#defineDSP5680XX_ERROR_TARGET_RUNNING-27#defineDSP5680XX_ERROR_NOT_IN_DEBUG-28120 defines/** * ---------------------------------------------------------------- *//* ... */structdsp5680xx_common{uint32_tstored_pc;intflush;booldebug_mode_enabled;...};staticinlinestructdsp5680xx_common*target_to_dsp5680xx(structtarget*target){returntarget->arch_info;}{ ... }/** * Writes to flash memory. * Does not check if flash is erased, it's up to the user to erase the flash before running * this function. * The flashing algorithm runs from RAM, reading from a register to which this function * writes to. The algorithm is open loop, there is no control to verify that the FM read * the register before writing the next data. A closed loop approach was much slower, * and the current implementation does not fail, and if it did the crc check would detect it, * allowing to flash again. * * @param target * @param buffer * @param address Word addressing. * @param count In bytes. * @param is_flash_lock * * @return *//* ... */intdsp5680xx_f_wr(structtarget*target,constuint8_t*buffer,uint32_taddress,uint32_tcount,intis_flash_lock);/** * The FM has the functionality of checking if the flash array is erased. This function * executes it. It does not support individual sector analysis. * * @param target * @param erased * @param sector This parameter is ignored because the FM does not support checking if * individual sectors are erased. * * @return *//* ... */intdsp5680xx_f_erase_check(structtarget*target,uint8_t*erased,uint32_tsector);/** * Erases either a sector or the complete flash array. If either the range first-last covers * the complete array or if first == 0 and last == 0 then a mass erase command is executed * on the FM. If not, then individual sectors are erased. * * @param target * @param first * @param last * * @return *//* ... */intdsp5680xx_f_erase(structtarget*target,intfirst,intlast);/** * Reads the memory mapped protection register. A 1 implies the sector is protected, * a 0 implies the sector is not protected. * * @param target * @param protected Data read from the protection register. * * @return *//* ... */intdsp5680xx_f_protect_check(structtarget*target,uint16_t*protected);/** * Writes the flash security words with a specific value. The chip's security will be * enabled after the first reset following the execution of this function. * * @param target * * @return *//* ... */intdsp5680xx_f_lock(structtarget*target);/** * Executes a mass erase command. The must be done from the Master tap. * It is up to the user to select the master tap (jtag tapenable dsp5680xx.chp) * before running this function. * The flash array will be unsecured (and erased) after the first reset following * the execution of this function. * * @param target * * @return *//* ... */intdsp5680xx_f_unlock(structtarget*target);/* ... */#endif/* OPENOCD_TARGET_DSP5680XX_H */
Details
Show: from
Types: Columns:
All items filtered out
All items filtered out
Click anywhere in the source to view detailed information here...