| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- #
- # Copyright (C) <2019-2021>
- # <Cypress Semiconductor Corporation (an Infineon company)>
- #
- source [find target/mxs40/psoc6_detect_geometry.cfg]
- source [find target/mxs40/traveo2_detect_geometry.cfg]
- #
- # shows flash boot version
- #
- # arguments:
- # target_arch - the target architecture - psoc6 or traveo2
- #
- proc show_flash_boot_ver { target_arch } {
- set fb_ver_str ""
- set fb_ver_hi_addr ""
- set fb_ver_lo_addr ""
- switch $target_arch {
- "psoc6" -
- "psoc6_2m" {
- set fb_ver_hi_addr 0x16002004
- set fb_ver_lo_addr 0x16002018
- set sflash_svn_ver_addr 0x16000028
- }
- "traveo21" -
- "traveo22" {
- set fb_ver_hi_addr 0x17002004
- set fb_ver_lo_addr 0x17002018
- set sflash_svn_ver_addr 0x170000A8
- }
- default {
- puts stderr "Error: Invalid Target passed into 'show_flash_boot_ver'"
- return
- }
- }
- set fb_ver_lo ""
- set fb_ver_hi ""
- catch { set fb_ver_hi [mrw $fb_ver_hi_addr] }
- if {$fb_ver_hi eq "" || !$fb_ver_hi} {
- puts stderr "Error: Invalid FlashBoot: High version word of Flash Boot is zero"
- return
- }
- catch { set fb_ver_lo [mrw $fb_ver_lo_addr] }
- set b0 [expr { $fb_ver_hi >> 28 } ]
- set b1 [expr {($fb_ver_hi >> 24) & 0xF } ]
- set b2 [expr {($fb_ver_hi >> 16) & 0xFF} ]
- set b3 [expr {$fb_ver_hi & 0x0000FFFF}]
- if {$b0 > 2} {
- puts stderr "Error: Unsupported Flash Boot Version - Flash Boot Version \[31:28] = $b0"
- return
- }
- if {$b3 != 0x8001} {
- puts stderr "Error: Flash Boot is corrupted or non Flash Boot image programmed"
- return
- }
- if { $b0 == 0 } { ; # Versioning scheme #1 or #2, PSoC6A-BLE-2 device family
- if { $b1 == 1 } { ; # Versioning scheme #1, ** or *A
- set fb_ver_str [format "1.%02d" $b2]
- } elseif { $b1 == 2 } {
- if { $b2 < 20 } {
- set fb_ver_str [format "1.0.0.%d" $b2]
- } elseif { $b2 < 29 } {
- set fb_ver_str [format "1.0.1.%d" $b2]
- } else {
- set fb_ver_str [format "1.20.1.%d" $b2]
- }
- }
- } elseif { $b0 == 1 } { ;# TVII-BE-1M **
- set fb_ver_str [format "2.0.0.%d" $b2]
- } elseif { $b0 == 2 } { ;# Versioning scheme #3
- set patch [expr { $fb_ver_lo >> 24} ]
- set build [expr { $fb_ver_lo & 0xFFFF } ]
- set fb_ver_str [format "%d.%d.%d.%d" $b1 $b2 $patch $build ]
- }
- echo "** Flash Boot version: $fb_ver_str"
- set sflash_svn_ver 0
- catch {
- set sflash_svn_ver [mrw $sflash_svn_ver_addr]
- }
- if { $sflash_svn_ver != 0 && $sflash_svn_ver != 0xFFFFFFFF } {
- echo "** SFlash version: $sflash_svn_ver"
- }
- return $fb_ver_str
- }
- #
- # shows chip protection
- #
- # arguments:
- # target_arch - the target architecture - psoc6 or traveo2
- #
- proc show_chip_protection {target_arch} {
- switch $target_arch {
- "psoc6" {
- set cpuss_prot_reg 0x40210500
- }
- "psoc6_2m" -
- "traveo21" -
- "traveo22" {
- set cpuss_prot_reg 0x402020C4
- }
- default {
- puts stderr "Error: Invalid Target passed into 'show_chip_protection'"
- return
- }
- }
- set protection [ mrw $cpuss_prot_reg ]
- set ret "X"
- switch $protection {
- 1 { set ret "VIRGIN" }
- 2 { set ret "NORMAL" }
- 3 { set ret "SECURE" }
- 4 { set ret "DEAD" }
- default { set ret "UNKNOWN" }
- }
- echo "** Chip Protection: $ret"
- }
- #
- # shows and set device specific parameters
- #
- # arguments:
- # target_arch - the target architecture - psoc6, psoc6_2m or traveo2
- # main_reg_name - the name of main region to be set
- # work_reg_name - the name of work region to be set
- #
- proc cy_get_set_device_param {target_arch {main_reg_name ""} {work_reg_name ""}} {
- set tgt [target current]
- set CHIPNAME [string range ${tgt} 0 [expr {[string first "." ${tgt}] - 1}]]
- global ${CHIPNAME}::info_runned
- global ${CHIPNAME}::wrong_cfg_msg
- if { ![info exist ${CHIPNAME}::info_runned] } {
- echo "***************************************"
- switch $target_arch {
- "psoc6" -
- "psoc6_2m" {
- psoc6_detect_geometry $target_arch $main_reg_name
- }
- "traveo21" -
- "traveo22" {
- traveo2_detect_geometry $target_arch $main_reg_name $work_reg_name
- }
- default {
- puts stderr [format "Error: Invalid target architecture '%s' is passed into 'cy_get_set_device_param' API" $target_arch]
- return
- }
- }
- show_flash_boot_ver $target_arch
- show_chip_protection $target_arch
- echo "***************************************"
- if { [info exist ${CHIPNAME}::wrong_cfg_msg] && [set ${CHIPNAME}::wrong_cfg_msg] != "" } {
- set cfg_file [set ${CHIPNAME}::wrong_cfg_msg]
- puts stderr "*******************************************************************************"
- if {[using_jtag]} {
- puts stderr "* JTAG CHIPNAME: ${CHIPNAME}"
- }
- puts stderr "* The detected device does not match the configuration file in use."
- puts stderr "* Flash programming will not work. Please use the $cfg_file"
- puts stderr "* configuration file, or attach a kit that matches the configuration file."
- puts stderr "*******************************************************************************"
- terminate
- }
- set ${CHIPNAME}::info_runned true
- }
- }
|