title: How to run baremetal application on Altera Cyclone V SoC using HPS loading from SD card
body: <p>I have a Terasic DE1-SoC board and I want to run a simple led-blinking baremetal application with using HPS. </p>
  
  <p>I've learned HPS tech ref, HPS Boot guide, SoC EDS guide and followed all instructions to run my app. </p>
  
  <p>Here's a brief list of my steps.</p>
  
  <ol>
  <li>Create a system in QSYS with HPS component and some PIOs (for on-board leds and buttons)</li>
  <li>Run bsp-editor to create a preloader. I want to run from SD card so I check BOOT_FROM_SDMMC option. Also i want my app to be in FAT partition (check FAT_SUPPORT, FAT_BOOT PARTITION 1, FAT_LOAD_PAYLOAD_NAME test.img (or should it be test.bin?)) Uncheck WATCHDOG_ENABLE. I want to see booting of preloader process in serial connection, so I check SERIAL_SUPPORT. Other settings keep unchanged.</li>
  <li>Type "make" in SOC EDS 15.0 command shell to obtain preloader-mkpimage.bin</li>
  <li>Write preloader-mkpimage.bin by typing alt-boot-disk-util on sd card with FAT32 partition and custom partition A2.</li>
  <li>Create simple app in DS-5, compile it and obtain test.axf then convert it to test.bin using fromelf command and then convert it in test.img with mkimage tool.</li>
  <li>Drag-n-drop test.img on sd card FAT32 partition.</li>
  <li>Insert it in board and power up</li>
  <li>Load .sof on board (my system FPGA-HPS)</li>
  <li>Reset HPS by pressing reset button</li>
  </ol>
  
  <p>So the problem is that there is nothing going on in serial connection so i thing that preloader isn't working at all, HPS reset not helping. </p>
  
  <p>I don't see even "&lt;0>" in terminal, just blank page.
  I've tried prebuilt images with linux provided by Terasic they are working on 100%. 
  I do everything according altera docs but nothing is working. 
  Even official example <code>altera-socfpga-hardwarelib-unhosted</code> isn't working. I've tried to use their preloader from example, but in terminal window I see only "&lt;0>" symbol when I reset HPS.</p>
  
  <p>By the way App is working only in debugger DS5 with inserted SD card and loaded .sof file on board. I don't clearly understand the meaning and the way of writing of .scat file. Don't understand what load address and entry point should I use when I use mkimage tool when converting test.bin->test.img (should i do this convertion or use in BSP settings test.bin???) In my opinion main problem is incorrect preloader. What is the problem with it?</p>
  
  <p>Please help!</p>
  
  <p><strong>UPD:</strong> After editing HPS part in QSYS (UART module was added) and re-generating system and re-building preloader (other previous settings was not changed) I started to receive correct messages in terminal about successfull loading of U-boot SPL. But still can't run test.img. Working on it.</p>
  
  <p><strong>UPD2:</strong> Ok, I solved this problem, now it's working fine</p>