at91bootstrap: Customizing a Default Configuration
Introduction
This training topic shows you how a default configuration can be changed using menuconfig. Here are a few examples of some of the changes that can be made for your custom project:
- Loading a bare metal binary image, RTOS, BusyBox, etc.
- Building at91bootstrap for use with MPLAB® X IDE
- Modifying Clock Source
- Customize External RAM
- Changing Display Banner
- Booting from a different SD Memory Card slot
Prerequisites
For an introduction to at91bootstrap, visit the "at91bootstrap: A Second Stage Bootloader for Microchip MPUs" page.
Loading a Bare Metal binary image, RTOS, BusyBox, etc.
The at91bootstrap bootloader is capable of loading a bare metal, RTOS, BusyBox or another binary image to external RAM from external NVM Flash memory.
Configure at91bootstrap with the chosen defconfig file
$ make <board>_<nvm_boot_memory>_uboot_defconfig
Start menuconfig
Select (X) Load 1 MB into start of SDRAM
If the image to load is larger than 1 MB, you can select (X) Load 4 MB into start of SDRAM.
Select Demo Application Image Storage Setup
To know what value to enter, refer to the linker file or MAP file as seen in the accompanying image.
Enter the address of the external SRAM to load the image
To find this value, you can refer to the linker file or MAP file generated by the build. For example, the snippet below shows the linker file of an example getting-started program:
define region RAM_region = mem:[from 0x00200000 to 0x0021FFFF];
define region DDRAM_region = mem:[from 0x20000000 to 0x23FFFFFF];
define region DDRAM_NOCACHE_region = mem:[from 0x24000000 to 0x24FFFFFF];
[..]
place at start of RAM_region { section .vectors };
place in RAM_region { block SRAM };
place in RAM_region { block IRQ_STACK };
place in RAM_region { block RAMCODE_BLOCK };
[..]
The snippet below shows the MAP file of an example getting-started program:
------- ---- ------- ---- ------
"A0": 0x3c
section .vectors-1 0x30'0000 0x3c <Init block>
.vectors inited 0x30'0000 0x3c cstartup.o [1]
- 0x30'003c 0x3c
"P1-P3|P5": 0x60
IRQ_STACK 0x30'0040 0x60 <Block>
IRQ_STACK uninit 0x30'0040 0x60 <Block tail>
- 0x30'00a0 0x60
"A1": 0xc8
.cstartup ro code 0x2000'0000 0xc8 cstartup.o [1]
- 0x2000'00c8 0xc8
Enter the name of the image to be loaded
Build at91bootstrap
$ make
The results of the build will be located in the binaries/ directory:
$ cd ~/project_1/at91bootstrap/binaries $ ls -l <board>_<nvm>_<image>_<version>.bin
Below is an example of loading files to an SD Memory Card.
Copy and rename <board>_<nvm>_<image>_<version>.bin as boot.bin.
Copy getting_started.bin and boot.bin to an SD Memory Card formatted with a single FAT partition.
Insert the SD Memory Card into the custom project board (or evaluation kit) and power on.
You will see on the console at91bootstrap executing followed by the getting_started program:
Building at91bootstrap for use with MPLAB X IDE
In this scenario, at91bootstrap is configured to initialize external DRAM and is configured to not load any binary image. MPLAB X IDE first loads at91bootstrap into internal SRAM, at91bootstrap initializes external DRAM, and then MPLAB X IDE loads the binary.
After configuration of make, run menuconfig
$ make menuconfig
Select (X) Do not load any image after bootstrap run
Select [*] Build image for use with debuggers
Build at91bootstrap
$ make
The results of the build will be available in the ~/at91bootstrap/binaries directory.
Modifying Clock Source
When a microprocessor unit (MPU) performs a power-on-reset, it begins running on its internal 12 MHz RC oscillator (due to its fast startup time) and starts the first-stage boot process stored in its internal ROM (ROM Boot Code). However, the internal RC oscillator may not be stable and accurate enough for some peripherals (for example, USB). Each of the Microchip MPU evaluation kits has a 12 MHz crystal that can be enabled. Therefore, the external 12 MHz crystal oscillator is initialized and the main clock is configured to the external crystal oscillator.
MPUs can be configured for an external clock source. This signal typically comes from an external oscillator device and the signal is fed directly to the MPU.
The at91bootstrap can be configured for this scenario by following the steps below:
After configuration of make, run menuconfig
$ make menuconfig
Build at91bootstrap
The results of the build will be available in the ~/at91bootstrap/binaries directory.
Customize External RAM
The at91bootstrap can be configured for the type and size of external RAM (DDR2/DDR3) on your custom project board.
After configuration of make, run menuconfig:
$ make menuconfig
Select RAM size ( )
Select DDR-SDRAM device type ( )
ESC-ESC back to the RAM Configuration menu.
Build at91bootstrap
The results of the build will be available in the ~/at91bootstrap/binaries directory.
Changing Display Banner
The at91bootstrap displays a banner on the target console when it begins running. For example, the default banner is shown below:
You can modify the banner to your requirements by following the steps below:
After configuration of make, run menuconfig:
$ make menuconfig
Select string value below [*] Display Banner
Build at91bootstrap
The results of the build will be available in the /at91bootstrap/binaries directory.
The at91bootstrap will now display the string you entered:
Booting from a different SD Memory Card Slot
Each of the Microchip 32-bit Microprocessor Units (MPU) contain two Secure Digital MultiMedia Card Controllers (SDMMC). Most of the evaluation kits also contain two SD Memory Card slots (often two different size jacks).
You can configure at91bootstrap to boot from either SD Memory Card slot. We show you how in the steps below:
After configuration of make, run menuconfig:
$ make menuconfig
Select SD Host Controller Select ( )
From this page you can select the SD Memory Card slot for your requirements.
Summary
In this training, you learned how to make changes to the default configuration and customize at91bootstrap for your project:
- Loading a Bare Metal Program, RTOS, BusyBox, etc.
- Building at91bootstrap for use with MPLAB X IDE
- Modifying Clock Source
- Customize External RAM
- Changing Display Banner
- Booting from a different SD Memory Card slot