application-ReadMe.text 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. Multiple applications in flash
  2. ==============================
  3. Some brief notes about mbr, menu, hello, *-test and *-loader
  4. 1. Each application must: #include "application.h"
  5. 2. Link with: application.lds
  6. 3. Do not add eeprom.o to list of objects as this is supplied by mbr
  7. (the vector is defined in application.lds)
  8. (still have to include "eeprom.h" though)
  9. 4. Makefile has a MAKE_APP macro to simplify the rules
  10. 5. application.c must start and end with special macros
  11. and also define a title. (see below)
  12. example: hello application:
  13. ===========================
  14. ************** start of hello.c **************
  15. #define APPLICATION_TITLE "hello world"
  16. #include "application.h"
  17. // main() must be first as the loader executes from the first program address
  18. int main(void)
  19. {
  20. APPLICATION_INITIALISE();
  21. print("hello world\n");
  22. print(" 1 + 2 = ");
  23. print_u32(1 + 2);
  24. print_char('\n');
  25. print("goodbye world\n");
  26. APPLICATION_FINALISE(0);
  27. }
  28. ************** end of hello.c **************
  29. The makefile must contain this line:
  30. $(call MAKE_APP, hello, misc.o)
  31. i.e part of the makefile contains:
  32. ==================================
  33. ************** section of Makefile **************
  34. # Applications
  35. $(call MAKE_APP, menu, misc.o)
  36. $(call MAKE_APP, hello, misc.o)
  37. $(call MAKE_APP, memory-test, misc.o)
  38. ************** end of section of Makefile **************
  39. Boot sequence for 8kByte applications
  40. =====================================
  41. 1. internal ROM load mbr from FLASH @ 0 to RAM @ 0
  42. 2. ROM jumps to RAM @ 0
  43. 3. mbr reads flash from ((block << 13) + 0x300) to ram @ 0x200
  44. where block is initially zero
  45. 4. mbr call code at RAM 0x200
  46. 5. if this code returns the the block = return code
  47. 6. back to step 3
  48. Missing is argument value that is initially zero and gets the high 16
  49. bits of the return value which then gets passed as a parameter to the
  50. next program.
  51. The boot menu program
  52. =====================
  53. This is just like any other application program and does the following.
  54. It scans the first 4 bytes of each 8kByte flash block looking for
  55. "SAMO" if there is a match then a letter from A..G is output followed
  56. by upto 32 bytes of text from block offset 4 (this is derived from
  57. APPLICATION_TITLE in the .c file.
  58. Finally it waits fo a key press then return 1..7 to the mbr to load
  59. another program.
  60. The purpose is to select between various programs such as the elf file
  61. loader, memory-test, etc. which are part of the initial load sequence
  62. or testing. Some of these (e.g. memory test) cannot run from SDRAM
  63. since the SDRAM is completely overwritten by the process and may not
  64. even work.
  65. The second reason is that it is not possible to fit all of the
  66. required code into a single 8kByte program, hence the need to "chain"
  67. between different programs. (an ancient technique from pre-history
  68. when computers came with basic in ROM)
  69. (Missing: There ought to ba a way for the menu program to determine
  70. the flash size)
  71. Ordering the programs (example mapfile)
  72. =======================================
  73. mbr is located at 0x1
  74. menu at 0x300
  75. application headers are located at 0xN000
  76. and their code at 0xN300.
  77. (where n is an even digit)
  78. ************** start of mapfile **************
  79. # samo_a1.map
  80. # FLASH = PM25LV512
  81. # SIZE = 64kB
  82. 0x1 mbr
  83. 0x0300 menu
  84. 0x2000 kernel-loader.header
  85. 0x2300 kernel-loader
  86. 0x4000 forth-loader.header
  87. 0x4300 forth-loader
  88. 0x6000 hello.header
  89. 0x6300 hello
  90. 0x8000 key-test.header
  91. 0x8300 key-test
  92. 0xa000 memory-test.header
  93. 0xa300 memory-test
  94. #0xc000 <other>.header
  95. #0xc300 <other>
  96. #0xe000 gfxtool/failed_boot.p
  97. ************** end of mapfile **************