For an introduction to at91bootstrap, see the "at91bootstrap: A Second Stage Bootloader for Microchip Microprocessors" page.
at91bootstrap: Customize a Default Configuration
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 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
Loading a Bare Metal Program, RTOS, BusyBox, etc.
The at91bootstrap bootloader is capable of loading a bare metal, RTOS, BusyBox, or other program to external RAM from external NVM Flash memory.
1
Configure at91bootstrap with the chosen defconfig file:
$ make mrproper
$ make <board>_<nvm_boot_memory>_uboot_defconfig
2
Start menuconfig:
$ make menuconfig
3
Select Image Loading Strategy ( ) --->.
5
ESC-ESC back to the top-level menu.
7
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 memory mem with size = 4G;
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:
Section Kind Address Size Object
------- ---- ------- ---- ------
"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
8
ESC-ESC back to the top-level menu.
9
Select ( ) Image Name.
11
ESC-ESC back to the top-level menu.
12
ESC-ESC to exit menuconfig and save your configuration.
13
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 a SD Memory Card.
For an example of loading files to a QSPI Flash Memory, see the "ATSAMA5D27-SOM1-EK1 Boot from QSPI Flash Memory" page.
Copy and rename <board>_<nvm>_<image>_<version>.bin as boot.bin.
Copy getting_started.bin and boot.bin to a 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.
There is a default configuration file for use with MPLAB X IDE for most evaluation kits. Look for <board>_bkptnone_defconfig in the at91bootstrap/boards/<board> directory.
The steps below are for evaluation kits that do not have a default configuration file for use with MPLAB X IDE.
1
After configuration of make, run menuconfig:
$ make menuconfig
2
Select Image Loading Strategy ( ) --->.
4
ESC-ESC back to the top menu.
6
ESC-ESC to exit and Save your configuration.
7
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 have 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.
MPU’s 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:
1
After configuration of make, run menuconfig:
$ make menuconfig
2
Select Main Crystal configuration --->.
3
Select [*] Use external clock signal as a source of main clock.
4
ESC-ESC back to the top menu.
5
ESC-ESC to exit and Save your configuration.
6
Build at91bootstrap.
The results of the build will be available in the ~/at91bootstrap/binaries directory.
Refer to the target device data sheet for more detailed information on clock management.
Customize External RAM
The at91bootstrap can be configured for the type and size of external RAM (DDR2/DDR3) on your custom project board.
1
After configuration of make, run menuconfig:
$ make menuconfig
2
Select Memory selection --->.
3
Select RAM Configuration --->.
5
ESC-ESC back to the RAM Configuration menu.
7
ESC-ESC back to the RAM Configuration menu.
DO NOT modify the Extern Memory Bank Base Address and Size.
8
ESC-ESC back to the top menu.
9
ESC-ESC to exit and Save your configuration.
10
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:
1
After configuration of make, run menuconfig:
$ make menuconfig
2
Select Hardware Initialization Options --->.
3
Observe that [*] Display Banner has been enabled.
5
Enter your desired string.
6
ESC-ESC back to the top menu.
7
ESC-ESC to exit and Save your configuration.
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:
1
After configuration of make, run menuconfig:
$ make menuconfig
2
Select Memory Selection --->.
3
Select SD Card Configuration.
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