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.

README.md 10KB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. # Collapse OS
  2. *Bootstrap post-collapse technology*
  3. Collapse OS is a z80 kernel and a collection of programs, tools and
  4. documentation that allows you to assemble an OS that can:
  5. 1. Run on an extremely minimal and improvised architecture.
  6. 2. Communicate through a improvised serial interface linked to some kind of
  7. improvised terminal.
  8. 3. Edit text files.
  9. 4. Compile assembler source files for a wide range of MCUs and CPUs.
  10. 5. Write files to a wide range of flash ICs and MCUs.
  11. 6. Access data storage from improvised systems.
  12. 7. Replicate itself.
  13. Additionally, the goal of this project is to be as self-contained as possible.
  14. With a copy of this project, a capable and creative person should be able to
  15. manage to build and install Collapse OS without external resources (i.e.
  16. internet) on a machine of her design, built from scavenged parts with low-tech
  17. tools.
  18. ## Status
  19. The project is progressing well! Highlights:
  20. * Has a shell that can poke memory, I/O, call arbitrary code from memory.
  21. * Can "upload" code from serial link into memory and execute it.
  22. * Can manage multiple "block devices"
  23. * Can read SD cards as block devices
  24. * A z80 assembler, written in z80 that is self-assembling and can assemble the
  25. whole project. 4K binary, uses less than 16K of memory to assemble the kernel
  26. or itself.
  27. * Extremely flexible: Kernel parts are written as loosely knit modules that
  28. are bound through glue code. This makes the kernel adaptable to many unforseen
  29. situations.
  30. * A typical kernel binary of less than 2K (but size vary wildly depending on
  31. parts you include).
  32. * Built with minimal tooling: only [libz80][libz80] is needed
  33. ## Why?
  34. I expect our global supply chain to collapse before we reach 2030. With this
  35. collapse, we won't be able to produce most of our electronics because it
  36. depends on a very complex supply chain that we won't be able to achieve again
  37. for decades (ever?).
  38. The fast rate of progress we've seen since the advent of electronics happened
  39. in very specific conditions that won't be there post-collapse, so we can't hope
  40. to be able to bootstrap new electronic technology as fast we did without a good
  41. "starter kit" to help us do so.
  42. Electronics yield enormous power, a power that will give significant advantages
  43. to communities that manage to continue mastering it. This will usher a new age
  44. of *scavenger electronics*: parts can't be manufactured any more, but we have
  45. billions of parts lying around. Those who can manage to create new designs from
  46. those parts with low-tech tools will be very powerful.
  47. Among these scavenged parts are microcontrollers, which are especially powerful
  48. but need complex tools (often computers) to program them. Computers, after a
  49. couple of decades, will break down beyond repair and we won't be able to
  50. program microcontrollers any more.
  51. To avoid this fate, we need to have a system that can be designed from
  52. scavenged parts and program microcontrollers. We also need the generation of
  53. engineers that will follow us to be able to *create* new designs instead of
  54. inheriting a legacy of machines that they can't recreate and barely maintain.
  55. This is where Collapse OS comes in.
  56. ## Goals
  57. On face value, goals outlined in the introduction don't seem very ambitious,
  58. that is, until we take the time to think about what kind of machines we are
  59. likely to be able to build from scavenged parts without access to (functional)
  60. modern technology.
  61. By "minimal machine" I mean [Grant Searle's minimal z80 computer][searle].
  62. This (admirably minimal and elegant) machine runs on 8k of ROM and 56k of RAM.
  63. Anything bigger starts being much more complex because you need memory paging,
  64. and if you need paging, then you need a kernel that helps you manage that,
  65. etc.. Of course, I don't mean that these more complex computers can't be built
  66. post-collapse, but that if we don't have a low-enough bar, we reduce the
  67. likeliness for a given community to bootstrap itself using Collape OS.
  68. Of course, with this kind of specs, a C compiler is out of the question. Even
  69. full-fledged assembler is beginning to stretch the machine's ressources. The
  70. assembler having to be written in assembler (to be self-replicating), we need
  71. to design a watered-down version of our modern full-fledged assembler
  72. languages.
  73. But with assemblers, a text editor and a way to write data to flash, you have
  74. enough to steadily improve your technological situation, build more
  75. sophisticated machines from more sophisticated scavenged parts and, who knows,
  76. in a couple of decades, build a new IC fab (or bring an old one back to life).
  77. ## Organisation of this repository
  78. There's very little done so far, but here's how it's organized:
  79. * `kernel`: Pieces of code to be assembled by the user into a kernel.
  80. * `apps`: Pieces of code to be assembled into "userspace" application.
  81. * `recipes`: collection of recipes that assemble parts together on a specific
  82. machine.
  83. * `doc`: User guide for when you've successfully installed Collapse OS.
  84. * `tools`: Tools for working with Collapse OS from "modern" environments. Mostly
  85. development tools, but also contains emulated zasm, which is
  86. necessary to build Collapse OS from a non-Collapse OS machine.
  87. Each folder has a README with more details.
  88. ## Roadmap
  89. The roadmap used to be really hazy, but with the first big goal (that was to
  90. have a self-assembling system) reached, the feasability of the project is much
  91. more likely and the horizon is clearing out.
  92. As of now, that self-assembling system is hard to use outside of an emulated
  93. environment, so the first goal is to solidify what I have.
  94. 1. Error out gracefully in ZASM. It can compile almost any valid code that scas
  95. can, but it has undfined behavior on invalid code and that make it very hard
  96. to use.
  97. 2. Make shell, CFS, etc. convenient enough to use so that I can easily assemble
  98. code on an SD card and write the binary to that same SD card from within a
  99. RC2014.
  100. After that, then it's the longer term goals:
  101. 1. Get out of the serial link: develop display drivers for a vga output card
  102. that I have still to cobble up together, then develop input driver for some
  103. kind of PS/2 interface card I'll have to cobble up together.
  104. 2. Add support for writing to flash/eeprom from the RC2014.
  105. 3. Add support for floppy storage.
  106. 4. Add support for all-RAM systems through bootloading from storage.
  107. Then comes the even longer term goals, that is, widen support for all kind of
  108. machines and peripherals. It's worth mentionning, however, that supporting
  109. *specific* peripherals isn't on the roadmap. There's too many of them out there
  110. and most peripheral post-collapse will be cobbled-up together anyway.
  111. The goal is to give good starting point for as many *types* of peripherals
  112. possible.
  113. It's also important to keep in mind that the goal of this OS is to program
  114. microcontrollers, so the type of peripherals it needs to support is limited
  115. to whatever is needed to interact with storage, serial links, display and
  116. receive text, do bit banging.
  117. ## Open questions
  118. ### Futile?
  119. For now, this is nothing more than an idea, and a fragile one. This project is
  120. only relevant if the collapse is of a specific magnitude. A weak-enough
  121. collapse and it's useless (just a few fabs that close down, a few wars here and
  122. there, hunger, disease, but people are nevertheless able to maintain current
  123. technology levels). A big enough collapse and it's even more useless (who needs
  124. microcontrollers when you're running away from cannibals).
  125. But if the collapse magnitude is right, then this project will change the
  126. course of our history, which makes it worth trying.
  127. This idea is also fragile because it might not be feasible. It's also difficult
  128. to predict post-collapse conditions, so the "self-contained" part might fail
  129. and prove useless to many post-collapse communities.
  130. But nevertheless, this idea seems too powerful to not try it. And even if it
  131. proves futile, it sounds like a lot of fun to try.
  132. ### 32-bit? 16-bit?
  133. Why go as far as 8-bit machines? There are some 32-bit ARM chips around that
  134. are protoboard-friendly.
  135. First, because I think there are more scavenge-friendly 8-bit chips around than
  136. scavenge-friendly 16-bit or 32-bit chips.
  137. Second, because those chips will be easier to replicate in a post-collapse fab.
  138. The z80 has 9000 transistors. 9000! Compared to the millions we have in any
  139. modern CPU, that's nothing! If the first chips we're able to create
  140. post-collapse have a low transistor count, we might as well design a system
  141. that works well on simpler chips.
  142. That being said, nothing stops the project from including the capability of
  143. programming an ARM or RISC-V chip.
  144. ### Prior art
  145. I've spent some time doing software archeology and see if something that was
  146. already made could be used. There are some really nice and well-made programs
  147. out there, such as CP/M, but as far as I know (please, let me know if I'm wrong,
  148. I don't know this world very well), these old OS weren't made to be
  149. self-replicating. CP/M is now open source, but I don't think we can recompile
  150. CP/M from CP/M.
  151. Then comes the idea of piggy-backing from an existing BASIC interpreter and
  152. make a shell out of it. Interesting idea, and using Grant Searle's modified
  153. nascom basic would be a good starting point, but I see two problems with this.
  154. First, the interpreter is already 8k. That's a lot. Second, it's
  155. copyright-ladden (by Searle *and* Microsoft) and can't be licensed as open
  156. source.
  157. Nah, maybe I'm working needlessly, but I'll start from scratch. But if someone
  158. has a hint about useful prior art, please let me know.
  159. ### Risking ridicule
  160. Why publish this hazy roadmap now and risk ridicule? Because I'm confident
  161. enough that I want to pour significant efforts into this in the next few years
  162. and because I have the intuition that it's feasible. I'm looking for early
  163. feedback and possibly collaboration. I don't have a formal electronic training,
  164. all my knowledge and experience come from fiddling as a hobbyist. If feasible
  165. and relevant (who knows, IPCC might tell us in 10 years "good job, humans!
  166. we've been up to the challenge! We've solved climate change!". Does this idea
  167. sound more or less crazy to you than what you've been reading in this text so
  168. far?), I will probably need help to pull this off.
  169. [searle]: http://searle.hostei.com/grant/z80/SimpleZ80.html
  170. [libz80]: https://github.com/ggambetta/libz80