startup.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. */
  9. #include <rthw.h>
  10. #include <rtthread.h>
  11. #include <sep4020.h>
  12. #include <board.h>
  13. #include <serial.h>
  14. #ifdef RT_USING_FINSH
  15. #include <finsh.h>
  16. #endif
  17. #ifdef RT_USING_LWIP
  18. #include <lwip/sys.h>
  19. #include <netif/ethernetif.h>
  20. #endif
  21. #define SDRAM_BASE 0x30000000
  22. #ifdef __CC_ARM
  23. extern int Image$$RW_RAM1$$ZI$$Limit;
  24. #elif (defined (__GNUC__))
  25. extern unsigned char __bss_end;
  26. #endif
  27. extern void rt_application_init(void);
  28. extern int finsh_system_init(void);
  29. extern void sd_init(void);
  30. void rtthread_startup()
  31. {
  32. /* init hardware interrupt */
  33. rt_hw_interrupt_init();
  34. /* init board */
  35. rt_hw_board_init();
  36. /* show version */
  37. rt_show_version();
  38. /* init timer system */
  39. rt_system_timer_init();
  40. /* init heap memory system */
  41. #ifdef __CC_ARM
  42. rt_system_heap_init((void*)&Image$$RW_RAM1$$ZI$$Limit, (void*)(SDRAM_BASE + 0x200000));
  43. #else
  44. rt_system_heap_init(&__bss_end, (void*)0x34000000);
  45. #endif
  46. /* init scheduler system */
  47. rt_system_scheduler_init();
  48. #ifdef RT_USING_DEVICE
  49. #ifdef RT_USING_DFS
  50. rt_hw_sdcard_init();
  51. #endif
  52. #ifdef RT_USING_LWIP
  53. eth_system_device_init();
  54. rt_hw_dm9161_init();
  55. #endif
  56. #endif
  57. /* init application */
  58. rt_application_init();
  59. #ifdef RT_USING_FINSH
  60. /* init finsh */
  61. finsh_system_init();
  62. #if !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE)
  63. finsh_set_device("uart0");
  64. #endif
  65. #endif
  66. /* init idle thread */
  67. rt_thread_idle_init();
  68. /* start scheduler */
  69. rt_system_scheduler_start();
  70. /* never reach here */
  71. return ;
  72. }
  73. int main()
  74. {
  75. /* disable interrupt first */
  76. rt_hw_interrupt_disable();
  77. /* startup RT-Thread RTOS */
  78. rtthread_startup();
  79. return 0;
  80. }