Detailed explanation of mw and md commands for memory operation under uboot

mw profile

The mw command in u-boot is a command for writing data to memory, and it has 4 forms:

  • mw.b - write 1 byte (8 bits) of data
  • mw.w - write 1 word (2 bytes, 16 bits) of data
  • mw.l - Write 1 long word (4 bytes, 32 bits) of data
  • mw.q - Write 1 quadword (8 bytes, 64 bits) data
    Their syntax format is:
    mw.b address, value
    mw.w address, value
    mw.l address, value
    mw.q address, value
    in:
  • address is the memory address where the data is written
  • value is the data to be written, and its width is determined by the command type (b is 8 bits, w is 16 bits, l is 32 bits, and q is 64 bits). These commands are usually used in the u-boot command line
    for Test and debug the memory system during system startup.

example of mw

To give a few examples:

=> mw.b 0x100, 0x12    # 往内存地址0x100写入字节数据0x12 
=> mw.w 0x200, 0x3456 # 往内存地址0x200写入字数据0x3456
=> mw.l 0x300, 0x789A # 往内存地址0x300写入长字数据0x789A 
=> mw.q 0x400, 0x0123456789ABCDEF # 往内存地址0x400写入四字数据  

image.png

Introduction to the md command

The md command in u-boot is used to read data from memory. It has 4 forms:

  • md.b - read 1 byte (8 bits) of data
  • md.w - read 1 word (2 bytes, 16 bits) of data
  • md.l - read 1 long word (4 bytes, 32 bits) of data
  • md.q - read 1 quadword (8 bytes, 64 bits) of data
    Their syntax format is:
    md.b address
    md.w address
    md.l address
    md.q address
    where address is the data to be read memory address.
    These commands will read the corresponding width of data from the specified memory address and print it out so that we can view the contents of the memory.

md example

To give a few examples:

=> md.b 0x100  
0x100: 0x12

=> md.w 0x200
0x200: 0x3456  

=> md.l 0x300
0x300: 0x789A  

=> md.q 0x400
0x400: 0x0123456789ABCDEF

Like the mw command, the md command also allows us to specify different widths to read data from memory. This allows us to look at different granularities of data content in memory to see if the data is stored correctly or as expected.
The md command is often used together with the mw command. We first use the mw command to write some test data to the memory, and then use the md command to read and verify that the data is stored correctly, which can effectively test and debug the memory system.

Guess you like

Origin blog.csdn.net/yikezhuixun/article/details/130606104