CCLib icon indicating copy to clipboard operation
CCLib copied to clipboard

Wrong flash size read if chip is DEBUG_LOCKED

Open ReDetection opened this issue 7 years ago • 3 comments

Hello again.

According to the cc_info output, my CC2541 chip has 16kb flash (looks similar to #1). In the datasheet however it's stated only 128kb and 256kb versions and markings on the chip itself tell me I have 256kb.

What is recommended way to find, verify and fix the issue?

ReDetection avatar Jan 24 '19 16:01 ReDetection

(output of cc_info)

INFO: Found a CC2541 chip on /dev/cu.usbserial-A70051tV

Chip information:
      Chip ID : 0x4113
   Flash size : 16 Kb
    Page size : 2 Kb
    SRAM size : 1 Kb
          USB : No

Device information:
 IEEE Address : 000000000000
           PC : 0000

Debug status:
 [ ] CHIP_ERASE_BUSY
 [ ] PCON_IDLE
 [X] CPU_HALTED
 [ ] PM_ACTIVE
 [ ] HALT_STATUS
 [X] DEBUG_LOCKED
 [X] OSCILLATOR_STABLE
 [ ] STACK_OVERFLOW

Debug config:
 [ ] SOFT_POWER_MODE
 [ ] TIMERS_OFF
 [ ] DMA_PAUSE
 [ ] TIMER_SUSPEND

ReDetection avatar Jan 24 '19 17:01 ReDetection

OK, according to datasheet:

When the debug-lock bit, DBGLOCK, is set to 0 (see Table 3-5), all debug commands except CHIP_ERASE, READ_STATUS, and GET_CHIP_ID are disabled. The status of the debug-lock bit can be read using the READ_STATUS command (see Section 3.3.2).

So that explains why I got only chip id and statuses. After chip erase (./cc_write_flash.py --erase with any hex in the --in= parameter, even dump from ./cc_read_flash.py would work just fine) everything is back to normal and reporting correct flash size 🎉

I think maybe it's a bad idea to try to read some particular register out of the chip if it's known to be debug locked. Would suggest to early exit if it's debug locked.

ReDetection avatar Jan 25 '19 03:01 ReDetection

It might be nice if there was a way to do this through the command, like --erase --empty-flash or something.

skandragon avatar Nov 06 '19 05:11 skandragon