Flash lock bits,如何设置
ti_51ew_cc2540b.xcl 中有定义有
//
// Flash lock bits
// ---------------
//
// The CC2540 has its flash lock bits, one bit for each 2048 B flash page, located in
// the last available flash page, starting 16 bytes from the page end. The number of
// bytes with flash lock bits depends on the flash size configuration of the CC2540
// (maximum 16 bytes, i.e. 128 page lock bits, for the CC2530 with 256 kB flash).
// But since the bit that controls the debug interface lock is always in the last byte
// we include all 16 bytes in the segment, regardless of flash size.
//
-D_FLASH_LOCK_BITS_START=((_NR_OF_BANKS*_FIRST_BANK_ADDR)+0xFFF0)
-D_FLASH_LOCK_BITS_END=((_NR_OF_BANKS*_FIRST_BANK_ADDR)+0xFFFF)
// (this should resolve to 0x7FFF0-0x7FFFF if 256 kB flash (_NR_OF_BANKS=7), and
// 0x3FFF0-0x3FFFF if 128 kB flash (_NR_OF_BANKS=3))
//
//
// Define as segment in case one wants to put something there intentionally (then comment out the hack below)
-Z(CODE)FLASH_LOCK_BITS=_FLASH_LOCK_BITS_START-_FLASH_LOCK_BITS_END
我在程序中使用下面的方法发现不起作用
#pragma location = "FLASH_LOCK_BITS"
const char arry[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
如何正确的设置可以防止程序被读出来?
找到一个解决方法.感觉应该是因为只定义未使用而被优化了
改成下面这个方式就可以设置成功了
#pragma location = "FLASH_LOCK_BITS" //在.XCL文件中修改
__root const char arry[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
Dear Grap,
//
// Flash lock bits
// ---------------
//
// The CC2540 has its flash lock bits, one bit for each 2048 B flash page, located in
// the last available flash page, starting 16 bytes from the page end. The number of
// bytes with flash lock bits depends on the flash size configuration of the CC2540
// (maximum 16 bytes, i.e. 128 page lock bits, for the CC2530 with 256 kB flash).
// But since the bit that controls the debug interface lock is always in the last byte
// we include all 16 bytes in the segment, regardless of flash size.
//
-D_FLASH_LOCK_BITS_START=((_NR_OF_BANKS*_FIRST_BANK_ADDR)+0xFFF0)
-D_FLASH_LOCK_BITS_END=((_NR_OF_BANKS*_FIRST_BANK_ADDR)+0xFFFF)
// (this should resolve to 0x7FFF0-0x7FFFF if 256 kB flash (_NR_OF_BANKS=7), and
// 0x3FFF0-0x3FFFF if 128 kB flash (_NR_OF_BANKS=3))
//
//
// Define as segment in case one wants to put something there intentionally (then comment out the hack below)
-Z(CODE)FLASH_LOCK_BITS=_FLASH_LOCK_BITS_START-_FLASH_LOCK_BITS_END
//
// Hack to reserve the FLASH_LOCK_BITS segment from being used as CODE, avoiding
// code to be placed on top of the flash lock bits. If code is placed on address 0x0000,
// (INTVEC is by default located at 0x0000) then the flash lock bits will be reserved too.
//
-U(CODE)0x0000=(CODE)_FLASH_LOCK_BITS_START-_FLASH_LOCK_BITS_END
#pragma location = "FLASH_LOCK_BITS" //在.XCL文件中修改
__root const char arry[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
//
////////////////////////////////////////////////////////////////////////////////
你是直接加在lcok bit最下面嗎?
你是在ti_51ew_cc2540b.xcl 增加的沒錯吧,但小弟有一個疑問是有關於你在flash programmer 的時候flash lock的時候
我看ti 文件參數只有單純對 1,4-126 4~126page 做flash lock,但我dump出來hex,比較好像沒有差別太多?
能否問一下你的使用方法?
謝謝,
Ben
Dear Ben,
我的做法是:
ti_51ew_cc2540b.xcl里面注释掉-U(CODE)0x0000=(CODE)_FLASH_LOCK_BITS_START-_FLASH_LOCK_BITS_END
在 .c 的文件中加入
#pragma location = "FLASH_LOCK_BITS" //在.XCL文件中修改
__root const char arry[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
配置文件默认会把所有程序中未用的FLASH设置为0xff,所以我只是改变了最后16byte的FLASH,反映至hex大小可能不会有变化,而且hex并不能代表实际下载的大小,也不能说明什么
也可以在生成的hex文件中修改!
Dear Grap,
所以假設你要使用的是bit lock file 是sensortag.c 這個function 在加上一段define
#pragrma location="FLASH_LOCK_BITS"
__root const char arry[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
我發現在build imageA和imageB好像會造成error 請問這有方法解嗎?
如果不使用oad功能是可以的,但我是想要試試看A/B .\
define 只包在sensortag.c 裡面應該只有lock sensortag.c ?這沒錯吧?
如果要lock bit整個FW呢?
thanks
Ben
Dear Ben,
我也没做过这样的尝试,不过我觉得设置成下面的数据可能会解决这个问题
__root const char arry[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f};