Skip to content

Files

Latest commit

Jun 21, 2017
08723eb · Jun 21, 2017

History

History

bootloader10

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
See the top level README for information on where to find documentation
for the raspberry pi and the ARM processor inside.  Also find information
on how to load and run these programs.

This example is for the pi zero, see other directories for other flavors
of raspberry pi.

This is a very simple bootloader.  Instead of the sd dance (see
top level README), this makes life a bit simpler and greatly reduces
physical wear and tear on the sd card socket.  Do the sd card dance one
more time with this kernel.img.  Get some sort of serial solution to
connect a dumb termial program with the ability to download raw/ascii
files.

The pi zero does not come with pins, you will want/need some way to
make the serial connection, if you can solder and get some header
pins great.  If not there are other ways, some pins can be shoved in
rather than soldered.  Or balanced if nothing else (stick them in and
lean them to the side so they touch), just dont short anything out.

On the sd card end of the board the P1 connector pins are like this,
same as other raspberry pi boards, but span the whole length of the
board rather than orentied more toward one corner than another.

|SD  |  12
|CARD|  34
        56
        78
        9.
        ..
        ..

The pins we care about

2
4
6
8  TX out
10 RX in

The pi TX goes to the uart RX and the pi RX to the uart TX.

Here are some examples of 3.3V level uarts, you need 3.3V level not 5V
definitely not RS-232C

https://www.sparkfun.com/products/9873
https://www.adafruit.com/products/954

You can find these on ebay from china for a buck or two each with a
jumper to select between 3.3V and 5V.

This bootloader is expecting motorola s-record formatted data.

en.wikipedia.org/wiki/SREC_(file_format)

arm-whatever-objcopy --srec-forceS3 notmain.elf -O srec notmain.srec

It is specifically expecting S3 records

S00F00006E6F746D61696E2E737265631F
S3150000800002D9A0E3050000EBFEFFFFEA001080E5C1
S315000080101EFF2FE1000090E51EFF2FE11EFF2FE15E
S3150000802010402DE9A4009FE5F9FFFFEB0E16C0E313
S31500008030021681E394009FE5F3FFFFEB90009FE5B6
S315000080400219A0E3F0FFFFEB0040A0E30400A0E16B
S31500008050014084E2F0FFFFEB020754E3FAFFFF1A48
S3150000806070009FE50219A0E3E7FFFFEB0040A0E3E5
S315000080700400A0E1014084E2E7FFFFEB020754E3BE
S31500008080FAFFFF1A48009FE50219A0E3DEFFFFEBA7
S315000080900040A0E30400A0E1014084E2DEFFFFEB24
S315000080A0020754E3FAFFFF1A28009FE50219A0E32E
S315000080B0D5FFFFEB0040A0E30400A0E1014084E20D
S315000080C0D5FFFFEB030654E3FAFFFF1ADAFFFFEAD8
S311000080D0100020202C0020202000202082
S705000080007A

Not S1 records

S00D000068656C6C6F2E7372656303
S113800002D9A0E3050000EBFEFFFFEA001080E5C3
S11380101EFF2FE1000090E51EFF2FE11EFF2FE160
S113802010402DE9A4009FE5F9FFFFEB0E16C0E315
S1138030021681E394009FE5F3FFFFEB90009FE5B8
S11380400219A0E3F0FFFFEB0040A0E30400A0E16D
S1138050014084E2F0FFFFEB020754E3FAFFFF1A4A
S113806070009FE50219A0E3E7FFFFEB0040A0E3E7
S11380700400A0E1014084E2E7FFFFEB020754E3C0
S1138080FAFFFF1A48009FE50219A0E3DEFFFFEBA9
S11380900040A0E30400A0E1014084E2DEFFFFEB26
S11380A0020754E3FAFFFF1A28009FE50219A0E330
S11380B0D5FFFFEB0040A0E30400A0E1014084E20F
S11380C0D5FFFFEB030654E3FAFFFF1ADAFFFFEADA
S10F80D0100020202C0020202000202084
S90380007C

It only supports S0, S3, and S7 records.  You can certainly add more
support.

Using minicom you download by selecting ascii instead of xmodem
or kermit or whatever.  This just sends the file as is.  If using
some other terminal emulator you have to just figure it out.  Or
cut and paste it from an editor like the program above and paste
it into your dumb terminal window.

Minicom spawns other programs to do the downloads so there is or
can be a dead period after downloading before minicom receives data
so to deal with that once downloaded you press the letter g to go or
run the program.  This way you or at least I dont lose any characters
from the downloaded program.

I normally do not deliver binaries.  In this case I have left the
binary in the root directory as bootloader.img, copy this file to
your sd card and name it kernel.img.

Remove or rename a config.txt file on the sd card if you have one.

There are a pair of holes on the board labelled RUN.  If you are able
to solder or find other solutions (there are pins that can be pushed
into holes like this), you can put a momentary switch that when closed
will reset the board, and released allow it to boot again.  Then you
can use this bootloader again by simply pressing the reset button.
Much easier than power cycling the board every time (turning the power
off, then on by unplugging the usb).

These two lines in vectors.s determine the size of the programs this
can handle

First off 0x200000 is close to where this program begins so if you use
this bootloader for larger programs you will overwrite the bootloader
while running and crash.  Make that number larger.

.space 0x200000-0x8004,0

If you approach this number

skip:
    mov sp,#0x08000000

Where the stack lives for this program, then you need to move that up
as well.

Oh, and this line too, this limits the overall size of the program
if you run into this then just make it bigger as well.

    ram : ORIGIN = 0x8000, LENGTH = 0x1000000