Autodetect SDRAM size in uBoot Bootloader via ARMv7 processor exception handler

Hi There,

I am writing some bootload code for the TI Sitara AM5726 processor which has Dual Arm-v7 Cortex-A15  cores. The uBoot bootloader is the code that runs before starting the Linux Kernel and is responsible for configuring the extents of the SDRAM.

I would like to be able to auto-detect the size (address space) of the installed SDRAM, which may either be 2GB or 4GB in size. To do this my thought process was to write a function that sets the minimum RAM size to 2 GB, then attempt to write and read from the 4GB address.

What happens is as expected when only 2GB of RAM is installed, an exception or trap is thrown and the processor goes into a HALT or infinite loop by hitting the _halt exception/trap vector.

I am looking for some ARM assembly or "C" code to do the following, that is to recover from the exception and keep executing.

void auto-detect() {
gd->ram_size = 2GB;
   save_cpu_state();
   try {
      writeAndRead4GB();
      if (successful) {
        gd->ram_size = 4GB;
      }
   } catch {
      restore_cpu_state();
   }
}

Some working C or assembly code would be much appreciated.

References:
https://developer.arm.com/docs/dui0471/i/handling-processor-exceptions
https://www.cs.utexas.edu/~simon/378/resources/ARMv7-AR_TRM.pdf

Thanks,

Mark

Parents Reply Children
No data
More questions in this forum