[2945559] | 1 | Getting Started with uMon for the Beaglebone Black |
---|
| 2 | |
---|
| 3 | ======================================================================= |
---|
| 4 | Booting: |
---|
| 5 | ======================================================================= |
---|
| 6 | |
---|
| 7 | ----------------------------------------------------------------------- |
---|
| 8 | SD Card: |
---|
| 9 | ----------------------------------------------------------------------- |
---|
| 10 | The Beaglebone Black can boot uMon from an SD card using two different |
---|
| 11 | boot modes. The first boot mode is to boot using "raw" mode. The |
---|
| 12 | second boot mode is to boot from a FAT primary partition marked as |
---|
| 13 | bootable. The details and the steps required to set up the SD card |
---|
| 14 | for each of the boot modes are elaborated in the following two sections |
---|
| 15 | on SD card booting. For more information on "raw" mode and FAT mode, |
---|
| 16 | please refer to the AM335s TRM Sections 26.1.7.5.5 "MMC/SD Read Sector |
---|
| 17 | Procedure in Raw Mode" and 26.1.7.5.6 "MMC/SD Read Sector Procedure |
---|
| 18 | in FAT Mode" respectively. |
---|
| 19 | |
---|
| 20 | In order to boot uMon from an SD card using FAT mode, a GP Header must |
---|
| 21 | be prepended to the uMon image. In the case of booting uMon using |
---|
| 22 | "raw" mode, both a Configuration Header TOC Structure followed by a |
---|
| 23 | GP Header must be prepended to the uMon image. |
---|
| 24 | |
---|
| 25 | The GP Header is 8 bytes long where the first 4 bytes specify the size |
---|
| 26 | of the uMon image that will be transferred while the last 4 bytes |
---|
| 27 | specify both the destination address where the uMon image will be |
---|
| 28 | transferred to and the entry point. |
---|
| 29 | |
---|
| 30 | For information on the layout of the Configuration Header TOC Structure |
---|
| 31 | required for "raw" mode booting, please refer to the AM335x TRM |
---|
| 32 | Section 26.1.7.5.5.1 "Configuration Header". |
---|
| 33 | |
---|
| 34 | One thing worth mentioning is that the Beaglebone Black is connected to |
---|
| 35 | the SD card using MMC0 and as a result the size of the SD card must not |
---|
| 36 | be greater than 4GB. This is indicated in the AM335x TRM Section |
---|
| 37 | 26.1.7.5.2 "System Interconnection". |
---|
| 38 | |
---|
| 39 | In order to configure the Beaglebone Black to boot from an SD card, |
---|
| 40 | a uSD must be inserted and the boot switch held down while the board |
---|
| 41 | is powered up. Once the board is powered on, the boot switch can |
---|
| 42 | be released. If the attempt to boot from the uSD fails, the |
---|
| 43 | Beaglebone Black will fall back and attempt to boot using UART. |
---|
| 44 | As a result, this will provide a way to determine whether the boot |
---|
| 45 | from SD has succeeded or not. |
---|
| 46 | |
---|
| 47 | Before starting, it is recommended that the device that will be |
---|
| 48 | manipulated is verified to be the right device. An approach to |
---|
| 49 | determine the right device name assigned to the SD card is by |
---|
| 50 | observing the output of |
---|
| 51 | |
---|
| 52 | cat /proc/partitions |
---|
| 53 | |
---|
| 54 | before and after inserting the SD card. |
---|
| 55 | |
---|
| 56 | |
---|
| 57 | RAW MODE: |
---|
| 58 | |
---|
| 59 | In order to boot from an SD card using "raw" mode, the uMon image |
---|
| 60 | must be prepended with a Configuration Header TOC Structure and a |
---|
| 61 | GP Header. The GP Header is placed right after the Configuration |
---|
| 62 | Header TOC Structure. |
---|
| 63 | |
---|
| 64 | When uMon is built, a uMon image containing the necessary headers |
---|
| 65 | is already created and is located under ./build_BEAGLEBONEBLACK. |
---|
| 66 | |
---|
| 67 | The next step is to setup the SD card. Fortunately, the script |
---|
| 68 | ./sd_setup.sh can be used to automate the process of setting up |
---|
| 69 | an SD card for "raw" mode booting. To do so, invoke the script as |
---|
| 70 | |
---|
| 71 | ./sd_setup.sh RAW <device> |
---|
| 72 | |
---|
| 73 | <device> shown above and for the remainder of this document will |
---|
| 74 | refer to the SD card. |
---|
| 75 | |
---|
| 76 | The following information specify how to manually set up the SD |
---|
| 77 | card. |
---|
| 78 | |
---|
| 79 | With the proper headers prepended, the image is ready to be booted. |
---|
| 80 | In order for the Beaglebone Black/AM335x to boot the image, the |
---|
| 81 | image must be placed at one of the offsets |
---|
| 82 | 0x00000/0x20000/0x40000/0x60000. |
---|
| 83 | |
---|
| 84 | As an example, to place the uMon image at the first offset |
---|
| 85 | |
---|
| 86 | # Get the size of the uMon image to transfer into the SD card |
---|
| 87 | export UMON_IMG_SIZE=`wc --bytes <uMon image> | cut -f 1 -d ' '` |
---|
| 88 | |
---|
| 89 | # Transfer the uMon image at offset 0x00000 |
---|
| 90 | dd if=<uMon image> bs=1 count=$UMON_IMG_SIZE of=/dev/<device> |
---|
| 91 | |
---|
| 92 | where <uMon image> is the path to the uMon image prepended with a |
---|
| 93 | Configuration Header TOC Structure and a GP Header. |
---|
| 94 | |
---|
| 95 | |
---|
| 96 | FAT MODE: |
---|
| 97 | |
---|
| 98 | In FAT Mode, an "MLO" file is searched for in the root directory of |
---|
| 99 | a primary partition formatted as FAT12/FAT16 or FAT32 and marked |
---|
| 100 | bootable. This "MLO" file must contain a GP Header followed by the |
---|
| 101 | uMon image. When uMon is built, an "MLO" file is already created and |
---|
| 102 | is located in ./build_BEAGLEBONEBLACK. |
---|
| 103 | |
---|
| 104 | For convenience, preparing the SD card for FAT Mode booting has |
---|
| 105 | been automated through the use of the same aforementioned script, |
---|
| 106 | ./sd_setup.sh. |
---|
| 107 | |
---|
| 108 | Invoking the script in order to create an SD card for FAT mode booting |
---|
| 109 | is as follows: |
---|
| 110 | |
---|
| 111 | ./sd_setup.sh FAT <device> |
---|
| 112 | |
---|
| 113 | The script simply sets up a primary partition on the SD card, marks |
---|
| 114 | it as bootable, formats it as FAT16 and then transfers the MLO file |
---|
| 115 | under ./build_BEAGLEBONEBLACK to the root directory of the primary |
---|
| 116 | partition on the SD card. |
---|
| 117 | |
---|
| 118 | The following elaborates the sequence of steps on how exactly an SD |
---|
| 119 | card is prepared for FAT Mode booting for the Beaglebone Black |
---|
| 120 | to boot from. |
---|
| 121 | |
---|
| 122 | Assuming that the SD card has not been formatted yet... |
---|
| 123 | |
---|
| 124 | Just to be safe, clear out the partition table at the base of the SD |
---|
| 125 | card to start fresh. |
---|
| 126 | |
---|
| 127 | dd if=/dev/zero of=<device> bs=1M count=1 |
---|
| 128 | |
---|
| 129 | The next step is to create a primary partition with the filesystem |
---|
| 130 | type set to FAT16. This primary partition will be placed as an entry |
---|
| 131 | in an MBR located in the first sector of the SD card. Fortunately, |
---|
| 132 | these intial steps are taken care of by the fdisk utility. |
---|
| 133 | |
---|
| 134 | To allocate a partition that will be formatted as FAT16 and to create |
---|
| 135 | an entry for the partition in the MBR, |
---|
| 136 | |
---|
| 137 | fdisk <device> |
---|
| 138 | |
---|
| 139 | Suppose the SD card is registered under /dev as "sdc", this would be |
---|
| 140 | |
---|
| 141 | fdisk /dev/sdc |
---|
| 142 | |
---|
| 143 | fdisk will then present a command-line dialog. |
---|
| 144 | |
---|
| 145 | From here, a new partition must be created using 'n'. This partition |
---|
| 146 | must have a type of 0x06 for FAT16 which is set with 't' and with the |
---|
| 147 | size allocated to the partition to be at least 3MB. This size is the |
---|
| 148 | minimum size required and is more than enough to hold a uMon image and |
---|
| 149 | to allow for future expansion. It is recommended that not all of the |
---|
| 150 | sectors of the SD card are allocated to the FAT16 primary partition |
---|
| 151 | in order to provide room for the possibility of storing user data or |
---|
| 152 | perhaps a kernel. |
---|
| 153 | |
---|
| 154 | Once that is done, the next step is to mark the primary partition as |
---|
| 155 | bootable. This is done using the 'a' option. |
---|
| 156 | |
---|
| 157 | With all that in place, the partition can be verified before writing |
---|
| 158 | it to the SD card with 'p'. Once the partition has been verified, |
---|
| 159 | it can be written to the SD card using 'w'. |
---|
| 160 | |
---|
| 161 | After using fdisk to set up the partition, the new partition can be |
---|
| 162 | viewed under /dev. So for example, if the base of the SD card is given |
---|
| 163 | as /dev/sdc, then the newly created FAT16 partition will be given as |
---|
| 164 | /dev/sdc1. |
---|
| 165 | |
---|
| 166 | The next step is to format this partition as FAT16: |
---|
| 167 | |
---|
| 168 | mkfs.fat -f 2 -F 16 -M 0xF8 -s 1 -S 512 <device> |
---|
| 169 | |
---|
| 170 | with <device> set to the primary partition of the SD card. |
---|
| 171 | |
---|
| 172 | The final step is to place the "MLO" file in the root directory |
---|
| 173 | of the FAT16 primary partition. |
---|
| 174 | |
---|
| 175 | cd ~ |
---|
| 176 | mkdir mnt |
---|
| 177 | mount <device> mnt |
---|
| 178 | cp <path_to_umon>/ports/beagleboneblack/build_BEAGLEBONEBLACK/MLO mnt |
---|
| 179 | umount mnt |
---|
| 180 | rmdir mnt |
---|
| 181 | |
---|
| 182 | In the previous set of commands, <device> is set to the primary |
---|
| 183 | partition of the SD card that was recently formatted as FAT16. |
---|
| 184 | |
---|
| 185 | The SD card is now ready. |
---|
| 186 | |
---|
| 187 | |
---|
[c900821] | 188 | ----------------------------------------------------------------------- |
---|
| 189 | eMMC: |
---|
| 190 | ----------------------------------------------------------------------- |
---|
| 191 | Booting uMon from the onboard eMMC requires a multiple-step procedure |
---|
| 192 | that will be simplified in the future as the uMon port progresses. |
---|
| 193 | |
---|
| 194 | To transfer a uMon image into the onboard eMMC requires an SD card where |
---|
| 195 | uMon is configured to boot in RAW mode from a known offset. |
---|
| 196 | |
---|
| 197 | With uMon configured to boot in RAW mode from a known offset in the |
---|
| 198 | SD card, the next step is to determine the size of the uMon image in |
---|
| 199 | 512-byte blocks. |
---|
| 200 | |
---|
| 201 | With all of this in place, the sequence of uMon commands required to |
---|
| 202 | transfer the uMon image are as follows: |
---|
| 203 | |
---|
| 204 | sd init |
---|
| 205 | mmc init |
---|
| 206 | sd read <destination in RAM> <SD sector address> <# of 512-byte blocks> |
---|
| 207 | mmc write <source in RAM> <eMMC sector address> <# of 512-byte blocks> |
---|
| 208 | |
---|
| 209 | With these steps, the uMon image is first transferred into DDR3 RAM |
---|
| 210 | and then written to the eMMC. The reason for this appraoch is that |
---|
| 211 | there is currently no supported mechanism to write the eMMC directly |
---|
| 212 | from an SD card. |
---|
| 213 | |
---|
| 214 | The user must take care to transfer the uMon image in a location in |
---|
| 215 | RAM not currently owned by the uMon image currently in execution. |
---|
| 216 | |
---|
| 217 | As for the final destination in the eMMC, the uMon image must be stored |
---|
| 218 | in a locatation where the internal ROM-bootloader will be able to find |
---|
| 219 | and boot this image. |
---|
| 220 | |
---|
| 221 | |
---|
[2945559] | 222 | ----------------------------------------------------------------------- |
---|
| 223 | UART: |
---|
| 224 | ----------------------------------------------------------------------- |
---|
| 225 | Unlike booting from SD, booting via UART does not require any GP |
---|
| 226 | Header, Configuration Header TOC Structure, or both to be prepended to |
---|
| 227 | the uMon image. The uMon image that will be booted using UART is |
---|
| 228 | boot.bin which is located in ./build_BEAGLEBONEBLACK. |
---|
| 229 | |
---|
| 230 | In order to boot from UART, a 3.3V USB-to-Serial cable is required, |
---|
| 231 | e.g. the FTDI USB TTL Serial cable is a possible option. |
---|
| 232 | |
---|
| 233 | The last requirement is to have a terminal emulator |
---|
| 234 | (e.g. minicom/picocom/etc.) set up to perform XMODEM transfers using |
---|
| 235 | 1K packets and 16-bit CRC. |
---|
| 236 | |
---|
| 237 | To initiate the UART booting procedure on the Beaglebone Black, ensure |
---|
| 238 | that there is no uSD card inserted and then hold the boot switch down |
---|
| 239 | while powering up the board. Once the board is powered on, the boot |
---|
| 240 | switch can be released. |
---|
| 241 | |
---|
| 242 | If a terminal emulator is set up already and connected to the serial |
---|
| 243 | port of the Beaglebone Black, the character 'C' will be outputted |
---|
| 244 | continuously. This indicates that the UART booting procedure has |
---|
| 245 | initiated and is waiting for an image to be transferred via UART. |
---|
| 246 | |
---|
| 247 | From here, the uMon image can now be transferred using the terminal |
---|
| 248 | emulator. |
---|
| 249 | |
---|
| 250 | For more information on the UART boot procedure, please refer to the |
---|
| 251 | AM335x TRM Section 26.1.8.5 "UART Boot Procedure". |
---|
| 252 | ======================================================================= |
---|