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