create-this-app 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #!/bin/bash
  2. #
  3. # This script creates the hello_world application in this directory.
  4. BSP_DIR=../hello_world_bsp
  5. QUARTUS_PROJECT_DIR=../../
  6. NIOS2_APP_GEN_ARGS="--elf-name hello_world.elf --set OBJDUMP_INCLUDE_SOURCE 1 --src-files hello_world.c"
  7. # First, check to see if $SOPC_KIT_NIOS2 environmental variable is set.
  8. # This variable is required for the command line tools to execute correctly.
  9. if [ -z "${SOPC_KIT_NIOS2}" ]
  10. then
  11. echo Required \$SOPC_KIT_NIOS2 Environmental Variable is not set!
  12. exit 1
  13. fi
  14. # Also make sure that the APP has not been created already. Check for
  15. # existence of Makefile in the app directory
  16. if [ -f ./Makefile ]
  17. then
  18. echo Application has already been created! Delete Makefile if you want to create a new application makefile
  19. exit 1
  20. fi
  21. # We are selecting hal_default bsp because it supports this application.
  22. # Check to see if the hal_default has already been generated by checking for
  23. # existence of the public.mk file. If not, we need to run
  24. # create-this-bsp file to generate the bsp.
  25. if [ ! -f ${BSP_DIR}/public.mk ]; then
  26. # Since BSP doesn't exist, create the BSP
  27. # Pass any command line arguments passed to this script to the BSP.
  28. pushd ${BSP_DIR} >> /dev/null
  29. ./create-this-bsp "$@" || {
  30. echo "create-this-bsp failed"
  31. exit 1
  32. }
  33. popd >> /dev/null
  34. fi
  35. # Don't run make if create-this-app script is called with --no-make arg
  36. SKIP_MAKE=
  37. while [ $# -gt 0 ]
  38. do
  39. case "$1" in
  40. --no-make)
  41. SKIP_MAKE=1
  42. ;;
  43. esac
  44. shift
  45. done
  46. # Now we also need to go copy the sources for this application to the
  47. # local directory.
  48. find "${SOPC_KIT_NIOS2}/examples/software/hello_world/" -name '*.c' -or -name '*.h' -or -name 'hostfs*' | xargs -i cp -L {} ./ || {
  49. echo "failed during copying example source files"
  50. exit 1
  51. }
  52. find "${SOPC_KIT_NIOS2}/examples/software/hello_world/" -name 'readme.txt' -or -name 'Readme.txt' | xargs -i cp -L {} ./ || {
  53. echo "failed copying readme file"
  54. }
  55. if [ -d "${SOPC_KIT_NIOS2}/examples/software/hello_world/system" ]
  56. then
  57. cp -RL "${SOPC_KIT_NIOS2}/examples/software/hello_world/system" . || {
  58. echo "failed during copying project support files"
  59. exit 1
  60. }
  61. fi
  62. chmod -R +w . || {
  63. echo "failed during changing file permissions"
  64. exit 1
  65. }
  66. cmd="nios2-app-generate-makefile --bsp-dir ${BSP_DIR} --set QUARTUS_PROJECT_DIR=${QUARTUS_PROJECT_DIR} ${NIOS2_APP_GEN_ARGS}"
  67. echo "create-this-app: Running \"${cmd}\""
  68. $cmd || {
  69. echo "nios2-app-generate-makefile failed"
  70. exit 1
  71. }
  72. if [ -z "$SKIP_MAKE" ]; then
  73. cmd="make"
  74. echo "create-this-app: Running \"$cmd\""
  75. $cmd || {
  76. echo "make failed"
  77. exit 1
  78. }
  79. echo
  80. echo "To download and run the application:"
  81. echo " 1. Make sure the board is connected to the system."
  82. echo " 2. Run 'nios2-configure-sof <SOF_FILE_PATH>' to configure the FPGA with the hardware design."
  83. echo " 3. If you have a stdio device, run 'nios2-terminal' in a different shell."
  84. echo " 4. Run 'make download-elf' from the application directory."
  85. echo
  86. echo "To debug the application:"
  87. echo " Import the project into Nios II Software Build Tools for Eclipse."
  88. echo " Refer to Nios II Software Build Tools for Eclipse Documentation for more information."
  89. echo
  90. echo -e ""
  91. fi
  92. exit 0