What is the bootstrap program ?

rigidigital

Senior Member
Hi, I have some questions regarding how it all works if you can help...

1.What is meant by the Boot Strap program;

2. Is there a non-erasable or a proprietry memory location in a PIC ? ;

3. What do you call this program, a compiler, interpreter or ..... ;

4. What is the difference between a picaxe and other PIC Basic development systems i.e.How do other PIC chips run basic;

5. Are there all kinds of Boot Strap programs which you can download into a specialised memory area of 'many' different/types of PIC's.

6. After programming some of the more powerfull picaxe's where the circuit board is a little more complex, might have resonators and capacitors and more resistors....,Can you remove the picaxe from this setup and place on a breadboard. (im assuming some of the circuitry is just enable the programming and testing)

Thanks for your time.,
ML.
 

westaust55

Moderator
Bootstrap vs Bootloader + compliers vs interpreter

Q1.What is meant by the Boot Strap program;

A1.The bootstrap program is a small program which is preloaded into a computer or microcontroller which allows the loading of (typically faster/easier) of the main program.

Q2. Is there a non-erasable or a proprietry memory location in a PIC ? ;
A2. Basically yes. For say the PIC used for the 40X1 and similar for others PIC chips, the memory space extends from 0x0000 to 0x3FFF. The first half is the user program memory space and the second half (0x2000-0x3FFF) being configuration memory.

Q3. What do you call this program, a compiler, interpreter or ..... ;
A3. A compiler is a program which takes high level language and converts it to machine code which the pic or other micro-processor runs directly.
An interpreter is used where the high level language (for example BASIC) is typically tokenised so each command might have a single byte token. A string may be saved as one character per byte. The interpreter is pre loaded into the PIC or other microprocessor and reads the tokenised program code and performs the necessary machine code instructions to achieve what the high level language intends to be done.

Q4. What is the difference between a PICAXE and other PIC Basic development systems i.e.How do other PIC chips run basic;
A4. The PICAXE chip is sold by Rev Ed with the program bootloader and PICAXE BASIC language interpreter pre installed. A straight PIC chip has no internal program as bought from microchip. Those who use straight PIC chips can buy a separate compiler (could use BASIC or C or even Assembler) and programmer hardware to programme the PIC chip – all at extra cost.

Q5. Are there all kinds of Boot Strap programs which you can download into a specialised memory area of 'many' different/types of PIC's.
A6. Not something I have done myself. Presume some companies (eg MIKRO) may sell a boot loader as part of their larger compiler package. For those who write in Assembler and program the PIC themselves, they might need to write their own Bootstrap/boot loader.
EDIT: note that a bootloader is a little different to a bootstrap in that the bootloader is a small piece of permanent code in the PIC boot memory area that allows you to change the main firmware at a future point. Rev Ed do not support/use a boot loader or allow users to update the firmware (i.e. bootstrap & BASIC interpreter).

Q6. After programming some of the more powerfull picaxe's where the circuit board is a little more complex, might have resonators and capacitors and more resistors....,Can you remove the picaxe from this setup and place on a breadboard. (im assuming some of the circuitry is just enable the programming and testing).
A6. Not quite sure what you are exactly trying to ask here.
If for example you have a 40X1, then you could have it mounted on an AXE022 protoboard and program it there. You could then take the programmed 40X1 and put it on a breadboard and test/work with it there keeping in mind that as a minimum you need a pull up resistor for the Reset pin, a pull down resistor for the Serial Input pin and if your pre-loaded PICAXE BASIC program requires an external resonator then you must have the resonator on the breadboard.


I am sure others can add further or correct if needed but that is a starting point to answering your questions.
 
Last edited:

Dippy

Moderator
BootLOADERs

Westy has covered just about everything.

I'll just add a note on Bootloaders.

Please get into the habit of calling them BootLOADERs when talking to PIC people.
Boot Strap is an older term which is, unfortunately, also used in hardware electronics to refer to something which helps something else start up. e.g. SMPSUs. - and we don't want ambiguities do we :)

Most F series PICs which have self writeable flash can take a bootloader.
You would have to read Microchip summary pages and/or Data Sheets to check this out.

This has to be loaded onto PIC using a hardware programmer, which you would have to buy.
The bootloader code sits in a specific area of PIC memory (usu the Reset vector) and is the first thing to be executed after a reset.

The 'traditional' bootloader is a small piece of code (aka Boot Code) which immediately looks to see if something is waiting on the Rx line.
If it sees a download pending it will read the code and save it to PIC memory.
(It is recommended never to allow random serial input on a PIC-Rxpin+bootloader at startup for obvious reasons).

The downside of bootloader versus hardware programming is that you have no control over all/most of the config bit setting and have to use the config settings in the original bootloader. This depends on specific PIC. You could write your own bootloader of course.
I've used bootloaders hundreds of times and there are many 'out there' ready for you to load.
Ad then, of course, there isthe issue of code protection.

There are hundreds of pages of documentation about how to write Bootloaders. I've never done it myself, but would like to have a go for specific applications.
Once you have read up then perhaps you can tell me how to do it.

Feel free to go to Microchip.com and search on Bootloader....
 

rigidigital

Senior Member
Great Answers to my Questions.

Thanks to you both. I reallly liked those replies.
I have also a Parallax programming experimental board recently purchased. I see you can get very powerful microcontrollers from XBasic $49 US or ZBasic microcontrollers $59 US. Which are compatible with the Board I have from Parallax.

The Basic Stamp 2p is $89 US and has nowhwere near the speed or memory of these other chips. So I intend to use both picaxe and others.

Mike.
 

tiscando

Senior Member
The pic's reset pin can also be used (sometimes) as a GPIO or the Vpp programming voltage input, according to the 28x1's pic16f886 datasheet.
 
Last edited:

Dippy

Moderator
28X1 ... 16F88 ... ? Really?


A 28X1 is a 16F886. (Manual 1, currently on page 13)

According to my Data Sheet MCLR (aka 'reset') is also PortE.3 which can be configured as a general purpose TTL Input, npt I/O.

And on a 16F88 (18X) the MCLR pin (PortA.5) can be configured as an ST Input pin, not I/O.

(The 'Programming voltage' only has significance for 'hardware' programmers.)

I haven't looked at every PIC ever made but I've only ever seen MCLR shared with a GPIO (Input/Output) on smaller PICs e.g. 12Fs

I think you've got your Data Sheets in a muddle.


Even if you had got it right, I'm not sure how that helps here tiscando.
Please explain relevance to bootloader question as I have missed something.
 

rigidigital

Senior Member
Thanks Dippy

Westy has covered just about everything.

I'll just add a note on Bootloaders.

Please get into the habit of calling them BootLOADERs when talking to PIC people.
Boot Strap is an older term which is, unfortunately, also used in hardware electronics to refer to something which helps something else start up. e.g. SMPSUs. - and we don't want ambiguities do we :)

Most F series PICs which have self writeable flash can take a bootloader.
You would have to read Microchip summary pages and/or Data Sheets to check this out.

This has to be loaded onto PIC using a hardware programmer, which you would have to buy.
The bootloader code sits in a specific area of PIC memory (usu the Reset vector) and is the first thing to be executed after a reset.

The 'traditional' bootloader is a small piece of code (aka Boot Code) which immediately looks to see if something is waiting on the Rx line.
If it sees a download pending it will read the code and save it to PIC memory.
(It is recommended never to allow random serial input on a PIC-Rxpin+bootloader at startup for obvious reasons).

The downside of bootloader versus hardware programming is that you have no control over all/most of the config bit setting and have to use the config settings in the original bootloader. This depends on specific PIC. You could write your own bootloader of course.
I've used bootloaders hundreds of times and there are many 'out there' ready for you to load.
Ad then, of course, there isthe issue of code protection.

There are hundreds of pages of documentation about how to write Bootloaders. I've never done it myself, but would like to have a go for specific applications.
Once you have read up then perhaps you can tell me how to do it.

Feel free to go to Microchip.com and search on Bootloader....
You cover it all thanks. I went to the Microchip site had a brouse around and wound up at Mikroelectronics. They had programmers and different compilers such as MikroBasic, MikroPascal, MikroC.
I also found on forums references to other companies providing programmers and compilers.

I downloaded the pdf's and I will stick to picaxe for quiteawhile if not forever!

What I now think I understand(to satisfy my curiosity) is that these companies provide compilers which after you write your code go to the programmer hardware which converts the code into assembly which is then loaded into the PIC. The compilers are free but are limeted in the program size unless you pay a couple of hundred for the PRO/Commercial versions.

Chips like the XBasic are similar to the picaxe in that they are able to interpret a subset of VB or more accuratly the assembly code generated by the programmer(I like VB) cheapest of these chips is about $29US though they are very fast and have loads of memory, you also have to buy very expensive programmers for them. Its all very interesting however I am learning why picaxe is so popular, a lot less expensive and youn can accomplish everything with them with patience. THE END.
 

Dippy

Moderator
Absolutely rigid.
(Note: that was an answer and not my current status :) ).

I'm a bit out of practice with MicroElektronika stuff, but I didn't think they, by default, gave you the option of loading into a bootloaded PIC. I thought with their stuff you had to use a programmer? I thought you had to use a third party 'loader' for plopping into BL'd PICs? But as I am now 40 I've probably gone daft.

I'm not a fan of M.E. actually, when I used all their IDEs (C, Pascal and BASIC) I found quite a few errors/typoes in their Help and samples. I found that when they upgraded the IDE some examples were out of date and wouldn't run. And I had quite a few issues with their IDE. Updates and corrections were slow.
Other than that... it was quite an experience. So I gave up.

The next step is potentially expensive and definitely time-consuming. And definitely requires greater knowledge of PIC Micros and very definitely requires the user to wrestle with multi-hundred page PIC Data Sheets.

So, if you don't want to:
A) Spend Money
B) Spend months
C) Spend time reading
... then stick to PICAXE. Most things can be done (more quickly) on PICAXE anyway. Writing stuff in any of the 'other' ways doesn't magically make anyone a great programmer.
 

rigidigital

Senior Member
I agree

So, if you don't want to:
A) Spend Money
B) Spend months
C) Spend time reading
... then stick to PICAXE. Most things can be done (more quickly) on PICAXE anyway. Writing stuff in any of the 'other' ways doesn't magically make anyone a great programmer.
I started investigating these other microtrollers as staff in my local electronics store were well slightly haughty, even a little insulting when I asked for help. That was after I told them I was using picaxe, twice two different staff had told me PIC and motorola chips and assembly & C were the only real deal !!!
Well they probably only use MAC computers too and have iphones in there pocket and wear tom cruise aviator glasses while driving to work in their little old VW's with spoilers on the back and are way too cool for school .

Thanks again Dippy, and dont worry about losing your mental faculties as latest studies have show than a couple of cups of coffee a day will prevent Alzimers, (you know what I mean) :)
 

SilentScreamer

Senior Member
That was after I told them I was using picaxe, twice two different staff had told me PIC and motorola chips and assembly & C were the only real deal !!!
It depends what you want, for speed they are, but if you want to get something that can be very complex running ASAP with little electronics knowledge then PICAXE are the real deal.

EDIT: And I second what BB said.
 

Dippy

Moderator
I'll third that.
If 90% of the questions posted here were put on some of the 'other' places I use then some very rude answers would be posted.

Even with the leg-pulling on this Forum you would never get the level of help elsewhere - remembering that some of those other Forums are populated by pro designers with commercially-related designs.

One other advantage of C is that many samples/snippets in Manuf's App Notes are in C - so they can be 'borrowed' more easily.

There is one BASIC compiler (NOT free by a long way) with a C-ish structure but that's another story.

And even if you (i.e. anyone) were the best C programmer in the world it doesn't mean you know how to interface to the Real World.

What we need is a good BOOK showing how to do it, with some code snippets ;)
 

papaof2

Senior Member
Back in the days of the ZX80 (anyone else remember them?), I did hand-coded assembly for a parallel printer driver (with a lookup table for ZX to ASCII conversion). The interface used a PIO chip on a homebrew expansion board. I submitted an article on it to one of the ZX-related magazines. The article was accepted for publication - but the magazine folded before the article was published. They sent me the camera-ready proofs, but at that point I was too busy to pursue the project.

I've done C and a little assembly on platforms from 8086 (MSDOS) to a PDP 11/70 (UNIX)so I probably could do PIC assembly, but the question is "Why?" The things an old retired guy builds are most likely going to be one-off and there's no "economy of scale" in a single unit ;-)

The PICAXE Programming Editor is easier to use than any of the free/inexpensive C or Basic PIC compilers that I have tried and the family of PICAXE chips supports everything I've been interested in building.

John
 

westaust55

Moderator
Westy has covered just about everything.

I'll just add a note on Bootloaders.

Please get into the habit of calling them BootLOADERs when talking to PIC people.


Feel free to go to Microchip.com and search on Bootloader....
Argh! :eek:

PICAXE Manual 1 page 13:
A PICAXE microcontroller is a standard Microchip PICmicro™ microcontroller
that has been pre-programmed with the PICAXE bootstrap code. The bootstrap code enables the PICAXE microcontroller to be re-programmed directly via a
simple serial connection.
cannot blame others for the terminolgy that the PICAXE manual itself uses!
 

Technical

Technical Support
Staff member
PICAXE does not use a bootloader. This is a small piece of permanent code in the PIC boot memory area that allows you to change the main firmware at a future point. PICAXE does not work like that, the firmware (what we call bootstrap) is preprogrammed and cannot be changed by the end user.
 

westaust55

Moderator
Thanks for that clarification Technical.

I am use to the term bootstrap as a small (typically in the past hand loaded via switches) program that permitted the loading of the main program such as the BASIC interpreter. A PDP 11 computer I had access to in the early 1970’s worked that way.

When I used the Motorola MC68705P3 microcontrollers for some projects back in the early 1980’s they also had a form of internal bootloader that would read a machinecode (firmware) program from an EPROM into the microcontrollers memory

However, when one looks on the internet (e.g. http://en.wikipedia.org/wiki/Booting) the terms bootstrap and bootloader are being used interchangeably.

From Microchip AN372 which is in line with your description of a bootloader:
The PIC16F87X family of microcontrollers has the ability to write to their own program memory. This feature allows a small bootloader program to receive and write new firmware into memory. This application note (AN372) explains how this can be implemented and discusses the features that may be desirable.
 
Top