ARM Notes: Bare Metal Experiment - Storage Controller

Publisher:huanranLatest update time:2017-11-12 Source: eefocusKeywords:ARM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

There are 8 banks in S3C2440, each with an address space of 128MB, for a total of 1GB. The data width of bank0 is selected by hardware, and the others can be changed by setting the corresponding registers. Bank0-bank5 supports external ROM and SRAM, and bank6 and bank7 also support SDRAM (i.e. the memory on the development board), and the address space size of bank6 and bank7 is variable.

       S3C2440 leads out 27 address lines ADDR0-ADDR26, accessing 128MB of space. It also leads out nGCS0-nGCS7, corresponding to bank0-bank7. When accessing the corresponding bank, the corresponding nGCSx outputs a low level to select the peripheral. The address distribution diagram is as follows.

ARM Notes: Bare Metal Experiment - Storage Controller

Steppingstone is the 4KB RAM inside the CPU. When the CPU is powered on and the hardware chooses to boot from Nand flash, the hardware will copy the first 4KB of data in Nand flash to Steppingstone, starting at address 0.

 

Using SDRAM:

       SDRAM needs to be connected to bank6 or bank7. The SDRAM used on the development board is HY57V561620, which consists of 4 logical banks (L-banks), each bank has 4M, and the data width is 16 bits. So its capacity is 4*4MB*2B=32MB. The development board has two SDRAMs. The data width is 32 bits, so the capacity is 64MB. The connection is as shown:

 ARM Notes: Bare Metal Experiment - Storage Controller

Because the total capacity of the SDRAM on the board is 64MB, 26 address lines are used. The last two bits LADDR24 and LADDR25 are connected to BA0 and BA1 of the SDRAM to select the logical bank of the SDRAM. Because the data width is 32 bits, the lower two bits LADDR0 and LADDR1 are not used. The chip select signal nSCS of the SDRAM is connected to nGCS6:nSCS0 of the CPU, so Bank6 is used.

       The steps for accessing SDRAM are roughly as follows:

       1. The CPU sends a chip select signal nSCS that is valid and SDRAM is selected.

       2. LADDR24 and LADDR25, select the L-bank in SDRAM.

       3. Perform row and column addressing on the selected chip.

       4. The data of the found storage unit is transferred to the data bus.

 

These operations are all performed automatically by the CPU when the corresponding registers are set and the memory is accessed. The CPU can automatically separate the L-bank, row, and column addresses according to the column address bits and memory size information set in the registers, and send them to the SDRAM in the corresponding timing.

 

 

Register introduction:

       The memory controller has 13 registers in total. Only BWSCON and BANKCONx need to be set for bank0-bank5. Other registers need to be set when bank6 and bank7 are connected to external SDRAM. The following is an introduction to each register.

 

BWSCON (Bus width & Wait CONtrol register) is a bit width and wait register. This register sets the bit width of each bank, where each 4 bits controls one bank. According to the data sheet, each 4 bits

       DWx: occupies two bits to set the bit width of bankx, 00 corresponds to 8 bits, 01 corresponds to 16 bits, and 10 corresponds to 32 bits

       WSx: occupies one bit, whether to use the WAIT signal, usually 0 is not used

       STx: occupies one bit. Whether to enable the SDRAM data mask pin. This bit of SDRAM is 0.

Among them, the more special one is bank0, whose bit width is determined by the hardware pins OM0 and OM1.

 

BANKCONx (BANK CONtrol register). In the 8 banks, bank 6 and bank 7 can be connected to SDRAM, so BANKCON6 and BANKCON7 are different from 0-5. 0-5 mainly control the access timing of external devices. 6 and 7 have additional,

MT: Used to set this bank to be an external memory type. SRAM/ROM is 00, SDRAM is 11

Trcd: delay from RAS to CAS

SCAN: SDRAM column address number, 00 is 8 bits, 01 is 9 bits, 10 is 10 bits,

 

REFRESH (refresh control register) Refresh control register, where REFEN 0 is to disable the refresh function, 1 is to enable the refresh function. TREFMD refresh mode, Trp precharge time, Tsrc half line cycle. The remaining 0-10 bits are refresh counters, calculated as 2^11+1-SDRAM clock frequency (MHz)*SDRAM refresh cycle (us). When the 2440 development board does not use PLL, the clock frequency is equal to the crystal frequency of 12MHz, and the calculated value is equal to 1955. The entire register is 0x008C07A3 in this development board

 

BANKSIZE bank size register, where BURST_EN 0 is to disable burst transfer 1 is to support burst transfer. SCKE_EN enables power-down mode or not, SCLK_EN only sends SCLK signal during access to SDRAM. BK76MAP sets BANK6/7 size. 010 is 128MB 001 is 64MB. In this example, it is 0xb1.

 

MRSRBx (SDRAM mode register set register) x is 6 and 7. Only CL[6:4] CAS wait time can be set. The entire register is set to 0x30

 

Experimental code introduction:

  1. @****************************************

  2. @ Set SDRAM to download to nandflash and transfer to internal

  3. @ The program in SRAM is copied to SDRAM and then jumps to SDRAM

  4. @ implement

  5. @****************************************



  6. .equ    MEM_CTL_BASE,    0x48000000

  7. .equ    SDRAM_BASE,    0x30000000

  8. .equ    WTCON,        0x53000000

  9. .text

  10. .global _start

  11. _start:

  12.     bl disable_watchdog

  13.     bl init_sdram

  14.     bl move_to_sdram

  15.     ldr pc,     =jump_to_main



  16. disable_watchdog:

  17.     ldr r1,    =WTCON

  18.     mov r2,    #0x0

  19.     str r2, [r1]

  20.     mov pc,    lr


  21. init_sdram:

  22.     ldr r1,    =MEM_CTL_BASE

  23.     adrl r2, mem_cfg_val

  24.     add r3,    r1,#52    @4*13 = 52

  25. 0: @Number labels are local labels, which can appear multiple times in different areas.

  26.     ldr r4,    [r2],#4

  27.     str r4,    [r1],#4

  28.     cmp r1,    r3

  29.     bne 0b

  30.     mov pc,    lr


  31. move_to_sdram:

  32.     mov r1,    #0;

  33.     ldr r2,    =SDRAM_BASE

  34.     add r3,    r1,#4*1024

  35. 0:

  36.     ldr r4,    [r1],#4

  37.     pg r4, [r2],#4

  38.     cmp r2,r3

  39.     bne 0b

  40.     mov pc,    lr


  41. jump_to_main:

  42.     ldr sp,    =0x34000000

  43.     bl main

  44.     


  45. .align 4

  46. mem_cfg_val:

  47.     .word    0x22011110    @BWSCON

  48.     .word    0x00000700    @BANKCON0

  49.     .word 0x00000700 @BANKCON1

  50.     .word    0x00000700    @BANKCON2

  51.     .word    0x00000700    @BANKCON3

  52.     .word    0x00000700    @BANKCON4

  53.     .word 0x00000700 @BANKCON5

  54.     .word    0x00018005    @BANKCON6

  55.     .word    0x00018005    @BANKCON7

  56.     .word    0x008C07A3    @REFRESH

  57.     .word    0x000000b1    @BANKSIZE

  58.     .word    0x00000030    @MRSRB6

  59.     .word    0x00000030    @MRSRB7

The Makefile is as follows:

sdram.bin : head.S  leds.c
    arm-linux-gcc  -c -o head.o head.S
    arm-linux-gcc -c -o leds.o leds.c
    arm-linux-ld -Ttext 0x30000000 head.o leds.o -o sdram_elf
    arm-linux-objcopy -O binary -S sdram_elf sdram.bin
    arm-linux-objdump -D -m arm  sdram_elf > sdram.dis
clean:
    rm -f   sdram.dis sdram.bin sdram_elf *.o


Keywords:ARM Reference address:ARM Notes: Bare Metal Experiment - Storage Controller

Previous article:ARM Notes: SDRAM Memory Driver
Next article:ARM Notes: Detailed explanation of assembly and C language programs 1

Recommended ReadingLatest update time:2024-11-16 13:54

How do beginners choose ARM development hardware?
1. If you have experience in hardware and microcontrollers, it is recommended that you make a minimum system board yourself: If you have never done ARM development, it is recommended that you do not be greedy for perfection at the beginning, and make all the applications well, because the startup method of ARM is diff
[Microcontroller]
ARM Painless Start (S3C44B0X)
arm (44b0x) painless start   I have been reading ARM documents for the past two weeks. After I figured out what was going on with the help of my friends, I felt that the introductory documents I read before were always not detailed enough. So I decided to write a document to summarize the introductory knowledge of ARM
[Microcontroller]
iOS reverse engineering: ARM instructions in Hopper
1. ARM instructions in Hopper I won't say much about ARM processors. Because of their low power consumption and other reasons, most mobile devices use ARM processors. Of course, Android phones and iPhones, as mobile devices, also use ARM processors. If you want to learn more about the iOS system and your applications,
[Microcontroller]
iOS reverse engineering: ARM instructions in Hopper
Linux ARM (IMX6U) BSP project management experiment
When we write a project, we put all the source code files in the root directory of the project. If there are relatively few project files, this is understandable. However, if the number of source files reaches dozens or even hundreds, putting them all in the root directory will make the project look messy. Therefore,
[Microcontroller]
Linux ARM (IMX6U) BSP project management experiment
ARM pipeline key technology analysis and code optimization
Introduction     Pipeline technology shortens program execution time and improves the efficiency and throughput of the processor core by making multiple functional components work in parallel, thus becoming one of the most important technologies in microprocessor design. The ARM7 processor core uses the typical three-
[Microcontroller]
ARM stack method
When the stack pointer points to the last data pushed into the stack, it is called a full stack. When the stack pointer points to the next empty location where data will be placed, it is called an empty stack. According to the battle generation method, it is divided into: Ascending Stack and Decreasing Sta
[Microcontroller]
Application of CAN bus acceptance filter embedded in LPC2000 series 32-bit ARM microcontroller
CAN (Controller Area Network) bus, or Controller Area Network bus, was developed and launched by Bosch in Germany in 1982 as the earliest data communication protocol for measuring and executing components inside automobiles. In its more than 20 years of history, CAN bus has been applied in many fields and is the only
[Microcontroller]
Application of CAN bus acceptance filter embedded in LPC2000 series 32-bit ARM microcontroller
Research on Remote Video Monitoring System Based on ARM Platform
introduction The video surveillance system is a component of the security system, and it is a comprehensive system with strong prevention capabilities. Today's surveillance system has entered the era of digitization and networking, that is, the video is output from the front-end image acquisition device
[Microcontroller]
Research on Remote Video Monitoring System Based on ARM Platform
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号