Please enable JavaScript to view this site.

winIDEA Help

Version: 9.21.253

Option Bytes Programming

In this topic:

Reading Option bytes (OPBTs)

Writing Option bytes for F1x

 

This topic describes how to inspect or / and modify Option bytes. For Option Bytes programming on RH850 G3 devices, you can:

use the Option Bytes plugin or

program Option Bytes with a Python script.

 

Warning_orange

From winIDEA build 9.21.23 and newer you can configure the FP5 clock via service call. Default value is 1500. If the default value is being used, no need to specify it in the service call.

Example for changing FP5 clock to 1MHz: out = ideCtrl.serviceCall("/IOPEN/HW.SoC.RH850_FP5", "GetSecurityMaskOptions:true, Clock_kHz: 1000")

 

i-icon

This page describes ICUM usage in RH850 1st Gen devices (where cores are shown as PE1/PE2/ICUM...). On U2A, ICUM enabling/disabling is performed through Hardware Property Area - see this topic U2x Hardware Property Area programming.

 

Reading Option bytes (OPBTs)

To inspect Option bytes use a service call via the winIDEA SDK. Below is an example of a Python script for reading the RH850 Option bytes via Renesas FP5 protocol. Any errors are logged to winIDEA log file.

 

# ReadOPBTs.py

 

import isystem.connect as ic

import time

 

device_family = 'Ignore' # Possible families: 'Ignore', 'F1x', 'E1x', 'E1M', 'P1x', 'D1x', 'F1H', 'F1KM', 'F1KH'

class OPBT_cfg:

  __default_service_call_options = 'GetSecurityMaskOptions:true'

  def __init__(self,df):

      self.__device_family = df

  # Private Methods

  def __winIDEA_supports_new_startup(self, ideCtrl):

      if -1 == ideCtrl.getWinIDEAVersion().compare(ic.CWinIDEAVersion('9.21.51.0')):

          return False

      return True

  def __get_service_call_URL(self, ideCtrl):

      if -1 == ideCtrl.getWinIDEAVersion().compare(ic.CWinIDEAVersion('9.21.7.0')):

          return '/IOPEN/HW.Debug.V850Fx4_FLASH' # Old URL

      return '/IOPEN/HW.SoC.RH850_FP5'

       

  def __get_service_call_options(self, ideCtrl):

      service_call_Options = self.__default_service_call_options

      if -1 != ideCtrl.getWinIDEAVersion().compare(ic.CWinIDEAVersion('9.21.74.0')):

          service_call_Options += ', Family:' + self.__device_family

      return service_call_Options

           

  def __prepare_winIDEA(self, session, dbg, ideCtrl):

      if self.__winIDEA_supports_new_startup(ideCtrl):

          print('>preparing session...')

          session.end()

          session.begin_prepare()

      else:

          print('>performing debug reset...')

          dbg.reset()

  def __parse_output_string(self, out):

      tokens = out.split(',') # convert to a readable form

      parsedTokens = {}

      for item in tokens:

          key, value = item.split(':')

          key = key.replace('[', '').replace(']', '')

          value = value.strip()

          key = key.strip()

          if value.isdigit():

              intValue = int(value)

              parsedTokens[key] = format(intValue, '08X')

          else:

              parsedTokens[key] = value

      return parsedTokens

           

  def __check_service_call_result(self, parsedTokens):

      if (parsedTokens['Result'] == 'true' or parsedTokens['Result'] == 'TRUE'):

          print('>OPBTs read successfully!')

          return True

      else:

          print('** Reading OPBTs failed! **')

          if 'StrResult' in parsedTokens:

              print(' Result string: ', parsedTokens['StrResult'])

          return False

 

  def __finish_session(self, session, dbg, ideCtrl) -> None:

      if self.__winIDEA_supports_new_startup(ideCtrl):

          print('>disconnecting from debug session')

          session.end()

      else:

          print('>performing reset again to end up in debug session')

          dbg.reset()

 

  # Public methods

  def read_OPBT(self):

      cmgr = ic.ConnectionMgr()

      cmgr.connectMRU('')

      dbg = ic.CDebugFacade(cmgr)

      ideCtrl = ic.CIDEController(cmgr)

      session = ic.CSessionCtrl(cmgr)

      self.__prepare_winIDEA(session, dbg, ideCtrl)

 

      service_call_URL = self.__get_service_call_URL(ideCtrl)

      service_call_Options = self.__get_service_call_options(ideCtrl)

      print('>OPBT serviceCall: ' + service_call_URL + ', options: ' + service_call_Options)

       

      # FP5 flash programming access is used.

      # Any errors are logged to winIDEA log-file.

      out = ideCtrl.serviceCall(service_call_URL, service_call_Options)

       

      parsedTokens = self.__parse_output_string(out)

       

      if not self.__check_service_call_result(parsedTokens):

          dbg.reset()

          input('Press Enter to exit...')

          exit(-1)

           

      self.__finish_session(session, dbg, ideCtrl)

      self.__parsedTokens = parsedTokens

      return parsedTokens

   

  def print_OPBTs(self, parsedTokens):

      print(' Result: ', parsedTokens['Result'])

       

      for index in range(8):

          print(' OPBT{a:02d}: '.format(a=index),

                    '0x{pt}'.format(pt=parsedTokens['FLASHMaskOptions'+str(index)]))

def main():

  print('##################################################')

  print('Starting script for reading OPBTs')

  O = OPBT_cfg(device_family)

  O.print_OPBTs(O.read_OPBT())

  print('Script finished')

  print('##################################################')

  input('Press Enter to exit...')

   

if __name__ == '__main__':

  try:

      main()

  except RuntimeError as ex:

      print('ERROR:', ex)

 

The example above lists only the first 8 OPBTs. The 2nd set of OPBTs, 8 to 15, may not be readable or, not available in F1x and other families. Where applicable, write access is supported for the complete set of 16 OPBTs, though.

 

The console output looks like this:

RH-opbt-read-console

 

 

Writing Option bytes for F1x

To program the RH850 Option bytes please note that this is a critical operation and that the OPBT values are different within the extensive RH850 family of devices. Renesas FP5 communication protocol is used for setting the OPBTs.

 

Warning_orange

Use the script with CAUTION! The device can get permanently LOCKED if incorrect values are specified! Should always double-check.

 

Below is an example script for a RH850/F1KM device. Again, please double-check the OPBT values and consult the Hardware User's Manual of the device used.

 

Note that all 16 OPBTs are defined and that this is the recommended approach.

 

# OPBT_write_F1KM_example.py

 
import isystem.connect as ic
import time
device_family = 'F1KM' # Possible families: 'Ignore', 'F1x', 'E1x', 'E1M', 'P1x', 'D1x', 'F1H', 'F1KM', 'F1KH'

 
OPBTs_conf =   'FLASHMaskOptions[0]: 0xBA27FDCF, \
               FLASHMaskOptions[1]: 0xFFFFFDFF, \
               FLASHMaskOptions[2]: 0xFFFFFFFF, \
               FLASHMaskOptions[3]: 0xFFFFFFFF, \
               FLASHMaskOptions[4]: 0xFFFFFFFF, \
               FLASHMaskOptions[5]: 0xFFFFFFFF, \
               FLASHMaskOptions[6]: 0xFFFFFFFF, \
               FLASHMaskOptions[7]: 0xFFFFFFFF, \
               FLASHMaskOptions[8]: 0xFFFFFFFF, \
               FLASHMaskOptions[9]: 0xFFFFFFFF, \
               FLASHMaskOptions[10]:0xFFFFFFFF, \
               FLASHMaskOptions[11]:0xFFFFFFFF, \
               FLASHMaskOptions[12]:0xFFFFFFFF, \
               FLASHMaskOptions[13]:0xFFFFFFFF, \
               FLASHMaskOptions[14]:0xFFFFFFFF, \
               FLASHMaskOptions[15]:0xFFFFFFFF'

 
class OPBT_cfg:
   __default_service_call_options = 'GetSecurityMaskOptions:true'

 
   def __init__(self,df):
       self.__device_family = df

 
   # Private Methods
   def __winIDEA_supports_new_startup(self, ideCtrl):
       if -1 == ideCtrl.getWinIDEAVersion().compare(ic.CWinIDEAVersion('9.21.51.0')):
           return False
       return True

 
   def __get_service_call_URL(self, ideCtrl):
       if -1 == ideCtrl.getWinIDEAVersion().compare(ic.CWinIDEAVersion('9.21.7.0')):
           return '/IOPEN/HW.Debug.V850Fx4_FLASH' # Old URL
       return '/IOPEN/HW.SoC.RH850_FP5'
       
   def __get_service_call_options(self, ideCtrl):
       service_call_Options = self.__default_service_call_options
       if -1 != ideCtrl.getWinIDEAVersion().compare(ic.CWinIDEAVersion('9.21.74.0')):
           service_call_Options += ', Family:' + self.__device_family
       return service_call_Options
           
   def __prepare_winIDEA(self, session, dbg, ideCtrl):
       if self.__winIDEA_supports_new_startup(ideCtrl):
           print('>preparing session...')
           session.end()
           session.begin_prepare()
       else:
           print('>performing debug reset...')
           dbg.reset()

 
   def __parse_output_string(self, out):
       tokens = out.split(',')  # convert to a readable form
       parsedTokens = {}
       for item in tokens:
           key, value = item.split(':')
           key = key.replace('[', '').replace(']', '')
           value = value.strip()
           key = key.strip()
           if value.isdigit():
               intValue = int(value)
               parsedTokens[key] = format(intValue, '08X')
           else:
               parsedTokens[key] = value
       return parsedTokens
           
   def __check_service_call_result(self, parsedTokens):
       if (parsedTokens['Result'] == 'true' or parsedTokens['Result'] == 'TRUE'):
           print('>OPBTs read successfully!')
           return True
       else:
           print('** Reading OPBTs failed! **')
           if 'StrResult' in parsedTokens:
               print(' Result string: ', parsedTokens['StrResult'])
           return False
 
   def __finish_session(self, session, dbg, ideCtrl) -> None:
 
       ideCtrl.iOpenDisconnect()
 
       if self.__winIDEA_supports_new_startup(ideCtrl):
           print('>disconnecting from debug session')
           session.end()
       else:
           print('>performing reset again to end up in debug session')
           dbg.reset()
 
   # Public methods
   def write_OPBT(self,OPBTs_conf_enable):
       cmgr = ic.ConnectionMgr()
       cmgr.connectMRU('')
       dbg = ic.CDebugFacade(cmgr)
       ideCtrl = ic.CIDEController(cmgr)
       session = ic.CSessionCtrl(cmgr)
       
       self.__prepare_winIDEA(session, dbg, ideCtrl)
       
       service_call_URL = self.__get_service_call_URL(ideCtrl)
       service_call_Options = self.__get_service_call_options(ideCtrl)
 
       print ('Setting OPBT[0-15]...')
       out = ideCtrl.serviceCall(service_call_URL,
                               'WriteMaskOptions:TRUE, ' + OPBTs_conf_enable)
 
       staus = None
       if (out.lower().find('result: true') != -1):
           print ('OPBT[0-15] programmed successfully!')
           status = True
       else:
           print ('OPBT[0-15] programming failed!')
           status = False
       
       time.sleep(1)
 
       self.__finish_session(session, dbg, ideCtrl)

 
       return status

 
 
def main():
   print('##################################################')
   print('Starting script for writing OPBTs')
   print("")
   print ("___ This script is for RH850/F1KM ___")
   print("")
 
   O = OPBT_cfg(device_family)
   O.write_OPBT(OPBTs_conf)
 
   print('Script finished')
   print('##################################################')
   input('Press Enter to exit...')
 
if __name__ == '__main__':
   try:
       main()
   except RuntimeError as ex:
       print('ERROR:', ex)

 

 

More resources

Python in winIDEA

winIDEA SKD documentation for more information about service calls

 

Copyright © 2024 TASKING