In Linux, use openjtag + openocd to burn and write NAND Flash

Source: Internet
Author: User

For a long time, many development tools are based on windows, and the same is true for NAND Flash.

I have several development boards, such as S3C2410, S3C2440, at91sam9263, and pxa310. Apart from windows, it seems that I cannot find a proper burning tool. Only jflash is available for S3C2410, And it is written through the parallel port and wigggler. Most laptops are not connected at all, and even desktop interfaces are slowly disappearing. Fortunately, my notebook has one. However, the company's laptops are all non-parallel Linux.

There are many arm simulators. Common jlinks can only be used in Windows environments. By chance, I found openocd, a good thing. Then I found openjtag, which is the same as jtagkey as layout. It is generally used in combination with openocd. In addition, openjtag uses ft2232, which contains two UART channels and a max UART --> RS232 level signal conversion chip, in this way, we can save a USB-to-string cable for our notebook. I even saved a USB hub for a relatively scarce USB port, but it is usually sold for 180 on the Internet. I think it is too outrageous, and 90 Yuan is worth a day.

No way. I took a video in Taobao and took it with a CD. The flash burning method described in the CD was init SDRAM first, and then u-boot was put into the SDRAM, use U-boot to burn and write NAND. this is very different from my requirements, because I want to burn the self-developed bootloader, not to burn anything else, although this can be done, but it is too troublesome. No way. I just got the latest version of openocd. I checked the code and burned the NAND part and supported several types of NAND.

Okay, let's talk about it. Let's talk about how to implement it directly. The following uses S3C2440 as an example:

Openocd compilation is omitted here. You can go to the csdndownload center to search for the openjtag.tar.bz2 package file that I uploaded. I made a small change to the openocd code, and detailed steps for compiling and using readme are provided.

 

First, add the following content to your openocd. cfg file:

Nand device S3C2440 0

Then start openocd:

Openocd

Connect to openocd using telnet:

Telnet fig 4444

Before executing the NAND command, you must first use the NAND probe test:

Nand probe 0

Check whether your NAND Flash is found. Remember to power on the Development Board.

Some platforms may encounter address translation failure, because there is a bug in openocd. Originally, d cache was not enabled. it thought it was enabled and MMU was also enabled, each address accessed is converted, but the page table cannot be found. Therefore, a conversion error occurs. The solution is to use:

Reset; halt

Restart the development. Note that the reset and halt should be input in one line and separated by semicolons. As a result, the arm will be suspended after the restart. At this time, the D cache will be closed. Use it again at this time:

Nand probe 0

The address conversion will not fail.

Next we can read, erase, and write:

Read 0th bytes from 10th NAND 512 bytes to the dump. binfile:

Nand dump 0 or dump. Bin 10 512

0th blocks are erased from 9th NAND to 15th blocks (7 * block_size bytes in total ):

Nand erase 0 9 15

Write/u-boot.bin to the beginning of 4 K on 0th NAND:

Nand write 0/u-boot.bin 4096

 

Note: You must erase all data before writing. It is written based on the size of your file.

In many cases, writing fails. You can use NAND dump to check whether the writing is successful. If not, write it again.

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.