WIP

bare metal:
  Executing programs "directly", without operating system.





GNU ld linker script:
  Specifies format and layout of the final linked binary, is specific to each
  platform. Syntax and commands:

  /* comment */

  OUTPUT_FORMAT(elf64-x86-64) /* output format */
 
  __myAddr = 0x100            /* custom symbol, can be reference from C as
                                 extern uintptr_t __myAddr;
                                 uint32_t* myAddr = &__myAddr; */

  ENTRY(resetISR)             /* specifies entry point */
  
  MEMORY                      /* describes memory regions */
  {
    myROM (rx) : ORIGIN = 0, LENGTH = 256k
    myRAM (wx) : OROGIN = 0x00010000, LENGTH = 1M
  }

  SECTIONS
  {
    .text (0x00000000):
    {
      
    }
  }
  




=== ARM ===

RISC architecture for CPUs, developed by Arm holdings (company) who licenses it
to other companies. They also design IP cores (circuit designs licensable to
other companies), which is their main business.

ARMs are mostly 32bit (addresses, arithmetic, instructions), but can be
different (16 bit thumb instruction mode, 64 bit ARMv8 etc.)

MCU (microcontroller) is a single chip consisting of CPU, memory, I/O. This is
NOT a SoC (system on a chip), which is more sophisticated (Wi-Fi, GPU, ...).

Thumb:
  16b fixed size instruction set, less powerful than 32b but better code
  density.

Thumb 2:
  Extension of Thumb to variable length instructions by adding some 32b
  instructions.

ARM Cortex-M:
  Group of ARM IP cores for low-cost energy-efficient computers.

  Cortex-M0:
    3 stage instruction pipeline, 32b HW multiplier, Thumb (some also Thumb 2).

  Cortex-M0+:
    Optimized superset of M0, has only 2 stage pipeline (less power needed),
    Thumb (most also Thumb 2).

LPC11U6x:
  Cortex-M0+ MCU usein e.g. in Pokitto operating on up to 50 MHz, with 256 KB
  flash, 4 KB EEPROM and 36 KB RAM. has DMA, USB controller, PWM, real time
  clock, 12b ADC, temperature sensor, 80 I/O pins, oscillators, unique device
  serial number, ...

  memory map:
  
  flash start      0x00000000    interrupt vector start
                                   initial stack pointer             
                                   code entry point (reset interrupt) 
                                 interrupt vector end
  flash end        0x00004000
  reserved
  RAM start        0x10000000
  RAM end          0x10008000
  stuff
  APB peripherals  0x40000000
                   0x4000C000    16b timer/counter 0
                   0x40010000    16b timer/counter 1
                   0x40014000    32b timer/counter 0
                   0x40018000    32b timer/counter 1
                   0x4001C000    12b ADC
                   0x4003C000    flash/EEPROM controller

GNU Arm Embedded Toolchain:
  ARM cross compiler and bianry tools that are normally used (gcc,
  objdump, ...).

  gcc-arm-none-eabi
    |  |   |    |
    |  |   |    \_ embedded application binary interface
    |  |   \_ operating system
    |  \_ architecture
    \_ compiler

EABI:
  Embedded application binary interface, defines file formats, data types,
  stack frame, parameter passing etc. EABI produces compatible obj files.

data section:
  .text       code, put in flash
  .data       initialized data like variables, put in RAM, possibly generate
              extra code to initialize the data
  .bss        uninitialized data like variable, put in RAM
  .dec        sum of text, data and bss
