Mirror of CollapseOS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
3.7KB

  1. # Assembling Collapse OS from within it
  2. This is where we tie lose ends, complete the circle, loop the
  3. loop: we assemble a new Collapse OS *entirely* from within
  4. Collapse OS.
  5. Build Collapse OS' from within Collapse OS is very similar to
  6. how we do it from the makefiles in /arch. If you take
  7. the time to look one, you'll see something that look like "cat
  8. xcomp.fs | $(STAGE)". That's the thing. Open "xcomp.fs" in a
  9. text editor and take a look at it. Some xcomp units are simple
  10. proxy to a block, which you'll find in the blk/ subfolder for
  11. this recipe.
  12. To assemble Collapse OS from within it, all you need to do is
  13. execute the content of this unit, minus the 2 lines of "spitting
  14. to port 2" at the end of the unit, which is a special signal for
  15. the stage binary.
  16. The rest can be executed on any Collapse OS system with enough
  17. memory. It will yield a binary in memory. To know the start/end
  18. offset of the binary, you'll type the same two commands at the
  19. end of xcomp.fs, but replace the "/MOD 2 PC! 2 PC!" words with
  20. ".X". Then, write that binary between those offsets on your
  21. target media. That binary should be the exact same as what you
  22. get in "os.bin" when you run "make". You now have a new Collapse
  23. OS deployment.
  24. Is that it? Yes. But for your own enlightenment, let's look at
  25. the xcomp unit in more details. Full details are at
  26. doc/bootstrap.txt.
  27. The first part is configuration of your new system. When RAM
  28. starts, where RSP and PSP start, what ports to use for what
  29. device, etc. These configuration declarations are expected in
  30. the boot code and driver code.
  31. Then, we load the proper assembler and the cross compiler (xcomp
  32. for short), which we'll of course need for the task ahead.
  33. Then come xcomp overrides, which are needed for xcomp to be
  34. effective.
  35. At this point, we're about to begin spitting binary content,
  36. this will be our starting offset. "ORG" will soon be set to your
  37. current "H@".
  38. Then, we assemble the boot binary, drivers' native words, then
  39. inner core, close the binary with a hook word. We're finished
  40. with cross-compiling.
  41. We're at the offset that will be "CURRENT" on boot, so we update
  42. "LATEST".
  43. Then, we spit the init source code that will be interpreted on
  44. boot. And... that's it!
  45. # What to do on SDerr?
  46. If you self host from a machine with a SD card and you get
  47. "SDerr" in the middle of a LOAD operation, something went wrong
  48. with the SD card. The bad news is that it left your xcomp
  49. operation in an inconsistent state. The easiest thing to do it
  50. to restart the operation from scratch. Those error are not
  51. frequent unless hardware is faulty.
  52. # Cross-compiling directly to EEPROM
  53. If your target media is a RAM mappable media, you can save prec-
  54. ious RAM by cross-compiling Collapse OS directly to it. It req-
  55. uires special handling.
  56. You can begin the process in a regular manner, but right before
  57. you're about to assemble the boot code, take a pause.
  58. Up until now, you've been loading your cross compiling tools in
  59. RAM, now, you're about to write Collapse OS. So what you need
  60. to do is change HERE to the address of your EEPROM. Example:
  61. 0x2000 HERE !
  62. If you need to activate special system overrides such as the
  63. one described in doc/hw/at28.txt, now is the time.
  64. Then, you can continue the process normally.
  65. # Verifying
  66. You can use "/tools/memdump" to dump the memory between your
  67. begin/end offsets so that you can compare against your reference
  68. stage 1. Before you do, you have to take yourself out of xcomp
  69. mode. First, run XCOFF to go back to your regular dict. Then,
  70. run "FORGET CODE" to undo the xcomp overrides you've added
  71. before. That will rewind HERE. You don't want that. Put HERE
  72. back to after your ending offset so that you don't overwrite
  73. your binary.
  74. Then, you can run "/tools/memdump".