 <?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://Robo.Fish/wiki/index.php?action=history&amp;feed=atom&amp;title=ARM_Bootloader</id>
	<title>ARM Bootloader - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://Robo.Fish/wiki/index.php?action=history&amp;feed=atom&amp;title=ARM_Bootloader"/>
	<link rel="alternate" type="text/html" href="https://Robo.Fish/wiki/index.php?title=ARM_Bootloader&amp;action=history"/>
	<updated>2026-04-22T10:49:48Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://Robo.Fish/wiki/index.php?title=ARM_Bootloader&amp;diff=2673&amp;oldid=prev</id>
		<title>Kai: Created page with &quot;&lt;br /&gt; The bootloader is the program that runs in an embedded processor immediately after a reset of the processor and is responsible for initializing the connected devices an...&quot;</title>
		<link rel="alternate" type="text/html" href="https://Robo.Fish/wiki/index.php?title=ARM_Bootloader&amp;diff=2673&amp;oldid=prev"/>
		<updated>2017-05-03T23:06:24Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;br /&amp;gt; The bootloader is the program that runs in an embedded processor immediately after a reset of the processor and is responsible for initializing the connected devices an...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
The bootloader is the program that runs in an embedded processor immediately after a reset of the processor and is responsible for initializing the connected devices and starting the main software (for example, the kernel of an OS). The ARM bootloader defines the &amp;#039;&amp;#039;&amp;#039;vector table&amp;#039;&amp;#039;&amp;#039; of the computing environment.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Assume that the main program is coded in C and the entry function is called &amp;#039;&amp;#039;entry&amp;#039;&amp;#039; as shown below:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;code&amp;quot;&amp;gt;&lt;br /&gt;
int entry(void)&lt;br /&gt;
{&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
which is compiled for the ARM Cortex-M0 (ARMv6-M architecture) target like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;terminal&amp;quot;&amp;gt;&lt;br /&gt;
arm-none-eabi-gcc -c -mcpu=cortex-m0 hello_world.c -o hw-entry.o&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
We also create an assembly file (hw-startup.s) that specifies the vector table, including the reset handler:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;code&amp;quot;&amp;gt;&lt;br /&gt;
/* Vector table for bootloader. Assemble via&lt;br /&gt;
       arm-none-eabi-as -mcpu=cortex-m0 hw-startup.s -o hw-startup.o&lt;br /&gt;
*/&lt;br /&gt;
.section INTERRUPT_VECTOR, &amp;quot;x&amp;quot;&lt;br /&gt;
.global _Reset&lt;br /&gt;
_Reset:&lt;br /&gt;
  b Reset_Handler /* Reset */&lt;br /&gt;
  b .             /* Undefined */&lt;br /&gt;
  b .             /* SWI */&lt;br /&gt;
  b .             /* Prefetch Abort */&lt;br /&gt;
  b .             /* Data Abort */&lt;br /&gt;
  b .             /* Reserved */&lt;br /&gt;
  b .             /* IRQ */&lt;br /&gt;
  b .             /* FIQ */&lt;br /&gt;
&lt;br /&gt;
Reset_Handler:&lt;br /&gt;
  /* In Thumb mode we can not load into SP directly.&lt;br /&gt;
  Only into the eight low registers */ &lt;br /&gt;
  ldr r1, =stack_top&lt;br /&gt;
  mov sp, r1&lt;br /&gt;
  /* In ARM mode we can simply write&lt;br /&gt;
  ldr sp, =stack_top&lt;br /&gt;
  */&lt;br /&gt;
  bl entry&lt;br /&gt;
  b .&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and assemble like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;terminal&amp;quot;&amp;gt;&lt;br /&gt;
arm-none-eabi-as -mcpu=cortex-m0 hw-startup.s -o hw-startup.o&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
The object files are linked into an executable Linux binary in ELF format like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;terminal&amp;quot;&amp;gt;&lt;br /&gt;
arm-none-eabi-ld -T hw-boot.ld hw-entry.o hw-startup.o -o hello_world.elf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
where &amp;#039;&amp;#039;hw-boot.ld&amp;#039;&amp;#039; is the linker file that defines where the code from the object files will be placed into the executable:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;code&amp;quot;&amp;gt;&lt;br /&gt;
ENTRY(_Reset)&lt;br /&gt;
SECTIONS&lt;br /&gt;
{&lt;br /&gt;
  . = 0x0;&lt;br /&gt;
  .text : {&lt;br /&gt;
    hw-startup.o (INTERRUPT_VECTOR)&lt;br /&gt;
    *(.text)&lt;br /&gt;
  }&lt;br /&gt;
  .data : { *(.data) }&lt;br /&gt;
  .bss : { *(.bss COMMON) }&lt;br /&gt;
  . = ALIGN(8);&lt;br /&gt;
  . = . + 0x100; /* allocating 4 KB for stack memory */&lt;br /&gt;
  stack_top = .;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The ELF file can be inspected with the &amp;#039;&amp;#039;readelf&amp;#039;&amp;#039; tool like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;terminal&amp;quot;&amp;gt;&lt;br /&gt;
arm-none-eabi-readelf -A hello_world.elf&lt;br /&gt;
Attribute Section: aeabi&lt;br /&gt;
File Attributes&lt;br /&gt;
  Tag_CPU_name: &amp;quot;Cortex-M0&amp;quot;&lt;br /&gt;
  Tag_CPU_arch: v6S-M&lt;br /&gt;
  Tag_CPU_arch_profile: Microcontroller&lt;br /&gt;
  Tag_THUMB_ISA_use: Thumb-1&lt;br /&gt;
  Tag_ABI_PCS_wchar_t: 4&lt;br /&gt;
  Tag_ABI_FP_denormal: Needed&lt;br /&gt;
  Tag_ABI_FP_exceptions: Needed&lt;br /&gt;
  Tag_ABI_FP_number_model: IEEE 754&lt;br /&gt;
  Tag_ABI_align_needed: 8-byte&lt;br /&gt;
  Tag_ABI_enum_size: small&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and disassembled via &amp;#039;&amp;#039;objdump&amp;#039;&amp;#039; like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;terminal&amp;quot;&amp;gt;&lt;br /&gt;
arm-none-eabi-objdump -d hello_world.elf&lt;br /&gt;
&lt;br /&gt;
hello_world.elf:     file format elf32-littlearm&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Disassembly of section .text:&lt;br /&gt;
&lt;br /&gt;
00000000 &amp;lt;_Reset&amp;gt;:&lt;br /&gt;
   0:	e006      	b.n	10 &amp;lt;Reset_Handler&amp;gt;&lt;br /&gt;
   2:	e7fe      	b.n	2 &amp;lt;_Reset+0x2&amp;gt;&lt;br /&gt;
   4:	e7fe      	b.n	4 &amp;lt;_Reset+0x4&amp;gt;&lt;br /&gt;
   6:	e7fe      	b.n	6 &amp;lt;_Reset+0x6&amp;gt;&lt;br /&gt;
   8:	e7fe      	b.n	8 &amp;lt;_Reset+0x8&amp;gt;&lt;br /&gt;
   a:	e7fe      	b.n	a &amp;lt;_Reset+0xa&amp;gt;&lt;br /&gt;
   c:	e7fe      	b.n	c &amp;lt;_Reset+0xc&amp;gt;&lt;br /&gt;
   e:	e7fe      	b.n	e &amp;lt;_Reset+0xe&amp;gt;&lt;br /&gt;
&lt;br /&gt;
00000010 &amp;lt;Reset_Handler&amp;gt;:&lt;br /&gt;
  10:	4902      	ldr	r1, [pc, #8]	; (1c &amp;lt;Reset_Handler+0xc&amp;gt;)&lt;br /&gt;
  12:	468d      	mov	sp, r1&lt;br /&gt;
  14:	f000 f804 	bl	20 &amp;lt;entry&amp;gt;&lt;br /&gt;
  18:	e7fe      	b.n	18 &amp;lt;Reset_Handler+0x8&amp;gt;&lt;br /&gt;
  1a:	0000      	.short	0x0000&lt;br /&gt;
  1c:	00000130 	.word	0x00000130&lt;br /&gt;
&lt;br /&gt;
00000020 &amp;lt;entry&amp;gt;:&lt;br /&gt;
  20:	b580      	push	{r7, lr}&lt;br /&gt;
  22:	af00      	add	r7, sp, #0&lt;br /&gt;
  24:	2300      	movs	r3, #0&lt;br /&gt;
  26:	0018      	movs	r0, r3&lt;br /&gt;
  28:	46bd      	mov	sp, r7&lt;br /&gt;
  2a:	bd80      	pop	{r7, pc}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Finally, &amp;#039;&amp;#039;objcopy&amp;#039;&amp;#039; is used to remove the ELF header and convert the file into an executable that can be run as-is on the Cortex-M0.&lt;br /&gt;
&amp;lt;pre class=&amp;quot;terminal&amp;quot;&amp;gt;&lt;br /&gt;
arm-none-eabi-objcopy -O binary hello_world.elf hello_world.bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kai</name></author>
	</entry>
</feed>