From: melvin c. <mel...@gm...> - 2021-07-02 11:29:12
|
I am trying to chip erase a SAML21 device which has been secured by setting the security bit. Reading the mailing list there is a reference to the SAMD chip erase --> https://sourceforge.net/p/openocd/mailman/message/36116190/ I noticed the *at91samd chip-erase* command references register addresses that are not correct for the SAML21. SAMD code is : #define SAMD_PAC1 0x41000000 /* Peripheral Access Control 1 */ #define SAMD_DSU 0x41002000 /* Device Service Unit */ #define SAMD_NVMCTRL 0x41004000 /* Non-volatile memory controller */ COMMAND_HANDLER(samd_handle_chip_erase_command) { struct target *target = get_current_target(CMD_CTX); if (target) { /* Enable access to the DSU by disabling the write protect bit */ target_write_u32(target, SAMD_PAC1, (1<<1)); /* Tell the DSU to perform a full chip erase. It takes about 240ms to * perform the erase. */ target_write_u8(target, SAMD_DSU, (1<<4)); command_print(CMD_CTX, "chip erased"); } return ERROR_OK; } The SAML registers are: #define SAMD_PAC1 0x44000000 /* Peripheral Access Control 1 */ #define SAMD_DSU 0x41002000 /* Device Service Unit */ #define SAMD_NVMCTRL 0x41004000 /* Non-volatile memory controller */ What's the best way to make this change? Is there a 'at91SAML chip-erase' command? Background Information. I am using the FT232H with a UM232H module using the FTDI MPSSE. You have to do a cold reset which is to hold the SWCLK line low while removing the reset. This I can do by running an openocd session which just holds the SWCLK and rst lines low using ftdi_layout_init. e.g. *adapter driver ftdi#ftdi_device_desc "UM232H"ftdi_vid_pid 0x0403 0x6014* *# data MSB..LSB direction (1:out) MSB..LSB# 1111'1101'1111'1000 1111'1111'1111'1011ftdi_layout_init 0xfdf8 0xfffbftdi_layout_signal SWD_EN -data 0ftdi_layout_signal SWDIO_OE -data 0x0800 -oe 0x0800ftdi_layout_signal nTRST -data 0x0100 -oe 0x0100ftdi_layout_signal nSRST -data 0x0200 -oe 0x0200ftdi_layout_signal Reset -data 0x0400 -oe 0x0400* *transport select swd# chip nameset CHIPNAME at91saml21j18set CPUTAPID 0x0bc11477source [find target/at91samdXX.cfg]reset_config none init* I then start a new openocd session to action the chip erase. *adapter driver ftditdi_vid_pid 0x0403 0x6014# data MSB..LSB direction (1:out) MSB..LSB# 1111'1111'1111'1000 1111'1111'1111'1011ftdi_layout_init 0xfff8 0xfffbftdi_layout_signal SWD_EN -data 0ftdi_layout_signal SWDIO_OE -data 0x0800 -oe 0x0800ftdi_layout_signal nTRST -data 0x0100 -oe 0x0100ftdi_layout_signal nSRST -data 0x0200 -oe 0x0200ftdi_layout_signal Reset -data 0x0400 -oe 0x0400transport select swdset CHIPNAME at91saml21j18set CPUTAPID 0x0bc11477source [find target/at91samdXX.cfg] reset_config none initsleep 100at91samd chip-erasesleep 100exit* With openocd in debug mode I get the error which shows openocd trying to access the USB register and not the PAC.: *Debug: 429 143 target.c:2482 target_write_u32(): address: 0x41000000, value: 0x00000002Debug: 430 144 target.c:2523 target_write_u8(): address: 0x41002100, value: 0x10Debug: 431 145 ftdi.c:1211 ftdi_swd_switch_seq(): JTAG-to-SWDInfo : 432 145 adi_v5_swd.c:136 swd_connect(): SWD DPIDR 0x0bc11477Debug: 433 145 arm_adi_v5.c:653 dap_dp_init(): at91saml21j18.dapDebug: 434 146 arm_adi_v5.c:698 dap_dp_init(): DAP: wait CDBGPWRUPACKDebug: 435 146 arm_adi_v5.h:506 dap_dp_poll_register(): DAP: poll 4, mask 0x20000000, value 0x20000000Debug: 436 146 arm_adi_v5.c:706 dap_dp_init(): DAP: wait CSYSPWRUPACKDebug: 437 146 arm_adi_v5.h:506 dap_dp_poll_register(): DAP: poll 4, mask 0x80000000, value 0x80000000Error: 438 148 arm_adi_v5.c:438 mem_ap_write(): Failed to write memory at 0x41000000Debug: 439 148 target.c:2528 target_write_u8(): failed: -4* |