Worth 1k Embedded Interview Questions - What did the MCU main function do before?

Top 50 Software Engineering Interview Questions and Answers - GeeksforGeeksStraight to the point

        Please tell me what kind of work does the single-chip microcomputer (Arm) do before running to the main() function?

common problem

  1. System initialization work, too generic
  2. Hardware initialization, less specific

Answer ideas

        This question should be answered from two aspects, one is the initialization of the superficial hardware (worth 200), and the other is the initialization of the deeper C environment, which is also a point with more points (worth 800).

        After the chip is powered on, the system fetches the address of the reset handler at the specified address and executes it; the reset handler mainly handles the things before main and finally jumps to main.

Hardware-related configuration mainly includes:

  • After the system is powered on, it will run with the default clock configuration, so it is not necessary to reconfigure the system clock (via PLL, etc.);
  • For the interrupt handler that needs dynamic registration, it is necessary to modify the interrupt table register to point to the interrupt vector table set in the memory;
  • Control the system's cache, access control and other features;
  • Configure the flash controller, etc.;

C environment initialization mainly includes:

  • clear bss segment
  • data section copy
  • stack pointer setting
  • Heap memory initialization

        The program in the single-chip microcomputer is usually executed on the chip (internal norfalsh), the program also conforms to the elf specification, the code and read-only data are stored on the norflash, and the non-zero data in the data is stored in the data segment of the binary, which needs to be copied after startup to SRAM to read and write data; for those zero data, it is not stored in flash, its segment name is bss, and only the range of the area is recorded in the program, and the corresponding area (bss position in SRAM) )Zero.

        Through the copying and clearing of the above data, the main function (C language function) can access global variables and other related data.

        At the same time, the C function will use the stack to temporarily store temporary data, and the sp stack pointer needs to be set to the planned stack address during the startup phase.

        In addition, it is necessary to call compiler-related initialization code, such as __main to initialize some features, and finally call the main function.

        For the above process, you can refer to the mcu startup code and link script, usually assembly files and ld files

arm cortex m boot code

arm cortex m linker script


        If you are interested in trusted computing, you can subscribe to my trusted computing column. The following is the relevant content in trusted computing:
1. Endorsement certificate (TPM is serious)

        The endorsement certificate is issued by the party that generates the endorsement key EK, and the EK is generated during the production process, that is, the TPM manufacturer will generate the EK. However, EKs can be generated at any point prior to distribution to end users, as long as the TPM manufacturer states that the EKs have been properly created and embedded in a working TPM.

        If the EK key pair is generated after the customer gets the platform, the conditions of key generation may affect the provision of endorsement.

        The information contained in the endorsement certificate is:

TPM 制造商名称
TPM 零件号
TPM 版本或阶段
EK 公钥


        Although the EK public key is public, it is sensitive and private because it is bound to the TPM one by one and will expand the platform. TCG expects that there needs to be one EK credential per TPM.

2. Credentials of compliance (TPM or platform design and implementation is serious)

        These certificates are issued by anyone with sufficient credibility to evaluate the TPM or the platform containing the TPM. These assessments can be performed by platform manufacturers, vendors, or independent entities. This certificate of conformity indicates that the assessor agrees to the design and implementation of the trusted building element TBB according to the assessment guidelines. By issuing a certificate, the evaluator can certify the evaluation results, which will be used for later inspection. TCG facilitates evaluation by defining meaningful evaluation criteria and guidelines.

        The evaluator can issue multiple compliance certificates to a platform, one is for TPM, and the other is for each trusted component TBB component.

Documentation of compliance may include the following information:

评估方名称
平台制造商名称
平台型号
平台版本(如果有的话)
TPM 制造商名称
TPM 型号
TPM 版本号或阶段
符合性凭证不包含任何唯一识别任何平台特定的信息。

        The TCG envisions that multiple certificates of conformity may exist for each platform model, but that multiple platforms of the same make and model will only require one set of certificates.

3. Platform credentials (the platform is a serious platform)

        The platform certificate is issued by the platform manufacturer, supplier or any related party with sufficient credit. The platform certificate can uniquely identify the platform manufacturer and describe the platform attributes. A platform credential references a TPM endorsement credential and associated compliance credential, and these references consist of message signatures referencing the credential. Platform credentials can be regarded as privacy-sensitive information, which is related to a specific platform rather than a class of platforms.

Platform credentials include the following information:

平台制造商名称
平台型号
平台版本(如果适用)
背书凭证
符合性凭证

        The platform credential proves that the platform contains a TPM based on the endorsement credential. TCG recommends only one platform credential per platform instance.

4. Authentication (qualification) credentials (hash of firmware authenticity within the platform)

        TCG recommends that measurable components (software and hardware) be able to generate their measurement values ​​after functional testing to form corresponding documents. Of course, this is only for those components that can pose a security threat. These metrics need to be generated in a secure environment and form signed documents, i.e. verification credentials, for comparison of metrics at runtime.

Some of the following components typically require certificates to be verified:

视频适配器
磁盘存储适配器
通信控制器/网络适配器
处理器
键盘和鼠标
软件

        Verification credentials are issued by verification entities, and any entity willing and able to measure and prove these measurements can be considered a verification entity. Usually, component manufacturers produce the best choices for these values. Any part of the component description may become raw material for trust decisions. However, candidate components for validating credentials may pose a security threat.

A component description contains at least the following elements:

验证实体名称
组件制造商名称
组件型号
组件版本或阶段
度量值
组件能力(比如不可改,这个是可选的)

        A group of components within a model can be issued one certificate or multiple certificates.

        The component update and upgrade process is customized by the supplier, such as how to invalidate the original verification certificate.

5. Identification Credentials (Business Identity)

        The identity certificate (ID card) is used to prove the AIK private key. It is composed of the AIK public key and other information that the issuer considers useful. It proves that the certificate is issued by a trusted server and can verify various certificates while ensuring the client's Privacy Policy.

        By issuing a proof identity certificate, the issuer can prove the authenticity of the TPM and prove some facts about the TPM. The purpose of the proof is that the TPM has an AIK and this AIK is bound with valid endorsement certificates, compliance certificates, and platform certificates. The trusted party further ensures that the privacy protection it complies with meets user expectations, including personal privacy data exposed during the registration process.

Proof identity credentials refer to other credentials as follows:

        The identity certificate contains a reference to the TPM manufacturer and model, as shown in C in the figure below. There is no reference to the privacy-sensitive EK to prove that the identity certificate also
includes the platform manufacturer and model as shown in D. It is worth noting that this reference does not refer to the platform. The credential itself, instead references information in the platform credential that is not sensitive to information.
        Finally, the proof identity credential contains an entry pointing to the TPM and platform compliance, as shown in Figure E. The
        challenger can use this information, along with other information in the certificate, to trust through the authentication protocol platform.

Guess you like

Origin blog.csdn.net/BillyThe/article/details/132041773