Implementation of Program program burning to S3C2440 nand flash in MDK

Source: Internet
Author: User

When you see the question may feel very simple, with J-LINK to burn program to nand flash is very simple, I want to say is, if it is learning, then it should not only to know its ran, let us know why. If you are a veteran, we recommend that you stop reading it, because you are no longer familiar with it, and it is useful for new users. Note: The Development Environment used is Keil MDK 3.50. You need to know the Bootloader, scattered loading of a job 1. Program burning to the S3C2440 nand flash is not difficult for beginners of ARM. Let's talk about my hardware configuration, 64 m nand flash, 64 m sdram, 2 m nor flash. When the program is downloaded to nand flash, after the system is powered on and running, the Controller of nand flash copies the first 4 K program to the SRAM for running. If the program is larger than 4 kb, you cannot download the program to nand flash completely because the program cannot be run in nand flash, the program must be moved from the nand flash to the SDRAM using the SRAM. After the migration is completed, the PC is directed to the starting position of the program in the SDRAM. At this time, the mission of the bootloader is complete. 2. To implement the above functions, you must write a startup or Bootloader program smaller than 4 K. The Bootloader should contain interrupt vector table, abnormal vector table, clock initialization, SDRAM initialization, GPIO and stack initialization, etc, in addition, the corresponding code also needs to be provided to move the program from nand flash to SDRAM. 3. Although Bootloader is implemented for program download, it can also be downloaded to nand flash, or the program can be moved from nand flash to SDRAM, in addition, the PC is handed over to the first address of the program, but the program cannot run correctly. Why? This is because the executable program downloaded to nand flash contains an absolute address. Although the program is moved from nand flash to SDRAM, when the absolute address is used, the program will run, thus, it cannot run correctly. How can this problem be solved? There is a way: Compile the program based on the SDRAM address, then download it to the nand flash, and then migrate the program back to the SDRAM through Bootloader, in this way, all the addresses are relative to the SDRAM, and the program can run correctly. Unfortunately, this method cannot be implemented by the MDK, because the *. axf file generated by the MDK carries the address information. The image file generated by using a distributed file is based on a specific address, which must be downloaded to the corresponding address of FLASH. If you want to compile the generated * based on a specific address of SDRAM *. when the axf file is downloaded to nand flash, the MDK prompts an error and cannot find the burning algorithm. If you do not generate a file with the address information, you can solve this problem. Bin cannot be directly generated in MDK. Enter C in the text After Run #1 in the Run User Programs After Build/Rebuild box: /Keil/ARM/BIN31/fromelf.exe-bin-o. /output/Axf_To_Bin.bin. the/output/Axf_To_Bin.axf command is used to convert a file in bin format. Then download the bin to SDRAM and move it to nank flash. The rest is completed by bootloader. Although the whole process is troublesome, the most effective method in MDK is. II. Implementation Process (1) Bootloader mainly initializes some hardware and moves the program from NAND to SDRAM. The compilation of the Bootloader program is relatively simple. Configure the read/write fields of RO and RW on the Target page and set the start address of ROM1 to 0 and the size to 0x1000, in RAM1, the starting address is set to 0x30800000, because bootloader needs to move the program to 0x30000000 for running. To avoid overwriting the RW segment of the bootloader, therefore, leave enough space to store user programs. The program can be downloaded to SDRAM using USB. here we need to explain that the user program needs to use a distributed file, that is, the starting address is 0x30000000. Next we will introduce the bootloader burning and writing process: 1.JPG FLASH download method I no longer said, if you have a J-LINK can be used, if there is no can also use the JTAG Small board download, you can also use MDK to download OK, in short, you can download it to nand flash. This step is a prerequisite. (2) It is very convenient to use the dnw software to download USB files. Note that you must add a write function to the nand flash file in your own programs, this function allows you to move files from SDRAM to flash. L compile routine generation. bin_rom1 0x30000000 {; load region ER_ROM1 0x30000000 {; load address = execution address *. o (RESET, + First) * (InRoot $ Sections ). ANY (+ RO)} RW_RAM1 0x30800000 0x0800000 {; RW data. ANY (+ RW + ZI)} RW_IRAM1 0x40000000 0x00001000 {. the ANY (+ RW + ZI)} above is clearly written. The user program code is placed at the 0x30000000 position, which is not in conflict with the RW segment of Bootloader. L run the USB program first to connect the USB cable, open the Super Terminal DNW, and then debug the USB program in RAM. When you run the program for the first time, the driver installation dialog box is displayed. Point the installation path to the usb driver folder in the USB routine directory and click confirm installation. After running the program, the following information is displayed on the Super Terminal: Enable Configration and select: Use the bootloader running routine to download the routine with USB. after the BIND file, the file is automatically moved to the nand flash, and the USB program can be closed. Press the reset key on the Development Board to run the program just downloaded to nand flash. So far, the program compiled by the user has been downloaded to the nand flash, as long as you restart the Development Board, Bootloader will copy the program in the nand flash to 0x30000000 of the sdram, after completion, send the PC to the SDRAM. Now, your program has been successfully run.


From: Id = 1698718

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: 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.