title: How can I boot bare metal from SD card on PocketBeagle?
body: <h1>What I'm Trying To Do:</h1>
  
  <p>I am trying to boot my new <a href="https://beagleboard.org/pocket" rel="nofollow noreferrer">PocketBeagle</a> into a plain assembly program.</p>
  
  <pre><code>.equ GPIO_BANK1, 0x4804C000
  .equ GPIO_OE, 0x134
  .equ GPIO_USR_SETPIN0, 0x194
  .equ GPIO_USR_PIN0, 0x13C
  
  .globl _start
  
  _start:
      ldr r0, =GPIO_BANK1 
      ldr r1, =GPIO_OE    @ Get the output enable register
      add r0, r1
      mov r1, #0          @ Set all of the GPIO1 Pins to output
      str r1, [r0]
  _main:
      ldr r0, =GPIO_BANK1    
      ldr r1, =GPIO_USR_PIN0 @ Get the output register
      add r0, r1
      mov r1, #1
      lsl r1, #24
      str r1, [r0]           @ Set the USR LED to hi.
  loop:
      ldr r2, =0x00010000
      sub r2, #1
      cmp r2, #0
      beq _main
      mov r1, #0
      str r1, [r0]
  _hang:
      b _main
  </code></pre>
  
  <p>I compile this file using the following makefile</p>
  
  <pre><code>ARMGNU = arm-eabi
  
  boot.bin: boot.asm
      $(ARMGNU)-as boot.asm -o boot.o
      $(ARMGNU)-ld -T linker.ld boot.o -o boot.elf
      $(ARMGNU)-objdump -D boot.elf &gt; boot.list
      $(ARMGNU)-objcopy boot.elf -O srec boot.srec
      $(ARMGNU)-objcopy boot.elf -O binary boot.bin
  </code></pre>
  
  <p>According to <a href="http://www.ti.com/lit/ug/spruh73p/spruh73p.pdf" rel="nofollow noreferrer">the manual</a> section 26.1.6 (26.1.8.5 for SD booting), I can boot into this code from an SD card with the FAT filesystem if I name the file <code>MLO</code>. Now, if I got my registers right in the assembly code, then the USR0, USR1, USR2, and USR3 LEDs on the PocketBeagle should light up. (See here <a href="http://beaglebone.cameon.net/home/using-the-user-leds" rel="nofollow noreferrer">USR to PIN Mappings</a>) This is because the GPIO1_21, 22, 23, and 24 pins correspond to those 4 LEDs, and those are the pins that I am (trying to) set high.</p>
  
  <p>But the LEDs do not light up. So I'm doing something wrong, but I can't figure it out. </p>
  
  <h1>What I've Tried:</h1>
  
  <p>There is very little documentation on the PocketBeagle online. Apparently the PocketBeagle should be electrically very similar to the BeagleBone Black.  </p>
  
  <ul>
  <li>I've tried the TI <a href="http://processors.wiki.ti.com/index.php/StarterWare" rel="nofollow noreferrer">StarterWare</a> which is supposed to contain functioning binaries. I used the MLO and an example program from that with no luck. Additionally, I've been unsuccessful getting the projects to compile myself. Code Composer Studio is frustrating me. I've tried looking into how to fix the toolchain for CCS, but, admittedly, I don't know enough about the subject to even know where to begin.</li>
  <li>I've tried the community driven <a href="https://sourceforge.net/p/starterwarefree/wiki/Home/" rel="nofollow noreferrer">StarterWareFree</a>. This doesn't come with binaries, but, like above, I can't compile because my tool chain is out of whack.  </li>
  <li>I've made sure that my PocketBeagle still works. I installed the linux distro that is suggested by the BeagleBone community, and I get the heartbeat on the USR0 LED. So the board works.</li>
  <li>I tried using that Linux's MLO, but I was unable to find the MLO in the image that I was using...  </li>
  <li>I tried using the GPIO_SETDATAOUT register instead; according to the docs it should accomplish the same thing I try to do in the assembly. (Section 25.4 of the manual.)</li>
  <li>I made sure that the board could recognize the FAT file system by verifying the presence of 0xAA55
  at offset 0x01FE of the SD card (I used <a href="https://mh-nexus.de/en/hxd/" rel="nofollow noreferrer">HxD</a> to do this). So the FAT MBR is there. (section 26.1.8.5.7.1)</li>
  </ul>
  
  <h1>What I'm Looking For:</h1>
  
  <p>Some direction. Where do I go from here? I've come to accept the fact that I probably won't be able to get the USR LEDs to blink. I don't think the manual can help me any more, and there aren't any resources on the web. I am still learning embedded programming, and I've had success with Arduino and Atmel Studio. I'm not completely novice but guidance is appreciated.</p>
  
  <p>Where can I look for information on embedded system booting?
  Is there a similar simpler problem that I can tackle to help me understand?</p>
  
  <p>This is probably a poorly formatted question for stackoverflow, but I have such little knowledge of the subject. Please advise.</p>
  
  <h1>Context - What is a PocketBeagle:</h1>
  
  <p>I linked to the website for the PocketBeagle above. For those who don't want to leave SO, here is some info.
  It is similar to the BeagleBoneBlack. It has three main components, a micro USB port, an SD card reader and the Octavo Systems OSD3358 1GHz ARM® Cortex-A8 System on Chip. The OSD3358 contains the AM3358 TI Processor; the manual is above. The PocketBeagle comes conveniently configured so that it can boot from the SD card without fussing around with the SYSCONFIG pins. So you can put code on the SD card, put it in the PocketBeagle, and it will boot into that code... hopefully.</p>