application.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. * 2017-08-08 Yang the first version
  9. */
  10. #include <rtthread.h>
  11. #ifdef RT_USING_FINSH
  12. #include <shell.h>
  13. #include <finsh.h>
  14. #endif
  15. /* thread phase init */
  16. void rt_init_thread_entry(void *parameter)
  17. {
  18. /* Initialization RT-Thread Components */
  19. #ifdef RT_USING_COMPONENTS_INIT
  20. rt_components_init();
  21. #elif defined(RT_USING_FINSH)
  22. finsh_system_init();
  23. #endif
  24. }
  25. void build_dump(void)
  26. {
  27. #if defined(__CC_ARM)
  28. rt_kprintf("using MDK\n");
  29. #elif defined(__IAR_SYSTEMS_ICC__)
  30. rt_kprintf("using IAR\n");
  31. #elif defined(__GNUC__)
  32. rt_kprintf("using GCC\n");
  33. #else
  34. rt_kprintf("unkown Compiler\n");
  35. #endif
  36. }
  37. void link_dump(void)
  38. {
  39. #ifdef __GNUC__
  40. extern unsigned int _sdata;
  41. extern unsigned int _edata;
  42. extern unsigned int _sidata;
  43. extern unsigned int _sbss;
  44. extern unsigned int _ebss;
  45. #define DUMP_VAR(__VAR) \
  46. rt_kprintf("%-20s %p\n", #__VAR, &__VAR)
  47. DUMP_VAR(_sdata);
  48. DUMP_VAR(_edata);
  49. DUMP_VAR(_sidata);
  50. DUMP_VAR(_sbss);
  51. DUMP_VAR(_ebss);
  52. #endif
  53. }
  54. int rt_application_init(void)
  55. {
  56. rt_thread_t tid;
  57. build_dump();
  58. link_dump();
  59. tid = rt_thread_create("init",
  60. rt_init_thread_entry, RT_NULL,
  61. 2048, RT_THREAD_PRIORITY_MAX / 3, 20);
  62. if (tid != RT_NULL) rt_thread_startup(tid);
  63. return 0;
  64. }