1*4882a593Smuzhiyun---------------------------------------- 2*4882a593SmuzhiyunSOCFPGA Documentation for U-Boot and SPL 3*4882a593Smuzhiyun---------------------------------------- 4*4882a593Smuzhiyun 5*4882a593SmuzhiyunThis README is about U-Boot and SPL support for Altera's ARM Cortex-A9MPCore 6*4882a593Smuzhiyunbased SOCFPGA. To know more about the hardware itself, please refer to 7*4882a593Smuzhiyunwww.altera.com. 8*4882a593Smuzhiyun 9*4882a593Smuzhiyun 10*4882a593Smuzhiyunsocfpga_dw_mmc 11*4882a593Smuzhiyun-------------- 12*4882a593Smuzhiyun 13*4882a593SmuzhiyunHere are macro and detailed configuration required to enable DesignWare SDMMC 14*4882a593Smuzhiyuncontroller support within SOCFPGA 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun#define CONFIG_SYS_MMC_MAX_BLK_COUNT 256 17*4882a593Smuzhiyun-> Using smaller max blk cnt to avoid flooding the limited stack in OCRAM 18*4882a593Smuzhiyun 19*4882a593Smuzhiyun-------------------------------------------------- 20*4882a593SmuzhiyunGenerating the handoff header files for U-Boot SPL 21*4882a593Smuzhiyun-------------------------------------------------- 22*4882a593Smuzhiyun 23*4882a593SmuzhiyunThis text is assuming quartus 16.1, but newer versions will probably work just fine too; 24*4882a593Smuzhiyunverified with DE1_SOC_Linux_FB demo project (https://github.com/VCTLabs/DE1_SOC_Linux_FB). 25*4882a593SmuzhiyunUpdated/working projects should build using either process below. 26*4882a593Smuzhiyun 27*4882a593SmuzhiyunNote: it *should* work from Quartus 14.0.200 onwards, however, the current vendor demo 28*4882a593Smuzhiyunprojects must have the IP cores updated as shown below. 29*4882a593Smuzhiyun 30*4882a593SmuzhiyunRebuilding your Quartus project 31*4882a593Smuzhiyun------------------------------- 32*4882a593Smuzhiyun 33*4882a593SmuzhiyunChoose one of the follwing methods, either command line or GUI. 34*4882a593Smuzhiyun 35*4882a593SmuzhiyunUsing the comaand line 36*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~~ 37*4882a593Smuzhiyun 38*4882a593SmuzhiyunFirst run the embedded command shell, using your path to the Quartus install: 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun $ /path/to/intelFPGA/16.1/embedded/embedded_command_shell.sh 41*4882a593Smuzhiyun 42*4882a593SmuzhiyunThen (if necessary) update the IP cores in the project, generate HDL code, and 43*4882a593Smuzhiyunbuild the project: 44*4882a593Smuzhiyun 45*4882a593Smuzhiyun $ cd path/to/project/dir 46*4882a593Smuzhiyun $ qsys-generate soc_system.qsys --upgrade-ip-cores 47*4882a593Smuzhiyun $ qsys-generate soc_system.qsys --synthesis=[VERILOG|VHDL] 48*4882a593Smuzhiyun $ quartus_sh --flow compile <project name> 49*4882a593Smuzhiyun 50*4882a593SmuzhiyunConvert the resulting .sof file (SRAM object file) to .rbf file (Raw bit file): 51*4882a593Smuzhiyun 52*4882a593Smuzhiyun $ quartus_cpf -c <project_name>.sof soc_system.rbf 53*4882a593Smuzhiyun 54*4882a593Smuzhiyun 55*4882a593SmuzhiyunGenerate BSP handoff files 56*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~~~~~~ 57*4882a593Smuzhiyun 58*4882a593SmuzhiyunYou can run the bsp editor GUI below, or run the following command from the 59*4882a593Smuzhiyunproject directory: 60*4882a593Smuzhiyun 61*4882a593Smuzhiyun $ /path/to/bsb/tools/bsp-create-settings --type spl --bsp-dir build \ 62*4882a593Smuzhiyun --preloader-settings-dir hps_isw_handoff/soc_system_hps_0/ \ 63*4882a593Smuzhiyun --settings build/settings.bsp 64*4882a593Smuzhiyun 65*4882a593SmuzhiyunYou should use the bsp "build" directory above (ie, where the settings.bsp file is) 66*4882a593Smuzhiyunin the following u-boot command to update the board headers. Once these headers 67*4882a593Smuzhiyunare updated for a given project build, u-boot should be configured for the 68*4882a593Smuzhiyunproject board (eg, de0-nano-sockit) and then build the normal spl build. 69*4882a593Smuzhiyun 70*4882a593SmuzhiyunNow you can skip the GUI section. 71*4882a593Smuzhiyun 72*4882a593Smuzhiyun 73*4882a593SmuzhiyunUsing the Qsys GUI 74*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~ 75*4882a593Smuzhiyun 76*4882a593Smuzhiyun1. Navigate to your project directory 77*4882a593Smuzhiyun2. Run Quartus II 78*4882a593Smuzhiyun3. Open Project (Ctrl+J), select <project_name>.qpf 79*4882a593Smuzhiyun4. Run QSys [Tools->QSys] 80*4882a593Smuzhiyun 4.1 In the Open dialog, select '<project_name>.qsys' 81*4882a593Smuzhiyun 4.2 In the Open System dialog, wait until completion and press 'Close' 82*4882a593Smuzhiyun 4.3 In the Qsys window, click on 'Generate HDL...' in bottom right corner 83*4882a593Smuzhiyun 4.3.1 In the 'Generation' window, click 'Generate' 84*4882a593Smuzhiyun 4.3.2 In the 'Generate' dialog, wait until completion and click 'Close' 85*4882a593Smuzhiyun 4.4 In the QSys window, click 'Finish' 86*4882a593Smuzhiyun 4.4.1 In the 'Quartus II' pop up window, click 'OK' 87*4882a593Smuzhiyun5. Back in Quartus II main window, do the following 88*4882a593Smuzhiyun 5.1 Use Processing -> Start -> Start Analysis & Synthesis (Ctrl+K) 89*4882a593Smuzhiyun 5.2 Use Processing -> Start Compilation (Ctrl+L) 90*4882a593Smuzhiyun 91*4882a593Smuzhiyun ... this may take some time, have patience ... 92*4882a593Smuzhiyun 93*4882a593Smuzhiyun6. Start the embedded command shell as shown in the previous section 94*4882a593Smuzhiyun 6.1 Change directory to 'software/spl_bsp' 95*4882a593Smuzhiyun 6.2 Prepare BSP by launching the BSP editor from ECS 96*4882a593Smuzhiyun => bsp-editor 97*4882a593Smuzhiyun 6.3 In BSP editor 98*4882a593Smuzhiyun 6.3.1 Use File -> Open 99*4882a593Smuzhiyun 6.3.2 Select 'settings.bsp' file 100*4882a593Smuzhiyun 6.3.3 Click Generate 101*4882a593Smuzhiyun 6.3.4 Click Exit 102*4882a593Smuzhiyun 103*4882a593Smuzhiyun 104*4882a593SmuzhiyunPost handoff generation 105*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~~~ 106*4882a593Smuzhiyun 107*4882a593SmuzhiyunNow that the handoff files are generated, U-Boot can be used to process 108*4882a593Smuzhiyunthe handoff files generated by the bsp-editor. For this, please use the 109*4882a593Smuzhiyunfollowing script from the u-boot source tree: 110*4882a593Smuzhiyun 111*4882a593Smuzhiyun $ ./arch/arm/mach-socfpga/qts-filter.sh \ 112*4882a593Smuzhiyun <soc_type> \ 113*4882a593Smuzhiyun <input_qts_dir> \ 114*4882a593Smuzhiyun <input_bsp_dir> \ 115*4882a593Smuzhiyun <output_dir> 116*4882a593Smuzhiyun 117*4882a593SmuzhiyunProcess QTS-generated files into U-Boot compatible ones. 118*4882a593Smuzhiyun 119*4882a593Smuzhiyun soc_type - Type of SoC, either 'cyclone5' or 'arria5'. 120*4882a593Smuzhiyun input_qts_dir - Directory with compiled Quartus project 121*4882a593Smuzhiyun and containing the Quartus project file (QPF). 122*4882a593Smuzhiyun input_bsp_dir - Directory with generated bsp containing 123*4882a593Smuzhiyun the settings.bsp file. 124*4882a593Smuzhiyun output_dir - Directory to store the U-Boot compatible 125*4882a593Smuzhiyun headers. 126*4882a593Smuzhiyun 127*4882a593SmuzhiyunThis will generate (or update) the following 4 files: 128*4882a593Smuzhiyun 129*4882a593Smuzhiyun iocsr_config.h 130*4882a593Smuzhiyun pinmux_config.h 131*4882a593Smuzhiyun pll_config.h 132*4882a593Smuzhiyun sdram_config.h 133*4882a593Smuzhiyun 134*4882a593SmuzhiyunThese files should be copied into "qts" directory in the board directory 135*4882a593Smuzhiyun(see output argument of qts-filter.sh command above). 136*4882a593Smuzhiyun 137*4882a593SmuzhiyunHere is an example for the DE-0 Nano SoC after the above rebuild process: 138*4882a593Smuzhiyun 139*4882a593Smuzhiyun $ ll board/terasic/de0-nano-soc/qts/ 140*4882a593Smuzhiyun total 36 141*4882a593Smuzhiyun -rw-r--r-- 1 sarnold sarnold 8826 Mar 21 18:11 iocsr_config.h 142*4882a593Smuzhiyun -rw-r--r-- 1 sarnold sarnold 4398 Mar 21 18:11 pinmux_config.h 143*4882a593Smuzhiyun -rw-r--r-- 1 sarnold sarnold 3190 Mar 21 18:11 pll_config.h 144*4882a593Smuzhiyun -rw-r--r-- 1 sarnold sarnold 9022 Mar 21 18:11 sdram_config.h 145*4882a593Smuzhiyun 146*4882a593SmuzhiyunNote: file sizes will differ slightly depending on the selected board. 147*4882a593Smuzhiyun 148*4882a593SmuzhiyunNow your board is ready for full mainline support including U-Boot SPL. 149*4882a593SmuzhiyunThe Preloader will not be needed any more. 150