2
2
3
3
The Tock bootloader provides a utility for flashing applications onto
4
4
a board over USB. It is compatible with the
5
- [ tockloader] ( https://github.com/helena-project /tockloader ) utility.
5
+ [ tockloader] ( https://github.com/tock /tockloader ) utility.
6
6
7
7
The Tock bootloader is implemented on top of the Tock OS itself.
8
8
@@ -25,12 +25,20 @@ make flash
25
25
Bootloader Operation
26
26
--------------------
27
27
28
- When reset, the board enters the bootloader and checks the status of the
29
- ` BOOTLOADER_SELECT_PIN ` . If the pin is high, the bootloader exits by
30
- moving the location of the vector table to address ` 0x10000 ` and then
31
- jumping to that address. If the pin is low, the board enters bootloader mode
32
- and waits for commands to be sent over UART. To exit the bootloader mode,
33
- the chip must be reset with the ` BOOTLOADER_SELECT_PIN ` pulled high.
28
+ When reset, the board enters the bootloader and checks whether it should
29
+ continue to run the bootloader, or jump to the kernel. The bootloader uses the
30
+ ` BootloaderEntry ` trait to determine if it should stay in the bootloader. The
31
+ method of staying in the bootloader can vary based on the board. Some options:
32
+
33
+ - Check a GPIO pin. If the pin is high then stay in the bootloader.
34
+ - Check a special memory address or register. If a magic value is stored there,
35
+ then stay in the bootloader.
36
+
37
+ If the bootloader exists, it uses the ` Jumper ` trait to start executing from a
38
+ different starting address. This implementation is likely architecture-specific.
39
+
40
+ The address the bootloader jumps to is stored in the bootloader flags section in
41
+ flash. See below for more information.
34
42
35
43
The list of valid commands the bootloader accepts is in the
36
44
[ Protocol] ( #over-the-wire-protocol ) section. At a high level, the commands
@@ -342,15 +350,78 @@ Set a new baud rate for the bootloader.
342
350
- ` Message ` : ` None ` .
343
351
344
352
353
+ #### ` EXIT `
345
354
355
+ Exit the bootloader.
346
356
347
- Future Goals
348
- ------------
357
+ ##### Command
358
+ - ` Command ` : ` 0x22 ` .
359
+ - ` Message ` : ` None ` .
349
360
350
- The bootloader is stable, but there are future improvements we would like
351
- to see added:
361
+ ##### Response
362
+ None.
363
+
364
+
365
+
366
+ Flags and Attributes
367
+ --------------------
368
+
369
+ The bootloader includes space near the beginning of the bootloader's space in flash for
370
+ flags and attributes. Attributes are key-value pairs used to store various properties of
371
+ the board. Flags are specified values for use by the bootloader.
372
+
373
+ ### Flags
374
+
375
+ The flag section is 512 bytes long. Most of the section is reserved for future
376
+ use.
377
+
378
+ ```
379
+ Bytes
380
+ 0 1 2 3
381
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
382
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
383
+ |T|O|C|K|B|O|O|T|L|O|A|D|E|R| Version Str | Reserved |
384
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
385
+ | Start | Reserved...
386
+ +-+-+-+-+-+-+-+-+-+-+-+-+
387
+ ```
388
+
389
+ - ` TOCKBOOTLOADER ` : The first fourteen bytes contain the string
390
+ "TOCKBOOTLOADER".
391
+ - ` Version Str ` : The next 8 bytes contain an ASCII string of the bootloader
392
+ version.
393
+ - ` Start ` : Four bytes of the start address to jump to if the bootloader is not
394
+ entered.
395
+
396
+ ### Attributes
397
+
398
+ The attributes section occupies the next 1024 bytes. Each attribute uses 64
399
+ bytes of space. There can be up to 16 attributes.
400
+
401
+ Attribute format:
402
+
403
+ ```
404
+ Bytes
405
+ 0 1 2 3
406
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
407
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
408
+ | Key | Value
409
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
410
+ |
411
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
412
+ ```
413
+
414
+ - ` Key ` : The key can be up to 8 bytes long. Keys are ` \0 ` padded to consume all
415
+ 8 bytes.
416
+ - ` Value ` : Values can be up to 56 bytes long.
417
+
418
+
419
+
420
+
421
+ Changelog
422
+ --------------------
352
423
353
- - Arbitrary code start location. Right now the bootloader assumes that the main
354
- application code is at address ` 0x10000 ` , and that is currently a hardcoded
355
- value. This should ideally be a special flag that can get updated if we want
356
- to move the main code (for Tock the kernel) to a different address .
424
+ - Version 1.1.0
425
+ - Added Exit command.
426
+ - Added SetStartAddress command.
427
+ - Restore ` BADADDR ` error when trying to overwrite the bootloader itself .
0 commit comments