microbit architecture Flashcards

1
Q

embedded system

A

an electronic product that has 1 or more micro controllers that execute software instructions stored on a memory module to perform an essential function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

microcontroller

A

processor/micro controller unit (mcu)
compact integrated circuit with one or more cpus and memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

runtime code/software

A

software platform that provides an environment for excecuting user code
acts as an abstraction layer that developers can use to write software

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what does the micro usb do

A

streams data to and from the microbit and provides power

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what is the microbit power supply

A

jst connector

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is daplink

A

open source interface firmware that creates a bridge between the pc and swd
the microbit presents itself as a usb disk

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is interface mode (daplink)

A

the hex dropped onto the usb disk is written into the target mcu flash
usb disk = microbit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

bootloader mode (daplink)

A

the hex file written into the interface mcu flash and updated the version of the daplink
usb disk = maintainance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what do you type to build microbit

A

python3 build.py

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what are the 4 parts needed in creating an executable file

A

preprocessor; outputs pure c code
compiler; transforms c into assembly (dependant on the machine architecture)
assembler; created machine code stored in an object file including meta data
linker; links different files together and gives every object what it needs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what are the different sections of an object file

A

machine code; text
required space for uninitialised data (bss; block starting symbol)
symbol tables; location of functions
relocation information; what to modify when linking

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

how is a symbol table used when calling library functions

A

when a program has several parts the address of the jump cannot be decided
a placeholder is put until the address is known and remember that the address is not resolved - managed through the symbol table in your library function and the relocation info in your program.
the linker resolves this when building the file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

what is the job of the linker

A

linking object files and libraries

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

how does the linker link multiple object files

A

object files includes references to eachothers code and data
the linker uses relocation records to fill in all addresses then combines info from the symbol table and relocation records
assembling to machine code removes all labels from the code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

in which two ways can libraries be used

A

statically linked archives; linked during compile time
dynamically linked shared objects; linked at runtime

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

static linking

A

program and library combines by the linker during compilation time therefore binding is fixed and you will need to link again to change the library
statically linked programmes are linked against archives (.a; multiple libraries compiled together)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

what are advantages of static linking

A

when you compile you know what library is being used
when you copy programs you know that everything is present

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

what is a disadvantage of static linking

A

programs take more disk space

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

dynamic linking

A

linked at runtime
the linker places information into the executable that tells the loader the location of the shared object files where required code can be found during runtime
linked against shared objects (.so)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

what are advantages of dynamic linking

A

small file sizes on the disk
libraries can be upgraded without reassembling the entire program
2 programs can store libraries in memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

what is a disadvantage of dynamic linking

A

libraries may change and the impact of the program is not always clear

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

what kind of linking is supported for the microbit

A

static

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

why dont we compile and link files in one stage

A

any change in a single source file would mean you would have to recompile the entire program which would be inefficient for large projects as it would consume a lot of time and resources

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

what does the loader do

A

loads code and data onto the main memory
part of the os
performs memory and access validation
performs process setup

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

what is part of process setup ( loader)

A

allocate memory
copy address space from secondary to main memory
copy program arguments to the stack
initialise registers (eg. stack pointer)
jump to start routine (copy main() and jump to main())

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

how does initial processing work in c

A

the input file is read into memory and broken into lines
continued lines are merged into one long line
all comments are replaces with single spaces

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

what is tokenization

A

the input c file is split into processing tokens
identifier; sequence of letters digits or underscore beginning with a letter or underscore
number; any c integer and floating point constants
string literals; string/character constants and header file names
a stream of tokens can be passed to the compilers parser but if it contains any identifiers/operations in the preprocessing language it will be transformed first

28
Q

pre processing language

A

has directives to be executed and macros to be expanded

29
Q

what are the primary capabilities of the preprocessing language

A

macro expansion
conditional compilation
diagnostics
inclusion of header files
control of the compiler

30
Q

macro expansion

A

abbreviations for c code fragments
the preprocessor replaces macros (identifier) with their definitions (code fragment) throughout the program (e.g. names to integer constants)
defined using #define followed by a macro name and the body (the intended expansion)
written in upper case

31
Q

conditional compilation

A

incluse or exclude code segments from compilation based on different conditions

32
Q

diagnostics

A

you can detect problems at compile time and issue errors or warnings

33
Q

inclusions of header files

A

file declarations substituted in your program

34
Q

control the compiler

A

provide hints to the compiler on how to process code

35
Q

function-like macros

A

macros that look like a function call
#define MACRO_NAME(arguments)

36
Q

stringification/stringize/number-sign operator (#)

A

converts a macro parameter into a string constant

define movie_title(a, b) \
printf(“When “ #a “ met “ #b “.\n”)
Output: When Harry met Sally.

37
Q

how do you undefine a macro

A

undef

38
Q

what is ##

A

token pasting operator; concatenates two tokens

39
Q

what are the 2 types of bugs

A

run time; logic errors, not working as expected
compilation time; syntax, warnings, invalid program,, violating programming ocnventions

40
Q

what are 2 debugging strategies

A

removing code until the program works and examining the removed code
add code until it breaks and examine the last added lines
using print statements
using a debugger

41
Q

how does the microbit communicate wirelessly

A

using a chip with a built in radio module
it can be places in a mode of operation that allows the microbit to broadcast general purpose data packets to other microbits

42
Q

what is a datagram

A

a packet that can be up to 32 bytes long

43
Q

what is the code used to send and receive datagrams

A

uBit.radio.datagram.send(datagram)
uBit.radio.datagram.recv()

44
Q

what do you have to do before transmitting and recieving

A

uBit.radio.enable()

45
Q

what is the difference between a managedString and PacketBuffer

A

managed string types are immutable (can’t be changed once created) and packet buffers aren’t

46
Q

how does the mum play a role in virtual memory

A

the memory management unit has a lookup table (translate look aside buffer(tlb)) that translates virtual addresses into physical
the os dynamically allocates pages of memory to processes and creates entries in the tab
different virtual spaces can correspond to the same physical space and vice versa

47
Q

what are the 5 main memory regions

A

os kernel; memory reserved by the os to monitor and control mapping between physical and virtual addresses
stack; data needed by functions
heap; dynamic memory allocation for variables with a known size at runtime and can’t be determined by the compiler before execution
bss; stores global variables that aren’t initialised or are initialised to 0
data; initialises global variables
text; stores code

48
Q

what are the 3 different pointers that are part of the stack layout

A

base pointer; points to the address of the caller function and is used when the frame completes
saved instruction pointer; indicated the line to resume at in the function
stack pointer; points to the lowest address of the stack for the current frame

49
Q

what are the 6 steps in examining code

A

determine the cpu architecture
develop the code to examine
compile and run the code using gdb
visualise the stack
check the registers
disassemble the code

50
Q

why is automating code good for large projects

A

good for collaboration
faster compilation through incremental builds

51
Q

build automation systems

A

automate source code compilation from multiple source files into binary executable code

52
Q

build script generation tools

A

generate files for build automation systems
doesn’t actually build executable code directly but can set up build scripts for specific os

53
Q

what happens when you type the command make

A

a makefile is created which tries to slow dependencies

54
Q

what does a makefile contain

A

the project structure; files and dependencies between them
instructions for creating binary files; object ands executable files

55
Q

what are the 3 different parts of a rule in makefiles

A

target
dependencies
actions

56
Q

target

A

filename/variable/string
the name for the actions
uses “make exec” to execute
if there’s more than one target you have to specify otherwise it will execute all if defined or the first target

57
Q

dependacies

A

the list of requirements for a target
if the target isn’t up to date then the compiler created an executable
actions are only executed if the target doesn’t exist or theyre older than the dependacies
if the dependacy is the name of another target control will decend to the othera

58
Q

actions

A

shell commands
each line has one action (/ used if an action can’t fit on one line)
tab used to indent

59
Q

rule

A

contains the actions to meet. target when the dependancies are fulfilled

exec: primary.c secondary.c mylib.h gcc primary.c secondary.c -o exec

60
Q

why do we somtimes have separate tules for objet files

A

because if you make a change in one of the source files the creation and linking of their object files will be triggered

exec: primary.o secondary.o
gcc primary.o secondary.o -o exec
primary.o: primary.c mylib.h
gcc -c primary.c -o primary.o
secondary.o: secondary.c mylib.h
gcc -c secondary.c -o secondary.o

61
Q

what is used to signify comments in make files

A

#

62
Q

how do you signify variable s in make files

A

$() / ${}
single character variables dont need brackets

CC = gcc
exec: primary.o secondary.o
$(CC) primary.o secondary.o -o exec

63
Q

what are some of the automatic variables in make files ($ symbols)

A

$@ - The filename of the TARGET.
$* - The filename of the TARGET without the file extension.
$^ - The filenames of all DEPENDENCIES.
$< - The filename of the first DEPENDENCY.
$? - The filenames of all DEPENDENCIES that are newer than the TARGET.

64
Q

%

A

matches a dependancy file name without the extension

65
Q

clean variable

A

removes the object files stated when “ make clean” is run

clean:
rm primary.o secondary.o

66
Q

all variable

A

explicitly states what you want the top of the tree to be (sets a default)