# Notion of 'bare-metal' platform - low-level view of embedded system - no resident OS, no libraries, just a tiny 'monitor' - user has to upload a full stand-alone executable (contains OS bricks, firmware + applicative program) # Arduino = a good example - 'tiny' platform (few inputs/outputs) but representative: * low level input/ouput (micro-controller) * limited hardware ressources (in particular memory) # Take a look at 'basic.cpp' - read the comments ! - note that: * programming language is C++ * most of the code consists of arduino library calls https://www.arduino.cc/reference/en/ * the core of the code are the procedures 'setup' and 'loop' # Compilation - compiling and linking a bare-metal program 'from scratch' is rather technical. * a generic Makefile is provided `/utils/Arduino.mk` (if familiar with Makefiles, you can take a look to it) * the application specific Makefile defines the missing parameters (list of user code, name of the appli etc.) **only modify this Makefile if necessary** - The makefile targets are (: * 'compile' (default) * 'u' (upload) * 't' (terminal) * clean # Compile and link all the necessary code (sytem and user): - type 'make compile' (or just 'make') * a folder 'objs' is created, containing compiled code # Upload the program - N.B. the BatCar must be connected to usb - type 'make u' * the program is flashed to the BC memory * the program immediately stars after, and remains in the memory until another program is uploaded # Open a serial terminal - N.B. the BatCar must be connected to usb - mainly for testing, debugging (unecessary when un-plugged) - type 'make t' * open a terminal where is displayed everithing sent to the Serial port * WARNING, to cleanly close the terminal: `CTRL-A Z`, then `q` # Clean-up - 'make clean' * removes the `objs` dir (including the program binary) # To go further: - compilation generates a (classic) translatable binary (.elf) - via 'objcopy' (and known allocation table) this code is compiled into an (absolute) eeprom binary (.eep) - since serial transfert only supports text transfert (ascii, no binary) the .eep code is encoded into (hexadecimal) text (.hex) - when uploded on the arduino, the text is decoded into binary, stored on the eeprom, and started - N.B. the decoding/storage/start functionality is (almost) the only resident firmware in the arduino. (equivalent to the boot-loader on PC platforms)