MBIC_Bootloader(4718).c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * MBIC_Bootloader.c
  3. *
  4. * Created on: 2020. 5. 18.
  5. * Author: parkyj
  6. */
  7. #include "main.h"
  8. #include "MBIC_Bootloader.h"
  9. void MBIC_FileDataCheck(uint8_t* data){
  10. int8_t MBIC_Mark[9] = "JT-NRDAS ";
  11. int8_t MBIC_FileName1[] = "jhfs-mbic-nrdas-v";
  12. int8_t MBIC_FileName2[] = "v00.00.01.mbc";
  13. uint8_t MBIC_type = 0x20;
  14. uint8_t MBIC_FileType = 0x00;
  15. int i = 0;
  16. /***
  17. MARK Check
  18. ***/
  19. for(i = 0; i < 9; i++){
  20. if(MBIC_Mark[i] != data[i]){
  21. printf("Data Diff \r\n");
  22. return;
  23. }else{
  24. printf("MARK Data Success \r\n");
  25. }
  26. }
  27. /***
  28. TYPE Check
  29. ***/
  30. for(i = i; i < 10; i++){
  31. if(MBIC_type != data[i]){
  32. printf("Data Diff \r\n");
  33. return;
  34. }
  35. else
  36. printf("Type Data Success \r\n");
  37. }
  38. /***
  39. File Type Check
  40. ***/
  41. for(i = i; i < 11; i++){
  42. if(MBIC_FileType != data[i]){
  43. printf("Data Diff \r\n");
  44. return;
  45. }
  46. else
  47. printf("File Type Data Success \r\n");
  48. }
  49. /***
  50. Version Check
  51. ***/
  52. for(i = i; i < 14; i++){
  53. printf("Version Data Success Version %x\r\n",data[i]);
  54. }
  55. /***
  56. File Name Check
  57. ***/
  58. for(i = i; i < 30; i++){
  59. if(MBIC_FileName1[i-14] != data[i]){
  60. printf("Data Diff \r\n");
  61. printf("MBIC_FileName1[%d] : %x, data[%d] : %x\r\n",i - 14,MBIC_FileName1[i - 14],i,data[i]);
  62. return;
  63. }
  64. else
  65. printf("File Name Data Success \r\n");
  66. }
  67. for(i = i; i < 43; i++){
  68. if(MBIC_FileName2[i-30] != data[i]){
  69. printf("Data Diff %c\r\n",data[i]);
  70. printf("MBIC_FileName2[%d] : %x, data[%d] : %x\r\n",i - 30,MBIC_FileName2[i - 30],i,data[i]);
  71. return;
  72. }
  73. else
  74. printf("File Name Data Success %c\r\n",data[i]);
  75. }
  76. for(i = i; i < 49; i++){
  77. printf("Creation Success %x\r\n",data[i]);
  78. }
  79. }
  80. void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
  81. uint8_t data[1024] = {
  82. 0x4A,0x54,0x2D,0x4E,0x52,0x44,0x41,0x53,0x20,0x20,0x00,0x00,
  83. 0x00,0x01,0x6A,0x68,0x66,0x73,0x2D,0x6D,0x62,0x69,0x63,0x2D,
  84. 0x6E,0x72,0x64,0x61,0x73,0x2D,0x76,0x30,0x30,0x2E,0x30,0x30,0x2E,
  85. 0x30,0x31,0x2E,0x6D,0x62,0x63,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
  86. 0x20,0x20,0x20,0x20,0x20,0x14,0x06,0x03,0x10,0x1F,0xC4,0x3C,0x49,
  87. 0x42,0x98,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  88. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  89. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  90. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  91. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
  92. };
  93. MBIC_FileDataCheck(data);
  94. uint8_t datatype = data[MBIC_PAYLOADSTART];
  95. printf("RX");
  96. for(int i = 0; i < 128; i++)
  97. printf("%c",*data++);
  98. switch(datatype){
  99. case MBIC_Notice_REQ:
  100. break;
  101. case MBIC_Download_DATA_REQ:
  102. break;
  103. case MBIC_Download_Confirm_REQ:
  104. break;
  105. case MBIC_Complete_Notice_REQ_REQ:
  106. break;
  107. case MBIC_Reboot_Notice_REQ:
  108. break;
  109. }
  110. }