startup.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2011-02-24 Bernard first implementation
  9. */
  10. #include <rthw.h>
  11. #include <rtthread.h>
  12. #include "board.h"
  13. /**
  14. * @addtogroup FM3
  15. */
  16. /*@{*/
  17. extern int rt_application_init(void);
  18. #ifdef __CC_ARM
  19. extern int Image$$RW_IRAM1$$ZI$$Limit;
  20. #elif __ICCARM__
  21. #pragma section="HEAP"
  22. #else
  23. extern int __bss_end;
  24. #endif
  25. /**
  26. * This function will startup RT-Thread RTOS.
  27. */
  28. void rtthread_startup(void)
  29. {
  30. /* initialize board */
  31. rt_hw_board_init();
  32. /* show version */
  33. rt_show_version();
  34. #ifdef RT_USING_HEAP
  35. #ifdef __CC_ARM
  36. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)FM3_SRAM_END);
  37. #elif __ICCARM__
  38. rt_system_heap_init(__segment_end("HEAP"), (void*)FM3_SRAM_END);
  39. #else
  40. /* init memory system */
  41. rt_system_heap_init((void*)&__bss_end, (void*)FM3_SRAM_END);
  42. #endif
  43. #endif
  44. /* init scheduler system */
  45. rt_system_scheduler_init();
  46. #ifdef RT_USING_DEVICE
  47. #if defined(RT_USING_DFS) && defined(RT_USING_DFS_UFFS)
  48. rt_hw_nand_init();
  49. #endif
  50. #endif
  51. /* initialize application */
  52. rt_application_init();
  53. /* initialize timer */
  54. rt_system_timer_init();
  55. /* initialize timer thread */
  56. rt_system_timer_thread_init();
  57. /* initialize idle thread */
  58. rt_thread_idle_init();
  59. /* start scheduler */
  60. rt_system_scheduler_start();
  61. /* never reach here */
  62. return ;
  63. }
  64. int main(void)
  65. {
  66. /* disable interrupt first */
  67. rt_hw_interrupt_disable();
  68. /* startup RT-Thread RTOS */
  69. rtthread_startup();
  70. return 0;
  71. }
  72. /*@}*/