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-exceptionshttps://www.cs.utexas.edu/~simon/378/resources/ARMv7-AR_TRM.pdf
Thanks,
Mark
u-boot needs to know the size of DDRAM to initialize it correctly (timing, number of banks, addresse lines etc). So it makes no sense to "try to detect" the size of DDRAM in u-boot.
Anyway, there are plenty of examples for exception handling out there.
I should have specified that the board is initially initialized such that the EMIF and LISA registers are configured for a 4 GB RAM address space in u-boot. Therefore the only issue is when 2 GB RAM is installed and attempting to access the 2 GB to 4 GB address space results in a data abort exception.
How does one recover from a data abort exception such as this? I have not been able to find any working C or assembly examples online.
https://www.embedded.com/how-to-use-arms-data-abort-exception/
Sure you can recover from such an abort if the CPU is not completely bailed out.
But I recommend to make the test access in some assembly file.
Your abort handler needs to detect the test access and then _skip_ the access opcode.No idea what you want to do with try/catch. This is low-level (assembly) not C++.