CN113946481B - RISC-V kernel MCU debugging downloading program method and debugger - Google Patents

RISC-V kernel MCU debugging downloading program method and debugger Download PDF

Info

Publication number
CN113946481B
CN113946481B CN202111560421.6A CN202111560421A CN113946481B CN 113946481 B CN113946481 B CN 113946481B CN 202111560421 A CN202111560421 A CN 202111560421A CN 113946481 B CN113946481 B CN 113946481B
Authority
CN
China
Prior art keywords
function
programming
mcu
verification
program
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111560421.6A
Other languages
Chinese (zh)
Other versions
CN113946481A (en
Inventor
张远伟
杨岩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nanjing Risco Microcontroller Research Institute Co ltd
Original Assignee
Nanjing Risco Microcontroller Research Institute Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nanjing Risco Microcontroller Research Institute Co ltd filed Critical Nanjing Risco Microcontroller Research Institute Co ltd
Priority to CN202111560421.6A priority Critical patent/CN113946481B/en
Publication of CN113946481A publication Critical patent/CN113946481A/en
Application granted granted Critical
Publication of CN113946481B publication Critical patent/CN113946481B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/22Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing
    • G06F11/26Functional testing
    • G06F11/263Generation of test inputs, e.g. test vectors, patterns or sequences ; with adaptation of the tested hardware for testability with external testers
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a method for downloading a program for debugging a RISC-V kernel MCU and a debugger, wherein in a debugging mode, the debugger writes a specific program into an RAM of the MCU, and the specific program comprises an erasing function, a programming function and a checking function; the MCU is continuously and circularly switched between a debugging mode and a working mode so as to complete the whole downloading of the debugged program; in a debugging mode, a debugger writes parameters of an execution function into an RAM (random access memory), changes a value in a dpc register into an initial address of the execution function, and sets a dmcontrol register to enable an MCU (microprogrammed control Unit) to enter a working mode; under the working mode, executing a corresponding function of a specific program according to the value in the dpc register, writing an execution result into the RAM, ending the execution function with an ebreak instruction, and entering the MCU into a debugging mode from the working mode when ebreak is executed. The invention accelerates the downloading speed of the debugged program and improves the debugging efficiency.

Description

RISC-V kernel MCU debugging downloading program method and debugger
Technical Field
The invention provides a microprocessor kernel debugging method, and particularly relates to a program downloading method for RISC-V kernel MCU debugging and a debugger.
Background
The microprocessor kernel has many ways of downloading programs, such as ISP, IAP, etc., and can be downloaded to MCU through interfaces such as USB, serial port, network interface, etc. But for the debugged program, the program can only be downloaded into the MCU through a special debugging interface.
The normal development, debugging and downloading process comprises the following steps: compiling the codes into a binary file after compiling, downloading the binary file into the MCU, and verifying whether the program is normal. And setting a breakpoint and tracking related variables when the program is executed. If the program is found to be problematic, the program is modified, then the program is downloaded into the MCU, and whether the modified result is normal is verified. Thus, the loop test is returned, if the downloading speed is slow during debugging, the working efficiency of developers is affected, the operation of relevant registers of the FLASH is executed by a debugger through Writing a Program Buffer register in the traditional downloading mode at present, the specific implementation mode refers to the Reading Memory and the Writing Memory of the RISC-V External Debug Support, one instruction lw s0, 0(s0) in the MCU working mode is needed, and the implementation can be realized only by 6 instructions in the debugging mode. Different commands require constant switching of the Program Buffer.
The RISC-V kernel has two working modes of working mode and debugging mode, generally, the program is executed in FLASH or RAM, when the debugger sends an instruction to make MCU enter pause or MCU execute ebreak instruction, MCU enters debugging mode, and dpc register stores PC value when MCU enters pause state. And when the debugger enables the MCU to recover to a working state from the debugging state, recovering the value in the dpc register to the PC, and reading the instruction from the PC by the MCU for execution.
The existing RISC-V chip debugging downloading program scheme is executed in the debugging mode of the MCU, and is mainly realized by a debugger plus link. The debugger sets the debugged MCU to a pause state through a link; sending an instruction to be executed by the debugged MCU to a Program Buffer register of the debugged MCU through link, wherein generally, the Program Buffer executes reading and writing operations on other peripheral registers, reading and writing operations on an MCU memory and the like; and after the Program Buffer is executed by the debugged MCU, entering a pause state and waiting for a next instruction of the debugger. During downloading, the reading and writing of the external register are required to be called continuously to control the FLASH controller, and the program to be operated is programmed into the FLASH inside the chip.
The Program Buffer provided by the RISC-V debugging specification is very small, the maximum is 32 bytes, only the read-write operation can be carried out on the level of the register, and the registers of a plurality of FLASH controllers can be operated by erasing, programming, checking and the like. Each time the peripheral registers of different FLASH controllers are operated, different instructions need to be downloaded into the Program Buffer for execution, so the downloading speed is very slow.
Disclosure of Invention
The purpose of the invention is as follows: the invention provides a program downloading method for RISC-V kernel MCU debugging, aiming at solving the problem that the debugging efficiency is greatly influenced because the program downloading speed is too low when the RISC-V kernel MCU is debugged in the prior art.
Another object of the present invention is to provide a debugger of a RISC-V core MCU.
The technical scheme is as follows: a method for downloading programs for debugging a RISC-V kernel MCU comprises the following steps:
the method comprises the following steps that the MCU enters a debugging mode, a debugger writes a specific program into an RAM of the MCU, the specific program comprises an erasing function, a programming function and a verification function, and an ebreak instruction is arranged at least at the tail end of the verification function;
the MCU is continuously and circularly switched between a debugging mode and a working mode so as to complete the whole downloading of the debugged program;
in a debugging mode, a debugger writes function parameters required by the current execution function into an RAM of an MCU (microprogrammed control Unit), changes a value in a dpc register into an initial address of the current execution function, and sets a dmcontrol register to enable the MCU to enter a working mode;
under the working mode, executing the function according to the value in the dpc register, writing the function execution result into the RAM, and when an ebreak instruction is executed, enabling the MCU to enter a debugging mode;
the current execution function is one or more of an erasing function, a programming function and a verifying function.
Furthermore, the debugger divides the debugged program into a plurality of program blocks, writes one program block into the RAM of the MCU in the form of parameters required by the programming function each time, and then downloads the program block into the FLASH of the MCU in the form of executing the programming function in the operating mode.
Further, the erase function, the program function, and the verify function in a particular program are arranged in order.
Further, the MCU continuously and circularly switching between the debugging mode and the working mode comprises:
step A, the current execution function is an erasing function, a programming function and a verification function, parameters required by the erasing function comprise an erasing initial address and an erasing size, parameters required by the programming function comprise a programming initial address, programming data and a programming size, parameters required by the verification function are the same as those of the programming function, and the programming data are the content of a first program block; the debugger changes the value in the dpc register to the initial address of the erase function, and sets the dmcontrol register to switch the MCU to the working mode; the MCU executes an erasing function, a programming function, a checking function and ebreak in sequence in a working mode, and returns to a debugging mode when an ebreak instruction is executed;
step B, the current execution function is a programming function and a verification function, parameters required by the programming function comprise a programming starting address, programming data and a programming size, parameters required by the verification function are the same as those of the programming function, and the programming data are the content of the current program block; the debugger changes the value in the dpc register to the initial address of the programming function, and sets the dmcontrol register to switch the MCU to the working mode; the MCU executes the programming function, the check function and the ebreak in sequence in the working mode, and returns to the debugging mode when executing an ebreak instruction;
and D, continuously repeating the step B until all the program blocks of the debugged program are completely downloaded.
Further, the end of the erase function also contains an ebreak instruction, and the continuous cycle switching of the MCU between the debugging mode and the working mode comprises the following steps:
step A, the execution function is an erasing function, and parameters required by the erasing function comprise an erasing initial address and an erasing size; the debugger changes the value in the dpc register to the initial address of the erase function, and sets the dmcontrol register to switch the MCU to the working mode; the MCU executes an erasing function and ebreak in sequence in a working mode, and returns to a debugging mode when an ebreak instruction is executed;
step B, the current execution function is a programming function and a verification function, parameters required by the programming function comprise a programming starting address, programming data and a programming size, parameters required by the verification function are the same as those of the programming function, and the programming data are the content of the current program block; the debugger changes the value in the dpc register into the initial address of the programming function, and sets the dmcontrol register to enable the MCU to be switched to a working mode to execute the programming function, the check function and the ebreak; when the ebreach instruction is executed, the MCU returns to a debugging mode;
and D, continuously repeating the step B until all the program blocks of the debugged program are completely downloaded.
Further, the MCU continuously and circularly switching between the debugging mode and the working mode comprises:
step A, the current execution function is an erasing function, a programming function and a verification function, and parameters required by the erasing function comprise an erasing initial address and an erasing size; the parameters required by the programming function comprise a programming starting address, programming data and a programming size, the parameters required by the verification function are the same as those of the programming function, the programming data are the content of the current program block, the erasing starting address is the same as the programming starting address, and the erasing size is the same as the programming size; the debugger changes the value in the dpc register to the initial address of the erase function, and sets the dmcontrol register to switch the MCU to the working mode; the MCU executes an erasing function, a programming function, a checking function and ebreak in sequence in a working mode, and returns to a debugging mode when an ebreak instruction is executed;
and D, continuously repeating the step A until all the program blocks of the debugged program are completely downloaded.
Further, the debugger writes the specific program into the RAM of the MCU, and the address of the RAM is a first address; the debugger writes parameters required by the execution function into an address of an RAM of the MCU as a second address; the address of the function execution result written into the RAM of the MCU is a third address, the third address and the second address can be the same, the function execution result covers parameters required by the function execution, and the third address and the second address can also be different.
A kind of RISC-V kernel MCU debugger, including processing unit, memory cell and software program stored on memory cell and can be executed by the processing unit, the processing unit can realize when carrying out the software program:
the method comprises the following steps that the MCU enters a debugging mode, a debugger writes a specific program into an RAM of the MCU, the specific program comprises an erasing function, a programming function and a verification function, and an ebreak instruction is arranged at least at the tail end of the verification function;
continuously and circularly controlling the MCU to enter a debugging mode and a working mode so as to finish the whole downloading of the debugged program;
in a debugging mode, a debugger writes parameters required by the current execution function into an RAM of an MCU (microprogrammed control Unit), changes a value in a dpc register into an initial address of the current execution function, and then controls the MCU to enter a working mode;
in the working mode, after the MCU finishes executing the execution function, executing an ebreak instruction and returning to the debugging mode;
the current execution function is one or more of an erasing function, a programming function and a verifying function.
Furthermore, the debugger divides the debugged program into a plurality of program blocks, writes one program block into the RAM of the MCU in the form of parameters required by the programming function each time, and then downloads the program block into the FLASH of the MCU in the form of executing the programming function in the operating mode.
Further, the continuously and circularly controlling the MCU to enter the debugging mode and the working mode includes:
step A, the current execution function is an erasing function, a programming function and a verification function, parameters required by the erasing function comprise an erasing initial address and an erasing size, parameters required by the programming function comprise a programming initial address, programming data and a programming size, parameters required by the verification function are the same as those of the programming function, and the programming data are the content of a first program block; the debugger changes the value in the dpc register to the initial address of the erase function, and sets the dmcontrol register to switch the MCU to the working mode; the MCU executes an erasing function, a programming function, a checking function and ebreak in sequence in a working mode, and returns to a debugging mode when an ebreak instruction is executed;
step B, the current execution function is a programming function and a verification function, parameters required by the programming function comprise a programming starting address, programming data and a programming size, parameters required by the verification function are the same as those of the programming function, and the programming data are the content of the current program block; the debugger changes the value in the dpc register to the initial address of the programming function, and sets the dmcontrol register to switch the MCU to the working mode; the MCU executes the programming function, the check function and the ebreak in sequence in the working mode, and returns to the debugging mode when executing an ebreak instruction;
and D, continuously repeating the step B until all the program blocks of the debugged program are completely downloaded.
Further, the end of the erase function also contains an ebreak instruction, and the continuous cycle switching of the MCU between the debugging mode and the working mode comprises the following steps:
step A, the execution function is an erasing function, and parameters required by the erasing function comprise an erasing initial address and an erasing size; the debugger changes the value in the dpc register to the initial address of the erase function, and sets the dmcontrol register to switch the MCU to the working mode; the MCU executes an erasing function and ebreak in sequence in a working mode, and returns to a debugging mode when an ebreak instruction is executed;
step B, the current execution function is a programming function and a verification function, parameters required by the programming function comprise a programming starting address, programming data and a programming size, parameters required by the verification function are the same as those of the programming function, and the programming data are the content of the current program block; the debugger changes the value in the dpc register into the initial address of the programming function, and sets the dmcontrol register to enable the MCU to be switched to a working mode to execute the programming function, the check function and the ebreak; when the ebreach instruction is executed, the MCU returns to a debugging mode;
and D, continuously repeating the step B until all the program blocks of the debugged program are completely downloaded.
Compared with the prior art, the invention provides a program downloading method for RISC-V kernel MCU debugging and a debugger, which have the following beneficial effects: half of the Program downloading process is carried out in a debugging mode, and half of the Program downloading process is carried out in a working mode, the ebreak instruction in RISC-V debugging and the dpc register are matched, the times of operating the Program Buffer in the RISC-V debugging module through a link interface are reduced, the quick downloading of the Program is realized, and the efficiency of the debugging work is greatly improved.
Drawings
FIG. 1 is a flowchart illustrating a method for downloading programs for MCU debugging in RISC-V core according to an embodiment;
FIG. 2 is a flowchart illustrating an exemplary method for downloading program for MCU debugging in a RISC-V kernel;
FIG. 3 is a flowchart illustrating an exemplary method for downloading programs for MCU debugging in triple RISC-V cores;
FIG. 4 is a flowchart illustrating a method for downloading program for MCU debugging in quad RISC-V kernel according to an embodiment.
Detailed Description
The invention is further explained below with reference to the figures and the specific embodiments.
The first embodiment is as follows:
a method for downloading programs for debugging a RISC-V kernel MCU is shown in FIG. 1, and comprises the following steps:
a specific program P is written in advance and will be executed in the operating mode of the MCU instead of the debug mode. The specific program comprises an erasing function, a programming function and a checking function, wherein an ebreak instruction is arranged at the tail end of the checking function, and a normal function return instruction ret is not used.
The method comprises the steps of enabling an MCU to enter a debugging mode (controlled by a debugger or entering the debugging mode after an ebreal instruction is executed), enabling the debugger to write a specific program P into a RAM of the MCU, wherein the address written into the RAM is P _ addr, and the initial addresses of an erasing function, a programming function and a checking function are P _ addr + erase _ addr, P _ addr + prog _ addr and P _ addr + verif _ addr respectively. The erase function, the program function, and the verify function are arranged in order and may be performed sequentially.
The debugger divides a debugged program T to be downloaded into the FLASH of the MCU into a plurality of program blocks according to the size of each program block being K, assuming that N program blocks are provided in total, the size of the first N-1 program blocks is K, and the size of the Nth program block is smaller than or equal to K. The data of each program block is used as programming data in parameters required by the programming function, and the program block is downloaded to the FLASH of the MCU in a mode of executing the programming function under the working mode.
And continuously and circularly switching the debugging mode and the working mode so as to finish the whole downloading of the debugged program, wherein the specific program downloading process comprises the following steps:
step A, the current execution function is an erasing function, a programming function and a verification function, parameters required by the erasing function comprise an erasing initial address and an erasing size (equal to the total size of a Flash chip or more than or equal to the total size of a debugged program), parameters required by the programming function comprise a programming initial address, programming data written in FALSH (namely the content of a program block to be written in at the current time) and a programming size, parameters required by the verification function are the same as those of the programming function, and the programming data are the content of a first program block; the debugger changes the value in the dpc register into the initial address of the erasing function, and the erasing of the FLASH and the writing and verification of the first program block are realized in a primary debugging mode and a working mode;
in a debugging mode, a debugger writes parameters required by an erasing function, a programming function and a checking function into another address parm _ addr of a RAM of the MCU, changes a value in a dpc register into an initial address of the erasing function, and then sets a dmcontrol register to enable the MCU to be switched from the debugging mode to a working mode;
in the working mode, executing an erasing function according to the value in the dpc register, sequentially executing the erasing function, a programming function and a checking function, writing a first program block into the FLASH, checking, and writing the result of the executing function into the RAM, when an ebreak instruction at the end of the checking function is executed, entering a pause state by the MCU, entering a debugging mode, and giving control right to the debugger; after the MCU enters a pause state, the debugger reads the result of executing the function, judges whether the result is correct or not according to the result, continues to execute the next operation if the result is correct, and repeatedly executes the function if the result is wrong or quits the downloading process;
step B, the current execution function is a programming function and a verification function, parameters required by the programming function comprise a programming starting address, programming data and a programming size, parameters required by the verification function are the same as those of the programming function, and the programming data are the content of the current program block; the debugger changes the value in the dpc register into the initial address of the programming function, and the writing and the verification of the program block are realized in a primary debugging mode and a working mode;
in a debugging mode, a debugger writes parameters required by a programming function and a check function into a parm _ addr position, changes a value in a dpc register into an initial address of the programming function, and then sets a dmcontrol register to switch the MCU from the debugging mode to a working mode;
under the working mode, a programming function and a verification function are sequentially executed according to the value in the dpc register, a program block to be written at this time is written into the FLASH and verified, the result of the execution function is written into the RAM, when an ebreak instruction at the end of the verification function is executed, the MCU enters a pause state, enters a debugging mode and gives control to a debugger; after the MCU enters a pause state, the debugger reads the result of executing the function, judges whether the result is correct or not according to the result, continues to execute the next operation if the result is correct, and repeatedly executes the function if the result is wrong or quits the downloading process;
and D, continuously repeating the step B until all the program blocks of the debugged program are completely downloaded. The debugger resets the MCU, and the MCU starts to execute by loading the downloaded program T from the FLASH in the working mode.
In this embodiment, the execution result obtained after each execution of the function is written behind the function parameter, and may be set as an override function parameter, or may be other addresses, as long as the debugger and the P program agree on the address of the function parameter written by the debugger and the address of the execution result.
In this embodiment, a special method is adopted to download a debugged program to a FLASH of an MCU, a debugger writes a debugged program block into a RAM of the MCU in the form of programming data parameters of a programming function in a debugging mode, and executes a check function in sequence, because an ebleak instruction is at the end of the check function, the MCU enters a suspended state after the check function is executed, and then enters the debugging mode, in the debugging mode, a control right is given to the debugger, the debugger writes function parameters into the RAM of the MCU according to a program block to be written below, writes a start address of a function to be executed below into a dpc register, and then controls the MCU to enter a working mode; in the working mode, the kernel debugging module gives the value of dpc to the PC and executes the function to be executed; and continuously circulating in this way, downloading one program block into the FLASH of the MCU, and finishing the whole downloading of the debugged program.
In the first cycle of this embodiment, FLASH is erased once according to the debugged program, because the function parameters required for erasing are few, the programming function can be continuously executed in the cycle at the same time, and the data of the first program block is written; and because the parameters required by the programming function are the same as those required by the verification function, the programming and the verification can be completed in the same cycle process. The switching times can be reduced as much as possible by the arrangement, so that the fastest downloading effect is achieved.
Example two:
in contrast to embodiment one, the end of the erase function also contains an ebreak instruction in addition to the check function.
Referring to fig. 2, the MCU continuously and cyclically switching between the debug mode and the working mode includes:
step A, the execution function is an erasing function, and parameters required by the erasing function comprise an erasing initial address and an erasing size; the debugger changes the value in the dpc register into the initial address of the erasing function, and the FLASH is erased in a primary debugging mode and a working mode;
in a debugging mode, a debugger writes parameters required by an erasing function into another address parm _ addr of the RAM of the MCU, the debugger changes a value in a dpc register into an initial address of the erasing function, and then a dmcontrol register is set to enable the MCU to be switched from the debugging mode to a working mode;
in a working mode, executing an erasing function according to the value in the dpc register, writing the result of the executed function into the RAM, and when an ebreak instruction at the end of the erasing function is executed, enabling the MCU to enter a pause state, enter a debugging mode and give control to a debugger; after the MCU enters a pause state, the debugger reads the result of executing the function, judges whether the result is correct or not according to the result, continues to execute the next operation if the result is correct, and repeatedly executes the function if the result is wrong or quits the downloading process;
step B, the current execution function is a programming function and a verification function, parameters required by the programming function comprise a programming starting address, programming data and a programming size, parameters required by the verification function are the same as those of the programming function, and the programming data are the content of the current program block; the debugger changes the value in the dpc register into the initial address of the programming function, and the writing and the verification of the program block are realized in a primary debugging mode and a working mode;
in a debugging mode, a debugger writes parameters required by a programming function and a check function into a parm _ addr position, the debugger changes a value in a dpc register into an initial address of the programming function, and then a dmcontrol register is set to enable an MCU to be switched from the debugging mode to a working mode;
under the working mode, a programming function and a verification function are sequentially executed according to the value in the dpc register, a program block to be written at this time is written into the FLASH and verified, the result of the execution function is written into the RAM, when an ebreak instruction at the end of the verification function is executed, the MCU enters a pause state, enters a debugging mode and gives control to a debugger; after the MCU enters a pause state, the debugger reads the result of executing the function, judges whether the result is correct or not according to the result, continues to execute the next operation if the result is correct, and repeatedly executes the function if the result is wrong or quits the downloading process;
and D, continuously repeating the step B until all the program blocks of the debugged program are completely downloaded. The debugger resets the MCU, and the MCU starts to execute by loading the downloaded program T from the FLASH in the working mode.
Example three:
because the parameters required by the programming function and the verification function are the same, in order to download more quickly, in the third embodiment, the programming function and the verification function are placed in the execution function in the switching process once and executed sequentially, or executed respectively in the switching process twice, which requires that an ebreak instruction is also set at the end of the programming function, when the programming function is executed, the debugging mode is returned, and then the next execution function is set as the verification function for verification, as shown in fig. 3. The rest is the same as in the first or second embodiment.
Example four:
in practical application, the FLASH can be erased at one time according to the size of the debugged program, and then each program block is written in times. The fourth embodiment can also be erased multiple times, with each erase cycle consisting of writing a block and verifying, erasing again, writing a block again and verifying … …, as shown in FIG. 4. For the case of multiple erasing, the program function and the verify function may be executed sequentially in one switching process, or may be executed separately in two switching processes.

Claims (11)

1. A method for downloading a program for debugging a RISC-V kernel MCU is characterized by comprising the following steps:
the method comprises the following steps that the MCU enters a debugging mode, a debugger writes a specific program into an RAM of the MCU, the specific program comprises an erasing function, a programming function and a verification function, and an ebreak instruction is arranged at least at the tail end of the verification function;
the MCU is continuously and circularly switched between a debugging mode and a working mode so as to complete the whole downloading of the debugged program;
in a debugging mode, a debugger writes function parameters required by the current execution function into an RAM of an MCU (microprogrammed control Unit), changes a value in a dpc register into an initial address of the current execution function, and sets a dmcontrol register to enable the MCU to enter a working mode;
under the working mode, executing the function according to the value in the dpc register, writing the function execution result into the RAM, and when an ebreak instruction is executed, enabling the MCU to enter a debugging mode;
the current execution function is one or more of an erasing function, a programming function and a verifying function.
2. A method for downloading a program for MCU debugging of RISC-V kernel as claimed in claim 1, wherein the debugger divides the debugged program into several blocks, each time writing one block in the RAM of the MCU in the form of parameters required for programming the function, and then downloading the block in the form of executing the programming function to the FLASH of the MCU in the working mode.
3. A method for downloading a program for MCU debugging with RISC-V kernel according to claim 2, wherein the erase function, program function and verify function in a specific program are arranged in sequence.
4. A method for downloading a program for MCU debugging of RISC-V core as claimed in claim 3, wherein the MCU constantly cycling between the debugging mode and the working mode comprises:
step A, the current execution function is an erasing function, a programming function and a verification function, parameters required by the erasing function comprise an erasing initial address and an erasing size, parameters required by the programming function comprise a programming initial address, programming data and a programming size, parameters required by the verification function comprise a verification initial address, verification data and a verification size, the verification initial address is the same as the programming initial address, the verification data is the same as the programming data, the verification size is the same as the programming size, and the programming data is the content of a first program block; the debugger changes the value in the dpc register to the initial address of the erase function, and sets the dmcontrol register to switch the MCU to the working mode; the MCU executes an erasing function, a programming function, a checking function and ebreak in sequence in a working mode, and returns to a debugging mode when an ebreak instruction is executed;
step B, the current execution function is a programming function and a verification function, parameters required by the programming function comprise a programming starting address, programming data and a programming size, parameters required by the verification function comprise a verification starting address, verification data and a verification size, the verification starting address is the same as the programming starting address, the verification data is the same as the programming data, the verification size is the same as the programming size, and the programming data is the content of the current program block; the debugger changes the value in the dpc register to the initial address of the programming function, and sets the dmcontrol register to switch the MCU to the working mode; the MCU executes the programming function, the check function and the ebreak in sequence in the working mode, and returns to the debugging mode when executing an ebreak instruction;
and D, continuously repeating the step B until all the program blocks of the debugged program are completely downloaded.
5. A method for downloading a program for MCU debugging with RISC-V kernel as recited in claim 3, wherein the end of erase function also contains ebreak command, and the MCU continuously and cyclically switching between debug mode and working mode comprises:
step A, the execution function is an erasing function, and parameters required by the erasing function comprise an erasing initial address and an erasing size; the debugger changes the value in the dpc register to the initial address of the erase function, and sets the dmcontrol register to switch the MCU to the working mode; the MCU executes an erasing function and ebreak in sequence in a working mode, and returns to a debugging mode when an ebreak instruction is executed;
step B, the current execution function is a programming function and a verification function, parameters required by the programming function comprise a programming starting address, programming data and a programming size, parameters required by the verification function comprise a verification starting address, verification data and a verification size, the verification starting address is the same as the programming starting address, the verification data is the same as the programming data, the verification size is the same as the programming size, and the programming data is the content of the current program block; the debugger changes the value in the dpc register into the initial address of the programming function, and sets the dmcontrol register to enable the MCU to be switched to a working mode to execute the programming function, the check function and the ebreak; when the ebreach instruction is executed, the MCU returns to a debugging mode;
and D, continuously repeating the step B until all the program blocks of the debugged program are completely downloaded.
6. A method for downloading a program for MCU debugging of RISC-V core as claimed in claim 3, wherein the MCU constantly cycling between the debugging mode and the working mode comprises:
step A, the current execution function is an erasing function, a programming function and a verification function, and parameters required by the erasing function comprise an erasing initial address and an erasing size; the parameters required by the programming function comprise a programming starting address, programming data and a programming size, the parameters required by the verification function comprise a verification starting address, verification data and a verification size, the verification starting address is the same as the programming starting address, the verification data is the same as the programming data, the verification size is the same as the programming size, the programming data is the content of the current program block, the erasing starting address is the same as the programming starting address, and the erasing size is the same as the programming size; the debugger changes the value in the dpc register to the initial address of the erase function, and sets the dmcontrol register to switch the MCU to the working mode; the MCU executes an erasing function, a programming function, a checking function and ebreak in sequence in a working mode, and returns to a debugging mode when an ebreak instruction is executed;
and D, continuously repeating the step A until all the program blocks of the debugged program are completely downloaded.
7. A method for downloading a program for MCU debugging within RISC-V core according to any of claims 1 to 6, wherein the address where the debugger writes the specific program into the RAM of the MCU is the first address; the debugger writes parameters required by the execution function into an address of an RAM of the MCU as a second address; the address of the function execution result written into the RAM of the MCU is a third address, the third address is the same as the second address, and the function execution result covers parameters required by the function execution or the third address is different from the second address.
8. A debugger of a RISC-V core MCU, comprising a processing unit, a storage unit and a software program stored on the storage unit and executable by the processing unit, the processing unit being operable to execute the software program to:
the method comprises the following steps that the MCU enters a debugging mode, a debugger writes a specific program into an RAM of the MCU, the specific program comprises an erasing function, a programming function and a verification function, and an ebreak instruction is arranged at least at the tail end of the verification function;
controlling the MCU to continuously and circularly switch between a debugging mode and a working mode so as to complete the whole downloading of the debugged program;
in a debugging mode, a debugger writes parameters required by the current execution function into an RAM of an MCU (microprogrammed control Unit), changes a value in a dpc register into an initial address of the current execution function, and then controls the MCU to enter a working mode;
in the working mode, after the MCU finishes executing the execution function, executing an ebreak instruction and returning to the debugging mode;
the current execution function is one or more of an erasing function, a programming function and a verifying function.
9. A RISC-V kernel MCU debugger according to claim 8, wherein the debugger divides the debugged program into a plurality of blocks, each time writing one block in the RAM of the MCU in the form of parameters required for programming the function, and then downloading the block in the FLASH of the MCU in the form of executing the programming function in the working mode.
10. A RISC-V core MCU debugger according to claim 9, wherein controlling the MCU to cycle continuously between debug mode and operational mode comprises:
step A, the current execution function is an erasing function, a programming function and a verification function, parameters required by the erasing function comprise an erasing initial address and an erasing size, parameters required by the programming function comprise a programming initial address, programming data and a programming size, parameters required by the verification function comprise a verification initial address, verification data and a verification size, the verification initial address is the same as the programming initial address, the verification data is the same as the programming data, the verification size is the same as the programming size, and the programming data is the content of a first program block; the debugger changes the value in the dpc register to the initial address of the erase function, and sets the dmcontrol register to switch the MCU to the working mode; the MCU executes an erasing function, a programming function, a checking function and ebreak in sequence in a working mode, and returns to a debugging mode when an ebreak instruction is executed;
step B, the current execution function is a programming function and a verification function, parameters required by the programming function comprise a programming starting address, programming data and a programming size, parameters required by the verification function comprise a verification starting address, verification data and a verification size, the verification starting address is the same as the programming starting address, the verification data is the same as the programming data, the verification size is the same as the programming size, and the programming data is the content of the current program block; the debugger changes the value in the dpc register to the initial address of the programming function, and sets the dmcontrol register to switch the MCU to the working mode; the MCU executes the programming function, the check function and the ebreak in sequence in the working mode, and returns to the debugging mode when executing an ebreak instruction;
and D, continuously repeating the step B until all the program blocks of the debugged program are completely downloaded.
11. A RISC-V core MCU debugger according to claim 9, wherein the end of the erase function also contains an ebreak instruction, controlling the MCU to cycle continuously between debug mode and working mode comprises:
step A, the execution function is an erasing function, and parameters required by the erasing function comprise an erasing initial address and an erasing size; the debugger changes the value in the dpc register to the initial address of the erase function, and sets the dmcontrol register to switch the MCU to the working mode; the MCU executes an erasing function and ebreak in sequence in a working mode, and returns to a debugging mode when an ebreak instruction is executed;
step B, the current execution function is a programming function and a verification function, parameters required by the programming function comprise a programming starting address, programming data and a programming size, parameters required by the verification function comprise a verification starting address, verification data and a verification size, the verification starting address is the same as the programming starting address, the verification data is the same as the programming data, the verification size is the same as the programming size, and the programming data is the content of the current program block; the debugger changes the value in the dpc register into the initial address of the programming function, and sets the dmcontrol register to enable the MCU to be switched to a working mode to execute the programming function, the check function and the ebreak; when the ebreach instruction is executed, the MCU returns to a debugging mode;
and D, continuously repeating the step B until all the program blocks of the debugged program are completely downloaded.
CN202111560421.6A 2021-12-20 2021-12-20 RISC-V kernel MCU debugging downloading program method and debugger Active CN113946481B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111560421.6A CN113946481B (en) 2021-12-20 2021-12-20 RISC-V kernel MCU debugging downloading program method and debugger

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111560421.6A CN113946481B (en) 2021-12-20 2021-12-20 RISC-V kernel MCU debugging downloading program method and debugger

Publications (2)

Publication Number Publication Date
CN113946481A CN113946481A (en) 2022-01-18
CN113946481B true CN113946481B (en) 2022-03-18

Family

ID=79339395

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111560421.6A Active CN113946481B (en) 2021-12-20 2021-12-20 RISC-V kernel MCU debugging downloading program method and debugger

Country Status (1)

Country Link
CN (1) CN113946481B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114546751B (en) * 2022-04-25 2022-07-26 南方科技大学 Kernel space debugging method and device, computer equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2003208332A (en) * 2002-01-10 2003-07-25 Ricoh Co Ltd Debugging device
CN101183330A (en) * 2007-12-13 2008-05-21 东信和平智能卡股份有限公司 Online debugging system of embedded system and debug method thereof
US20080155342A1 (en) * 2006-12-21 2008-06-26 Novell, Inc. Methods and apparatus for debugging software
CN101382915A (en) * 2008-10-23 2009-03-11 北京中星微电子有限公司 Software debugging system and debugging method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2003208332A (en) * 2002-01-10 2003-07-25 Ricoh Co Ltd Debugging device
US20080155342A1 (en) * 2006-12-21 2008-06-26 Novell, Inc. Methods and apparatus for debugging software
CN101183330A (en) * 2007-12-13 2008-05-21 东信和平智能卡股份有限公司 Online debugging system of embedded system and debug method thereof
CN101382915A (en) * 2008-10-23 2009-03-11 北京中星微电子有限公司 Software debugging system and debugging method

Also Published As

Publication number Publication date
CN113946481A (en) 2022-01-18

Similar Documents

Publication Publication Date Title
US20050268195A1 (en) Apparatus and method for improving emulation speed of high-level languages in on-chip emulation systems
CN109522033B (en) ECU program and data upgrading method based on device operation self-programming and double-interrupt vector table
US6798713B1 (en) Implementing software breakpoints
JPH05224911A (en) Dynamic-instruction correcting and controlling apparatus
CN113946481B (en) RISC-V kernel MCU debugging downloading program method and debugger
JP2010500682A (en) Flash memory access circuit
US20050015541A1 (en) Memory device controller
CN109725941A (en) A kind of programmable initial method and system for display driver chip
US5802268A (en) Digital processor with embedded eeprom memory
CN111008045B (en) Automatic loading method for off-chip flash high-capacity program
US7574585B1 (en) Implementing software breakpoints and debugger therefor
US20040177344A1 (en) Debugging method for the keyboard controller code
CN102568583A (en) In-circuit programing method for Flash memory of micro controller unit (MCU) in Freescale HCS12 series
CN208722090U (en) Built-in terminal with the accurate configuration feature of memory parameters
CN112802527B (en) Method for realizing high-speed programming of embedded flash memory and programming system of embedded flash memory
CN105045647B (en) Emulator supporting NVM rapid page programming
KR101548960B1 (en) Method for making and debuging program using virtual platform and appparatus therof
KR100788913B1 (en) Pre-Branch Pattern Generator for Test System of Semiconductor Apparatus
CN111221767B (en) FLASH interface circuit
CN113986321A (en) Method, device and equipment for upgrading PLC equipment and storage medium
CN116414356A (en) Program design method of children offline programmer
KR100506316B1 (en) Interrupt handling of micro firmware loader on IC bus
GB2424500A (en) Debugging code stored in EEPROM by inserting a breakpoint into code using a read/modify/write cycle on block containing individual instruction to be modified
CN116881120A (en) OpenOCD single port debugging method and system for isomorphic asymmetric multi-core
CN117632301A (en) MCU double BootROM program starting method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant