Program bare metal application to NAND flash

HuyNguyen
Hi all,

I want to program a bare metal application to NAND flash so that I can run
it from NAND at power-on or reset.

Can anyone guide me how to program to NAND flash on mini2440?

Thanks,
Huy

googlemi
just see here
http://oi38.tinypic.com/a2q4u8.jpg

HuyNguyen
Hi,

Do you mean "Download Nboot for WinCE" ?
I tried it but it does not work:
 - Switch to NOR flash, then press "n" and download 2440test.bin from USB
 - Power off, then switch to NAND flash
 - Power on again, there is no response from mini2440

Enter your selection: n
USB host is connected. Waiting a download.

Now, Downloading [ADDRESS:30000000h,TOTAL:1822882]
RECEIVED FILE SIZE: 1822882 (593KB/S, 3S)
Downloaded file at 0x30000000, size = 1822872 bytes
Erase flash ok: start address = 0x0, size = 0x1c0000
Write to flash ok: start address = 0x0, size = 0x1bd098

Can you suggest any problem?

Thanks

googlemi
Yeah,the "n""v" and "a" is as the same,there're be OK

googlemi
Attachment: uart.rar (168.81 KB)
"no response from mini2440" means your program has error,you can try
mine,just that uart as above,you can open it with keil MDK

HuyNguyen
Hi,

My program is from a reference project which is 2440test.
It is used to test various functions of mini2440 like PWM, I2C, LCD, etc.
It can work if I use "Download and Run" to download it to DRAM space
(0x30000000) and execute from there.
Anyway, I will try your UART program.

Thanks,
Huy

Juergen Beisert
> I want to program a bare metal application to NAND flash
> so that I can run it from NAND at power-on or reset.

NAND != NOR. You can't run a program directly from NAND. NAND is a block
based memory. It acts like a hard disk: you must first load all blocks
where your program is stored to into the SDRAM and then you can run it from
SDRAM.

If you want to run your program directly from a non-volatile memory, you
need NOR memory.

HuyNguyen
Hi,

Yes, I know about that.
But if the system starts from NAND, it will copy 4K of program code from
NAND to the internal stepping stone SRAM and execute from there. Then the
executed code will copy the whole program from NAND to external DRAM and
jump to the external DRAM for normal execution.

I want to verify that process with my program.

Thanks,
Huy

HuyNguyen
Hi googlemi,

I tried your UART program and it works.
However, when I add "uart0_printf()", the program hands.
I think stack has not been initialized.
In addition, I check 2440init.s file and see that you made some changes:
  Ex: From nand_boot_beg, you skip all instuctions to interface with NAND
flash

Can you explain for me about your changes and about the user stack for C
code whether it is available or not?

Thanks,
Huy

HuyNguyen
Hi googlemi,

I want to ask about your UART code:
  Does it copy the program to the external DRAM and execute from there?
  Or does it just execute in the internal stepping stone SRAM ?

Thanks,
Huy

googlemi
@HuyNguyen 

Yes,it does in the startcode(2440init.s).after power on,the s3c2440 nand
control will automaticly copy the firt 4K code from nand to STEEPING
STONE(SRAM),then the cpu runs from here and copy all the code 2 SDRAM and
jump there.

googlemi
@HuyNguyen 
the code is lager than 4K,so I'm sure it runs in the SDRAM from nand boot

HuyNguyen
Hi googlemi,

Have you tried "uart0_printf()" function? Can you try it?
I tried and the program hangs.
In addition, I have question:
  Why do you skip all instructions to setup NAND boot like (read NAND ID,
read NAND status, etc) in 2440init.s file? 

Thanks,
Huy

googlemi
@HuyNguyen

exactly say,that's just where I dont understand,you can see my topic
here,and if you hv any ideas plz tell me.3kx

googlemi
Attachment: uart.rar (170.26 KB)
Err,I know what's the problem.in the before code,My link setting is as
flowings
http://oi34.tinypic.com/2m4ww3q.jpg

But the 2440init.s there's a code:
ldr pc,=copy_proc_beg
before I dont understan this(its used to jump to SDRAM from SRAM),nopw I
see that:the location of copy_proc_beg=0x30000000+offset adress(the offset
address is the distance from entry to copy_proc_beg).but the before setting
is 0x000000+offset adress

about how 2 do this you can see my blog here:
http://blog.csdn.net/googlemi/article/details/8836609

googlemi
sorry,before link settiing is this and its wrong
http://oi34.tinypic.com/r07cb6.jpg


above is just the right linker setting

HuyNguyen
Hi googlemi,

Thank you for your information.
I tried and it works as expected.
I will investigate your refernce code more detail tomorrow.
If I have any confusing points, I will ask your help ^_^/

Thanks,
Huy

HuyNguyen
Hi googlemi,

I use your 2440init.s file for my 2440test project.
My main application is as follow:
void Main(void)
{
  char *mode;
  int i;

   int c;
   unsigned char key;
   unsigned int mpll_val = 0 ;
  
   i = 2 ;
   switch ( i ) 
   {
      case 0: //200
         key = 12;
         mpll_val = (92<<12)|(4<<4)|(1);
         break;
      case 1: //300
         key = 13;
         mpll_val = (67<<12)|(1<<4)|(1);
         break;
      case 2: //400
         key = 14;
         mpll_val = (92<<12)|(1<<4)|(1);
         break;
      case 3: //440!!!
         key = 14;
         mpll_val = (102<<12)|(1<<4)|(1);
         break;
      default:
         key = 14;
         mpll_val = (92<<12)|(1<<4)|(1);
         break;
   }
       
   uart0_init(115200);
   uart0_printf( "<***********************************************>\n");
   uart0_printf( "           Mini2440 Test Program VER1.0          \n");
   uart0_printf( "<***********************************************>\n");
     
  while(1)
  {
    c=uart0_getbyte();
    uart0_sendbyte(c);
    uart0_printf("\nThe test output is %d\n",c);
  }
}

If I comment out all code of "switch" statement, the program can run and
display message on UART0.
But when I dont comment out, no message display from UART0 

I dont know the reason. Could you help me to figure out?

Thanks,
Huy

googlemi
@HuyNguyen 

Sorry,Im not very clear,but as I know its used to set cpu clock,but the cpu
clock had been setted in the 2440init.s so I feel comfused a lot.How to
say,I would rather write by myself but not the provided source because I
think the program style is very awful