Bootstrapping Freestanding, part 2
Parts: 1, 2
Time to start using the C library! Though this article is about all the things that can go wrong when you start to do that. First, let’s replace the infinite loop at the end of init.S with a jump to the C library’s entry point (in this case newlib).
init.S@@ -21,19 +28,38 @@ _entry: stmia r9!, {r0-r7} b 1b 2: -1: b 1b + b _mainCRTStartup
The first issue is:
Bootstrapping Freestanding, part 1
Parts: 1, 2
Recently I was building the platform support for a Cortex-R5 microcontroller. It is executing out of QSPI flash, with SRAM (static RAM, doesn’t need a controller set up unlike DRAM) and tightly coupled memory: ATCM is typically for instructions, and BTCM is typically for data. The benefit of {A,B}TCM is much faster access, and it is present even when doing erases/writes to the flash. On the other hand, it is not accessible for other devices in the system (e.g. network DMA engines), unlike the SRAM.
Interactive Bootstraps
One of the things that helps1 my depression is having interesting projects to do. A long running one for me is bootstrapping a high level language with the maximum interactivity, rather than with some opaque binary blob.
The original inspiration came from the GNU Mes (Maxwell’s Equations for Software), but there are numerous other sources of inspiration, some I have probably forgotten.
Initially I started with a small stack based VM which uses printable ASCII characters as instructions, so could be typed, but quickly came across JONESFORTH, which at the same time is both a nice introduction to assembly programming, and an introduction to Forth, a language only slightly less minimal than my stack based printable ASCII interpreter, but is much more powerful.