Basics

Bootloader
The bootloader is a small program running inside your Pinguino's microcontroller (PIC18F or PIC32MX) which is responsible for transferring your user program from your computer to the Pinguino's microcontroller program memory and handing over the control to this program afterwards.

The bootloader is always pre-installed on commercial boards.

If you made your own board, then you must program your Pinguino (only one time) using a standard PIC programmer which supports your PIC microcontroller to install the bootloader.

About 8-bit Pinguino
There are currently 4 bootloaders but 2 are really supported (available here):


 * Version 1 which can be used only on 18F2550 based Pinguinos (about 7K);


 * Version 2 which can be used on both 18F2550 and 18F4550 based Pinguinos (about 7K).


 * Version 3 is based on Diolan bootloader and is written in ASM (about 1.5K). Unfortunately it can not work with SDCC which does not support PIC18F Extended Instructions Set. However it works perfectly with MPLAB X.


 * Version 4 is written with SDCC (>3.0.0), is less than 3K and is available for PIC18F 1xK50 (not tested), x455, x550, x6J50, x6j53 and x7j53 based Pinguinos, with Internal or External crystal, at low (not supported by the Pinguino IDE) or high speed USB.

When using version 1 you have to include the run button in your design or nothing will happen.

When using version 2, 3 or 4 the run button can be omitted because control will be handed over to the user program 5 seconds (version 2), 10 seconds (version 3 and up to version 4.12) after powerup or reset.

Note that bootloader version 4.13 and above, starts when Reset button is pressed and has no time limit. Control will be handed over the user program at the end of the upload process.

About 32-bit bootloaders
All 32-bit bootloaders can be found here.

Uploading your program
First of all run the Pinguino IDE.

Write your user program and then regardless of the bootloader you are using, compile it.

on 8-bit Pinguino
Depending on your Pinguino design, there are several bootloader versions.

In version 1 (see above) of the bootloader:

Push the reset button on your Pinguino board. The run led should remain dark. If it is lit, you have probably short circuited the run button with a jumper.

Click on the upload button and wait for the VascoBootloader to appear. Click the 'write' button in VascoBootLoader.

You should get something like PIC found followed by XXX.hex uploaded, XXX being the filename of your user program.

Now push the run button to start your program.

When using version 2 (see above) things get a little easier.

First press the reset button on the Pinguino Board. Then wait 3 seconds and click the upload button in the Pinguino IDE. The built-in led should stay on solid.

You should get something like Pinguino found followed by XXX.hex uploaded, XXX being the filename of your user program.

If you get 'Pinguino not found !!' you have not waited long enough, just click 'write' again.

If you get 'Pinguino found' followed by nothing you waited too long. In this case Reset your Pinguino board, wait 3 seconds and try again.

Using version 3 (see above).

First press the reset button on your Pinguino board. The built-in led should stay on solid. You now have 5 seconds to upload your program.

Second, click the upload button in the Pinguino IDE.

That's it !

You should get something like :  Pinguino found ... - with PIC18f26j50 (id=0x4c40) - with USB bootloader v4.x Writing User Application ... xxxxxxx.hex successfully uploaded Starting Application ... 

If you get:

 Pinguino not found Is your device connected and/or in bootloader mode ? 

you may have not connected your board or you may have waited too long after pressing the reset button before uploading your program. Try again from the beginning.

Using version 4 up to v4.11 (see above)

First press the reset button on your Pinguino board.
 * If you connect a USB cable between your PC and your Pinguino board, the bootloader waits 10 seconds for a program to be uploaded during which time the red LED blinks every half-second.
 * If the board is powered with an external power supply and the USB to PC cable is not connected, the bootloader waits about 5 seconds during which time the red LED stays lit.

Second, click the upload button in the Pinguino IDE.

That's it !

You should get something like :

 Pinguino found ... - with PIC18f26j50 (id=0x4c40) - with USB bootloader v4.x Writing User Application ... xxxxxxx.hex successfully uploaded Starting Application ... 

If you get:

 Pinguino not found Is your device connected and/or in bootloader mode ? 

you may have not connected your board via USB to your computer or you may have waited too long after pressing the reset button before uploading your program. Try again from the beginning.

Using version 4.12 and above

Versions 4.12 and above behave now differently from previous versions:


 * The user application starts without any delay on Power-on Reset
 * The bootloader starts only if Reset button has been pressed
 * The bootloader mode stays on until a program has been uploaded (no more time limit)
 * The led blinks at high frequency (T=2*43ms)

First press the reset button on your Pinguino board.

Second, click the upload button in the Pinguino IDE.

No hurry, take your time, the bootloader will wait until you press the upload button in the IDE.

That's it !

On a Pinguino 26j50, you should get something like :

 Pinguino found ... - with PIC18f26j50 (id=0x4c40) - with 62464 bytes free (61 KB) - with USB bootloader v4.xx Uploading user program ... xxxxx bytes written. xxxxx.hex successfully uploaded Starting user program ... 

On a Pinguino 47j53, you should get something like:

 Pinguino found ... - with PIC18f47j53 (id=0x58e0) - with 128000 bytes free (125 KB) - with USB bootloader v4.xx Uploading user program ... xxxxx bytes written. xxxxx.hex successfully uploaded Starting user program ... 

If you get :

 Pinguino not found Is your device connected and/or in bootloader mode ? 

you may not have connected your board via USB to your computer or not pressed the reset button.

on 32-bit Pinguino
Before telling the Pinguino IDE to upload your program you need to connect your board and put it in bootloader mode:

Press and hold down the user button BUT Press and release the user button RST (Reset) Release the user button BUT

You should now see the two built-in LEDs (yellow and green) flashing alternately. Now you and your Pinguino are ready to upload your program.

Once the upload is complete, the two LEDs will stop flashing and the program will start automatically.

To exit the bootloader mode without uploading a new program:-

Press and release the user button RST (Reset)

The two LEDs will stop flashing and the previously installed program will start running again.

Hello World example to run
Step 1

Prepare the connection to the Pinguino device by installing the MCHPCDC driver from :
 * Windows

..\PINGUINO\x4\extra\drivers\CDC\mchpcdc.inf or x4-easypack-rev999 instead of x4 according your installation (case of IDE version x.4).

Otherwise for other versions search the well-known MCHPCDC driver on the Web.

You will have a COMx connection once you have uploaded a program calling CDC functions. Then you will find this connection each time you will connect your Pinguino to a PC thru a USB cable. See Step 4 for more details about this connection.

Nothing to do.
 * Linux

Does not work with CDC functions at this time (November 2013).
 * OS X

Step 2: Write the following in the Pinguino IDE

Step 3: Compile and upload the code (see above)

Step 4:

You can use a terminal or console such as hyperterminal or putty to view the output. The settings are: Then start the connection. You get continuously Hello World!!! lines
 * Windows
 * Port: it depends. Normally it will be COM7. You can guess or you can check it. In Windows you can do this by right clicking on "my computer" -> manage -> device manager -> ports -> there should be a "communications port (COMx)" or "USB Serial Port (COMx)". The x is the number of your COM port. If there is none but you have a yellow question mark in the device manager, you need to (re)install the CDC driver.
 * Speed (Baud): 115200
 * Data bits: 8
 * Stop bits: 1
 * Parity: None
 * Flow control: none (or XON/XOFF)

If available save this connection for later use. You can use a Terminal Emulation Program such as Minicom : sudo minicom -o -D /dev/ttyACM0
 * Linux

Init function
TODO

Main function
TODO

Interrupt function
TODO

If an interrupt service routine changes variables which are accessed by other functions these variables have to be declared volatile. See Wikipedia (From the SDCC Documentation).